Skip to content

Commit cbee106

Browse files
committed
Make +split-vep print the expected -f output even in the absence of the CSQ subfields.
For example, this command bcftools +split-vep file.bcf -s worst:exon_loss+ -f '%POS\n' should print the list of matching positions even though none of the CSQ subfields are present in the formatting expression. This is different from the default behavior where -f skips empty records, very likely more fine tuning will be needed to meet the user's intuition.
1 parent 3231c34 commit cbee106

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

plugins/split-vep.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ static void init_data(args_t *args)
324324
}
325325
if ( args->format_str )
326326
{
327-
if ( !args->column_str ) error("Error: No %s field selected in the formatting expression (a typo?)\n",args->vep_tag);
327+
if ( !args->column_str && !args->select ) error("Error: No %s field selected in the formatting expression and -s not given: a typo?\n",args->vep_tag);
328328
args->convert = convert_init(args->hdr_out, NULL, 0, args->format_str);
329329
if ( !args->convert ) error("Could not parse the expression: %s\n", args->format_str);
330330
}
@@ -492,7 +492,6 @@ static int csq_severity_pass(args_t *args, char *csq)
492492

493493
int min_severity, max_severity;
494494
csq_to_severity(args, csq, &min_severity, &max_severity);
495-
496495
if ( max_severity < args->min_severity ) return 0;
497496
if ( min_severity > args->max_severity ) return 0;
498497
return 1;
@@ -553,6 +552,7 @@ static void process_record(args_t *args, bcf1_t *rec)
553552
itr_min = itr_max = get_worst_transcript(args, rec, args->cols_tr);
554553

555554
annot_reset(args->annot, args->nannot);
555+
int severity_pass = 0;
556556
for (i=itr_min; i<=itr_max; i++)
557557
{
558558
args->cols_csq = cols_split(args->cols_tr->off[i], args->cols_csq, '|');
@@ -561,6 +561,7 @@ static void process_record(args_t *args, bcf1_t *rec)
561561

562562
char *csq = args->cols_csq->off[args->csq_idx];
563563
if ( !csq_severity_pass(args, csq) ) continue;
564+
severity_pass = 1;
564565

565566
for (j=0; j<args->nannot; j++)
566567
{
@@ -588,7 +589,14 @@ static void process_record(args_t *args, bcf1_t *rec)
588589
}
589590
if ( args->format_str )
590591
{
591-
if ( !updated ) return;
592+
if ( args->nannot )
593+
{
594+
if ( !updated ) return; // the standard case: using -f to print the CSQ subfields, skipping if missing
595+
}
596+
else
597+
{
598+
if ( !severity_pass ) return; // request to print only non-CSQ tags at sites that pass severity
599+
}
592600

593601
args->kstr.l = 0;
594602
convert_line(args->convert, rec, &args->kstr);

test/split-vep.4.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
17365
2+
69428
3+
69469
4+
69496
5+
69511
6+
69559
7+
69569
8+
69590
9+
69604
10+
69610
11+
69634
12+
69640
13+
69678
14+
69713
15+
69719
16+
69761
17+
69808
18+
69816

test/test.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
test_vcf_plugin($opts,in=>'split-vep',out=>'split-vep.2.out',cmd=>'+split-vep',args=>qq[-c Consequence -s worst:missense+ | $$opts{bin}/bcftools query -f'%POS\\t%Consequence\\n' -i'Consequence!="."']);
364364
test_vcf_plugin($opts,in=>'split-vep',out=>'split-vep.2.out',cmd=>'+split-vep',args=>qq[-s worst:missense+ -f'%POS\\t%Consequence\\n']);
365365
test_vcf_plugin($opts,in=>'split-vep',out=>'split-vep.3.out',cmd=>'+split-vep',args=>qq[-s primary:missense+ -f'%POS\\t%Consequence\\n']);
366+
test_vcf_plugin($opts,in=>'split-vep',out=>'split-vep.4.out',cmd=>'+split-vep',args=>qq[-s primary:missense+ -f'%POS\\n']);
366367
test_vcf_concat($opts,in=>['concat.1.a','concat.1.b'],out=>'concat.1.vcf.out',do_bcf=>0,args=>'');
367368
test_vcf_concat($opts,in=>['concat.1.a','concat.1.b'],out=>'concat.1.bcf.out',do_bcf=>1,args=>'');
368369
test_vcf_concat($opts,in=>['concat.2.a','concat.2.b'],out=>'concat.2.vcf.out',do_bcf=>0,args=>'-a');

0 commit comments

Comments
 (0)