forked from Axolotl233/Simple_Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stat.bamdst.res.pl
52 lines (48 loc) · 1.02 KB
/
Stat.bamdst.res.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
40
41
42
43
44
45
46
47
48
49
50
51
52
#! perl
use warnings;
use strict;
my $dir = shift;
$dir //= "./";
my @file = sort{$a cmp $b} grep{/coverage.report/} `find $dir`;
#map {print $_} @file;exit;
my %h;
foreach my $file (@file){
#print $file;exit;
chomp $file;
(open IN,"< $file") or die "$!";
my $name;
my $dp;
my $coverage;
my $map_rate;
my $proper_map_rate;
while(<IN>){
chomp;
if(/^## Files/){
/\/(.*?)\..*/;
$name = $1;
}
if(/\[Total\] Fraction of Mapped Reads\s+/){
s/.*\t//;
$map_rate = $_;
$h{$name} = "$map_rate";
}
if(/\[Total\] Fraction of Properly paired\s+/){
s/.*\t//;
$proper_map_rate = $_;
$h{$name} .= "\t$proper_map_rate";
}
if(/\[Target\] Average depth\s+/){
s/.*\t//;
$dp = $_;
$h{$name} .= "\t$dp";
}
if(/\[Target\] Coverage \(>0x\)\s+/){
s/.*\t//;
$coverage = $_;
$h{$name} .= "\t$coverage";
}
}
close IN;
}
print "Sample\tMapRate\tProperlyMapRate\tAverageDepth\tCoverage\n";
map{print "$_\t$h{$_}\n"} sort{$a cmp $b} keys %h;