The reverse complement of a DNA sequence signifies the contents of the opposite strand in a DNA molecule. DNA molecules are constructed as such because each nucleotide has a complementary nucleotide on the other strand to which a non-covalent bond exists.
Steps
Method 1
Method 1 of 2:
By Hand
-
Trace through the sequence backwards, starting from the last nucleotide in the sequence.
-
As you pass over each nucleotide, add its complementary nucleotide to the next line, beginning the complemented string from the left-hand side of the page. Remember, guanine (G) bonds to cytosine (C) and adenine (A) bonds to thymine (T).Advertisement
Method 2
Method 2 of 2:
Programmatically (Python 2)
-
Create or accept an input file. This article assumes that the input is in FASTA format, with a single sequence per file. The following steps also assume that all nucleotides are ATGC bases.
-
Read in the file. For FASTA format:
- Discard the first line of the file.
- Remove all remaining newlines and other trailing whitespace.
def init ( sequence ): with open ( argv [ 1 ]) as input : sequence = "" . join ([ line . strip () for line in input . readlines ()[ 1 :]]) return sequence
-
Create a hash table that maps each nucleotide to its complement.
complement = { 'A' : 'T' , 'C' : 'G' , 'G' : 'C' , 'T' : 'A' }
-
Iterate through the sequence and use a hash table lookup to construct the complementary sequence. Reverse the resulting vector.
def reverse_complement ( seq ): bases = [ complement [ base ] for base in seq ] bases = reversed ( bases ) return bases
-
Print the contents of the vector. =
result = reverse_complement ( seq ) print '' . join ( result )
Advertisement
Expert Q&A
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Tips
- If you're calculating the reverse complement by hand, be sure to double check! It can be easy to miss a base pair or use the wrong complement, especially if you're reading a long sequence on paper.Thanks
Advertisement
References
- StackOverflow: Reverse complement of DNA strand using Python - Source of original programmatic solution that handles non-ATGC base pairs. Solution by Gabriel . Licensed under a CC-By-SA 3.0 license .
About this article
Thanks to all authors for creating a page that has been read 16,149 times.
Advertisement