skbio.sequence.DNA.to_regex

DNA.to_regex()[source]

Return regular expression object that accounts for degenerate chars.

State: Stable as of 0.4.1.

Returns:

regex

Pre-compiled regular expression object (as from re.compile) that matches all non-degenerate versions of this sequence, and nothing else.

Examples

>>> from skbio import DNA
>>> seq = DNA('TRG')
>>> regex = seq.to_regex()
>>> regex.match('TAG').string
'TAG'
>>> regex.match('TGG').string
'TGG'
>>> regex.match('TCG') is None
True