【发布时间】:2014-12-01 04:31:53
【问题描述】:
我有一长串 DNA 序列,我需要找到由两个回文序列组成的区域,它们位于间隔序列的两侧。
输入是:
cgtacacgagtagtcgtagctgtcagtcgatcgtacgtacgtagctgctgtagcactatcgaccccacacgtgtgtacacgatgcacagtcgtctatcacatgctagcgctgcccgtacgGATGGCCAAGGCCATCcgatcgctagctagcgccgcgcgtagcccgatcgagacatgctagcagttgtgctgatgtcgagatagctgtgatgcgatgctagcgccgcctagccgcctcgtgtaggctggatgcga的 tcgatcgatgctagcggcgcgatcga 强> tgcactagccgtagcgctagctgatcgatcgtaGATGGCCAAGGCCATCcgcgtagatacgacatgccgggggtatataa P>
这是我的代码:
use strict;
use warnings;
my $input= $ARGV[0];
chomp $input;
open (my $fh_in, "<", $input) or die "Cannot open file $input $!";
my $dna= <$fh_in>;
chomp $dna;
#######################################################################################
if ($dna=~ /[^ACGT]/gi) {
print "This is not a valid DNA sequence, it has unknown base(s)\n";
}
$dna=~ tr/[acgt]/[ACGT]/;
######################################################################################
print "Minimum length of palindromic sequence?\n";
my $min= <STDIN>;
chomp $min;
print "Maximum length of palindromic sequence?\n";
my $max= <STDIN>;
chomp $max;
print "Minimum length of spacer region?\n";
my $min_spacer= <STDIN>;
chomp $min_spacer;
print "Maximum length of spacer region?\n";
my $max_spacer= <STDIN>;
chomp $max_spacer;
######################################################################################
my $dna_length= length($dna);
my ($length , $offset , $string_1 , $string_2);
for ($offset= 0 ; $offset <= $dna_length-$max-$max-$max_spacer ; $offset++) {
for ($length= $min ; $length <= $max ; $length++) {
$string_1= substr ($dna, $offset, $length);
$string_2= reverse $string_1;
$string_2=~ tr/[ACGT]/[TGCA]/;
if ($dna=~ /(($string_1)([ACGT]{$min_spacer,$max_spacer})($string_2))/) {
print "IR starts at $offset => $2***$3***$4\n$1\n\n";
}
}
}
带参数: $min = 6 , $max = 12 , $min_spacer = 4 , $max_spacer = 12 我得到的输出是:
IR starts at 26 => TCGATCG***ATGCTAGCGGCG***CGATCGA
TCGATCGATGCTAGCGGCGCGATCGA
IR starts at 27 => CGATCG***ATGCTAGCGGCG***CGATCG
CGATCGATGCTAGCGGCGCGATCG
IR starts at 118 => CGGATG***GCCAAGGC***CATCCG
CGGATGGCCAAGGCCATCCG
IR starts at 118 => CGGATGG***CCAAGG***CCATCCG
CGGATGGCCAAGGCCATCCG
IR starts at 118 => CGGATGGC***CAAG***GCCATCCG
CGGATGGCCAAGGCCATCCG
IR starts at 119 => GGATGG***CCAAGG***CCATCC
GGATGGCCAAGGCCATCC
IR starts at 119 => GGATGGC***CAAG***GCCATCC
GGATGGCCAAGGCCATCC
IR starts at 120 => GATGGC***CAAG***GCCATC
GATGGCCAAGGCCATC
IR starts at 136 => CGATCG***ATGCTAGCGGCG***CGATCG
CGATCGATGCTAGCGGCGCGATCG
IR starts at 164 => CGATCG***ATGCTAGCGGCG***CGATCG
CGATCGATGCTAGCGGCGCGATCG
IR starts at 252 => CGATCG***ATGCTAGCGGCG***CGATCG
CGATCGATGCTAGCGGCGCGATCG
IR starts at 254 => ATCGAT***GCTAGCGGCGCG***ATCGAT
ATCGATGCTAGCGGCGCGATCGAT
IR starts at 254 => ATCGATCG***ATGCTAGCGGCG***CGATCGAT
ATCGATCGATGCTAGCGGCGCGATCGAT
IR starts at 255 => TCGATCG***ATGCTAGCGGCG***CGATCGA
TCGATCGATGCTAGCGGCGCGATCGA
IR starts at 256 => CGATCG***ATGCTAGCGGCG***CGATCG
CGATCGATGCTAGCGGCGCGATCG
IR starts at 258 => ATCGAT***GCTAGCGGCGCG***ATCGAT
ATCGATGCTAGCGGCGCGATCGAT
IR starts at 274 => CGATCG***ATGCTAGCGGCG***CGATCG
CGATCGATGCTAGCGGCGCGATCG
IR starts at 276 => ATCGAT***GCTAGCGGCGCG***ATCGAT
ATCGATGCTAGCGGCGCGATCGAT
IR starts at 304 => ATCGAT***GCTAGCGGCGCG***ATCGAT
ATCGATGCTAGCGGCGCGATCGAT
IR starts at 304 => ATCGATCG***ATGCTAGCGGCG***CGATCGAT
ATCGATCGATGCTAGCGGCGCGATCGAT
IR starts at 305 => TCGATCG***ATGCTAGCGGCG***CGATCGA
TCGATCGATGCTAGCGGCGCGATCGA
IR starts at 306 => CGATCG***ATGCTAGCGGCG***CGATCG
CGATCGATGCTAGCGGCGCGATCG
IR starts at 314 => GATGGC***CAAG***GCCATC
GATGGCCAAGGCCATC
但是,当我检查我的第一个命中的区域(在输入中以粗体突出显示)时,这个命中的偏移量似乎不在位置 26。谁能告诉我我的代码有什么问题?谢谢。
【问题讨论】:
-
我尝试使用其他 DNA 序列,代码似乎有效,但除了这个。
-
抱歉,我无法弄清楚您的代码在做什么,以及究竟是什么不起作用。你能澄清一下吗?
-
对不起,我没有评论我的代码。我打算确定一个具有两个侧翼 DNA 回文的区域。例如,当反向阅读时,GAATTC 是其互补链的回文。区域示例可以是 GAATTC-----GAATTC 或 GGGC----GCCC,其中 - 是间隔区中的核苷酸。
-
您没有得到的预期输出是什么?恐怕我 - 像该网站的大多数读者一样 - 发现代码很容易,而 DNA 很难 :)
-
你们为什么要使用 perl 正则表达式引擎来完成您的任务?用你大大减少的字母表对我来说这似乎是非常低效的。
标签: regex perl bioinformatics dna-sequence