-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcutecodons.js
More file actions
115 lines (105 loc) · 2.42 KB
/
cutecodons.js
File metadata and controls
115 lines (105 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
codonCount = new Object();
codonCount.AAA = 0;
codonCount.AAC = 0;
codonCount.AAG = 0;
codonCount.AAU = 0;
codonCount.ACA = 0;
codonCount.ACC = 0;
codonCount.ACG = 0;
codonCount.ACU = 0;
codonCount.AGA = 0;
codonCount.AGC = 0;
codonCount.AGG = 0;
codonCount.AGU = 0;
codonCount.AUA = 0;
codonCount.AUC = 0;
codonCount.AUG = 0;
codonCount.AUU = 0;
codonCount.CAA = 0;
codonCount.CAC = 0;
codonCount.CAG = 0;
codonCount.CAU = 0;
codonCount.CCA = 0;
codonCount.CCC = 0;
codonCount.CCG = 0;
codonCount.CCU = 0;
codonCount.CGA = 0;
codonCount.CGC = 0;
codonCount.CGG = 0;
codonCount.CGU = 0;
codonCount.CUA = 0;
codonCount.CUC = 0;
codonCount.CUG = 0;
codonCount.CUU = 0;
codonCount.GAA = 0;
codonCount.GAC = 0;
codonCount.GAG = 0;
codonCount.GAU = 0;
codonCount.GCA = 0;
codonCount.GCC = 0;
codonCount.GCG = 0;
codonCount.GCU = 0;
codonCount.GGA = 0;
codonCount.GGC = 0;
codonCount.GGG = 0;
codonCount.GGU = 0;
codonCount.GUA = 0;
codonCount.GUC = 0;
codonCount.GUG = 0;
codonCount.GUU = 0;
codonCount.UAA = 0;
codonCount.UAC = 0;
codonCount.UAG = 0;
codonCount.UAU = 0;
codonCount.UCA = 0;
codonCount.UCC = 0;
codonCount.UCG = 0;
codonCount.UCU = 0;
codonCount.UGA = 0;
codonCount.UGC = 0;
codonCount.UGG = 0;
codonCount.UGU = 0;
codonCount.UUA = 0;
codonCount.UUC = 0;
codonCount.UUG = 0;
codonCount.UUU = 0;
function generateTable(){
textInput = document.getElementById("fastainput").value;
fastaentries = readFASTA(textInput);
for(j=0;j<fastaentries.length;j++){
incrementCodons(processSequence(fastaentries[j].sequence));
}
displayOutput();
}
function processSequence(sequence){
// Converts sequence to upper case
// Converts all T's to U's to make sure all sequence is RNA
// Replaces all other characters with '-' (hyphen)
processed = '';
sequence = sequence.toUpperCase();
for(i=0;i<sequence.length;i++){
if(sequence[i]=='A' || sequence[i]=='G' || sequence[i]=='C' || sequence[i]=='U'){
processed += sequence[i];
}
else if(sequence[i]=='T'){
processed += 'U';
}
else{
processed += '-';
}
}
return processed;
}
function incrementCodons(sequence){
for(k=0;k<sequence.length/3;k++){
codonCount[sequence.slice(3*k,3*k+3)]++;
}
}
function displayOutput(output){
outhtml = ''
codons = Object.keys(codonCount);
for(m=0;m<codons.length;m++){
outhtml += codons[m] + ": " + codonCount[codons[m]].toString() + '<br>';
}
document.getElementById('outputArea').innerHTML = outhtml;
}