);
GetOptions(\%options,
+ 'merge=s',
'debug|d+','help|h|?','man|m');
pod2usage() if $options{help};
$rsids{$_} = 1;
}
+my %merge_rsids;
+if (defined $options{merge}) {
+ my $merge = open_compressed_file($options{merge})
+ or die "Unable to open file $options{merge}: $!";
+ while (<$merge>) {
+ chomp;
+ my ($old,$new,undef) = split /\t/;
+ next unless exists $rsids{'rs'.$old};
+ $merge_rsids{'rs'.$old} = 'rs'.$new;
+ $rsids{'rs'.$new} = 1;
+ }
+ close ($merge);
+}
+
while (<$vcf>) {
if (/^#/o) {
print $_;
$_ =~ /^\S+\s+\S+\s+(\S+)/o;
next unless $1;
next unless exists $rsids{$1} and $rsids{$1};
+ $rsids{$1}++;
print $_;
}
+my @unused_rsids;
+for my $rsid (keys %rsids) {
+ if ($rsids{$rsid} == 1) {
+ push @unused_rsids,$rsid;
+ }
+}
+if (@unused_rsids) {
+ print STDERR "The following rsids were not found\n";
+ print STDERR map {$_."\n"} @unused_rsids;
+}
+
+
__END__