Skip to content

Commit

Permalink
add a screen output mode
Browse files Browse the repository at this point in the history
  • Loading branch information
oushujun committed Aug 28, 2020
1 parent 570ae5b commit 8c6975a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions util/combine_overlap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
my ($dmr, $out, $max_gap); #$max_gap, gaps between this length (bp) will be joined
($dmr, $out, $max_gap) = @ARGV;
$max_gap = 0 unless defined $max_gap;
die usage() unless @ARGV >= 2;
$out = '' unless defined $out;

die usage() unless @ARGV >= 1;
open DMR,"sort -suV $dmr |" or die "$!";
open OUT, ">$out" or die "$!";
open OUT, ">$out" or die "$!" if $out ne '';
while (my $line = <DMR>){
chomp $line;
next if $line =~ /^\s+$/;
Expand All @@ -18,7 +20,11 @@
PATH:{ #loop the entire file except the first line
$line = <DMR>;
if (!$line){
print OUT "$chr1\t$stt1\t$end1\t$info1\n"; #print out the last line
if ($out ne ''){
print OUT "$chr1\t$stt1\t$end1\t$info1\n"; #print out the last line
} else {
print "$chr1\t$stt1\t$end1\t$info1\n"; #print out the last line
}
}
else {
my ($chr2, $stt2, $end2, $info2) = (split /\s+/, $line, 4);
Expand All @@ -30,7 +36,11 @@
redo PATH;
}
else {
print OUT "$chr1\t$stt1\t$end1\t$info1\n";
if ($out ne ''){
print OUT "$chr1\t$stt1\t$end1\t$info1\n";
} else {
print "$chr1\t$stt1\t$end1\t$info1\n";
}
($chr1, $stt1, $end1, $info1) = ($chr2, $stt2, $end2, $info2);
redo PATH;
}
Expand Down

0 comments on commit 8c6975a

Please sign in to comment.