-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path008. Translating RNA into Protein.py
39 lines (36 loc) · 1.31 KB
/
008. Translating RNA into Protein.py
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
# Translation
DNA_Sample = ["CACAUA"]
def translation(my_dictionary, codon_dict):
amino_acids = []
for i in range(0, len(DNA_Sample[0]), 3):
codon = DNA_Sample[0][i:i + 3]
if codon in codon_dict:
amino_acids.append(codon_dict[codon])
else:
amino_acids.append(codon)
return amino_acids
codons_to_proteins = {
"UUU": "F", "UUC": "F",
"UUA": "L", "UUG": "L", "CUU": "L", "CUC": "L", "CUA": "L", "CUG": "L",
"AUU": "I", "AUC": "I", "AUA": "I",
"AUG": "M", # the start codon
"GUU": "V", "GUC": "V", "GUA": "V", "GUG": "V",
"UCU": "S", "UCC": "S", "UCA": "S", "UCG": "S", "AGU": "S", "AGC": "S",
"CCU": "P", "CCC": "P", "CCA": "P", "CCG": "P",
"ACU": "T", "ACC": "T", "ACA": "T", "ACG": "T",
"GCU": "A", "GCC": "A", "GCA": "A", "GCG": "A",
"UAU": "Y", "UAC": "Y",
"CAU": "H", "CAC": "H",
"CAA": "Q", "CAG": "Q",
"AAU": "N", "AAC": "N",
"AAA": "K", "AAG": "K",
"GAU": "D", "GAC": "D",
"GAA": "E", "GAG": "E",
"UGU": "C", "UGC": "C",
"UAA": " ", "UAG": " ", "UGA": " ", # the stop codons
"UGG": "W",
"CGU": "R", "CGC": "R", "CGA": "R", "CGG": "R", "AGA": "R", "AGG": "R",
"GGU": "G", "GGC": "G", "GGA": "G", "GGG": "G",
}
result = translation(DNA_Sample, codons_to_proteins)
print(''.join(result))