@@ -22,6 +22,15 @@ typedef struct
2222 samfile_t * in;
2323} tmpstruct_t ;
2424
25+ // reinit members of tmpstruct_t
26+ static int re_init_tmp (tmpstruct_t * tmp)
27+ {
28+ // re-init sane defaults for struct members that should be filled in by pileup callback fonction
29+ tmp->forwM = tmp->revM = tmp->forwT = tmp->revT = 0 ;
30+ tmp->pval = 1 .;
31+ return 0 ;
32+ }
33+
2534// callback for bam_fetch()
2635static int fetch_func (const bam1_t * b, void * data)
2736{
@@ -170,6 +179,8 @@ int main(int argc, char* argv[])
170179 if (sscanf (str_buf, " %s %d %c %c %s %s" , chr, &pos, &ref, &var, fr1, p1) == 6 ) {
171180 tmp.nuc = var;
172181 sprintf (reg, " %s:%d-%d" , chr, pos, pos);
182+
183+ re_init_tmp (&tmp);
173184 bam_parse_region (tmp.in ->header , reg, &name, &tmp.pos , &tmp.pos1 );
174185 bam_fetch (tmp.in ->x .bam , idx, name, tmp.pos , tmp.pos1 , buf, fetch_func);
175186 bam_plbuf_push (0 , buf);
@@ -185,6 +196,8 @@ int main(int argc, char* argv[])
185196 fr3, p1, p2, p3) == 10 ) {
186197 tmp.nuc = var;
187198 sprintf (reg, " %s:%d-%d" , chr, pos, pos);
199+
200+ re_init_tmp (&tmp);
188201 bam_parse_region (tmp.in ->header , reg, &name, &tmp.pos , &tmp.pos1 );
189202 bam_fetch (tmp.in ->x .bam , idx, name, tmp.pos , tmp.pos1 , buf, fetch_func);
190203 bam_plbuf_push (0 , buf);
0 commit comments