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.

5 Steps 1 min read Medium

Step-by-Step Guide

  1. 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)
  2. Step 2: Read in the file.

  3. Step 3: Create a hash table that maps each nucleotide to its complement.

  4. Step 4: Iterate through the sequence and use a hash table lookup to construct the complementary sequence.

  5. 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

I

Isabella Thompson

Committed to making organization accessible and understandable for everyone.

137 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: