我需要创建一个大小为15的滑动窗口,浏览Fasta文件并将滑动窗口的所有值存储到哈希中。当我尝试打印时,我收到错误
全局符号“$ sequence”需要在./findAllKmers.1.pl第60行显式包名。
执行./findAllKmers.1.pl因编译错误而中止“
#!/usr/bin/perl
use warnings;
use strict;
my %windowSeqScores = ();
my $sequenceRef = loadSequence("/scratch/Drosophila/dmel-2L-chromosome-r5.54.fasta");
my $windowSize = 23;
my $stepSize = 1;
my $maxScore = 0;
my $sequence = @_;
my $in_file = 'uniqueKmersEndingGG.fasta';
open (my $fh, '>', $in_file) or die "Could not open file 'filename' $!";
for (
my $windowStart = 0;
$windowStart <= (length($$sequenceRef) - $windowSize);
$windowStart += $stepSize
)
{
my $windowSeq = substr($$sequenceRef, $windowStart, $windowSize);
sub loadSequence {
my ($sequenceFile) = @_;
my $sequence = "";
my $counter = 0;
unless (open(FASTA, "<", $sequenceFile)) {
die $!;
}
while (<FASTA>) {
my $line = $_;
chomp($line);
if ($line !~ /^>/) {
my $sequence = $line;
if (length($sequence) == 15) {
$counter = $counter + 1;
print $_;
}
}
return \$sequence;
}
}
print $sequence;
答案 0 :(得分:0)
我尝试编译代码。我收到了错误&#34;在test.pl第44行,在行尾#34时错过了正确的卷曲或方括号;我刚刚添加了一个紧密的支撑&#34;}&#34;在最后一行之后编译。
您正在for()循环中声明一个函数。那个退出了不寻常的。我可以在循环之外做大部分事。