From 73f084f1220766308a0469e6d75184ae8114334e Mon Sep 17 00:00:00 2001 From: Brent Pedersen Date: Fri, 17 Mar 2017 21:34:59 -0600 Subject: [PATCH] use description from source file as new Description thanks @xuyangy for implementing. also don't add ID or FILTER to the header. closes #43 --- api/api.go | 13 ++++++++----- docs/CHANGES.md | 2 +- tests/functional-test.sh | 5 +++++ tests/id-test/dbsnp.small.vcf.gz | Bin 170 -> 474 bytes tests/id-test/dbsnp.small.vcf.gz.tbi | Bin 155 -> 158 bytes 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/api/api.go b/api/api.go index 21c3e92..0d8378d 100644 --- a/api/api.go +++ b/api/api.go @@ -426,9 +426,8 @@ func (s *Source) AnnotateOne(v interfaces.IVariant, vals []interface{}, prefix s } // UpdateHeader does what it suggests but handles left and right ends for svs -func (s *Source) UpdateHeader(r HeaderUpdater, ends bool, htype string, number string) { +func (s *Source) UpdateHeader(r HeaderUpdater, ends bool, htype string, number string, desc string) { ntype := "String" - var desc string // for 'self' and 'first', we can get the type from the header of the annotation file. if htype != "" && (s.Op == "self" || s.Op == "first") { ntype = htype @@ -464,7 +463,7 @@ func (s *Source) UpdateHeader(r HeaderUpdater, ends bool, htype string, number s } } if (s.Op == "first" || s.Op == "self") && htype == ntype { - desc = fmt.Sprintf("transfered from matched variants in %s", s.File) + desc = fmt.Sprintf("%s (from %s)", desc, s.File) } else if strings.HasSuffix(s.File, ".bam") && s.Field == "" { desc = fmt.Sprintf("calculated by coverage from %s", s.File) } else if s.Field == "DP2" { @@ -666,7 +665,8 @@ func (a *Annotator) Setup(query HeaderUpdater) ([]interfaces.Queryable, error) { if q, ok := queryables[i].(*bix.Bix); ok { for _, src := range fmap[file] { num := q.GetHeaderNumber(src.Field) - src.UpdateHeader(query, a.Ends, q.GetHeaderType(src.Field), num) + desc := q.GetHeaderDescription(src.Field) + src.UpdateHeader(query, a.Ends, q.GetHeaderType(src.Field), num, desc) src.NumberA = num == "A" } } else if _, ok := queryables[i].(*parsers.BamQueryable); ok { @@ -675,7 +675,7 @@ func (a *Annotator) Setup(query HeaderUpdater) ([]interfaces.Queryable, error) { if src.IsNumber() { htype = "Float" } - src.UpdateHeader(query, a.Ends, htype, "1") + src.UpdateHeader(query, a.Ends, htype, "1", "") } } else { log.Printf("type not known: %T\n", queryables[i]) @@ -683,6 +683,9 @@ func (a *Annotator) Setup(query HeaderUpdater) ([]interfaces.Queryable, error) { } for _, post := range a.PostAnnos { + if post.Name == "" || post.Name == "ID" || post.Name == "FILTER" { + continue + } query.AddInfoToHeader(post.Name, ".", post.Type, fmt.Sprintf("calculated field: %s", post.Name)) } return queryables, nil diff --git a/docs/CHANGES.md b/docs/CHANGES.md index 4fadf10..4e9ca24 100644 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -2,7 +2,7 @@ v0.2.3 ------ + allow pulling the 'FILTER' field from a VCF by specifing 'FILTER' in the `fields` + add new op for postannotation only 'delete' which can be used to remove fields from the INFO. - ++ use Description from annotation as Description in annotated file (thanks @xuyangy for the implementation #43) v0.2.2 ------ diff --git a/tests/functional-test.sh b/tests/functional-test.sh index 09f1eb4..17ca0d9 100755 --- a/tests/functional-test.sh +++ b/tests/functional-test.sh @@ -150,3 +150,8 @@ assert_in_stdout "rs9996;COSM4590035;COSM4590034" assert_in_stdout "cosmic_filter=QQ,ZZ" # test delete assert_equal $(grep -c "NS=" $STDOUT_FILE) 0 +# test that Description is transferred from CAF +assert_in_stdout "comma delimited list of allele frequencies based on 1000Genomes" +# make sure that ID didn't get added to the header as we're just updating the ID column. +assert_equal $(grep -c "ID=ID" $STDOUT_FILE) 0 +assert_equal $(grep -c "ID=FILTER" $STDOUT_FILE) 0 diff --git a/tests/id-test/dbsnp.small.vcf.gz b/tests/id-test/dbsnp.small.vcf.gz index a139bbf1354a6274fb7b4f2905f645dd94ded477..e06c2cc08cd3c0e5e065c70fdc239a98ce7adcd1 100644 GIT binary patch delta 455 zcmV;&0XY7u0ont9ABzYC000000RIL6LPG)oy#Z}fO^@0z5Ivh;Fz4{wiP~o&x`XotA)QW9SC2Xa^$O*IL-M{4RU)Cup#U3UQpT3;yC(c)R2j8j)?Zu%$BTJEVr|gb#G=+9qe;I#3tipH0Ck0ZWJec9K~_O<}7C+ xee|MI9*&YE3BrJfaTGoOWkq}v@lg~JZ8Dj}Y|HXs-gCmiA6KaD@TdZjj2@Vj(4hbT literal 170 zcmb2|=3rp}f&Xj_PR>jWy$rgiHgX*@5MjOW^PBl5uant_7E8)_-MZpnBDHvThpVID zq91>?rfil|Tz31fk?rZnU*hD}{(cb^c4%EtOtSR%54M*cTxjjNyO6uU?up{T{FpW8 zu3r-9$(uT@=Tp!fFW)mQf?{9q*LX-x>UuG~$FPTIx5V?0tZ~0>Dw}|gkVkWkGy^l( HaUcQ!g11Cb diff --git a/tests/id-test/dbsnp.small.vcf.gz.tbi b/tests/id-test/dbsnp.small.vcf.gz.tbi index 1562f27c2c674674e88b3f41f9ce08ba1345f737..a3d857a17b4797a9415245dd0bc49a1619666a91 100644 GIT binary patch literal 158 zcmb2|=3rp}f&Xj_PR>jWjSSp{pHfm%5)u-ak|cPUP6f>3?U-!b)x#q>qfuwQr+_G< zK`PI0hglDHB|MnOab$~`N$K5y!Wnfl{^+Q++|aP~>c6!33qC4gsbKOv0S1OW7Bz>G SL>U<5(Oe+SzzlW}hyVa#2{m5; literal 155 zcmb2|=3rp}f&Xj_PR>jWbqsIMY~*cF5NLhKEUaF@tbXCvDZgxXg@qf-c!jyWj~5FC z?vR*s;8Fd_j}ssFt(5N(6qNSb8?1ghpf2u~TUUYfcZ-XiY1Mw(mFKknJ+mv$e)W3a jKKXBN6_sG%U#NPe9@9JVWl5q84Dx8!OEWNoT>~Nj9U(J%