Skip to content

Commit

Permalink
handle by_alt + float correctly
Browse files Browse the repository at this point in the history
closes #113
  • Loading branch information
brentp committed Jul 19, 2019
1 parent deeeee3 commit 8c692e2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ func (s *Source) UpdateHeader(r HeaderUpdater, ends bool, htype string, number s
if s.Op == "by_alt" {
number = "A"
ntype = "String"
if strings.HasSuffix(s.Name, "_float") {
ntype = "Float"
s.Name = s.Name[:len(s.Name)-6]
} else if strings.HasSuffix(s.Name, "_int") {
ntype = "Integer"
s.Name = s.Name[:len(s.Name)-4]
}
// for 'self' and 'first', we can get the type from the header of the annotation file.
} else if htype != "" && (s.Op == "self" || s.Op == "first") {
ntype = htype
Expand Down
Binary file added tests/by_alt_float/annotation.tsv.gz
Binary file not shown.
Binary file added tests/by_alt_float/annotation.tsv.gz.tbi
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/by_alt_float/conf.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[annotation]]
names = ["CADD_RAW_float"]
file = "annotation.tsv.gz"
columns = [5]
ops = ["by_alt"]
7 changes: 7 additions & 0 deletions tests/by_alt_float/q.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##fileformat=VCFv4.2
##contig=<ID=chr2,length=242193529,assembly=GRCh38>
##INFO=<ID=AF,Number=.,Type=Float,Description="">
##INFO=<ID=AQ,Number=.,Type=Integer,Description="">
##hailversion=0.2.9-8588a25687af
#CHROM POS ID REF ALT QUAL FILTER INFO
chr2 41647 2_41647_A_G A G 1328.0 . AF=1.56250e-02;AQ=1328
7 changes: 7 additions & 0 deletions tests/functional-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,10 @@ run self_test_with_A_and_many_overlaps fn_self_test_with_A_and_many_overlaps
assert_exit_code 0
assert_equal $(tail -1 $STDOUT_FILE | cut -f 8) "AC=35,65;GN_AF=0.3717,0.6122"
assert_in_stdout "ID=GN_AF,Number=A"
run check_by_alts_float vcfanno -base-path tests/by_alt_float/ tests/by_alt_float/conf.toml tests/by_alt_float/q.vcf
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

0 comments on commit 8c692e2

Please sign in to comment.