Team:Aberdeen Scotland/DNA/JS

From 2014.igem.org

(Difference between revisions)
Line 104: Line 104:
//return
//return
return dna;
return dna;
 +
}
 +
 +
dna.prototype.colorBlock = function(letter) {
 +
return '<div class="'+letter+'">'+letter+'</div>';
 +
}
 +
 +
dna.prototype.colorDNA = function(dna) {
 +
var txt = dna.text;
 +
var canvas = "";
 +
 +
if (txt == "") { // check for dna
 +
return canvas;
 +
};
 +
 +
txt = txt.toUpperCase();
 +
 +
for (var i = 0; i < txt.length; i++) {
 +
canvas += '<div class="'+txt[i]+'">'+txt[i]+'</div>';
 +
};
 +
 +
return canvas;
}
}

Revision as of 21:35, 12 August 2014

function dna(f) {


this.char = new Object; // ALPHABET // ACCORDING TO E.COLI CODON BIAS

this.char.start = 'ATG'; this.char.stop = 'TGA';

this.char.A = "GCC"; this.char.B = "AAG"; // "BOOK" - K(2) this.char.C = "TGC"; this.char.D = "GAT";

this.char.E = "GAA"; this.char.F = "TTT"; this.char.G = "GGC"; this.char.H = "CAT";

this.char.I = "ATT"; this.char.J = "CCA"; // "JUMP" - P(2) this.char.K = "AAA"; this.char.L = "CTG";

this.char.M = "ATG"; this.char.N = "AAT"; this.char.O = "CGT"; // "ORANGE" - R(2) this.char.P = "CCG";

this.char.Q = "CAG"; this.char.R = "CGC"; this.char.S = "AGC"; this.char.T = "ACC";

this.char.U = "AGA"; // "UMBRELLA" - R(4) this.char.V = "GTG"; this.char.W = "TGG"; this.char.X = "TAC"; // "XYLOPHONE" - Y(2)

this.char.Y = "TAT"; this.char.Z = "CGA"; // "ZEBRA" - R(3)

this.char["0"] = "AGG"; // "ZERO" - R(4) this.char["1"] = "AAC"; // "ONE" - N(2) this.char["2"] = "ACG"; // "TWO" - T(2) this.char["3"] = "ACT"; // "THREE" - T(3) this.char["4"] = "TTC"; // "FOUR" - F(2)

this.char["5"] = "ATC"; // "FIVE" - I(2) this.char["6"] = "TCG"; // "SIX" - S(2) this.char["7"] = "AGT"; // "SEVEN" - S(3) this.char["8"] = "GAG"; // "EIGHT" - E(2) this.char["9"] = "ATA"; // "NINE" - I(3)

this.char[" "] = "GGT"; // GLYCINE SPACER PROTEIN this.char["."] = "TGA"; // STOP

this.nchars = 40;

this.color_codes = { A: "red", C: "green", G: "blue", T: "yellow", };

};

dna.prototype.toDNA = function(f) { var txt = f.text; var separator = typeof f.separator !== 'undefined' ? f.separator : "none"; var dna = "";

if (txt == "") { // check of string is empty return dna; };

if (separator !== "none") { var re = new RegExp(separator, "g"); txt = txt.replace(re, " "); } txt = txt.toUpperCase();

// add start codon dna += this.char["start"];

// translate to dna for (var i=0; i<txt.length; i++) { if (typeof this.char[txt[i]] !== 'undefined') { if (txt[i] == ".") { // cut protein and go to next sentence dna += this.char["stop"]; dna += this.char[" "]; dna += this.char["start"]; continue; }; dna += this.char[txt[i]]; } }

//put a stop codon dna += this.char["stop"];

//return return dna; }

dna.prototype.colorBlock = function(letter) {

return '
'+letter+'
';

}

dna.prototype.colorDNA = function(dna) { var txt = dna.text; var canvas = "";

if (txt == "") { // check for dna return canvas; };

txt = txt.toUpperCase();

for (var i = 0; i < txt.length; i++) {

canvas += '
'+txt[i]+'
';

};

return canvas; }