Skip to content

Commit 35ed1f0

Browse files
committed
Remove unnecessary assert in text output, only with no csq. Fixes #2446
1 parent 314c204 commit 35ed1f0

File tree

9 files changed

+26
-6
lines changed

9 files changed

+26
-6
lines changed

csq.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,7 @@ fprintf(stderr,"csq_push: pos=%d .. type=%d ial=%d\n",(int)rec->pos+1,csq->type
21082108
#define node2rend(i) (hap->stack[i].node->sbeg + hap->stack[i].node->rlen)
21092109
#define node2rpos(i) (hap->stack[i].node->rec->pos)
21102110

2111+
// Format variant consequence into a string like "inframe_deletion|XYZ|ENST01|+|5TY>5I|121ACG>A+124TA>T"
21112112
void kput_vcsq(args_t *args, vcsq_t *csq, kstring_t *str)
21122113
{
21132114
// Remove start/stop from incomplete CDS, but only if there is another
@@ -2143,7 +2144,6 @@ void kput_vcsq(args_t *args, vcsq_t *csq, kstring_t *str)
21432144
if ( csq->gene ) kputs(csq->gene , str);
21442145

21452146
kputc_('|', str);
2146-
// if ( csq->type & CSQ_PRN_TSCRIPT ) kputs(args->tscript_ids.str[csq->trid], str);
21472147
if ( csq->type & CSQ_PRN_TSCRIPT ) kputs(gff_id2string(args->gff,transcript,csq->trid), str);
21482148

21492149
kputc_('|', str);
@@ -2561,7 +2561,7 @@ static inline void csq_print_text(args_t *args, csq_t *csq, int ismpl, int ihap)
25612561
fprintf(args->out,"-");
25622562

25632563
args->str.l = 0;
2564-
kput_vcsq(args, &csq->type, &args->str);
2564+
kput_vcsq(args, &csq->type, &args->str); // format the csq string
25652565
fprintf(args->out,"\t%s\t%d\t%s\n",chr,csq->pos+1,args->str.s);
25662566
}
25672567
static inline void hap_print_text(args_t *args, gf_tscript_t *tr, int ismpl, int ihap, hap_node_t *node)
@@ -2576,7 +2576,7 @@ static inline void hap_print_text(args_t *args, gf_tscript_t *tr, int ismpl, int
25762576
{
25772577
csq_t *csq = node->csq_list + i;
25782578
if ( csq->type.type & CSQ_PRINTED_UPSTREAM ) continue;
2579-
assert( csq->type.vstr.l );
2579+
if ( !csq->type.vstr.l ) continue; // not sure why this happens, see test/csq/ENST00000000001
25802580

25812581
fprintf(args->out,"CSQ\t%s\t", smpl);
25822582
if ( ihap>0 )
@@ -2585,7 +2585,7 @@ static inline void hap_print_text(args_t *args, gf_tscript_t *tr, int ismpl, int
25852585
fprintf(args->out,"-");
25862586

25872587
args->str.l = 0;
2588-
kput_vcsq(args, &csq->type, &args->str);
2588+
kput_vcsq(args, &csq->type, &args->str); // format the csq string
25892589
fprintf(args->out,"\t%s\t%d\t%s\n",chr,csq->pos+1,args->str.s);
25902590
}
25912591
}
@@ -2636,7 +2636,9 @@ void hap_flush(args_t *args, uint32_t pos)
26362636
if ( args->output_type==FT_TAB_TEXT ) // plain text output, not a vcf
26372637
{
26382638
if ( args->phase==PHASE_DROP_GT )
2639+
{
26392640
hap_print_text(args, tr, -1,0, TSCRIPT_AUX(tr)->hap[0]);
2641+
}
26402642
else
26412643
{
26422644
for (i=0; i<args->smpl->n; i++)
@@ -2743,11 +2745,11 @@ void vbuf_flush(args_t *args, uint32_t pos)
27432745
}
27442746

27452747
args->str.l = 0;
2746-
kput_vcsq(args, &vrec->vcsq[0], &args->str);
2748+
kput_vcsq(args, &vrec->vcsq[0], &args->str); // format the csq string
27472749
for (j=1; j<vrec->nvcsq; j++)
27482750
{
27492751
kputc_(',', &args->str);
2750-
kput_vcsq(args, &vrec->vcsq[j], &args->str);
2752+
kput_vcsq(args, &vrec->vcsq[j], &args->str); // format the csq string
27512753
}
27522754
bcf_update_info_string(args->hdr, vrec->line, args->bcsq_tag, args->str.s);
27532755
if ( args->hdr_nsmpl )
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>example
2+
ATGGCCGTCA
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example 10 9 10 11
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
##gff-version 3
2+
example custom gene 1 10 . + . ID=gene00000000001;biotype=protein_coding
3+
example custom transcript 1 10 . + . ID=transcript00000000001;Parent=gene00000000001;biotype=protein_coding
4+
example custom CDS 1 10 . + 0 Parent=transcript00000000001
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{bin}/bcftools csq -f ENST00000000001.fa -g ENST00000000001.gff test.vcf -p a | ../sort-csq | {bin}/bcftools query -f'%POS\t%REF\t%ALT\t%BCSQ\n'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1 A T start_lost|gene00000000001|transcript00000000001|protein_coding|+
2+
3 GGC G .
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{bin}/bcftools csq -f ENST00000000001.fa -g ENST00000000001.gff test.vcf -p a -Ot | grep -v ^#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CSQ T 2 example 1 start_lost|gene00000000001|transcript00000000001|protein_coding|+

test/csq/ENST00000000001/test.vcf

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

0 commit comments

Comments
 (0)