Skip to content

Commit

Permalink
Fix a bug introduced in 1.14
Browse files Browse the repository at this point in the history
The bug caused that records with INFO/END annotation would incorrectly
trigger `-c ~INFO/END` mode of comparison even when not explicitly requested,
which would result in not transferring the annotation from a tab-delimited file.

Resolves #1733
  • Loading branch information
pd3 committed Jun 13, 2022
1 parent 665b07a commit 1745829
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Changes affecting the whole of bcftools, or multiple commands:

Changes affecting specific commands:

* bcftools annotate

- A bug introduced in 1.14 caused that records with INFO/END annotation would
incorrectly trigger `-c ~INFO/END` mode of comparison even when not explicitly
requested, which would result in not transferring the annotation from a tab-delimited
file (#1733)

* bcftools mpileup

- New NMBZ annotation for Mann-Whitney U-z test on number of mismatches within
Expand Down
12 changes: 12 additions & 0 deletions test/annotate.32.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##ALT=<ID=DEL,Description="Deletion">
##ALT=<ID=INS,Description="Duplication">
##INFO=<ID=END,Number=1,Type=Integer,Description="End position of the structural variant">
##INFO=<ID=EVIDENCE,Number=.,Type=String,Description="Classes of random forest support.">
##contig=<ID=chr1,length=248956422>
#CHROM POS ID REF ALT QUAL FILTER INFO
chr1 54713 . N <INS> . PASS END=54714;EVIDENCE=RD,PE,SR
chr1 66224 . N <DEL> . PASS END=66275;EVIDENCE=RD,PE,SR
chr1 66242 . N <DEL> . PASS END=66520;EVIDENCE=RD,PE,SR
chr1 998763 . N <INS> . PASS END=998764;EVIDENCE=RD,PE,SR
4 changes: 4 additions & 0 deletions test/annotate27.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
chr1 54713 N <INS> RD,PE,SR
chr1 66224 N <DEL> RD,PE,SR
chr1 66242 N <DEL> RD,PE,SR
chr1 998763 N <INS> RD,PE,SR
12 changes: 12 additions & 0 deletions test/annotate27.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##ALT=<ID=DEL,Description="Deletion">
##ALT=<ID=INS,Description="Duplication">
##INFO=<ID=END,Number=1,Type=Integer,Description="End position of the structural variant">
##INFO=<ID=EVIDENCE,Number=.,Type=String,Description="Classes of random forest support.">
##contig=<ID=chr1,length=248956422>
#CHROM POS ID REF ALT QUAL FILTER INFO
chr1 54713 . N <INS> . PASS END=54714
chr1 66224 . N <DEL> . PASS END=66275
chr1 66242 . N <DEL> . PASS END=66520
chr1 998763 . N <INS> . PASS END=998764
1 change: 1 addition & 0 deletions test/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
test_vcf_annotate($opts,in=>'annotate.olap',tab=>'annots.olap',out=>'annotate.olap.2.out',args=>'-c CHROM,BEG,END,DB -l DB:unique --min-overlap 0.4:0.5');
test_vcf_annotate($opts,in=>'annotate.id',vcf=>'annots.id',out=>'annotate.id.1.out',args=>'-c ALT');
test_vcf_annotate($opts,in=>'annotate.id',vcf=>'annots.id',out=>'annotate.id.2.out',args=>'-c +ALT');
test_vcf_annotate($opts,in=>'annotate27',tab=>'annotate27',out=>'annotate.32.out',args=>'-c CHROM,POS,REF,ALT,EVIDENCE');
test_vcf_plugin($opts,in=>'checkploidy',out=>'checkploidy.out',cmd=>'+check-ploidy --no-version');
test_vcf_plugin($opts,in=>'checkploidy.2',out=>'checkploidy.2.out',cmd=>'+check-ploidy --no-version');
test_vcf_plugin($opts,in=>'checkploidy.2',out=>'checkploidy.3.out',cmd=>'+check-ploidy --no-version',args=>'-- -m');
Expand Down
7 changes: 4 additions & 3 deletions vcfannotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ typedef struct _args_t
int ref_idx, alt_idx, chr_idx, beg_idx, end_idx; // -1 if not present
annot_col_t *cols; // column indexes and setters
int ncols;
int match_id; // set iff `-c ~ID` given
int match_end; // set iff `-c ~INFO/END` is given
int match_id; // set iff `-c ~ID` given, -1 otherwise
int match_end; // set iff `-c ~INFO/END` is given, -1 otherwise

char *set_ids_fmt;
convert_t *set_ids;
Expand Down Expand Up @@ -3145,7 +3145,7 @@ static void annotate(args_t *args, bcf1_t *line)
ialt++;
}
if ( args->match_id>=0 && !strstr_match(line->d.id,args->alines[i].cols[args->match_id]) ) continue;
if ( match_end.l && strcmp(match_end.s,args->alines[i].cols[args->match_end]) ) continue;
if ( args->match_end>=0 && match_end.l && strcmp(match_end.s,args->alines[i].cols[args->match_end]) ) continue;
args->srt_alines[args->nsrt_alines++] = (ialt<<16) | i;
has_overlap = 1;
break;
Expand Down Expand Up @@ -3335,6 +3335,7 @@ int main_vcfannotate(int argc, char *argv[])
args->ref_idx = args->alt_idx = args->chr_idx = args->beg_idx = args->end_idx = -1;
args->set_ids_replace = 1;
args->match_id = -1;
args->match_end = -1;
args->clevel = -1;
args->pair_logic = -1;
int regions_is_file = 0;
Expand Down

0 comments on commit 1745829

Please sign in to comment.