Wednesday 13 July 2016

RNA Splicing

This time we are looking at splicing. When mRNA has been transcribed from a DNA strand it often contains introns that have to be spliced away before the mRNA is translated into a protein. In this task we are given a FASTA file containing the sequences of one DNA strand and several introns. The goal is to remove the introns and print the resulting protein.

So, I wrote the following program that does exactly that:

from Bio import SeqIO                          
from Bio.Seq import Seq                        
from Bio.Alphabet import generic_dna           

sequences = []                                 
handle = open('sampledata.fasta', 'r')         
for record in SeqIO.parse(handle, 'fasta'):    
    sequence = ''                              
    for nt in record.seq:                      
        sequence += nt                         
    sequences.append(sequence)                 
handle.close()                                 

long_seq = sequences[0]                        
introns = sequences[1:]                        

for i in range(len(introns)):                  
    long_seq = long_seq.replace(introns[i], '')

long_seq = Seq(long_seq)                       
print(long_seq.translate(to_stop=True))        

No comments:

Post a Comment