forked from molgenis/ngs-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect_coverage_stats.pl
executable file
·55 lines (48 loc) · 1.44 KB
/
collect_coverage_stats.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
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use File::Glob ':glob';
#############################
##USAGE: perl collect_coverage_stats.pl <working_directory> <outputfile_prefix>
#############################
my $input_dir = $ARGV[0];
my $output_dir = $ARGV[1];
chomp $input_dir;
chomp $output_dir;
my $line;
my $lines;
##Retrieve files containing QC information
#/data/gcc/projects/gonl/results/first_batch
my @coverage_prop = glob "$input_dir/*/*.coverage.*proportions";
my @coverage_counts = glob "$input_dir/*/*.coverage.*counts";
open (OUTPUTPROP, ">$output_dir.proportions.txt");
open (OUTPUTCOUNTS, ">$output_dir.counts.txt");
#foreach my $element (@coverage_prop){
# print $element . "\n";
#}
while ($_ = shift @coverage_prop) {
#print $_ . "\n";
chomp $_;
open (COVPROP, "<$_") or die "Can't open $_$!";
while ($line = <COVPROP>){
chomp $line;
if ($line =~ m/[A-Za-z0-9]{1,10}.+1\.00.+/gs){
print OUTPUTPROP "$line\n";
}
}
}
while ($_ = shift @coverage_counts) {
chomp $_;
if ($_ =~ m/.+\/([A-Za-z0-9]{1,}).(.+).(.+).sample_cumulative_coverage_counts/gs){
my $sample = $1;
open (COVCOUNTS, "<$_") or die "Can't open $_$!";
while ($lines = <COVCOUNTS>){
chomp $lines;
if ($lines =~ m/(NSamples_1)\t(.+)/gs){
my $counts = $2;
print OUTPUTCOUNTS "$sample\t$counts\n";
}
}
}
}