-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_MAFfer.pl
40 lines (31 loc) · 1009 Bytes
/
sync_MAFfer.pl
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
38
39
#!/usr/bin/perl
use strict; use warnings;
my $input = $ARGV[0]; #input file - sync
my $output = $ARGV[1]; #name of output
my $maf = $ARGV[2]; #maf cut off - e.g. for 5% type 5
open (INPUT, $input) || die "must stay away from the light";
open (OUTPUT, ">$output") || die "it's too late for me, save yourself";
while (my $line = <INPUT>){
chomp($line);
my @alleles = split(/\t/, $line);
shift @alleles for (0..2);
my $A = 0; my $T = 0; my $G = 0; my $C = 0;
foreach(@alleles){
my @freqs = split(/:/, $_);
$A += $freqs[0];
$T += $freqs[1];
$G += $freqs[2];
$C += $freqs[3];
}
my $total = $A + $T + $G + $C;
push (my @allfreq, $A, $T, $G, $C);
my @sortedfreq = sort {$a <=> $b } @allfreq;
if ($sortedfreq[1] == 0){ #no triallelics
my $maftest = $total / 100 * $maf;
if ($sortedfreq[2] >= $maftest){
print OUTPUT "$line\n";
}
}
}
close INPUT;
close OUTPUT;