The reverse complement of a DNA sequence is the sequence of the opposite strand, written in the usual 5′ to 3′ direction. You need it whenever you design a reverse primer, search for a motif on the minus strand, check a restriction site or read a gene that lies on the other strand of a genome.
Why "reverse" and "complement"
DNA strands are antiparallel. If one strand runs 5′ to 3′ from left to right, its partner runs 5′ to 3′ from right to left. To write the partner in the standard 5′ to 3′ direction you have to do two things:
- Complement each base: A pairs with T, and G pairs with C.
- Reverse the order, so the sequence reads 5′ to 3′.
Doing only one of the two is the most common mistake. The complement alone gives the partner strand written 3′ to 5′; the reverse alone gives a sequence that does not pair with anything.
A worked example
Start with 5′-ATGCCGTTAG-3′.
- Complement: 3′-TACGGCAATC-5′
- Reverse that to read 5′ to 3′: 5′-CTAACGGCAT-3′
So the reverse complement of ATGCCGTTAG is CTAACGGCAT. Check it by pairing the first base of one with the last base of the other: A with T, T with A, G with C, and so on.
Ambiguous bases (IUPAC codes)
Real sequences often contain IUPAC ambiguity codes. Each has a defined complement:
| Code | Meaning | Complement |
|---|---|---|
| R | A or G | Y |
| Y | C or T | R |
| K | G or T | M |
| M | A or C | K |
| S | G or C | S |
| W | A or T | W |
| B | not A | V |
| V | not T | B |
| D | not C | H |
| H | not G | D |
| N | any | N |
A good tool keeps the case of each letter and handles these codes. For RNA, U pairs with A, so the reverse complement of an RNA sequence uses U instead of T.
Where you use it
- Reverse primers. The reverse primer binds the top strand at the 3′ end of the target, so its sequence is the reverse complement of that region.
- Minus-strand genes. A gene annotated on the minus strand of a genome is read by taking the reverse complement of the genomic coordinates.
- Palindromes and restriction sites. Many restriction sites, such as EcoRI (GAATTC), are their own reverse complement. That property is what lets the enzyme cut both strands at the same site.
- Searching both strands. A motif search that does not also search the reverse complement misses half of the possible matches.
Doing it in Python
COMP = str.maketrans("ACGTRYKMSWBVDHNacgtrykmswbvdhn",
"TGCAYRMKSWVBHDNtgcayrmkswvbhdn")
def reverse_complement(seq: str) -> str:
return seq.translate(COMP)[::-1]
print(reverse_complement("ATGCCGTTAG")) # CTAACGGCATBiopython gives the same result with Seq("ATGCCGTTAG").reverse_complement().
Common mistakes
- Taking the complement but forgetting to reverse it, or the other way round.
- Pasting a FASTA header or line numbers along with the sequence.
- Losing ambiguity codes by converting them to N.
- Mixing DNA and RNA alphabets.
Try it free
The Reverse Complement tool handles IUPAC codes, keeps upper and lower case and runs in your browser, so the sequence is never uploaded. To check a primer once you have it, use the Primer Tm calculator.
Learn it properly with Vedicgen
Sequence handling, strands, file formats and the first steps in Python are the opening weeks of Vedicgen's Bioinformatics Foundations course, which assumes no programming. To automate tasks like this one, continue with Python for Bioinformatics.
Sources and further reading
Written by the Solagene team for research and education. Found an error? Tell us and we will correct it.