regex - Perl 正则表达式 : howto get open-reading-frames without internal stop-codons?

标签 regex perl substring bioinformatics

我正在尝试以字符串格式从 (DNA) 基因组序列的一条链中分离出所有重叠的 ORF(包括基因组上的起始 (i) 和终止 (j) 位置以及 ORF 的长度 (l)); ORF 应以 ATG 开头,至少有 24 个内部核苷酸 [ACGT],并以 (TAA|TAG|TGA) 结尾。

通过查看find ORF with minimal size of 45 bases using perl regular expression - why this regex doesn't work我想出了这个(所以需要调整):

    my $genome = $_[0];
    my $ATG_count = 0;
    my $ORF_count = 0;
    my @i = (); 
    my @j = (); 
    my @l = (); 
    my @frames = (); 

    while ($genome =~ m/ATG/ig) {   ### I need to do this to find every ORF starting with ATG, including ORFs which are located inside other ORFs.
        $ATG_count++;
        my $start = $-[0]+1;
        foreach (substr($genome,$-[0]) =~ m/^ATG(?:[ATGC]{3}){8,}(?:TAA|TAG|TGA)/ig) {
            my $length = $+[0];
            if ($length%3 == 0) {   ### I need to do this because sadly, the above regex DOESN'T recover only Strings are dividable by 3. (Why not?!?)
                my $stop = $start+$length;
                my $readingframe = ($start%3);
                push(@i, $start), push(@j, $stop), push(@l, $length), push (@frames, $readingframe);
                $ORF_count++;
            }
        }
    }

现在,上面的代码恢复以 ATG 开头、以 (TAA|TAG|TGA) 结尾且 >=30 的 ORF - 我已经尝试过 - 但恢复的 ORF 具有内部终止密码子!

我的问题是如何使恢复的 ORF 停止在 ATG 之后的第一个终止密码子处?我想一种可能性是从正则表达式的中间部分排除 (TAA|TAG|TGA) -> (?:[ATGC]{3}){8,} 但我该怎么做呢?

非常感谢!

编辑:

好吧,在尝试了下面的建议后,我想出了一个解决方案,可以从给定的基因组序列中恢复所有大于等于 30 bp 的重叠 ORF,这些序列以 ATG 开头并且没有内部终止密码子:

    my $genome = $_[0];
    my $ATG_count = 0;
    my $ORF_count = 0;
    my @i = (); 
    my @j = (); 
    my @l = (); 
    my @frames = (); 

    while ($genome =~ m/ATG/ig) {
        $ATG_count++;
        my $start = $-[0]+1;
        foreach (substr($genome,$-[0]) =~ m/^ATG(?:[ATGC]{3})*?(?:TAA|TAG|TGA)/ig) {    
        ### This was changed so that it matches "ATG - first(lazy) stop-codon". 
            my $length = $+[0];
            if ($length%3 == 0 && $length >=30) {    
            ### This was changed so that the matches must be >=30 in length.
                my $stop = $start+$length;
                my $readingframe = ($start%3);
                push(@i, $start), push(@j, $stop), push(@l, $length), push (@frames, $readingframe);
                $ORF_count++;
            }
        }
    }

最佳答案

您编写的模式将贪婪地搜索密码子,直到到达字符串中的最后一个终止密码子。尝试像这样重写您的模式:

m/ATG(?:[ATGC]{3}){8,}?(?:TAA|TAG|TGA)/ig

? 添加到 (?:[ATGC]{3}){8,}? 告诉正则表达式引擎匹配尽可能多的密码子,直到第一个终止密码子,而不是最后一个。我还会从您的模式中省略 ^ ,假设起始密码子不会是您序列中的第一个密码子。

为了确保返回的字符串不包含终止密码子,请将结果包装在第二个正则表达式测试中,以检查终止密码子。据我所知,没有办法在单个正则表达式模式中对此进行可变长度的负后向测试。

关于regex - Perl 正则表达式 : howto get open-reading-frames without internal stop-codons?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17528778/

相关文章:

正则表达式匹配传统的提交语法

windows - 如何使用 Perl 从 Windows 命令行获取文件的 SHA1 哈希值?

xml - 如何使用 xmlstarlet 搜索和编辑符合条件的 xml 标记

javascript - 使用 jQuery 或纯 JavaScript 的 html 子字符串

javascript - String.slice 和 string.substring

javascript - 带有点、空格和数字的正则表达式 javascript

javascript - 不接受一系列点(.) 的正则表达式

javascript - 检查字符串是否为 Spotify URL

python - 如何运行只能写入 STDOUT 并从 STDIN 读取的脚本?

perl - 在 Perl 中,在 void 上下文中使用 map 而不是 foreach 循环是否合适?