Lesson 7 of 15
Translation
RNA → Protein
The second step after transcription is translation: ribosomes read the mRNA codons and assemble a chain of amino acids — a protein.
Each 3-letter RNA codon maps to one amino acid (using standard single-letter codes):
CODON_TABLE = {
"AUG": "M", # Start / Methionine
"UUU": "F", "UUC": "F", # Phenylalanine
"UAA": "*", "UAG": "*", "UGA": "*", # Stop
# ... 61 more
}
Translation starts at AUG and continues until a stop codon (*) is reached:
def translate(rna):
protein = ""
for i in range(0, len(rna) - 2, 3):
aa = CODON_TABLE.get(rna[i:i+3], "?")
if aa == "*":
break
protein += aa
return protein
print(translate("AUGAAAUAA")) # MK
AlphaGenome predicts splice junction usage — which RNA pieces get stitched together before translation — because errors in splicing cause many genetic diseases.
Your Task
Implement translate(rna) using the provided codon table.
Python runtime loading...
Loading...
Click "Run" to execute your code.