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 a139bbf..e06c2cc 100644 Binary files a/tests/id-test/dbsnp.small.vcf.gz and b/tests/id-test/dbsnp.small.vcf.gz differ diff --git a/tests/id-test/dbsnp.small.vcf.gz.tbi b/tests/id-test/dbsnp.small.vcf.gz.tbi index 1562f27..a3d857a 100644 Binary files a/tests/id-test/dbsnp.small.vcf.gz.tbi and b/tests/id-test/dbsnp.small.vcf.gz.tbi differ