add video tutorial link to about menu.
[sgn.git] / bin / replace_accessions_in_vcf.pl
blob574db44041340f91e958bdfaaee9a67fe0c5c8a3
2 use strict;
4 my $vcf_file = shift;
5 my $equivalence_file = shift;
8 open(my $E, "<", $equivalence_file) || die "Can't open $equivalence_file\n";
10 my %ids;
11 while (<$E>) {
12 chomp;
14 my ($original_id, $modified_id, $new_id, $match_type, $stock_type) = split /\t/;
15 $ids{$original_id} = $new_id;
18 close($E);
20 open(my $V, "<", $vcf_file) || die "Can't open $vcf_file\n";
22 while (<$V>) {
23 chomp();
25 if ($_ =~ m/^\#CHROM/) {
26 print STDERR "Parsing ids in vcf file...\n";
27 my @F = split /\t/;
28 my $count = 0;
29 foreach my $f (@F) {
30 $count++;
31 if (exists($ids{$f}) && ($ids{$f} ne $f)) {
32 print STDERR "replace $f with $ids{$f} ($count), ";
33 $f = $ids{$f};
36 my $line = join("\t", @F);
37 print "$line\n";
39 else {
40 print $_."\n";