Skip to content

Commit

Permalink
bugfix: missing values are not filled sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
lh3 committed Jun 20, 2012
1 parent ffc8d65 commit 9ea927a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions htslib/vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,24 @@ int vcf_parse1(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v)
for (; l != z->size>>2; ++l) *(int32_t*)(x+l) = bcf_missing_float;
} else abort();
if (*t == 0) {
for (++j; j < v->n_fmt; ++j) { // fill missing values
z = &fmt[j];
if ((z->y>>4&0xf) == BCF_HT_STR) {
if (z->is_gt) {
int32_t *x = (int32_t*)(z->buf + z->size * m);
for (l = 0; l != z->size>>2; ++l) x[l] = INT32_MIN;
} else {
char *x = (char*)z->buf + z->size * m;
for (l = 0; l != z->size; ++l) x[l] = 0;
}
} else if ((z->y>>4&0xf) == BCF_HT_INT) {
int32_t *x = (int32_t*)(z->buf + z->size * m);
for (l = 0; l != z->size>>2; ++l) x[l] = INT32_MIN;
} else if ((z->y>>4&0xf) == BCF_HT_REAL) {
float *x = (float*)(z->buf + z->size * m);
for (l = 0; l != z->size>>2; ++l) *(int32_t*)(x+l) = bcf_missing_float;
}
}
if (t == end) break;
++m, j = 0;
} else if (*t == ':') ++j;
Expand Down
2 changes: 1 addition & 1 deletion test/ex2.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
20 14370 rs6054257 G A 29.1 . NS=3;DP=14;AF=0.5;HOMSEQ;DB GT:GQ:DP:HQ:CNL 0|0:48:1:25,30:10,20 1|0:48:8:49,51:. ./.:43:5:.,.:1
20 17330 . T A . q10;s50 NS=3;DP=11;AF=0.017;H2 GT:GQ:DP:HQ 0|0:49:3:58,50 0|1:3:5:65,3 0/0:41:3:4,5
20 1110696 rs6040355 A G,T 67 PASS NS=2;DP=10;AF=0.333,0.667;AA=T;DB GT:GQ:DP:HQ 1|2:21:6:23,27 2|1:2:0:18,2 2/2:35:4:10,20
20 1230237 . T . 47 PASS NS=3;DP=13;AA=T GT:GQ:DP:HQ 0|0:54:7:56,60 0|0:48:4:51,51 0/0:61:2:0,3
20 1230237 . T . 47 PASS NS=3;DP=13;AA=T GT:GQ:DP:HQ 0|0:54:7:56,60 0|0:48:4:51,51 ./.
20 1234567 microsat1 GTC G,GTCT 50 PASS NS=3;DP=9;AA=G GT:GQ:DP 0/1:35:4 0/2:17:2 1/1:40:3

0 comments on commit 9ea927a

Please sign in to comment.