Skip to content

Commit d64b67c

Browse files
committed
fix long-standing bug (#27) that would cause sigsegv in some cases
1 parent d8fb9a0 commit d64b67c

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.2.4
2+
======
3+
+ fix long-standing bug (#27) that would cause sigsegv in some cases
4+
15
v0.2.3
26
======
37
+ add `feature_fusion` to impact order list (#92)

js/slivar-functions.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function hq(kid, mom, dad) {
55
}
66

77
function hq1(sample) {
8-
if (sample.unknown || sample.GQ < config.min_GQ) { return false; }
8+
if (sample.unknown || (sample.GQ < config.min_GQ)) { return false; }
99
if ((sample.AD[0] + sample.AD[1]) < config.min_DP) { return false; }
1010
if (sample.hom_ref){
1111
return sample.AB < 0.02
@@ -16,11 +16,6 @@ function hq1(sample) {
1616
return sample.AB > 0.98
1717
}
1818

19-
function hqrv(variant, INFO, af_cutoff) {
20-
// hi-quality, rare variant.
21-
return INFO.gnomad_popmax_af < af_cutoff && variant.FILTER == 'PASS'
22-
}
23-
2419
function denovo(kid, mom, dad){
2520
// check genotypes match expected pattern
2621
if(!(kid.het && mom.hom_ref && dad.hom_ref)){ return false; }

src/slivarpkg/evaluator.nim

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,11 @@ proc id2names*(h:Header): seq[idpair] =
438438
## lookup of headerid -> name
439439
var hdr = h.hdr
440440
result = newSeq[idpair](hdr.n[0])
441-
for i in 0..<hdr.n[0].int:
442-
var idp = cast[seq[bcf_idpair_t]](hdr.id[0])[i]
443-
if idp.val == nil or idp.key.len == 0: continue
441+
let arr = cast[ptr UncheckedArray[bcf_idpair_t]](hdr.id[0])
442+
for i in 0..<hdr.n[0].int32:
443+
var idp = arr[i]
444+
if idp.val == nil or idp.key == nil: continue
445+
if idp.key.len == 0: continue
444446
var name = idp.key
445447
if idp.val.hrec[1] == nil and idp.val.hrec[2] == nil: continue
446448
if idp.val.id >= result.len:
@@ -795,7 +797,10 @@ proc set_format_fields*(ev:var Evaluator, v:Variant, alts: var seq[int8], ints:
795797
stderr.write_line &""" expected 2 values per sample for 'AD' field, but got {ints.len / ev.samples.len:.1f} for variant: {v.CHROM}:{v.start + 1}:{v.REF}:{join(v.ALT, ",")}"""
796798
stderr.write_line """ see: https://github.com/brentp/slivar/wiki/decomposing-and-subsetting-vcfs"""
797799
if not has_ab:
798-
ev.set_ab(fmt, ints, v.ALT.len + 1)
800+
if ev.samples.len * (1 + valt_len) == ints.len:
801+
ev.set_ab(fmt, ints, v.ALT.len + 1)
802+
else:
803+
ev.fmt_field_sets.curr.excl(f.i.uint8)
799804
has_ab = true
800805

801806
elif f.name == "AB":

src/slivarpkg/version.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
const slivarVersion* = "0.2.3"
1+
const slivarVersion* = "0.2.4"
22
const slivarGitCommit* = staticExec("git rev-parse --verify HEAD")

tests/functional-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,5 @@ assert_in_stderr "sample compound-het
196196
SID_3 2
197197
SID_4 2"
198198
199+
run check_issue_27 $exe expr -g _clinvar.test.zip -v tests/test-27.vcf.gz
199200

tests/test-27.vcf.gz

1.81 KB
Binary file not shown.

0 commit comments

Comments
 (0)