skbio.sequence.DNA.__eq__

DNA.__eq__(other)[source]

Determine if this sequence is equal to another.

State: Stable as of 0.4.0.

Sequences are equal if they are exactly the same type and their sequence characters, metadata, and positional metadata are the same.

Parameters:

other : Sequence

Sequence to test for equality against.

Returns:

bool

Indicates whether this sequence is equal to other.

Examples

Define two Sequence objects that have the same underlying sequence of characters:

>>> from skbio import Sequence
>>> s = Sequence('ACGT')
>>> t = Sequence('ACGT')

The two sequences are considered equal because they are the same type, their underlying sequence of characters are the same, and their optional metadata attributes (metadata and positional_metadata) were not provided:

>>> s == t
True
>>> t == s
True

Define another sequence object with a different sequence of characters than the previous two sequence objects:

>>> u = Sequence('ACGA')
>>> u == t
False

Define a sequence with the same sequence of characters as u but with different metadata and positional metadata:

>>> v = Sequence('ACGA', metadata={'id': 'abc'},
...              positional_metadata={'quality':[1, 5, 3, 3]})

The two sequences are not considered equal because their metadata and positional metadata do not match:

>>> u == v
False