-
Notifications
You must be signed in to change notification settings - Fork 0
/
reads_stat.pl
79 lines (69 loc) · 1.74 KB
/
reads_stat.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl -w
use strict;
my $inbbnormlog=shift;
my $incutadapterlog=shift;
my $sample=shift;
print "$sample\t";
my ($rawreads, $rawbase);
open IN, "$inbbnormlog" ||die "$!\n";
lable:while(<IN>){
chomp;
if(/Total reads in:\s+(\d+)/){
#print "$1\t";
$rawreads=$1;
my $nextline=<IN>;
if($nextline=~/Total bases in:\s+(\d+)/){
#print "$1\t";
$rawbase=$1;
last lable;
}
}
}
close IN;
my ($inputreads,$inputbase,$inputbase1,$inputbase2,$outputreads,$outputbase,$outputbase1,$outputbase2,$remain_rate);
open IN2, "$incutadapterlog" || die "$!\n";
while(<IN2>){
chomp;
if(/Total read pairs processed:\s+(\S+)/){
#print "$1\n";
$inputreads=$1;
}
if (/Pairs written \(passing filters\):\s+(\S+)/){
#print "$1\n";
$outputreads=$1;
}
if (/Total basepairs processed:\s+(\S+)/){
#print "$1\n";
$inputbase=$1;
my $next1stline=<IN2>;
if ($next1stline=~/Read 1:\s+(\S+)/){
#print "$1\n";
$inputbase1=$1;
}
my $next2ndline=<IN2>;
if ($next2ndline=~/Read 2:\s+(\S+)/){
#print "$1\n";
$inputbase2=$1;
}
}
if (/Total written \(filtered\):\s+(\S+) bp \((\S+)%\)/){
#print "$1\t$2\n";
$outputbase=$1;
$remain_rate=$2;
my $next1stline=<IN2>;
if ($next1stline=~/Read 1:\s+(\S+)/){
#print "$1\n";
$outputbase1=$1;
}
my $next2ndline=<IN2>;
if ($next2ndline=~/Read 2:\s+(\S+)/){
#print "$1\n";
$outputbase2=$1;
}
}
}
close IN2;
$inputreads=~s/,//g;$inputbase=~s/,//g;$inputbase1=~s/,//g;$inputbase2=~s/,//g;$outputreads=~s/,//g;$outputbase=~s/,//g;$outputbase1=~s/,//g;$outputbase2=~s/,//g;
print "$rawreads\t$rawbase\t$inputreads\t$inputbase\t$inputbase1\t$inputbase2";
printf "\t%.1f", $inputbase/$rawbase*100;
print "\t$outputreads\t$outputbase\t$outputbase1\t$outputbase2\t$remain_rate\n";