From de8fc9a0d42d009266101bc870159322954015df Mon Sep 17 00:00:00 2001 From: Max Levine Date: Fri, 4 Jan 2019 11:43:46 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20high=20coverage=20position?= =?UTF-8?q?=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/split_bed_by_reads.nim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/split_bed_by_reads.nim b/src/split_bed_by_reads.nim index 1066cc6..e37ee12 100644 --- a/src/split_bed_by_reads.nim +++ b/src/split_bed_by_reads.nim @@ -84,7 +84,6 @@ proc main() = var bam:Bam - tot_count = 0 count = 0 start = 0 stop = 0 @@ -103,17 +102,16 @@ proc main() = for region in regions[chrom]: start = region.start for record in bam.query(region.chrom,region.start,region.stop): - inc(tot_count) inc(count) if count mod split == 0: - echo region.chrom,":",start,"-",record.start," ",count - out_bed.writeLine(region.chrom & "\t" & $start&"\t" & $record.start & "\t" & $count) + if record.start > start: # if ending on high coverage position + echo region.chrom,":",start,"-",record.start," ",count + out_bed.writeLine(region.chrom & "\t" & $start & "\t" & $record.start & "\t" & $count) start = record.start + 1 count = 0 echo region.chrom,":",start,"-",region.stop," ",count out_bed.writeLine(region.chrom & "\t" & $start & "\t" & $region.stop & "\t" & $count) count = 0 - start = 0 echo "Chr ", chrom, ":", now() - time echo now() - time close(bam)