Skip to content

Commit

Permalink
bump versions and fix #216
Browse files Browse the repository at this point in the history
closes #216
  • Loading branch information
brentp committed Nov 22, 2023
1 parent 8696b5b commit c300eb2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions functional-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ assert_equal "MT 0 80 1 MT 80 16569 0 " "$(zgrep ^MT t.per-base.bed.gz | tr -s '

run length_filter $exe t tests/ovl.bam --min-frag-len 81
assert_exit_code 0
assert_equal "MT 0 16569 0" "$(zgrep ^MT t.per-base.bed.gz)"
assert_equal "MT 0 16569 0" "$(zgrep ^MT t.per-base.bed.gz)"

run length_filter $exe t tests/ovl.bam --max-frag-len 79
assert_exit_code 0
assert_equal "MT 0 16569 0" "$(zgrep ^MT t.per-base.bed.gz)"
assert_equal "MT 0 16569 0" "$(zgrep ^MT t.per-base.bed.gz)"

run bad_frag_len_filter $exe t tests/ovl.bam --min-frag-len 10 --max-frag-len 9
assert_in_stderr "--max-frag-len was lower than --min-frag-len."
assert_exit_code 1
assert_exit_code 2


unset MOSDEPTH_Q0
Expand Down
22 changes: 11 additions & 11 deletions mosdepth.nim
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ proc write_thresholds(fh:BGZI, tid:int, arr:var coverage_t, thresholds:seq[int],
if tid == -2:
for i in thresholds:
line.add("\t0")
discard fh.write_interval(line, region.chrom, start, stop)
doAssert fh.write_interval(line, region.chrom, start, stop) >= 0
return

var counts = new_seq[int](len(thresholds))
Expand All @@ -513,13 +513,13 @@ proc write_thresholds(fh:BGZI, tid:int, arr:var coverage_t, thresholds:seq[int],

for count in counts:
line.add("\t" & intToStr(count))
discard fh.write_interval(line, region.chrom, start, stop)
doAssert fh.write_interval(line, region.chrom, start, stop) >= 0

proc write_header(fh:BGZI, thresholds: seq[int]) =
discard fh.bgz.write("#chrom start end region")
doAssert fh.bgz.write("#chrom start end region") >= 0
for threshold in thresholds:
discard fh.bgz.write("\t" & intToStr(threshold) & "X")
discard fh.bgz.write("\n")
doAssert fh.bgz.write("\t" & intToStr(threshold) & "X") >= 0
doAssert fh.bgz.write("\n") >= 0

proc get_min_levels(targets: seq[Target]): int =
# determine how many levels are needed to store the data given
Expand Down Expand Up @@ -658,7 +658,7 @@ proc main(bam: hts.Bam, chrom: region_t, mapq: int, min_len: int, max_len: int,
line.add(starget & intToStr(int(r.start)) & "\t" & intToStr(int(r.stop)) & "\t" & m)
else:
line.add(starget & intToStr(int(r.start)) & "\t" & intToStr(int(r.stop)) & "\t" & r.name & "\t" & m)
discard fregion.write_interval(line, target.name, int(r.start), int(r.stop))
doAssert fregion.write_interval(line, target.name, int(r.start), int(r.stop)) >= 0
line = line[0..<0]
if tid != -2:
if region.isdigit: #stores the aggregated coverage for each region when working with even windows across the genome
Expand Down Expand Up @@ -694,7 +694,7 @@ proc main(bam: hts.Bam, chrom: region_t, mapq: int, min_len: int, max_len: int,
if use_d4:
fd4.write(target.name, @[Interval(left: 0'u32, right: target.length.uint32, value: 0'i32)])
else:
discard fbase.write_interval(starget & "0\t" & intToStr(int(target.length)) & "\t0", target.name, 0, int(target.length))
doAssert fbase.write_interval(starget & "0\t" & intToStr(int(target.length)) & "\t0", target.name, 0, int(target.length)) >= 0
else:
var write_fbase = true
when defined(d4):
Expand All @@ -713,15 +713,15 @@ proc main(bam: hts.Bam, chrom: region_t, mapq: int, min_len: int, max_len: int,
fastIntToStr(p.stop.int32, line, line.len)
line.add('\t')
fastIntToStr(p.value.int32, line, line.len)
discard fbase.write_interval(line, target.name, p.start, p.stop)
doAssert fbase.write_interval(line, target.name, p.start, p.stop) >= 0
if quantize.len != 0:
if tid == -2 and quantize[0] == 0:
var lookup = make_lookup(quantize)
discard fquantize.write_interval(starget & "0\t" & intToStr(int(target.length)) & "\t" & lookup[0], target.name, 0, int(target.length))
doAssert fquantize.write_interval(starget & "0\t" & intToStr(int(target.length)) & "\t" & lookup[0], target.name, 0, int(target.length)) >= 0
else:
if tid == -2: continue
for p in gen_quantized(quantize, arr):
discard fquantize.write_interval(starget & intToStr(p.start) & "\t" & intToStr(p.stop) & "\t" & p.value, target.name, p.start, p.stop)
doAssert fquantize.write_interval(starget & intToStr(p.start) & "\t" & intToStr(p.stop) & "\t" & p.value, target.name, p.start, p.stop) >= 0

write_summary("total", global_stat, fh_summary)
if region != "":
Expand Down Expand Up @@ -782,7 +782,7 @@ when(isMainModule):
when not defined(release) and not defined(lto):
stderr.write_line "[mosdepth] WARNING: built in debug mode; will be slow"

let version = "mosdepth 0.3.5"
let version = "mosdepth 0.3.6"
let env_fasta = getEnv("REF_PATH")
var doc = format("""
$version
Expand Down
2 changes: 1 addition & 1 deletion mosdepth.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.3.5"
version = "0.3.6"
author = "Brent Pedersen"
description = "fast depth"
license = "MIT"
Expand Down

0 comments on commit c300eb2

Please sign in to comment.