-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmergePicardMetrics.pl
executable file
·68 lines (58 loc) · 1.04 KB
/
mergePicardMetrics.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
#!/usr/bin/perl
use strict;
use Getopt::Long qw(GetOptions);
use FindBin qw($Bin);
### takes in picard metrics (tested on hs/is/as/md
### through -metrics
### and/or can give it a file of files (-files)
my $pre = 'TEMP';
my @metrics = ();
my $files = '';
GetOptions ('pre=s' => \$pre,
'files=s' => \$files,
'metrics|m=s' => \@metrics) or exit(1);
if($files){
open(FI, "$files") or die "Can't open file $files $!";
while(<FI>){
chomp;
push @metrics, $_;
}
close FI;
}
my $hflag = 0;
foreach my $met (@metrics){
if(!-s $met){
die "METRICS FILE $met DOES NOT EXIST OR IS EMPTY";
}
}
foreach my $met (@metrics){
open(MET, $met);
my $mflag = 0;
while(my $line=<MET>){
chomp $line;
if($line =~ /^\#\# METRICS CLASS/){
if($mflag == 0){
$mflag = 1;
}
my $header = <MET>;
if($hflag == 0){
print "$header";
$hflag = 1;
}
}
else{
if($mflag == 0){
next;
}
else{
if($line){
print "$line\n";
}
else{
last;
}
}
}
}
close MET;
}