Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Translating DNA into a protein

After this lesson: I can translate a DNA sequence into a protein with a codon table.

60 min lesson1 commandJupyterLab data science lab: pandas, Matplotlib and scikit-learn in the browser

Translation turns DNA letters into a protein

A protein is a chain of amino acids, and a gene's DNA letters say which ones, three letters at a time. Translation is the step that reads those letters and builds the chain.

You will translate invented DNA with a dictionary and a loop, and see why the starting point matters.

By the end of this lesson

Note

I can translate a DNA sequence into a protein with a codon table.

Key words

WordWhat it meansExample
Codona group of three basesGCT
Amino acidone building block of a protein
Start codonthe codon ATG, where translation begins
Stop codona codon that ends translation
Reading framewhere the first codon starts

The cells students fill in are left blank in this preview.

A codon is three bases

DNA is read in groups of three bases. Each group is a codon, and a table says which amino acid it stands for. Amino acids have a one-letter code, such as M or K.

Some codons are stop codons. They mean the chain is finished. The full table has 64 codons. The one below is a short piece of it.

A cut-down codon table of 12 codons

CodonLetterCodonLetter
ATGM (start)TTTF
GGCGGCTA
AAAKGAAE
CCCPCTGL
TGGWTAAstop
TAGstopTGAstop

The cells students fill in are left blank in this preview.

The reading frame decides where codons start

The same letters give different codons if you start in a different place. The reading frame is the position of the first codon. Frame 0 starts at the first letter, frame 1 at the second and frame 2 at the third.

A shift of one letter changes every codon after it, so the protein changes completely.

Worked example: ATGGCTAAATAG in three frames

FrameCodonsProtein
0ATG GCT AAA TAGM A K and a stop
1TGG CTA AAT (AG left over)W, then two codons not in the cut-down table
2GGC TAA ATA (G left over)G, a stop, then a codon not in the table

The cells students fill in are left blank in this preview.

Read the same DNA in three frames

Code: python
codons = {
    "ATG": "M", "TTT": "F", "GGC": "G", "GCT": "A",
    "AAA": "K", "GAA": "E", "CCC": "P", "CTG": "L",
    "TGG": "W", "TAA": "*", "TAG": "*", "TGA": "*",
}
dna = "ATGGCTAAATAG"
for frame in [0, 1, 2]:
    protein = ""
    for start in range(frame, len(dna) - 2, 3):
        codon = dna[start:start + 3]
        if codon in codons:
            protein = protein + codons[codon]
        else:
            protein = protein + "?"
    print("frame", frame, protein)
# A ? means this cut-down table has no entry. A * is a stop codon.

Cut a DNA string into codons

Command
docker exec jupyter python3 -c "s = 'ATGGCTAAATAG'; print([s[i:i + 3] for i in range(0, 12, 3)])"

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

The command prints four codons

The command steps through the string three letters at a time, starting at 0. It prints a list of four codons: ['ATG', 'GCT', 'AAA', 'TAG'].

The last of them, TAG, is a stop codon.

Translation stops at the first stop codon

To translate, cut the DNA into codons from the chosen frame, look each one up and join the letters. When you meet a stop codon, you stop and leave it out.

Letters left over at the end, fewer than three, make no codon and are ignored.

Translate until the stop codon

Code: python
codons = {
    "ATG": "M", "TTT": "F", "GGC": "G", "GCT": "A",
    "AAA": "K", "GAA": "E", "CCC": "P", "CTG": "L",
    "TGG": "W", "TAA": "*", "TAG": "*", "TGA": "*",
}
dna = "ATGGCTAAATAGGAA"
protein = ""
for start in range(0, len(dna) - 2, 3):
    amino = codons[dna[start:start + 3]]
    if amino == "*":
        break
    protein = protein + amino
print(protein)
# Change dna to "ATGTTTGAA" and predict the protein.

A common mistake

Warning

Many people think a protein is read from the first letter of the DNA. Translation begins at a start codon, ATG, and the frame matters. Shift the start by one letter and you read different codons, so you get a different protein.

About this lab and its source: JupyterLab data science lab: pandas, Matplotlib and scikit-learn in the browser

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.