带密码子的Python正则表达式

2024-09-27 02:22:10 发布

您现在位置:Python中文网/ 问答频道 /正文

正在努力寻找序列“TAA”(三个字符的三胞胎)“TAA”。

我尝试了以下方法:

re.findall('TAA...+?TAA',seq)这当然不是三胞胎,而是序列

re.findall('TAA([ATGC]{3})+?TAA' , seq)但是给了我一个列表作为输出

'AGG', 'TCT', 'GTG', 'TGG', 'TGA', 'TAT',

有什么想法吗?我当然可以检查

re.findall('TAA...+?TAA',seq)

如果长度%3==0,但如何使用RE?


Tags: 方法re列表序列字符seqaggfindall
1条回答
网友
1楼 · 发布于 2024-09-27 02:22:10

你想要一个非捕获组。在

(?:...)

A non-capturing version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.

试试这个:

re.findall('TAA(?:[ATGC]{3})+?TAA' , seq)

相关问题 更多 >

    热门问题