-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistic_length_for_all_file.pl
85 lines (68 loc) · 1.99 KB
/
statistic_length_for_all_file.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
78
79
#!/usr/bing/perl -w
use strict;
use warnings;
use FindBin '$Bin';
use Cwd qw(getcwd abs_path);
use Getopt::Long;
use File::Basename;
my $pragram_name=basename($0);
print $pragram_name,"\n";
my @para=();
GetOptions(
"io:s" => \@para,
"h|?" => \&USAGE,
) or &USAGE;
##recursion read file
sub readfile{
my $dir=shift;
my @realfile=();
if(!-d "$dir" && !-e "$dir"){
push(@realfile,$dir);
return @realfile;
}
if(-d "$dir" || -e "$dir"){
my @dirfile=grep{!(/^\./)} glob("$dir/*");
for my $sub_file(@dirfile){
if(-d "$sub_file"){
push(@realfile,&readfile($sub_file));
}else{
push(@realfile,$sub_file);
}
}
}
return @realfile;
}
my @arrayfile=&readfile($ARGV[0]);
open(OUT,">$ARGV[1]");
print OUT "ID","\t","Length <18","\t","Length >30","\t","clean reads","\n";
for my $file(@arrayfile){
if($file =~m/.*Arab_L283-02-(S.{2})\.filter.stat$/){
open(IN,"$file") or die "$!";
print OUT $1,"\t";
while(<IN>){
chomp;
if(/Length\s+<18|Length\s+>30/){
my ($goal)=(split /\t/,$_)[2];
print OUT $goal,"\t";
}
if(/^Clean\s+Reads/){
my ($goal1)=(split /\t/,$_)[1];
print OUT $goal1;
}
}
print OUT "\n";
}
close IN;
}
close OUT;
sub USAGE{
my $usage=<<EOF;
-----------------------
contact:honghh\@biomarker.com.cn
USAGE:
$pragram_name -io <directory> -io <file> -h
-----------------------
EOF
print $usage;
exit(1);
}