diff CoverageReport.pl @ 24:fd788f9db899 draft

Added (default) option to collapse repetitive bed files
author geert-vandeweyer
date Thu, 12 Feb 2015 08:51:37 -0500
parents 95062840f80f
children 6cb012c8497a
line wrap: on
line diff
--- a/CoverageReport.pl	Thu Feb 12 08:51:06 2015 -0500
+++ b/CoverageReport.pl	Thu Feb 12 08:51:37 2015 -0500
@@ -28,12 +28,13 @@
 # n : sample (n)ame.
  
 
-getopts('b:t:o:z:rsSALm:n:f:', \%opts) ;
+getopts('b:t:o:z:rsSALm:n:f:T', \%opts) ;
 
 # make output directory in (tmp) working dir
 our $wd = "/tmp/Coverage.".int(rand(1000));
 while (-d $wd) {
 	$wd = "/tmp/Coverage.".int(rand(1000));
+
 }
 system("mkdir $wd");
 
@@ -75,6 +76,15 @@
 	$tarfile = "$wd/Results.tar.gz";
 }
 
+## 0. Collapse overlapping target regions.
+if (defined($opts{'T'})) {
+	my $targets = $opts{'t'};
+	my $tmptargets = "$wd/collapsedtargets.bed";
+	system("sort -k1,1 -k2,2n $targets > $wd/sorted.targets.bed");
+	system("bedtools merge -s -scores max -nms -i $wd/sorted.targets.bed > $tmptargets");
+	$opts{'t'} = $tmptargets;
+}
+
 # 1. Global Summary => default
 &GlobalSummary($opts{'b'}, $opts{'t'});