Skip to content

Commit

Permalink
use description from source file as new Description
Browse files Browse the repository at this point in the history
thanks @xuyangy for implementing.

also don't add ID or FILTER to the header.

closes #43
  • Loading branch information
brentp committed Mar 18, 2017
1 parent e03c059 commit 73f084f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
13 changes: 8 additions & 5 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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 {
Expand All @@ -675,14 +675,17 @@ 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])
}
}

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
Expand Down
2 changes: 1 addition & 1 deletion docs/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------
Expand Down
5 changes: 5 additions & 0 deletions tests/functional-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified tests/id-test/dbsnp.small.vcf.gz
Binary file not shown.
Binary file modified tests/id-test/dbsnp.small.vcf.gz.tbi
Binary file not shown.

0 comments on commit 73f084f

Please sign in to comment.