skbio.sequence.GrammaredSequence.index#

GrammaredSequence.index(subsequence, start=None, end=None)[source]#

Find position where subsequence first occurs in the sequence.

Parameters:
subsequencestr, Sequence, or 1D np.ndarray (np.uint8 or ‘|S1’)

Subsequence to search for in this sequence.

startint, optional

The position at which to start searching (inclusive).

endint, optional

The position at which to stop searching (exclusive).

Returns:
int

Position where subsequence first occurs in this sequence.

Raises:
ValueError

If subsequence is not present in this sequence.

TypeError

If subsequence is a Sequence object with a different type than this sequence.

Examples

>>> from skbio import Sequence
>>> s = Sequence('ACACGACGTT-')
>>> s.index('ACG')
2