skbio.sequence.Protein.to_regex¶
- Protein.to_regex(within_capture=False)[源代码]¶
返回说明退化字符的正则表达式对象。
状态:自0.4.1起稳定。
- 参数:
within_capture (bool) -- 如果
True
,将序列的regex模式格式化为单个捕获组。如果False
,按原样编译regex模式,不使用捕获组。- 返回:
预编译的正则表达式对象(从
re.compile
)它与这个序列的所有确切版本相匹配,没有其他的。- 返回类型:
regex
示例
>>> 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 >>> regex = seq.to_regex(within_capture=True) >>> regex.match('TAG').groups(0) ('TAG',)