-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalayze_dedup_metrics.pl
More file actions
87 lines (76 loc) · 2.65 KB
/
Copy pathanalayze_dedup_metrics.pl
File metadata and controls
87 lines (76 loc) · 2.65 KB
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
80
81
82
83
84
85
86
87
#!/usr/bin/perl -w
use strict;
=head1
Author: Ian Beddows
Date: 3/22/18
Short description:
Input a directory where there are '${SAMPLE}.dedup.metrics' files.
These will be found automatically and the dedup estimates writte to the output:
One outfiles:
contamination_stats.txt:
sample contamination std_error
=cut
use Getopt::Long;
my $usage = <<EOF;
OPTIONS:
-dir
OPTIONAL:
-h|help = print usage
-b = uppercase arguments
EOF
my($help,$bold,$dir);
#======================================================================# get options
GetOptions(
'dir=s' => \$dir, # string
#~ '=i' => \$, # integer
#~ '=f' => \$, # floating point number
#~ 'bold' => \$bold, # flag
'h|help' => \$help # flag for help
);
if (defined($help)){die print "HELP:\n",$usage;}
if (!defined($dir)){die print "define -dir:\n",$usage;}
#======================================================================# done with get options
open(my $out,'>','dedup_stats.txt')||die;
# Print the header:
print $out join("\t",'sample','LIBRARY' ,'UNPAIRED_READS_EXAMINED' ,'READ_PAIRS_EXAMINED' ,'SECONDARY_OR_SUPPLEMENTARY_RDS' ,'UNMAPPED_READS' ,'UNPAIRED_READ_DUPLICATES' ,'READ_PAIR_DUPLICATES' ,'READ_PAIR_OPTICAL_DUPLICATES' ,'PERCENT_DUPLICATION' ,'ESTIMATED_LIBRARY_SIZE'),"\n";
my @files = `ls -1 $dir|grep dedup.metrics`; chomp(@files);
print STDOUT "Found ",scalar @files," dedup.metrics files:\n";
foreach my $fh (@files){
my $sample = $fh;
$sample =~s/\.dedup.metrics//;
# open & get info
open(my $in,'<',"$dir/$fh") || die;
my $i=0;
while(<$in>){
chomp;
if($_=~/^LIBRARY/){
$i=1;
#~ my @data = split('\t',$_);
#~ foreach my $field (@data){
#~ print STDOUT "\t\t$field\n";
#~ }
#~ print join("\'\t\,\'",@data),"\n"; # for header
#~ print join("\,\$",@data),"\n"; # for print out
next;
}elsif($i==1){
my @data = split('\t',$_);
my $LIBRARY = shift @data;
my $UNPAIRED_READS_EXAMINED = shift @data;
my $READ_PAIRS_EXAMINED = shift @data;
my $SECONDARY_OR_SUPPLEMENTARY_RDS = shift @data;
my $UNMAPPED_READS = shift @data;
my $UNPAIRED_READ_DUPLICATES = shift @data;
my $READ_PAIR_DUPLICATES = shift @data;
my $READ_PAIR_OPTICAL_DUPLICATES = shift @data;
my $PERCENT_DUPLICATION = shift @data;
my $ESTIMATED_LIBRARY_SIZE = shift @data;
#~ print STDOUT "\t\t$PERCENT_DUPLICATION\n";
print $out join("\t",$sample,$LIBRARY,$UNPAIRED_READS_EXAMINED,$READ_PAIRS_EXAMINED,$SECONDARY_OR_SUPPLEMENTARY_RDS,$UNMAPPED_READS,$UNPAIRED_READ_DUPLICATES,$READ_PAIR_DUPLICATES,$READ_PAIR_OPTICAL_DUPLICATES,$PERCENT_DUPLICATION,$ESTIMATED_LIBRARY_SIZE),"\n";
$i=0
}else{
next;
}
}
print STDOUT "\t$sample:\t$fh\n";
}
close($out);