ゲノミクス アプリケーションに perl を使用する方法を学習中です。ペアエンドリードをクリーンアップしようとしています (1 フォワード、1 リバース)。これらは2つのファイルに保存されていますが、行は一致しています。私が問題を抱えているのは、関連するサブルーチンを 2 番目のファイルから読み取ることです (初期化されていない値に関する警告が表示されます)。
これらのファイルは 4 行のブロック (fastq) で設定されます。最初の行は実行 ID、2 番目はシーケンス、3 番目は "+"、4 番目は 2 行目のシーケンスの品質値を保持します。
このコードを 1 つのファイルにのみ適用した場合は特に問題はありませんでしたが、複数のファイルを処理する方法を誤解していると思います。
どんなガイダンスも大歓迎です!
このシナリオでの私の警告は次のとおりです。./pairedendtrim.pl 137 行目、4 行目の減算 (-) での初期化されていない値 $thisline の使用。
#!/usr/bin/perl
#pairedendtrim.pl by AHU
use strict;
use warnings;
die "usage: readtrimmer.pl <file1> <file2> <nthreshold> " unless @ARGV == 3;
my $nthreshold = "$ARGV[2]";
open( my $fastq1, "<", "$ARGV[0]" );
open( my $fastq2, "<", "$ARGV[1]" );
my @forline;
my @revline;
while ( not eof $fastq2 and not eof $fastq1 ) {
chomp $fastq1;
chomp $fastq2;
$forline[0] = <$fastq1>;
$forline[1] = <$fastq1>;
$forline[2] = <$fastq1>;
$forline[3] = <$fastq1>;
$revline[0] = <$fastq2>;
$revline[1] = <$fastq2>;
$revline[2] = <$fastq2>;
$revline[3] = <$fastq2>;
my $ncheckfor = removen( $forline[1] );
my $ncheckrev = removen( $revline[1] );
my $fortest = 0;
if ( $ncheckfor =~ /ok/ ) { $fortest = 1 }
my $revtest = 0;
if ( $ncheckrev =~ /ok/ ) { $revtest = 1 }
if ( $fortest == 1 and $revtest == 1 ) { print "READ 1 AND READ 2" }
if ( $fortest == 1 and $revtest == 0 ) { print "Read 1 only" }
if ( $fortest == 0 and $revtest == 1 ) { print "READ 2 only" }
}
sub removen {
my ($thisline) = $_;
my $ntotal = 0;
for ( my $i = 0; $i < length($thisline) - 1; $i++ ) {
my $pos = substr( $thisline, $i, 1 );
#print "$pos\n";
if ( $pos =~ /N/ ) { $ntotal++ }
}
my $nout;
if ( $ntotal <= $nthreshold ) #threshold for N
{
$nout = "ok";
} else {
$nout = "bad";
}
return ($nout);
}