From 8c692e2de47ec435cbe4f87744c671aa3d2f8015 Mon Sep 17 00:00:00 2001 From: Brent Pedersen Date: Thu, 18 Jul 2019 19:38:32 -0600 Subject: [PATCH] handle by_alt + float correctly closes #113 --- api/api.go | 7 +++++++ tests/by_alt_float/annotation.tsv.gz | Bin 0 -> 237 bytes tests/by_alt_float/annotation.tsv.gz.tbi | Bin 0 -> 99 bytes tests/by_alt_float/conf.toml | 5 +++++ tests/by_alt_float/q.vcf | 7 +++++++ tests/functional-test.sh | 7 +++++++ 6 files changed, 26 insertions(+) create mode 100644 tests/by_alt_float/annotation.tsv.gz create mode 100644 tests/by_alt_float/annotation.tsv.gz.tbi create mode 100644 tests/by_alt_float/conf.toml create mode 100644 tests/by_alt_float/q.vcf diff --git a/api/api.go b/api/api.go index e8f9059..cf470f3 100644 --- a/api/api.go +++ b/api/api.go @@ -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 diff --git a/tests/by_alt_float/annotation.tsv.gz b/tests/by_alt_float/annotation.tsv.gz new file mode 100644 index 0000000000000000000000000000000000000000..6a4373a1393465286c04b50c0139ae904ed5ad9b GIT binary patch literal 237 zcmb2|=3rp}f&Xj_PR>jW7Z`lcY|J}kAkgse=O+>M)Xb&F4jsuooH41Z#CfGwn)c2k z(|Y)Cs&#B{pZIisU2SUT+ILnqJZsm^&YJ4<@b-_s{|DEKOg>%yMABa^QheH(hs?iU zPq7HO6~E@-{Rx{+U-z*nKC<_*&tl#;l{*)63cu5=5|7)aer@u{n~%zrU%#5^w&0uG z;^-Vd3C+NmOd;2sw@##66g4%bU9dZxkXNtl-jrjWZVcRopHfm%8W;r5vK&1XU?^~#!>7u(>BBdJ0|#7p=%qZ+ iWf61^Ki;F#=69HZL1eMm`97d-c{F3B8JIzaf&l=oG#Qlu literal 0 HcmV?d00001 diff --git a/tests/by_alt_float/conf.toml b/tests/by_alt_float/conf.toml new file mode 100644 index 0000000..d0468ac --- /dev/null +++ b/tests/by_alt_float/conf.toml @@ -0,0 +1,5 @@ +[[annotation]] +names = ["CADD_RAW_float"] +file = "annotation.tsv.gz" +columns = [5] +ops = ["by_alt"] diff --git a/tests/by_alt_float/q.vcf b/tests/by_alt_float/q.vcf new file mode 100644 index 0000000..791d665 --- /dev/null +++ b/tests/by_alt_float/q.vcf @@ -0,0 +1,7 @@ +##fileformat=VCFv4.2 +##contig= +##INFO= +##INFO= +##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 diff --git a/tests/functional-test.sh b/tests/functional-test.sh index ab6dd3c..11aa5b6 100755 --- a/tests/functional-test.sh +++ b/tests/functional-test.sh @@ -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 +