Skip to content

Commit 503d7e7

Browse files
committed
handle read-groups correctly
closes #153
1 parent a9e4e6f commit 503d7e7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

mosdepth.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ proc init(arr: var coverage_t, tlen:int) =
229229
arr.set_len(int(tlen))
230230
zeroMem(arr[0].addr, len(arr) * sizeof(arr[0]))
231231

232-
proc coverage(bam: hts.Bam, arr: var coverage_t, region: var region_t, mapq:int= -1, eflag: uint16=1796, iflag:uint16=0, read_groups:seq[cstring]=(@[]), fast_mode:bool=false): int =
232+
proc coverage(bam: hts.Bam, arr: var coverage_t, region: var region_t, mapq:int= -1, eflag: uint16=1796, iflag:uint16=0, read_groups:seq[string]=(@[]), fast_mode:bool=false): int =
233233
# depth updates arr in-place and yields the tid for each chrom.
234234
# returns -1 if the chrom is not found in the bam header
235235
# returns -2 if the chrom was found in the header, but there was no data for it
@@ -258,7 +258,7 @@ proc coverage(bam: hts.Bam, arr: var coverage_t, region: var region_t, mapq:int=
258258
if iflag != 0 and ((rec.flag and iflag) == 0):
259259
continue
260260
if has_read_groups:
261-
var t = tag[cstring](rec, "RG")
261+
var t = tag[string](rec, "RG")
262262
if t.isNone or not read_groups.contains(t.get):
263263
continue
264264
if tgt.tid != rec.b.core.tid:
@@ -551,7 +551,7 @@ proc main(bam: hts.Bam, chrom: region_t, mapq: int, eflag: uint16, iflag: uint16
551551
var
552552
targets = bam.hdr.targets
553553
sub_targets = get_targets(targets, chrom)
554-
read_groups: seq[cstring]
554+
read_groups: seq[string]
555555
rchrom : region_t
556556
arr: coverage_t
557557
prefix: string = $(args["<prefix>"])
@@ -582,7 +582,7 @@ proc main(bam: hts.Bam, chrom: region_t, mapq: int, eflag: uint16, iflag: uint16
582582

583583
if $args["--read-groups"] != "nil":
584584
for r in ($args["--read-groups"]).split(','):
585-
read_groups.add(r.cstring)
585+
read_groups.add($r)
586586
var levels = get_min_levels(targets)
587587

588588
var chrom_region_distribution, chrom_global_distribution: seq[int64]
@@ -775,7 +775,7 @@ when(isMainModule):
775775
when not defined(release) and not defined(lto):
776776
stderr.write_line "[mosdepth] WARNING: built in debug mode; will be slow"
777777

778-
let version = "mosdepth 0.3.1"
778+
let version = "mosdepth 0.3.2"
779779
let env_fasta = getEnv("REF_PATH")
780780
var doc = format("""
781781
$version

mosdepth.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.3.1"
3+
version = "0.3.2"
44
author = "Brent Pedersen"
55
description = "fast depth"
66
license = "MIT"

0 commit comments

Comments
 (0)