- if (conf->vcf) {
- double f0, f; // the reference allele frequency
- int j, _ref, _alt, _ref0, depth, rms_q, _ref0b;
- uint64_t sqr_sum;
- _ref0 = _ref0b = (ref && pos < ref_len)? ref[pos] : 'N';
- _ref0 = bam_nt16_nt4_table[bam_nt16_table[_ref0]];
- f = f0 = mc_freq0(_ref0, n_plp, plp, ma, &_ref, &_alt);
- if (f >= 0.0) {
- double flast = f;
- for (j = 0; j < 10; ++j) {
- f = mc_freq_iter(flast, ma);
- if (fabs(f - flast) < 1e-3) break;
- flast = f;
+ if (conf->flag & MPLP_GLF) {
+ int _ref0, ref16;
+ bcf1_t *b = calloc(1, sizeof(bcf1_t));
+ group_smpl(&gplp, sm, &buf, n, fn, n_plp, plp);
+ _ref0 = (ref && pos < ref_len)? ref[pos] : 'N';
+ ref16 = bam_nt16_table[_ref0];
+ for (i = 0; i < gplp.n; ++i)
+ bcf_call_glfgen(gplp.n_plp[i], gplp.plp[i], ref16, bca, bcr + i);
+ bcf_call_combine(gplp.n, bcr, ref16, &bc);
+ bcf_call2bcf(tid, pos, &bc, b, (conf->flag&(MPLP_FMT_DP|MPLP_FMT_SP))? bcr : 0,
+ (conf->flag&MPLP_FMT_SP), 0, 0);
+ bcf_write(bp, bh, b);
+ bcf_destroy(b);
+ if (!(conf->flag&MPLP_NO_INDEL)) {
+ // call MNPs
+ if (bcf_call_mnp_prep(gplp.n, gplp.n_plp, gplp.plp, pos, bca, ref) >= 0) {
+ for (i = 0; i < gplp.n; ++i)
+ bcf_call_glfgen(gplp.n_plp[i], gplp.plp[i], B2B_REF_MNP, bca, bcr + i);
+ if (bcf_call_combine(gplp.n, bcr, B2B_REF_MNP, &bc) >= 0) {
+ b = calloc(1, sizeof(bcf1_t));
+ bcf_call2bcf(tid, pos, &bc, b, (conf->flag&(MPLP_FMT_DP|MPLP_FMT_SP))? bcr : 0,
+ (conf->flag&MPLP_FMT_SP), bca, ref);
+ bcf_write(bp, bh, b);
+ bcf_destroy(b);
+ bca->last_mnp_pos = pos;
+ }