skbio.sequence.DNA.complement

DNA.complement(reverse=False)[source]

Return the complement of the nucleotide sequence.

State: Stable as of 0.4.0.

Parameters:

reverse : bool, optional

If True, return the reverse complement. If positional metadata is present, it will be reversed.

Returns:

NucleotideMixin

The (reverse) complement of the nucleotide sequence. The type and metadata of the result will be the same as the nucleotide sequence. If reverse is True, positional metadata will be reversed if it is present.

Examples

>>> from skbio import DNA
>>> seq = DNA('TTCATT', positional_metadata={'quality':range(6)})
>>> seq
DNA
-----------------------------
Positional metadata:
    'quality': <dtype: int64>
Stats:
    length: 6
    has gaps: False
    has degenerates: False
    has definites: True
    GC-content: 16.67%
-----------------------------
0 TTCATT
>>> seq.complement()
DNA
-----------------------------
Positional metadata:
    'quality': <dtype: int64>
Stats:
    length: 6
    has gaps: False
    has degenerates: False
    has definites: True
    GC-content: 16.67%
-----------------------------
0 AAGTAA
>>> rc = seq.complement(reverse=True)
>>> rc
DNA
-----------------------------
Positional metadata:
    'quality': <dtype: int64>
Stats:
    length: 6
    has gaps: False
    has degenerates: False
    has definites: True
    GC-content: 16.67%
-----------------------------
0 AATGAA
>>> rc.positional_metadata['quality'].values
array([5, 4, 3, 2, 1, 0])