skbio.sequence.Protein.__eq__#

Protein.__eq__(other)[source]#

Determine if this sequence is equal to another.

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

Parameters:
otherSequence

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, positional metadata, and interval metadata:

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

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

>>> u == v
False