This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Help translating RNA to amino acid sequence

Need help with a coding project. I need to translate a strand of RNA to an amino acid sequence. This is what I have so far but when I run it it only print 2 of the amino acids. If anyone could help with that and also help with how to have it start translating when it finds AUG and how to have it stop when it reaches a STOP codon that would also be helpful. Thank you!

rna = "AUGGCAACU"

print ("RNA Sequence: ", rna)


translation_dict = {'UUU':'Phe', 'UUC':'Phe', 'UUA':'Leu', 'UUG':'Leu', 'UCU':'Ser', 'UCC':'Ser', 'UCA':'Ser', 'UCG':'Ser', 'UAA': 'Stop', 'UAG': 'Stop', 'UAU':'Tyr', 'UAC':'Tyr', 'UGU':'Cys', 'UGC':'Cys', 'UGA': 'Stop', 'UGG':'Trp', 'CUU':'Leu', 'CUC':'Leu', 'CUA':'Leu', 'CUG':'Leu', 'CCU':'Pro', 'CCC':'Pro', 'CCA':'Pro', 'CCG':'Pro', 'CAU':'His', 'CAC':'His', 'CAA':'Gln', 'CAG':'Gln', 'CGU':'Arg', 'CGC':'Arg', 'CGA':'Arg', 'CGG':'Arg', 'AUU':'Ile', 'AUC':'Ile', 'AUA':'Ile', 'AUG':'Met', 'ACU':'Thr', 'ACC':'Thr', 'ACA':'Thr', 'ACG':'Thr', 'AAU':'Asn', 'AAC':'Asn', 'AAA':'Lys', 'AAG':'Lys', 'AGU':'Ser', 'AGC':'Ser', 'AGA':'Arg', 'AGG':'Arg', 'GUU':'Val', 'GUC':'Val', 'GUA':'Val', 'GUG':'Val', 'GCU':'Ala', 'GCC':'Ala', 'GCA':'Ala', 'GCG':'Ala', 'GAU':'Asp', 'GAC':'Asp', 'GAA':'Glu', 'GAG':'Glu', 'GGU':'Gly', 'GGC':'Gly', 'GGA':'Gly','GGG':'Gly'
           }

amino_acid_sequence = ""


for i in range(0, len(rna)-(3+len(rna)%3), 3):
    if translation_dict[rna[i:i+3]] == "STOP" :
        break
    amino_acid_sequence += protein[rna[i:i+3]]

print ("Amino Acid Sequence: ", amino_acid_sequence)
rna-seq sequencing rna-seq

This looks like homework. The program should almost work but there are two mistakes you have to find. Also, this is not the full code or it should not compile or run.

0 answers

No answers yet.

Log in to answer this question.