comparison CoverageReport.pl @ 25:6cb012c8497a draft

Added BED format check before collapsing regions.
author geert-vandeweyer
date Thu, 12 Feb 2015 09:54:03 -0500
parents fd788f9db899
children 859999cb135b
comparison
equal deleted inserted replaced
24:fd788f9db899 25:6cb012c8497a
76 $tarfile = "$wd/Results.tar.gz"; 76 $tarfile = "$wd/Results.tar.gz";
77 } 77 }
78 78
79 ## 0. Collapse overlapping target regions. 79 ## 0. Collapse overlapping target regions.
80 if (defined($opts{'T'})) { 80 if (defined($opts{'T'})) {
81 ## check BED format. Must have 6 cols if using this.
82 my $head = `head -n 1 $opts{'t'}`;
83 chomp;
84 my @c = split(/\t/,$head);
85 if (scalar(@c) < 6) {
86 die("Targets BED file must be in 6-column format for collapsings. See tool documentation for more info.\n");
87 }
81 my $targets = $opts{'t'}; 88 my $targets = $opts{'t'};
82 my $tmptargets = "$wd/collapsedtargets.bed"; 89 my $tmptargets = "$wd/collapsedtargets.bed";
83 system("sort -k1,1 -k2,2n $targets > $wd/sorted.targets.bed"); 90 system("sort -k1,1 -k2,2n $targets > $wd/sorted.targets.bed");
84 system("bedtools merge -s -scores max -nms -i $wd/sorted.targets.bed > $tmptargets"); 91 system("bedtools merge -s -scores max -nms -i $wd/sorted.targets.bed > $tmptargets");
85 $opts{'t'} = $tmptargets; 92 $opts{'t'} = $tmptargets;