-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount-variant-types.pl
More file actions
executable file
·37 lines (35 loc) · 1.02 KB
/
count-variant-types.pl
File metadata and controls
executable file
·37 lines (35 loc) · 1.02 KB
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/perl
use strict;
use ProgramName;
use EssexParser;
use EssexICE;
my $name=ProgramName::get();
die "$name <in.essex>\n" unless @ARGV==1;
my ($infile)=@ARGV;
my ($sampleSize,%counts,%sumSquares);
my $parser=new EssexParser($infile);
while(1) {
my $root=$parser->nextElem(); last unless $root;
my $ice=new EssexICE($root);
my $transcript=$root->findDescendent("mapped-transcript");
next unless $transcript;
++$sampleSize;
my $variants=$transcript->findDescendent("variants");
next unless $variants;
my $numChildren=$variants->numElements();
for(my $i=0 ; $i<$numChildren ; ++$i) {
my $child=$variants->getIthElem($i);
my $tag=$child->getTag();
my $numVariants=$child->numElements();
$counts{$tag}+=$numVariants;
$sumSquares{$tag}+=$numVariants*$numVariants;
}
}
my @keys=keys %counts;
foreach my $key (@keys) {
my $count=$counts{$key};
my $mean=$count/$sampleSize;
$mean=int($mean*1000000+5/9)/1000000;
my $sumXX=$sumSquares{$key};
print "$key\t$mean\t$count\t$sumXX\t$sampleSize\n";
}