私はこのような巨大なタブ区切りファイルを持っています:
contig04733 contig00012 77
contig00546 contig01344 12
contig08943 contig00001 14
contig00765contig0312588
など
そして、私は次のようなこれらのコンティグペアのサブセットのみを含む別のタブ区切りファイルを持っています:
contig04733
contig00012contig08943contig00001
など
2番目にリストされている行に対応する最初のファイルの行を新しいファイルに抽出したいと思います。この特定のデータセットでは、各ペアのどちらの方向が両方のファイルで同じである必要があると思います。しかし、次のように言うかどうかも知りたいです:
file1 contig08943 contig00001 14
しかし、file2ではその
contig00001 contig08943
そして私はまだその組み合わせが欲しいのですが、これのために何かをスクリプト化することも可能ですか?
私のコードは以下の通りです。
use strict;
use warnings;
#open the contig pairs list
open (PAIRS, "$ARGV[0]") or die "Error opening the input file with contig pairs";
#hash to store contig IDs - I think?!
my $pairs;
#read through the pairs list and read into memory?
while(<PAIRS>){
chomp $_; #get rid of ending whitepace
$pairs->{$_} = 1;
}
close(PAIRS);
#open data file
open(DATA, "$ARGV[1]") or die "Error opening the sequence pairs file\n";
while(<DATA>){
chomp $_;
my ($contigs, $identity) = split("\t", $_);
if (defined $pairs->{$contigs}) {
print STDOUT "$_\n";
}
}
close(DATA);