limit fstBC to 30bp in Python3 ver.
[GalaxyCodeBases.git] / tools / linkage / fmt.pl
blobb46b46fffac24c1a883f2608e4156cebc4b1b8f1
1 #!/bin/env perl
2 use strict;
3 use warnings;
5 my $minMAF=0.2;
6 my $minCOV=0.5;
8 unless (@ARGV > 0) {
9 print "perl $0 <In_file> <Out_File> <ChrID>\n";
10 exit 0;
13 open I,'<',$ARGV[0] or die $!;
14 open O,'>',$ARGV[1] or die $!;
15 my $t=<I>;
16 $t=~s/^#//;
17 print O "#ChrID\tPos\t$t";
18 while (<I>) {
19 chomp;
20 my ($Pos,$D)=split /\s+/,$_,2;
21 my @Dat=split / /,$D;
22 my ($cvg,%cnt)=(0);
23 for (@Dat) {
24 ++$cnt{$_} if /\d/;
25 ++$cvg if /\d/;
27 next if $cvg < @Dat * $minCOV;
28 ($cvg)=sort {$a<=>$b} values %cnt;
29 next if $cvg < @Dat * $minMAF;
30 print O "$ARGV[2]\t$Pos\t$D\n"
32 close O;
33 close I;
34 __END__
35 ./fmt.pl ./p15/Chr01 Chr01.15 Chr01
36 cat chrorder | while read a; do ./fmt.pl ./p15/$a $a.15 $a;done &