-
Notifications
You must be signed in to change notification settings - Fork 0
/
reads_stat_v2.pl
59 lines (46 loc) · 1.01 KB
/
reads_stat_v2.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
53
54
55
56
#!/usr/bin/perl -w
use strict;
my $incutadapterlog=shift;
my $inbbnormlog=shift;
my $sample=shift;
print "$sample\t";
my ($outputreads, $outputbase);
open IN, "$inbbnormlog" ||die "$!\n";
lable:while(<IN>){
chomp;
if (/Pass 2/){
while(<IN>){
if(/Total reads in:\s+(\d+)\s+(\S+)% Kept/){
#print "$1\t$2\n";
#$outputreads=$1;
$outputreads=int($1*$2/100);
my $nextline=<IN>;
if($nextline=~/Total bases in:\s+(\d+)\s+(\S+)% Kept/){
#print "$1\t$2\n";
#$outputbase=$1;
$outputbase=int($1*$2/100);
last lable;
}
}
}
}
}
close IN;
my ($inputreads, $inputbase);
open IN2, "$incutadapterlog" || die "$!\n";
while(<IN2>){
chomp;
if(/Total read pairs processed:\s+(\S+)/){
#print "$1\n";
$inputreads=$1;
}
if (/Total basepairs processed:\s+(\S+)/){
#print "$1\n";
$inputbase=$1;
}
}
close IN2;
$inputreads=~s/,//g;$inputbase=~s/,//g;
$inputreads *=2;
print "$inputreads\t$inputbase\t$outputreads\t$outputbase";
printf "\t%.2f\n", $outputbase/$inputbase*100;