Skip to content

Commit

Permalink
πŸ› fix high coverage position bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mflevine committed Jan 4, 2019
1 parent aa1e263 commit de8fc9a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/split_bed_by_reads.nim
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ proc main() =

var
bam:Bam
tot_count = 0
count = 0
start = 0
stop = 0
Expand All @@ -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)
Expand Down

0 comments on commit de8fc9a

Please sign in to comment.