-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProtein_Translations.js
48 lines (44 loc) · 1.07 KB
/
Protein_Translations.js
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
let proteinName = {
AUG: "Methionine",
UUU: "Phenylalanine",
UUC: "Phenylalanine",
UUA: "Leucine",
UUG: "Leucine",
UCU: "Serine",
UCC: "Serine",
UCA: "Serine",
UCG: "Serine",
UAU: "Tyrosine",
UAC: "Tyrosine",
UGC: "Cysteine",
UGC: "Cysteine",
UGG: "Tryptophan",
UAA: "STOP",
UAG: "STOP",
UGA: "STOP"
};
function protein_translation(rna){
let helper="";
let protein="";
if(rna.length%3!=0){
return "RNA not complete "
}
for(let i=0;i<rna.length;i++){
helper+=rna.charAt(i);
//console.log(helper+"\t");
if(helper.length==3){
if(proteinName[helper]==="STOP"){
return protein;
}
if(proteinName[helper]===undefined){
return "Error Invalid condon =>"+helper;
}
// console.log(helper+"\n");
protein+= proteinName[helper]+" ";
helper="";
}
}
return protein
}
let protein="AUGUUUUCUUAAAUG";
console.log(protein_translation(protein));