Skip to content

Commit

Permalink
handle missing value in postannotation. closes #116
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Apr 15, 2020
1 parent 1d140d4 commit 9f857a9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ func (a *Annotator) PostAnnotate(chrom string, start int, end int, info interfac
}
}
// we need to try even if it didn't get all values.
if len(vals) == 0 && len(post.Fields) > 0 {
if len(vals) == 0 && len(post.Fields) == 0 {
continue
}

Expand Down
5 changes: 5 additions & 0 deletions tests/functional-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,8 @@ assert_exit_code 0
assert_equal $(tail -1 $STDOUT_FILE | cut -f 8) "AF=1.56250e-02;AQ=1328;CADD_RAW=0.591814"
go install -a
run check_missing_postanno vcfanno -lua tests/missing_postanno/o.lua tests/missing_postanno/o.conf tests/missing_postanno/o.vcf
assert_exit_code 0
assert_in_stdout "exome_af=-1"
5 changes: 5 additions & 0 deletions tests/missing_postanno/o.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[postannotation]]
fields=["exome_af"]
op="lua:checkaf(exome_af)"
name="exome_af"
type="Float"
5 changes: 5 additions & 0 deletions tests/missing_postanno/o.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function checkaf(v)
local output = v
if (v == nil) then output = -1 end
return output
end
4 changes: 4 additions & 0 deletions tests/missing_postanno/o.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
##fileformat=VCFv4.1
##INFO=<ID=exome_af,Number=1,Type=Float,Description="xxx">
#CHROM POS ID REF ALT QUAL FILTER INFO
chr1 123456 . G T . PASS .

0 comments on commit 9f857a9

Please sign in to comment.