Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 49 ยท Getting Started

DNA, RNA and protein as data

Treat the central dogma as a string problem: complements, reverse complements, transcription, the codon table, reading frames and translation, with Python examples.

The central dogma of molecular biology, named by Francis Crick in 1958, says that sequence information flows from DNA to RNA to protein. For a programmer that sentence is a recipe: DNA is a string, RNA is that string with one letter swapped, and a protein is the result of reading the RNA three letters at a time and looking each triplet up in a table. Once you see it this way, the whole of molecular biology becomes a collection of small string functions.

Eight codons shown as coding strand, template strand, mRNA and amino acids for a short gene
Caption: the coding strand reads ATG GCC ATT GTA ATG GGC CGC TGA; the mRNA has U for T; translation gives Met-Ala-Ile-Val-Met-Gly-Arg and then stops.

What you will learn

  • How base pairing lets you compute the complementary and reverse-complementary strand.
  • Why transcription copies the coding strand's sequence into RNA (with U in place of T).
  • How the codon table maps 64 triplets to 20 amino acids and three stop signals.
  • What reading frames and open reading frames (ORFs) are, and why there are six frames.

Key terms

  • Base pairing: A pairs with T (U in RNA); G pairs with C.
  • Strand polarity (5โ€ฒ and 3โ€ฒ): each strand has a direction; sequences are written 5โ€ฒ to 3โ€ฒ by convention.
  • Codon: three consecutive bases that specify one amino acid or a stop.
  • Reading frame: one of the three ways to group a strand into codons, depending on the starting offset.
  • ORF: an open reading frame, a run of codons from a start codon to a stop codon with no stop in between.

DNA is two strings that mirror each other

A DNA molecule has two strands wound around each other. The bases pair by fixed rules: adenine (A) with thymine (T), guanine (G) with cytosine (C). Because of that rule, one strand completely determines the other. If a strand reads ATGCC, the other strand contains TACGG at the matching positions.

There is a twist that matters in code. The two strands run in opposite directions (they are antiparallel). Each strand has a 5โ€ฒ end and a 3โ€ฒ end, named after carbon atoms of the sugar, and cellular machinery always reads and builds along a strand from 5โ€ฒ to 3โ€ฒ. We write sequences in that direction. So when you want the other strand written 5โ€ฒ to 3โ€ฒ, you cannot just complement each letter. You must complement and then reverse. The result is called the reverse complement.

Take ATGGCC. Complement each base: TACCGG. Reverse it: GGCCAT. That is the reverse complement, and it is the sequence of the opposite strand read in its own 5โ€ฒ to 3โ€ฒ direction. A common bug in beginner code is to forget the reversal. You will see exactly this mistake in real analysis scripts, and it silently produces nonsense, because the reverse strand then no longer reads like a gene.

Transcription: copy the coding strand, swap T for U

A gene sits on one of the two strands. The strand whose sequence matches the final RNA is called the coding strand (or sense strand). The other, which RNA polymerase actually reads, is the template strand. The polymerase moves along the template from its 3โ€ฒ end towards its 5โ€ฒ end and builds RNA 5โ€ฒ to 3โ€ฒ, adding the base that pairs with each template base. The result has the same sequence as the coding strand, except that RNA uses uracil (U) in place of thymine.

So the computational recipe for transcription is a one-liner: take the coding strand and replace every T with U. Beginners often think this means the template strand is the sequence they should see in the mRNA. It is the other way round: the mRNA matches the coding strand. Databases nearly always store the coding strand, so you can transcribe directly.

The genetic code: 64 codons, 21 meanings

Translation reads the mRNA in non-overlapping groups of three bases. With four letters and three positions there are 4 ร— 4 ร— 4 = 64 codons. They specify 20 amino acids plus a "stop" signal. Sixty-one codons are sense codons and three (TAA, TAG, TGA in DNA letters) are stop codons. Since 61 codons share 20 amino acids, the code is degenerate: most amino acids have several codons. Methionine (ATG) and tryptophan (TGG) are the only two amino acids with a single codon. Leucine, serine and arginine have six each.

The degeneracy is not random. Codons for the same amino acid often differ only in the third base, a pattern that makes the code robust to some point mutations (a change of the third base often leaves the protein unchanged, called a synonymous change). The code is nearly universal: the same table is used by bacteria, plants and humans. The standard table is NCBI "translation table 1". Some genomes depart from it. In vertebrate mitochondria, for example, TGA codes for tryptophan instead of stop, and ATA codes for methionine. Always check which table a genome uses.

Translation usually begins at a start codon, almost always ATG (methionine), and ends at the first in-frame stop. The stretch of codons between them is an open reading frame.

Reading frames and the six-frame problem

If you hand a program a raw stretch of DNA and ask "what protein is encoded here?", the answer depends on where you begin grouping. Starting at the first base, the second base or the third base gives three different frames (offsets 0, 1 and 2). The reverse complement is a second strand that also carries genes, giving three more. Altogether there are six reading frames. A gene finder for bacteria translates all six, looks for long ORFs (random sequence hits a stop codon, on average, about once every 21 codons, since 3 of 64 triplets are stops), and treats a very long ORF as evidence of a real gene.

In bacteria, genes are continuous, so ORF finding is a good first pass. In humans and other eukaryotes, genes are cut into exons separated by introns, and the cell splices out the introns before translation. ORF-finding on raw genomic DNA is then far less informative, and gene finders use more elaborate models.

Worked example by hand

Translate the coding strand ATGGCCATTGTAATGGGCCGCTGA.

  1. Split into codons: ATG GCC ATT GTA ATG GGC CGC TGA.
  2. Look each up: ATG is Met (M), GCC is Ala (A), ATT is Ile (I), GTA is Val (V), ATG is Met (M), GGC is Gly (G), CGC is Arg (R), TGA is stop.
  3. The protein is MAIVMGR and translation ends.

The transcript is AUGGCCAUUGUAAUGGGCCGCUGA. The template strand, written 5โ€ฒ to 3โ€ฒ, is the reverse complement of the coding strand: TCAGCGGCCCATTACAATGGCCAT. Check this against the picture above, where the template is shown 3โ€ฒ to 5โ€ฒ directly under the coding strand.

Common misconceptions

  • "One gene makes one protein." Alternative splicing, alternative start sites and later chemical modification mean a single gene can yield several protein products, especially in eukaryotes.
  • "ATG always marks the start of a protein." ATG is the usual start codon, but ATG also codes for methionine in the middle of a protein, and some genes start with other codons.
  • "The mRNA is the complement of the coding strand." The mRNA is a copy of the coding strand (with U for T), and a complement of the template strand.
  • "Reverse complement and complement are the same." They differ by a reversal, which changes the sequence completely.

Try it

Python Complement, transcribe and translate

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Interactive translator
Python How degenerate is the genetic code?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the reverse complement of ATGGCC?

    Complementing gives TACCGG; reversing that gives GGCCAT. The reversal is essential.
  2. 2. A coding strand reads ATGAAATAG. What is the mRNA?

    The mRNA copies the coding strand and replaces T with U.
  3. 3. How many codons code for stop in the standard genetic code?

    TAA, TAG and TGA (UAA, UAG, UGA in RNA) are the three stop codons.
  4. 4. Why are there six reading frames in a stretch of double-stranded DNA?

    Each strand can be grouped into codons starting at offset 0, 1 or 2, giving 3 x 2 = 6 frames.
  5. 5. Which pair of amino acids has only one codon each?

    Met (ATG) and Trp (TGG) are the only amino acids encoded by a single codon.

Summary

  • DNA has two antiparallel strands; the reverse complement gives the opposite strand read 5โ€ฒ to 3โ€ฒ.
  • mRNA copies the coding strand with U in place of T.
  • 64 codons encode 20 amino acids and three stops, so the code is degenerate.
  • Translation starts at ATG and ends at a stop; a stretch can be read in six frames.
  • Eukaryotic genes contain introns, so raw ORF finding works best in bacteria and viruses.

Next: Working with sequences in Python