new file: cell2loc.py
[GalaxyCodeBases.git] / perl / etc / justonce / sperm / cntsnpns.pl
blob00b17761470af44176fb26d4ca0349558f7d326e
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
5 die "Usage: $0 <stat.txt> <flag>\n" if @ARGV < 2;
6 my ($inf,$flag)=@ARGV;
8 my $sum=0;
10 open I,'<',$inf or die $!;
11 while (<I>) {
12 next if /\[/;
13 chomp;
14 my @a = split /\t/;
15 if ( ($a[2] & $flag)==$flag ) {
16 $sum += $a[1];
17 print join("\t",$a[0],$a[2],$a[1],$sum),"\n";
20 close I;
21 my $v = sprintf("%b",$flag);
22 print "Sum[${v}] = $sum\n";