\
PyCogent 1.9 documentation

# Getting the reverse complement

Section author: Gavin Huttley

This is a property of DNA, and hence alignments need to be created with the appropriate `MolType`. In the following example, the alignment is truncated to just 50 bases for the sake of simplifying the presentation.

    >>> from cogent import LoadSeqs, DNA
    >>> aln = LoadSeqs("data/long_testseqs.fasta", moltype=DNA)[:50]

The original alignment looks like this.

    >>> print aln
    >Human
    TGTGGCACAAATACTCATGCCAGCTCATTACAGCATGAGAACAGCAGTTT
    >HowlerMon
    TGTGGCACAAATACTCATGCCAGCTCATTACAGCATGAGAACAGCAGTTT
    >Mouse
    TGTGGCACAGATGCTCATGCCAGCTCATTACAGCCTGAGACCAGCAGTTT
    >NineBande
    TGTGGCACAAATACTCATGCCAACTTATTACAGCATGAGAACAGCAGTTT
    >DogFaced
    TGTGGCACAAATACTCATGCCAACTCATTACAGCATGAGAACAGCAGTTT

We do reverse complement very simply.

    >>> naln = aln.rc()

The reverse complemented alignment looks like this.

    >>> print naln
    >Human
    AAACTGCTGTTCTCATGCTGTAATGAGCTGGCATGAGTATTTGTGCCACA
    >HowlerMon
    AAACTGCTGTTCTCATGCTGTAATGAGCTGGCATGAGTATTTGTGCCACA
    >Mouse
    AAACTGCTGGTCTCAGGCTGTAATGAGCTGGCATGAGCATCTGTGCCACA
    >NineBande
    AAACTGCTGTTCTCATGCTGTAATAAGTTGGCATGAGTATTTGTGCCACA
    >DogFaced
    AAACTGCTGTTCTCATGCTGTAATGAGTTGGCATGAGTATTTGTGCCACA