How to Find the Reverse Complement of a DNA Sequence
Create or accept an input file., Read in the file., Create a hash table that maps each nucleotide to its complement., Iterate through the sequence and use a hash table lookup to construct the complementary sequence., Print the contents of the vector.
Step-by-Step Guide
-
Step 1: 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., For FASTA format:
Discard the first line of the file.
Remove all remaining newlines and other trailing whitespace. def init(sequence): with open(argv) as input: sequence = "".join(]) return sequence , complement = {'A': 'T'
'C': 'G'
'G': 'C'
'T': 'A'} , Reverse the resulting vector. def reverse_complement(seq): bases = for base in seq] bases = reversed(bases) return bases , result = reverse_complement(seq) print ''.join(result) -
Step 2: Read in the file.
-
Step 3: Create a hash table that maps each nucleotide to its complement.
-
Step 4: Iterate through the sequence and use a hash table lookup to construct the complementary sequence.
-
Step 5: Print the contents of the vector.
Detailed Guide
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., For FASTA format:
Discard the first line of the file.
Remove all remaining newlines and other trailing whitespace. def init(sequence): with open(argv) as input: sequence = "".join(]) return sequence , complement = {'A': 'T'
'C': 'G'
'G': 'C'
'T': 'A'} , Reverse the resulting vector. def reverse_complement(seq): bases = for base in seq] bases = reversed(bases) return bases , result = reverse_complement(seq) print ''.join(result)
About the Author
Isabella Thompson
Committed to making organization accessible and understandable for everyone.
Rate This Guide
How helpful was this guide? Click to rate: