Getting the reverse complement — PyCogent v1.3 documentation

### Navigation

- index
- next |
- previous |
- PyCogent v1.3 documentation »
- Cogent Usage Examples »

# 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
    >NineBande
    AAACTGCTGTTCTCATGCTGTAATAAGTTGGCATGAGTATTTGTGCCACA
    >Mouse
    AAACTGCTGGTCTCAGGCTGTAATGAGCTGGCATGAGCATCTGTGCCACA
    >Human
    AAACTGCTGTTCTCATGCTGTAATGAGCTGGCATGAGTATTTGTGCCACA
    >HowlerMon
    AAACTGCTGTTCTCATGCTGTAATGAGCTGGCATGAGTATTTGTGCCACA
    >DogFaced
    AAACTGCTGTTCTCATGCTGTAATGAGTTGGCATGAGTATTTGTGCCACA

### Navigation

- index
- next |
- previous |
- PyCogent v1.3 documentation »
- Cogent Usage Examples »