how-to · 5 min read
DNA complements, codons and diversity basics
Molecular biology questions often start with a sequence and end with an interpretation. The same strand can be read in two directions, grouped into codons in three different frames, summarised by its base composition, or used as evidence about a population. Each step has a rule that is simple once stated and easy to misapply.
This guide works through complementary strands, reading frames, the genetic code, GC content and the Shannon diversity index, with short examples that can be checked by hand. It also states what each calculation does not cover, because a correct number from the wrong model is still the wrong answer.
Complements and the direction of DNA
The two strands of DNA are held together by base pairing: adenine pairs with thymine and cytosine pairs with guanine. They are also antiparallel, meaning one strand runs 5′ to 3′ while its partner runs 3′ to 5′. Together these two rules mean a single sequence determines its partner completely, as long as you track direction as carefully as you track letters.
The complement of ATGC is TACG, and that string is aligned with the original read in the opposite direction, so it is normally written 3′ to 5′. The reverse complement reverses it to GCAT, giving the partner strand in the familiar 5′ to 3′ orientation that databases, primers and most file formats use. RNA follows the same logic with uracil in place of thymine, so the complement of AUGC is UACG and its reverse complement is GCAU. Ambiguity codes use their standard partners — R with Y, K with M, B with V, D with H, and S, W, N and X with themselves — which keeps partially called sequences usable.
Reading frames and the standard genetic code
Codons are groups of three nucleotides, and translation starts at a chosen base. Reading from base one, two or three produces three different groupings of the same sequence, called reading frames. In a real gene the correct frame is usually the long open reading frame that begins with a start codon, but when a short fragment is pasted the frame often has to be chosen explicitly.
DNA is transcribed to messenger RNA before translation, with thymine replaced by uracil, and the ribosome then reads each codon. The standard genetic code maps the 64 possible codons to 20 amino acids and three stop signals: UAA, UAG and UGA. Mitochondrial genomes and a few organisms use small variations of this code, so a translation produced with the standard code can differ at a handful of codons in those systems. Ambiguous bases cannot be resolved into an amino acid, so they are usually written as X rather than guessed.
A translation example in all three frames
Take the DNA sequence ATGTTTGCTTAA. Transcribed to mRNA it becomes AUGUUUGUUUAA, and in frame 1 the codons are AUG, UUU, GCU and UAA: methionine, phenylalanine, alanine and a stop. That is the reading frame a gene annotation would normally use, and the stop codon tells the ribosome where to finish.
Frames 2 and 3 show why the choice matters. Frame 2 starts one base later, giving UGU, UUG, CUU and a trailing A, which translates as cysteine, leucine and leucine with no stop in the fragment. Frame 3 starts two bases later, giving GUU, UGC and UUA, which translates as valine, cysteine and leucine. All three are valid translations of the letters; only the biology of the sequence says which one is meaningful, and a tool should show the frame explicitly rather than quietly picking one.
GC content and what it summarises
GC content is the percentage of unambiguous bases that are guanine or cytosine: (G + C) / (A + T + U + G + C) × 100. It is a compact description of base composition, often used to compare sequences or as a rough input to estimates of melting behaviour, and it is easy to calculate once the sequence has been cleaned of formatting.
The cleaning step matters more than it looks. FASTA headers, line breaks, digits from numbered output and punctuation are not bases, and ambiguity codes such as N do not identify a base, so including them silently would distort the result. For the sequence ATGCGCNN the two Ns are excluded, leaving six unambiguous bases with two Gs and two Cs, so GC content is 4/6 = 66.7%. A percentage over six known bases is far less reliable than the same percentage over thousands, which is why the denominator should always be reported alongside the number.
Shannon diversity: richness and evenness
The Shannon diversity index combines two ideas about a community: how many species are present (richness) and how evenly individuals are divided among them (evenness). It is calculated as H′ = −Σ pᵢ ln pᵢ, where pᵢ is the proportion of individuals belonging to species i. Evenness is H′ divided by ln S, the maximum possible value for S species, so it ranges from 0 to 1.
For a community with 50, 30 and 20 individuals, the proportions are 0.5, 0.3 and 0.2 and the index is about 1.0297. Dividing by ln 3 ≈ 1.0986 gives an evenness of roughly 0.937, and Simpson's index of diversity, 1 − Σ pᵢ², is 0.62. Two communities with the same richness can have very different indexes if one is dominated by a single species, and both indexes are sensitive to sample size and sampling effort.
Checking results before you use them
Each of these calculations is easy to run and easy to misread, so a short check catches most mistakes. The list below is a practical final pass before a number goes into a report or a lab notebook.
- For a complement, confirm the molecule (DNA or RNA) and the direction labels before reusing the sequence as a primer.
- When translating, confirm the reading frame and remember that the standard code does not cover mitochondrial variants.
- Check whether an ambiguous base would have changed a start or stop codon; the tool reports X and cannot recover the hidden signal.
- For GC content, check how many unambiguous bases formed the denominator and how ambiguity codes were handled.
- For diversity, check the counts, the logarithm base and the sampling method before comparing two communities.