Skip to content

Commit

Permalink
fix long-standing bug (#27) that would cause sigsegv in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Jun 28, 2021
1 parent d8fb9a0 commit d64b67c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.2.4
======
+ fix long-standing bug (#27) that would cause sigsegv in some cases

v0.2.3
======
+ add `feature_fusion` to impact order list (#92)
Expand Down
7 changes: 1 addition & 6 deletions js/slivar-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function hq(kid, mom, dad) {
}

function hq1(sample) {
if (sample.unknown || sample.GQ < config.min_GQ) { return false; }
if (sample.unknown || (sample.GQ < config.min_GQ)) { return false; }
if ((sample.AD[0] + sample.AD[1]) < config.min_DP) { return false; }
if (sample.hom_ref){
return sample.AB < 0.02
Expand All @@ -16,11 +16,6 @@ function hq1(sample) {
return sample.AB > 0.98
}

function hqrv(variant, INFO, af_cutoff) {
// hi-quality, rare variant.
return INFO.gnomad_popmax_af < af_cutoff && variant.FILTER == 'PASS'
}

function denovo(kid, mom, dad){
// check genotypes match expected pattern
if(!(kid.het && mom.hom_ref && dad.hom_ref)){ return false; }
Expand Down
13 changes: 9 additions & 4 deletions src/slivarpkg/evaluator.nim
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,11 @@ proc id2names*(h:Header): seq[idpair] =
## lookup of headerid -> name
var hdr = h.hdr
result = newSeq[idpair](hdr.n[0])
for i in 0..<hdr.n[0].int:
var idp = cast[seq[bcf_idpair_t]](hdr.id[0])[i]
if idp.val == nil or idp.key.len == 0: continue
let arr = cast[ptr UncheckedArray[bcf_idpair_t]](hdr.id[0])
for i in 0..<hdr.n[0].int32:
var idp = arr[i]
if idp.val == nil or idp.key == nil: continue
if idp.key.len == 0: continue
var name = idp.key
if idp.val.hrec[1] == nil and idp.val.hrec[2] == nil: continue
if idp.val.id >= result.len:
Expand Down Expand Up @@ -795,7 +797,10 @@ proc set_format_fields*(ev:var Evaluator, v:Variant, alts: var seq[int8], ints:
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, ",")}"""
stderr.write_line """ see: https://github.com/brentp/slivar/wiki/decomposing-and-subsetting-vcfs"""
if not has_ab:
ev.set_ab(fmt, ints, v.ALT.len + 1)
if ev.samples.len * (1 + valt_len) == ints.len:
ev.set_ab(fmt, ints, v.ALT.len + 1)
else:
ev.fmt_field_sets.curr.excl(f.i.uint8)
has_ab = true

elif f.name == "AB":
Expand Down
2 changes: 1 addition & 1 deletion src/slivarpkg/version.nim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const slivarVersion* = "0.2.3"
const slivarVersion* = "0.2.4"
const slivarGitCommit* = staticExec("git rev-parse --verify HEAD")
1 change: 1 addition & 0 deletions tests/functional-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,5 @@ assert_in_stderr "sample compound-het
SID_3 2
SID_4 2"
run check_issue_27 $exe expr -g _clinvar.test.zip -v tests/test-27.vcf.gz
Binary file added tests/test-27.vcf.gz
Binary file not shown.

0 comments on commit d64b67c

Please sign in to comment.