Fork me on GitHub"

# skbio.sequence.GrammaredSequence.to_regex

`GrammaredSequence.``to_regex`()

  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 definite 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