Last active
September 1, 2021 13:24
-
-
Save Vini2/cbcf4d379952dc64c7742265510aa5d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read the file and get the RNA string | |
file = open('sample_rna.txt', 'r') | |
rna = file.read() | |
print "RNA String: ", rna | |
# RNA codon table | |
rna_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" : "STOP", "CAA" : "Q", "AAA" : "K", "GAA" : "E", | |
"UAG" : "STOP", "CAG" : "Q", "AAG" : "K", "GAG" : "E", | |
"UGU" : "C", "CGU" : "R", "AGU" : "S", "GGU" : "G", | |
"UGC" : "C", "CGC" : "R", "AGC" : "S", "GGC" : "G", | |
"UGA" : "STOP", "CGA" : "R", "AGA" : "R", "GGA" : "G", | |
"UGG" : "W", "CGG" : "R", "AGG" : "R", "GGG" : "G" | |
} | |
protein_string = "" | |
# Generate protein string | |
for i in range(0, len(rna)-(3+len(rna)%3), 3): | |
if rna_codon[rna[i:i+3]] == "STOP" : | |
break | |
protein_string += rna_codon[rna[i:i+3]] | |
# Print the protein string | |
print "Protein String: ", protein_string | |
# End of program |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Translating RNA into Protein
Solution for problem at ROSALIND.info