Tag Archives: code

Validate DNA FASTA file with a javascript function

gitlogoI couldn’t find a quick function that validates a single DNA FASTA file in javascript, so here a setup (it uses the same structure as this protein FASTA validator from the Oxford Protein Informatics Group).

function validateDNA (seq)	{
	//Based on: http://www.blopig.com/blog/2013/03/a-javascript-function-to-validate-fasta-sequences/

	// immediately remove trailing spaces
	seq = seq.trim();

	// split on newlines... 
	var lines = seq.split('\n');

	// check for header
	if (seq[0] == '>') {
		// remove one line, starting at the first position	
		lines.splice(0, 1);

	// join the array back into a single string without newlines and 
	// trailing or leading spaces
	seq = lines.join('').trim();
	//Search for charaters that are not G, A, T or C.
	if (seq.search(/[^gatc\s]/i) != -1) {	
		//The seq string contains non-DNA characters
		return false;
		/// The next line can be used to return a cleaned version of the DNA
		/// return seq.replace(/[^gatcGATC]/g, "");
		//The seq string contains only GATC
		return true;

Have fun

Leave a Comment

Filed under Tools

Visualize your trail

Screen Shot 2013-07-23 at 12.50.45 PMCurrently I’m participating in the Quantified Self summer school at the CIID (Copenhagen Institute for Interaction Design). The focus lies on the visualisation of complex data sets, currently a hot topic in science. As workhorse the Java based environment Processing is used, which is widely known in the visualization community. (For some vivid examples check openprocessing.org).

To get a better grasp of Java in general and processing in particular I wrote a small package that visualizes all the places you have visited with the corresponding color mood (=the most prominent color in the pictures you took).

Continue reading

Leave a Comment

Filed under Course