codon={'UUU':'Phe','UUC':'Phe','uua':'Leu','UUG':'Leu','CUU':'Leu','CUC':'Leu','CUA':'Leu','CUG':'Leu','AUU':'Ile','AUC':'Ile','AUA':'Ile','AUG':'Met','GUU':'Val','GUC':'Val','GUA':'Val','GUG':'Val','UCU':'Ser','UCC':'Ser','UCA':'Ser','UCG':'Ser','CCU':'Pro','CCC':'Pro','CCA':'Pro','CCG':'Pro','ACU':'Thr','ACC':'Thr','ACA':'Thr','ACG':'Thr','GCU':'Ala','GCC':'Ala','GCA':'Ala','GCG':'Ala','UAU':'Tyr','UAC':'Tyr','UAA':'STOP','UAG':'STOP','CAU':'His','CAC':'His','CAA':'Gln','CAG':'Gln','AAU':'Asn','AAC':'Asn','AAA':'Lys','AAG':'Lys','GAU':'Asp','GAC':'Asp','GAA':'Glu','GAG':'Glu','UGU':'Cys','UGC':'Cys','UGA':'STOP','UGG':'Trp','CGU':'Arg','CGC':'Arg','CGA':'Arg','CGG':'Arg','AGU':'Ser','AGC':'Ser','AGA':'Arg','AGG':'Arg','GGU':'Gly','GGC':'Gly','GGA':'Gly','GGG':'Gly'}
Can any one help me that how to give function to translate this codon dictionary into amino acid sequence. I need help
2 answers
You already have your dictionary of codon to amino acid associations. Now you need to write a function to traverse an RNA sequence, pull out three bases at a time, and then use your dictionary to find the matching amino acid. If the codon is a STOP codon, simply returnwhat you've built without proceeding further.
One strategy would be to split your sequence into a list. Then you can iterate over that list. Have another list for your amino acids. For each codon, append that amino acid to your list. When you return from the function, simply join that amino acid list.
If Biopython has the three-letter amino acid alphabet available, you could also use it or define your own alphabet I suppose.
Google's solutions
- http://stackoverflow.com/questions/21188579/translate-a-dna-sequence-into-its-aminoacids-in-python
- http://isites.harvard.edu/fs/docs/icb.topic1122119.files/dna2aa.py
- Python Script To Translate Rna Sequences To Protein Sequences (with slight modification)
- http://pythonforbiologists.com/index.php/old-python-for-biologists-pages/python-for-biologists-6/ (for learning purpose)
- https://bytes.com/topic/python/answers/907514-how-write-program-python-2-6-decodes-dna-codons
Log in to answer this question.
Assignment?
Please, note that one of the keys in your dictionary is in lowercase, namely the 'uua' codon. You need to fix it in order for your translation code to work correctly.
That or you could coerce everything to upper/lowercase before the lookup. Not as efficient, but probably good enough for the scale of this homework assignment.