@@ -22,6 +22,15 @@ typedef struct
22
22
samfile_t * in;
23
23
} tmpstruct_t ;
24
24
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
+
25
34
// callback for bam_fetch()
26
35
static int fetch_func (const bam1_t * b, void * data)
27
36
{
@@ -170,6 +179,8 @@ int main(int argc, char* argv[])
170
179
if (sscanf (str_buf, " %s %d %c %c %s %s" , chr, &pos, &ref, &var, fr1, p1) == 6 ) {
171
180
tmp.nuc = var;
172
181
sprintf (reg, " %s:%d-%d" , chr, pos, pos);
182
+
183
+ re_init_tmp (&tmp);
173
184
bam_parse_region (tmp.in ->header , reg, &name, &tmp.pos , &tmp.pos1 );
174
185
bam_fetch (tmp.in ->x .bam , idx, name, tmp.pos , tmp.pos1 , buf, fetch_func);
175
186
bam_plbuf_push (0 , buf);
@@ -185,6 +196,8 @@ int main(int argc, char* argv[])
185
196
fr3, p1, p2, p3) == 10 ) {
186
197
tmp.nuc = var;
187
198
sprintf (reg, " %s:%d-%d" , chr, pos, pos);
199
+
200
+ re_init_tmp (&tmp);
188
201
bam_parse_region (tmp.in ->header , reg, &name, &tmp.pos , &tmp.pos1 );
189
202
bam_fetch (tmp.in ->x .bam , idx, name, tmp.pos , tmp.pos1 , buf, fetch_func);
190
203
bam_plbuf_push (0 , buf);
0 commit comments