-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPROT.py
More file actions
18 lines (13 loc) · 1.22 KB
/
PROT.py
File metadata and controls
18 lines (13 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
# Translating RNA into Protein
file = open('data/rosalind_prot.txt', 'r')
rna = file.read()
# RNA triplet codon table
triplet_codon = {"UUU" : "F", "CUU" : "L", "AUU" : "I", "GUU" : "V", "UUC" : "F", "CUC" : "L", "AUC" : "I", "GUC" : "V", "UUA" : "L", "CUA" : "L", "AUA" : "I", "GUA" : "V", "UUG" : "L", "CUG" : "L", "AUG" : "M", "GUG" : "V", "UCU" : "S", "CCU" : "P", "ACU" : "T", "GCU" : "A", "UCC" : "S", "CCC" : "P", "ACC" : "T", "GCC" : "A", "UCA" : "S", "CCA" : "P", "ACA" : "T", "GCA" : "A", "UCG" : "S", "CCG" : "P", "ACG" : "T", "GCG" : "A", "UAU" : "Y", "CAU" : "H", "AAU" : "N", "GAU" : "D", "UAC" : "Y", "CAC" : "H", "AAC" : "N", "GAC" : "D", "UAA" : "-", "CAA" : "Q", "AAA" : "K", "GAA" : "E", "UAG" : "-", "CAG" : "Q", "AAG" : "K", "GAG" : "E", "UGU" : "C", "CGU" : "R", "AGU" : "S", "GGU" : "G", "UGC" : "C", "CGC" : "R", "AGC" : "S", "GGC" : "G", "UGA" : "-", "CGA" : "R", "AGA" : "R", "GGA" : "G", "UGG" : "W", "CGG" : "R", "AGG" : "R", "GGG" : "G"}
protein_string = ""
for i in range(0, len(rna)-(3+len(rna)%3), 3):
if triplet_codon[rna[i:i+3]] == "-" :
break
protein_string += triplet_codon[rna[i:i+3]]
with open('output/PROT.txt', 'w') as output_data:
output_data.write(protein_string)