Skip to content

Commit e9bff3f

Browse files
committed
Support dynamic variables read from a tab-delimited annotation file
For example, in the two cases below the field 'STR' from the -a file is required to match the INFO/TAG in VCF. In the first example the alleles REF,ALT must match, in the second example they are ignored. The option -k is required to output also records that were not annotated: bcftools annotate -a ann.tsv.gz -c CHROM,POS,REF,ALT,SCORE,STR -i'TAG={STR}' -k in.vcf bcftools annotate -a ann.tsv.gz -c CHROM,POS,-,-,SCORE,STR -i'TAG={STR}' -k in.vcf Resolves #2151
1 parent 466ceae commit e9bff3f

File tree

10 files changed

+582
-184
lines changed

10 files changed

+582
-184
lines changed

NEWS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33

44
Changes affecting specific commands:
55

6+
* bcftools annotate
7+
8+
- Support dynamic variables read from a tab-delimited annotation file (#2151)
9+
For example, in the two cases below the field 'STR' from the -a file is required to match
10+
the INFO/TAG in VCF. In the first example the alleles REF,ALT must match, in the second
11+
example they are ignored. The option -k is required to output also records that were not
12+
annotated:
13+
14+
bcftools annotate -a ann.tsv.gz -c CHROM,POS,REF,ALT,SCORE,STR -i'TAG={STR}' -k in.vcf
15+
bcftools annotate -a ann.tsv.gz -c CHROM,POS,-,-,SCORE,STR -i'TAG={STR}' -k in.vcf
16+
17+
618
* bcftools consensus
719

820
- Add new --regions-overlap option which allows to take into account overlapping deletions

doc/bcftools.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ Add or remove annotations.
380380
To replace only existing values without modifying missing annotations, use "-TAG".
381381
To match the record also by ID or INFO/END, in addition to REF and ALT, use "~ID" or "~INFO/END".
382382
If position needs to be replaced, mark the column with the new position as "~POS".
383+
Note that this works only for ID and POS, for other fields see the description of *-i* below.
383384
{nbsp} +
384385
{nbsp} +
385386
If the annotation file is not a VCF/BCF, all new annotations must be
@@ -423,6 +424,17 @@ Add or remove annotations.
423424
*-i, --include* 'EXPRESSION'::
424425
include only sites for which 'EXPRESSION' is true. For valid expressions see
425426
*<<expressions,EXPRESSIONS>>*.
427+
{nbsp} +
428+
{nbsp} +
429+
Additionally, the command *bcftools annotate* supports expressions updated from the annotation
430+
file dynamically for each record:
431+
----
432+
# The field 'STR' from the -a file is required to match INFO/TAG in VCF. In the first example
433+
# the alleles REF,ALT must match, in the second example they are ignored. The option -k is required
434+
# to output also records that were not annotated
435+
bcftools annotate -a annots.tsv.gz -c CHROM,POS,REF,ALT,SCORE,STR -i'TAG={STR}' -k input.vcf
436+
bcftools annotate -a annots.tsv.gz -c CHROM,POS,-,-,SCORE,STR -i'TAG={STR}' -k input.vcf
437+
----
426438

427439
*-k, --keep-sites*::
428440
keep sites which do not pass *-i* and *-e* expressions instead of discarding them

0 commit comments

Comments
 (0)