Lesson 11 of 16 · 11 min
Reverse complement & the two strands
DNA is the molecule inside every living cell that stores the instructions for building and running that organism, written as a long string of just four letters. It does not float around as a single thread: it comes as two strands zipped together, like the two sides of a ladder.
The two strands
Each strand is a chain of building blocks called nucleotides, and the part of a nucleotide we read is its base, which is one of four letters: A, C, G, or T. In the ladder picture, two bases meet in the middle to form each rung, and they are always paired the same way: A always sits opposite T, and G always sits opposite C. The two strands are also antiparallel, meaning each strand has a start called the 5' end and a finish called the 3' end, and the two strands run from 5' to 3' in opposite directions.
Complement then reverse
The complement of a strand is what you get by swapping each letter for its partner: A becomes T, T becomes A, G becomes C, and C becomes G. To get the reverse complement you take that complement and then reverse the whole order, because the partner strand is read from its own 5' end, which lines up with the 3' end of the strand you started with. Let's work out the reverse complement of the strand 5'-ATGC-3' by hand.
Start (5' -> 3'): A T G C
Complement each base: T A C G
Reverse the order: G C A T <- reverse complement (5' -> 3')So the reverse complement of ATGC is GCAT. This matters because a gene you care about may actually be written on the opposite strand, so you need its reverse complement to read it correctly. It is also how you design a primer, a short piece of DNA that must match the opposite strand to grab onto the right spot.
Doing this by hand is fine for four letters but slow and error-prone for thousands, so you let a computer do it. In the terminal, the text-only window where you type commands instead of clicking buttons, two tiny tools do the work: rev reverses text, and tr swaps one set of characters for another. You can also do it in Python, a beginner-friendly programming language.
echo ATGC | rev | tr 'ACGTacgt' 'TGCAtgca'GCAT
seq = "ATGC"
pairs = {"A": "T", "T": "A", "G": "C", "C": "G"}
revcomp = "".join(pairs[base] for base in reversed(seq))
print(revcomp)Try it yourself: Find the reverse complement of 5'-GATTACA-3'. First do it by hand (write the complement, then reverse it), then check your answer by running: echo GATTACA | rev | tr 'ACGTacgt' 'TGCAtgca'