int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b);
int bcf_shrink_alt(int n_smpl, bcf1_t *b, int n);
+ int bcf_gl2pl(int n_smpl, bcf1_t *b);
+
void *bcf_build_refhash(bcf_hdr_t *h);
void bcf_str2id_destroy(void *_hash);
int bcf_str2id_add(void *_hash, const char *str);
bcf_sync(n_smpl, b);
return 0;
}
+
+int bcf_gl2pl(int n_smpl, bcf1_t *b)
+{
+ char *p;
+ int i;
+ bcf_ginfo_t *g;
+ float *d0;
+ uint8_t *d1;
+ if (strstr(b->fmt, "PL")) return -1;
+ if ((p = strstr(b->fmt, "GL")) == 0) return -1;
+ *p = 'P';
+ for (i = 0; i < b->n_gi; ++i)
+ if (b->gi[i].fmt == bcf_str2int("GL", 2))
+ break;
+ g = b->gi + i;
+ g->fmt = bcf_str2int("PL", 2);
+ g->len /= 4; // 4 == sizeof(float)
+ d0 = (float*)g->data; d1 = (uint8_t*)g->data;
+ for (i = 0; i < n_smpl * g->len; ++i) {
+ int x = (int)(-10. * d0[i] + .499);
+ if (x > 255) x = 255;
+ if (x < 0) x = 0;
+ d1[i] = x;
+ }
+ return 0;
+}
}
if (vc.flag & VC_CALL) {
bcf_p1rst_t pr;
+ bcf_gl2pl(h->n_smpl, b);
bcf_p1_cal(b, p1, &pr); // pr.g[3] is not calculated here
if (vc.flag&VC_HWE) bcf_p1_cal_g3(p1, pr.g);
if ((n_processed + 1) % 50000 == 0) bcf_p1_dump_afs(p1);