skbio.sequence.DNA.find_with_regex

DNA.find_with_regex(regex, ignore=None)[source]

Generate slices for patterns matched by a regular expression.

State: Stable as of 0.4.0.

Parameters:

regex : str or regular expression object

String to be compiled into a regular expression, or a pre- compiled regular expression object (e.g., from calling re.compile).

ignore : 1D array_like (bool) or iterable (slices or ints), optional

Indicate the positions to ignore when matching.

Yields:

slice

Location where the regular expression matched.

Examples

>>> from skbio import Sequence
>>> s = Sequence('AATATACCGGTTATAA')
>>> for match in s.find_with_regex('(TATA+)'):
...     match
...     str(s[match])
slice(2, 6, None)
'TATA'
slice(11, 16, None)
'TATAA'