我与DNA序列工作的文件,这个文件的格式是这样的,虽然有超过一个序列:的Perl:字符串中子字符串或子字符串中
>name of sequence
EXAMPLESEQUENCEATCGATCGATCG
我需要能告诉我们,如果一个变量(这也是一个序列)匹配任何序列的文件中,以及它匹配序列的名称,如果有的话,是。由于这些序列的性质,我的整个变量可能包含在文件的一行中,或者变量的一行可能是我变量的一部分。 现在我的代码看起来是这样的:
use warnings;
use strict;
my $filename = "https://stackoverflow.com/users/me/file/path/file.txt";
my $exampleentry = "ATCG";
my $returnval = "The sequence does not match any in the file";
open file, "<$filename" or die "Can't find file";
my @Name;
my @Sequence;
my $inx = 0;
while (<file>){
$Name[$inx] = <file>;
$Sequence[$inx] = <file>;
$indx++;
}unless(index($Sequence[$inx], $exampleentry) != -1 || index($exampleentry, $Sequence[$inx]) != -1){
$returnval = "The sequence matches: ". $Name[$inx];
}
print $returnval;
然而,即使我故意设置$条目从文件中比赛,我还是回到The sequence does not match any in the file
。此外,当运行代码时,我得到Use of uninitialized value in index at thiscode.pl line 14, <file> line 3002.
以及Use of uninitialized value within @Name in concatenation (.) or string at thiscode.pl line 15, <file> line 3002.
我怎么能执行这个搜索?
谢谢!对不起,在这个问题上我可怜的措词。 –