Skip to content

Commit

Permalink
Fix Number in the header definition of transferred FILTER and ID tags
Browse files Browse the repository at this point in the history
Resolves #2335
  • Loading branch information
pd3 committed Jan 1, 2025
1 parent da58fb4 commit c58d522
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Changes affecting specific commands:
- New experimental plugin for scoring variants and assess site noisiness (allelic frequency profiles)
from a large number of unaffected parental samples

* bcftools annotate

- Fix Number in the header definition of transferred FILTER and ID tags (#2335)

* bcftools convert

- The command `convert --gvcf2vcf` was not filling the REF allele when BCF was output (#243)
Expand Down
2 changes: 1 addition & 1 deletion test/annotate19.1.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
##FILTER=<ID=ori_filter1,Description="Test">
##FILTER=<ID=ori_filter2,Description="Test">
##INFO=<ID=ID,Number=1,Type=String,Description="Transferred ID column">
##INFO=<ID=ID,Number=.,Type=String,Description="Transferred ID column">
##INFO=<ID=INFO_ID,Number=1,Type=String,Description="Test">
#CHROM POS ID REF ALT QUAL FILTER INFO
1 3000001 id_id1;id_id2;info_id C T . ori_filter1;ori_filter2 ID=id_id1,id_id2;INFO_ID=info_id
2 changes: 1 addition & 1 deletion test/annotate19.2.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
##FILTER=<ID=ori_filter1,Description="Test">
##FILTER=<ID=ori_filter2,Description="Test">
##FILTER=<ID=filter_filter,Description="Test">
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
##INFO=<ID=FILTER,Number=.,Type=String,Description="Transferred FILTER column">
##INFO=<ID=INFO_FILTER,Number=1,Type=String,Description="Test">
#CHROM POS ID REF ALT QUAL FILTER INFO
1 3000001 ori_id C T . filter_filter FILTER=filter_filter;INFO_FILTER=info_filter
2 changes: 1 addition & 1 deletion test/annotate19.3.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
##FILTER=<ID=ori_filter1,Description="Test">
##FILTER=<ID=ori_filter2,Description="Test">
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
##INFO=<ID=FILTER,Number=.,Type=String,Description="Transferred FILTER column">
##INFO=<ID=INFO_FILTER,Number=1,Type=String,Description="Test">
#CHROM POS ID REF ALT QUAL FILTER INFO
1 3000001 ori_id C T . ori_filter1;ori_filter2 FILTER=filter_filter;INFO_FILTER=info_filter
2 changes: 1 addition & 1 deletion test/annotate19.4.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
##FILTER=<ID=ori_filter1,Description="Test">
##FILTER=<ID=ori_filter2,Description="Test">
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
##INFO=<ID=FILTER,Number=.,Type=String,Description="Transferred FILTER column">
#CHROM POS ID REF ALT QUAL FILTER INFO
1 3000001 ori_id C T . ori_filter1;ori_filter2 FILTER=ori_filter1,ori_filter2
2 changes: 1 addition & 1 deletion test/annotate19.5.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
##FILTER=<ID=ori_filter1,Description="Test">
##FILTER=<ID=ori_filter2,Description="Test">
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
##INFO=<ID=FILTER,Number=.,Type=String,Description="Transferred FILTER column">
#CHROM POS ID REF ALT QUAL FILTER INFO
1 3000001 ori_id C T . ori_filter1;ori_filter2 FILTER=filter_filter
2 changes: 1 addition & 1 deletion test/annotate19.6.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##reference=file:///lustre/scratch105/projects/g1k/ref/main_project/human_g1k_v37.fasta
##FILTER=<ID=ori_filter1,Description="Test">
##FILTER=<ID=ori_filter2,Description="Test">
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
##INFO=<ID=FILTER,Number=.,Type=String,Description="Transferred FILTER column">
##FILTER=<ID=filter_filter,Description="Test">
#CHROM POS ID REF ALT QUAL FILTER INFO
1 3000001 ori_id C T . filter_filter FILTER=ori_filter1,ori_filter2
2 changes: 1 addition & 1 deletion test/annotate19.7.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
##FILTER=<ID=ori_filter1,Description="Test">
##FILTER=<ID=ori_filter2,Description="Test">
##FILTER=<ID=filter_filter,Description="Test">
##INFO=<ID=FILTER,Number=1,Type=String,Description="Transferred FILTER column">
##INFO=<ID=FILTER,Number=.,Type=String,Description="Transferred FILTER column">
#CHROM POS ID REF ALT QUAL FILTER INFO
1 3000001 ori_id C T . filter_filter FILTER=filter_filter
8 changes: 4 additions & 4 deletions vcfannotate.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* vcfannotate.c -- Annotate and edit VCF/BCF files.
Copyright (C) 2013-2024 Genome Research Ltd.
Copyright (C) 2013-2025 Genome Research Ltd.
Author: Petr Danecek <[email protected]>
Expand Down Expand Up @@ -2414,7 +2414,7 @@ static void init_columns(args_t *args)
col->hdr_key_src = strdup(ptr+2);
col->hdr_key_dst = strdup(str.s+5);
tmp.l = 0;
ksprintf(&tmp,"##INFO=<ID=%s,Number=1,Type=String,Description=\"Transferred FILTER column\">",col->hdr_key_dst);
ksprintf(&tmp,"##INFO=<ID=%s,Number=.,Type=String,Description=\"Transferred FILTER column\">",col->hdr_key_dst);
bcf_hdr_append(args->hdr_out, tmp.s);
if (bcf_hdr_sync(args->hdr_out) < 0) error_errno("[%s] Failed to update header", __func__);
int hdr_id = bcf_hdr_id2int(args->hdr_out, BCF_DT_ID, col->hdr_key_dst);
Expand Down Expand Up @@ -2672,13 +2672,13 @@ static void init_columns(args_t *args)
{
// transferring ID column into a new INFO tag
tmp.l = 0;
ksprintf(&tmp,"##INFO=<ID=%s,Number=1,Type=String,Description=\"Transferred ID column\">",key_dst);
ksprintf(&tmp,"##INFO=<ID=%s,Number=.,Type=String,Description=\"Transferred ID column\">",key_dst);
}
else if ( !strcasecmp("FILTER",key_src) && !explicit_src_info )
{
// transferring FILTER column into a new INFO tag
tmp.l = 0;
ksprintf(&tmp,"##INFO=<ID=%s,Number=1,Type=String,Description=\"Transferred FILTER column\">",key_dst);
ksprintf(&tmp,"##INFO=<ID=%s,Number=.,Type=String,Description=\"Transferred FILTER column\">",key_dst);
}
else
{
Expand Down

0 comments on commit c58d522

Please sign in to comment.