@@ -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"
21112112void 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}
25672567static 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 )
0 commit comments