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
|
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
my %opts = (n=>33088, s=>100);
getopts('n:', \%opts);
my $pseudo = .5;
my $tot = $pseudo;
my $err = $pseudo;
my $tot_last_out = -$opts{s};
my $state = 0;
my $mapq = 0;
while (<>) {
chomp;
if (/^Q\t(\d+)\t(\d+)\t(\d+)/) {
$tot += $2;
$err += $3;
if ($tot - $tot_last_out >= $opts{s}) {
print join("\t", $1, $err/$tot, $tot / $opts{n}), "\n";
$tot_last_out = $tot;
$state = 0;
} else {
$state = 1;
$mapq = $1;
}
}
}
if ($state) {
print join("\t", $mapq, $err/$tot, $tot / $opts{n}), "\n";
}
|