Friday, 24 June 2016

Translating RNA into Protein

In this task we are asked to translate a RNA-sequence into its corresponding protein sequence. To write this program 'from scratch' would probably take me a lot of time, mainly because there are 64 different codons available when translating RNA into proteins. Instead, there is an excellent function in Biopython for doing this, so I decided to save myself some time and effort and just use this instead. The following is the final code that i came up with:

from Bio.Seq import Seq              
from Bio.Alphabet import generic_rna 
with open('sampledata.txt','r') as f:
    data = f.read()                  
rnaseq = Seq(data, generic_rna)      
protein = rnaseq.translate()         
print(protein)                       

I think this approach was a lot faster than if I had set to write this program from scratch. At this point I feel like I have a good grasp of the basics of Python, and I will continue working more with Biopython when applicable. 

No comments:

Post a Comment