Skip to content

Commit 168d070

Browse files
committed
Fix error introduced by e412f74, the precedence of smpl_count function was not set
1 parent e412f74 commit 168d070

File tree

6 files changed

+27
-4
lines changed

6 files changed

+27
-4
lines changed

filter.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ struct _filter_t
170170
#define TOK_FISHER 42
171171
#define TOK_sCOUNT 43
172172

173-
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
173+
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
174174
// ( ) [ < = > ] ! | & + - * / M m a A O ~ ^ S . l f c p b P i s %
175-
static int op_prec[] = {0,1,1,5,5,5,5,5,5,2,3, 6, 6, 7, 7, 8, 8, 8, 3, 2, 5, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 0};
175+
static int op_prec[] = {0,1,1,5,5,5,5,5,5,2,3, 6, 6, 7, 7, 8, 8, 8, 3, 2, 5, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 0, 8, 8};
176176
#define TOKEN_STRING "x()[<=>]!|&+-*/MmaAO~^S.lfcpis" // this is only for debugging, not maintained diligently
177177

178178
static void cmp_vector_strings(token_t *atok, token_t *btok, token_t *rtok);
@@ -2007,8 +2007,7 @@ static int func_smpl_count(filter_t *flt, bcf1_t *line, token_t *rtok, token_t *
20072007
if ( !rtok->usmpl ) rtok->usmpl = (uint8_t*) malloc(tok->nsamples);
20082008
memcpy(rtok->usmpl, tok->usmpl, tok->nsamples);
20092009
int i,j;
2010-
assert( tok->tag && tok->nsamples );
2011-
if ( tok->tag && tok->nsamples )
2010+
if ( tok->nsamples )
20122011
{
20132012
// raw number of values in a FMT tag, e.g. COUNT(FMT/TAG)
20142013
if ( tok->is_str ) error("todo: Type=String for COUNT on FORMAT fields?\n");

test/smpl-count.1.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
chr 1 0/0 . 0
2+
chr 1 0/1 1 1
3+
4+
chr 2 1/1 1 1
5+
chr 2 1/2 1,2 2
6+

test/smpl-count.2.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
chr 1 0/1 1 1
2+
3+
chr 2 1/1 1 1
4+

test/smpl-count.3.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
chr 2 1/1 1 1
2+

test/smpl-count.vcf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
##fileformat=VCFv4.2
2+
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
3+
##FORMAT=<ID=LAA,Number=.,Type=Integer,Description="">
4+
##contig=<ID=chr,length=123456>
5+
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT smpl1 smpl2
6+
chr 1 . A C . . . GT:LAA 0/0:. 0/1:1
7+
chr 2 . A C,T . . . GT:LAA 1/1:1 1/2:1,2

test/test.pl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
run_test(\&test_vcf_isec,$opts,in=>['isec-miss.1.1','isec-miss.1.2','isec-miss.1.3'],out=>'isec-miss.1.1.out',args=>'-R {PATH}/isec-miss.1.regs.txt -n +1');
6262
run_test(\&test_vcf_isec,$opts,in=>['isec-miss.2.1','isec-miss.2.2','isec-miss.2.3'],out=>'isec-miss.2.1.out',args=>'-n +1 -r 20:100,20:140,12:55,20:140,20:100');
6363
run_test(\&test_vcf_isec,$opts,in=>['isec-miss.2.1','isec-miss.2.2','isec-miss.2.3'],out=>'isec-miss.2.1.out',args=>'-R {PATH}/isec-miss.1.regs.txt -n +1');
64+
#run_test(\&test_vcf_merge,$opts,in=>['merge.broken-phase.a','merge.broken-phase.b'],out=>'merge.broken-phase.1.out',args=>'');
6465
run_test(\&test_vcf_merge,$opts,in=>['merge.broken-gvcf.a','merge.broken-gvcf.b'],out=>'merge.broken-gvcf.1.out',args=>'');
6566
run_test(\&test_vcf_merge,$opts,in=>['merge.symbolic.1.a','merge.symbolic.1.b'],out=>'merge.symbolic.1.1.out',args=>'');
6667
run_test(\&test_vcf_merge,$opts,in=>['merge.multiallelics.1.a','merge.multiallelics.1.b'],out=>'merge.multiallelics.1.1.out',args=>'--merge none');
@@ -119,6 +120,10 @@
119120
run_test(\&test_vcf_merge,$opts,in=>['merge.gvcf.5.a','merge.gvcf.5.b'],out=>'merge.gvcf.5.1.out',args=>'--gvcf - --merge none');
120121
run_test(\&test_vcf_merge,$opts,in=>['merge.gvcf.11.a','merge.gvcf.11.b','merge.gvcf.11.c'],out=>'merge.gvcf.11.1.out',args=>'--gvcf -');
121122
# run_test(\&test_vcf_merge_big,$opts,in=>'merge_big.1',out=>'merge_big.1.1',nsmpl=>79000,nfiles=>79,nalts=>486,args=>''); # commented out for speed
123+
run_test(\&test_vcf_query,$opts,in=>'smpl-count',out=>'smpl-count.1.out',args=>q[-f '[%CHROM\\t%POS\\t%GT\\t%LAA\\t%smpl_count(FMT/LAA)\\n]\\n']);
124+
run_test(\&test_vcf_query,$opts,in=>'smpl-count',out=>'smpl-count.2.out',args=>q[-f '[%CHROM\\t%POS\\t%GT\\t%LAA\\t%smpl_count(FMT/LAA)\\n]\\n' -i'smpl_count(LAA)==1']);
125+
run_test(\&test_vcf_query,$opts,in=>'smpl-count',out=>'smpl-count.3.out',args=>q[-f '[%CHROM\\t%POS\\t%GT\\t%LAA\\t%smpl_count(FMT/LAA)\\n]\\n' -i'smpl_count(LAA)==1 & GT="hom"']);
126+
run_test(\&test_vcf_query,$opts,in=>'smpl-count',out=>'smpl-count.3.out',args=>q[-f '[%CHROM\\t%POS\\t%GT\\t%LAA\\t%smpl_count(FMT/LAA)\\n]\\n' -i'GT="hom" & smpl_count(LAA)==1']);
122127
run_test(\&test_vcf_query,$opts,in=>'query.filter.15',out=>'query.filter.15.1.out',args=>q[-f '%TAG' -i 'TAG[*]="."']);
123128
run_test(\&test_vcf_query,$opts,in=>'query.filter.15',out=>'query.filter.15.1.out',args=>q[-f '%TAG' -i 'TAG[*]~"\."']);
124129
run_test(\&test_vcf_query,$opts,in=>'query.filter.15',out=>'query.filter.15.2.out',args=>q[-f '%TAG' -i 'TAG[*]!="."']);

0 commit comments

Comments
 (0)