-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnormalFilterVCF.pl
More file actions
executable file
·37 lines (32 loc) · 886 Bytes
/
normalFilterVCF.pl
File metadata and controls
executable file
·37 lines (32 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env perl
# filter tumor based on normal
# usage: normalFilterVCF.pl [tumor.vcf] [normal.vcf]
use strict;
if (@ARGV != 2) {
print "Usage: normalFilterVCF.pl [tumor.vcf] [normal.vcf]\n" and exit(1);
}
my $tumorVCF = $ARGV[0];
my $normalVCF = $ARGV[1];
my $varPosn = {};
open IN, $normalVCF or die("Unable to open " . $normalVCF . "\n");
while (<IN>) {
next if /^#/;
my @F = split /\t/;
my $chr = $F[0];
my $posn = $F[1];
my $alt = $F[3];
$varPosn->{$chr} = {} unless exists $varPosn->{$chr};
$varPosn->{$chr}{$posn} = {} unless exists $varPosn->{$chr}{$posn};
$varPosn->{$chr}{$posn}{$alt} = 1;
}
close IN;
open IN, $tumorVCF or die("Unable to open " . $tumorVCF . "\n");
while (<IN>) {
print and next if /^#/;
my @F = split /\t/;
my $chr = $F[0];
my $posn = $F[1];
my $alt = $F[3];
print unless (exists $varPosn->{$chr}{$posn}{$alt});
}
close IN;