-
Notifications
You must be signed in to change notification settings - Fork 2
/
sat_extract
executable file
·58 lines (52 loc) · 1.14 KB
/
sat_extract
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
#!/usr/bin/perl -w
use strict;
use FileHandle;
use File::Basename;
use Getopt::Long;
my @tmpline;
my $stock = "";
my $nseq = 1;
my $biggest = 0;
my $pflag = 0;
my $paired = 0;
my ($FILE,$OUTPUT_DIR) = ("duplicates_data.csv","./");
my $result = &GetOptions(
'f=s' => \$FILE,
"o=s" => \$OUTPUT_DIR
);
opendir (DIR, $OUTPUT_DIR) or die $!;
while (my $file = readdir(DIR)) {
if ($file =~ /duplicates_reads_(.*).stats/){
open(FILE,"<","$OUTPUT_DIR/$file");
$stock .= int($1);
$pflag = 0;
while(<FILE>){
@tmpline = split(" ",$_);
if (@tmpline && ($tmpline[0] eq "nbReadsInSample=")){
$stock .= "\t".$tmpline[$#tmpline];
$pflag++;
}
if(@tmpline && $tmpline[0] eq "nbReadsInInput="){
$nseq = $tmpline[1];
if($biggest<$nseq){
$biggest = $nseq;
}
}
}
if($pflag >= 3){
$paired = 1;
}
$stock .= "\t".$nseq;
$stock .= "\n";
close(FILE);
}
}
closedir(DIR);
open(FTAB, ">", "$OUTPUT_DIR/$FILE");
if($paired==1){
print FTAB "$biggest\tPAIRS\tREAD1\tREAD2\tNSEQ\n";
}else{
print FTAB "$biggest\tDUPL\tNSEQ\n";
}
print FTAB $stock;
close(FTAB);