2 番目のファイルを使用してファイルをフィルター処理しようとしています (最高のブラスト ヒットを見つけようとしています)。フィルタリングしたいファイルは次のようになります。
conserved1 chr22 100.00 92 0 0 1 92 19679676 19679767 2e-44 182
.....................
私が使用している 2 番目のファイル (スクリプトの最初の入力) は次のようなものです。
conserved1 92
conserved2 76
.....................
(最初の列は私の「アイテム」の名前で、前のファイルの最初の列とまったく同じで、2 番目の列はサイズです)。
最初のファイルを保存された要素のサイズに接続し、サイズ (4 列目) が (2 番目のファイルから) サイズの 70% である行のみをフィルター処理するために、2 番目のファイルをハッシュに保存しました。
私はその目的のためにこのスクリプトを書きました。それは機能しますが、選択した各行を複数回出力します。どうすればこれを修正できますか?
my $size_file = $ARGV[0];
my $alignment_file = $ARGV[1];
open my $con_info, $size_file or die "Could not open $size_file: $!";
my %hash;
while (<$con_info>)
{
chomp;
my ($key, $val) = split /\t/;
$hash{$key} .= exists $hash{$key} ? "$val" : $val;
}
#print "# %hash\n", Dump \%hash;
#print %hash;
#print "@{[%hash]}";
close $con_info;
open my $al_info, $alignment_file or die "Could not open $alignment_file: $!";
while (my $line = <$al_info>) {
chomp;
my@data = split('\t', $line);
my $con_name = $data[0];
my $evalue = $data[10];
my $percent = $data[2];
my $length = $data[3];
# print $con_name. "\n";
foreach my $key (keys %hash) {
if ($key == $con_name) {
#print "key: $key, value: $hash{$key}\n";
if ($evalue <= 1e-4 && $length >= 0.70 * $hash{$key}) {
print $line;
}
}
}
}
出力は最初のファイル (最初のコード ボックスにあるファイル) である必要がありますが、最後の if 条件を通過する行が少なくなります。どうもありがとうございました。