@@ -2723,20 +2723,31 @@ void gvcf_flush(args_t *args, int done)
2723
2723
}
2724
2724
}
2725
2725
2726
- static inline int is_gvcf_block (bcf1_t * line )
2726
+ static inline int is_gvcf_block (args_t * args , bcf1_t * line )
2727
2727
{
2728
2728
if ( line -> rlen <=1 ) return 0 ;
2729
2729
if ( strlen (line -> d .allele [0 ])== line -> rlen ) return 0 ;
2730
- if ( line -> n_allele == 1 ) return 1 ;
2730
+ if ( line -> n_allele == 1 ) goto is_gvcf ;
2731
2731
2732
2732
int i ;
2733
2733
for (i = 1 ; i < line -> n_allele ; i ++ )
2734
2734
{
2735
- if ( !strcmp (line -> d .allele [i ],"<*>" ) ) return 1 ;
2736
- if ( !strcmp (line -> d .allele [i ],"<NON_REF>" ) ) return 1 ;
2737
- if ( !strcmp (line -> d .allele [i ],"<X>" ) ) return 1 ;
2735
+ if ( !strcmp (line -> d .allele [i ],"<*>" ) ) goto is_gvcf ;
2736
+ if ( !strcmp (line -> d .allele [i ],"<NON_REF>" ) ) goto is_gvcf ;
2737
+ if ( !strcmp (line -> d .allele [i ],"<X>" ) ) goto is_gvcf ;
2738
2738
}
2739
2739
return 0 ;
2740
+
2741
+ is_gvcf :
2742
+ maux_t * ma = args -> maux ;
2743
+ if ( !ma -> gvcf )
2744
+ {
2745
+ args -> do_gvcf = 1 ;
2746
+ ma -> gvcf = (gvcf_aux_t * ) calloc (ma -> n ,sizeof (gvcf_aux_t )); // -Walloc-size-larger-than gives a harmless warning caused by signed integer ma->n
2747
+ for (i = 0 ; i < ma -> n ; i ++ )
2748
+ ma -> gvcf [i ].line = bcf_init1 ();
2749
+ }
2750
+ return 1 ;
2740
2751
}
2741
2752
2742
2753
/*
@@ -2776,7 +2787,7 @@ void gvcf_stage(args_t *args, int pos)
2776
2787
int irec = maux -> buf [i ].beg ;
2777
2788
bcf_hdr_t * hdr = bcf_sr_get_header (files , i );
2778
2789
bcf1_t * line = args -> files -> readers [i ].buffer [irec ];
2779
- int ret = is_gvcf_block (line ) ? bcf_get_info_int32 (hdr ,line ,"END" ,& end ,& nend ) : 0 ;
2790
+ int ret = is_gvcf_block (args , line ) ? bcf_get_info_int32 (hdr ,line ,"END" ,& end ,& nend ) : 0 ;
2780
2791
if ( ret == 1 )
2781
2792
{
2782
2793
if ( end [0 ] == line -> pos + 1 ) // POS and INFO/END are identical, treat as if a normal w/o INFO/END
@@ -3133,7 +3144,7 @@ int can_merge(args_t *args)
3133
3144
var_type &= ~VCF_INDEL ;
3134
3145
}
3135
3146
var_type = var_type ? var_type <<1 : ref_mask ;
3136
- if ( args -> do_gvcf && is_gvcf_block (line ) ) var_type |= ref_mask ;
3147
+ if ( args -> do_gvcf && is_gvcf_block (args , line ) ) var_type |= ref_mask ;
3137
3148
buf -> rec [j ].var_types = var_type ;
3138
3149
}
3139
3150
maux -> var_types |= buf -> rec [j ].var_types ;
@@ -3233,7 +3244,8 @@ void stage_line(args_t *args)
3233
3244
if ( buf -> rec [j ].skip )
3234
3245
{
3235
3246
int is_gvcf = maux -> gvcf && maux -> gvcf [i ].active ? 1 : 0 ;
3236
- if ( !is_gvcf && is_gvcf_block (buf -> lines [j ]) ) is_gvcf = 1 ;
3247
+ if ( !is_gvcf && is_gvcf_block (args ,buf -> lines [j ]) ) is_gvcf = 1 ;
3248
+ if ( is_gvcf && buf -> rec [j ].skip && !maux -> gvcf [i ].active ) continue ;
3237
3249
if ( !is_gvcf ) continue ; // done or not compatible
3238
3250
}
3239
3251
if ( args -> merge_by_id ) break ; // if merging by ID and the line is compatible, the this is THE line
0 commit comments