Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Reverse complement

Reverse complement converts one strand of DNA to its complement which travels in the opposite direction.

DNA is a double strand which means that information can be stored on either of these two strands. Therefore one must search twice using the reverse complement string also to find sequences on the opposite strand.

void reverse_complement()
{
    using namespace boost::genetics;

    // In this example the string is reversed to AACCTTTT
    // and then complemented (T <-> A and C <-> G) to TTGGAAAA.
    dna_string str("TTTTCCAA");

    std::cout << "reverse complement of " << str << " is " << rev_comp(str) << "\n";

    // This also works for `std::string`.
    std::string stdstr("TTGGAAAA");

    std::cout << "reverse complement of " << stdstr << " is " << rev_comp(stdstr) << "\n";
} // void reverse_complement()

PrevUpHomeNext