#ifndef BCF_H
#define BCF_H
-#define BCF_VERSION "0.1.17 (r973:277)"
+#define BCF_VERSION "0.1.17-dev (r973:277)"
#include <stdint.h>
#include <zlib.h>
int bcf_fix_pl(bcf1_t *b);
// convert PL to GLF-like 10-likelihood GL
int bcf_gl10(const bcf1_t *b, uint8_t *gl);
+ // convert up to 4 INDEL alleles to GLF-like 10-likelihood GL
+ int bcf_gl10_indel(const bcf1_t *b, uint8_t *gl);
// string hash table
void *bcf_build_refhash(bcf_hdr_t *h);
for (i = 0; i < b->n_smpl; ++i) {
const uint8_t *p = PL->data + i * PL->len; // the PL for the i-th individual
uint8_t *g = gl + 10 * i;
- for (j = 0; j < PL->len; ++j)
- if (p[j]) break;
for (k = j = 0; k < 4; ++k) {
for (l = k; l < 4; ++l) {
int t, x = map[k], y = map[l];
}
return 0;
}
+
+int bcf_gl10_indel(const bcf1_t *b, uint8_t *gl)
+{
+ int k, l, j, i;
+ const bcf_ginfo_t *PL;
+ if (b->alt[0] == 0) return -1; // no alternate allele
+ for (i = 0; i < b->n_gi; ++i)
+ if (b->gi[i].fmt == bcf_str2int("PL", 2)) break;
+ if (i == b->n_gi) return -1; // no PL
+ PL = b->gi + i;
+ for (i = 0; i < b->n_smpl; ++i) {
+ const uint8_t *p = PL->data + i * PL->len; // the PL for the i-th individual
+ uint8_t *g = gl + 10 * i;
+ for (k = j = 0; k < 4; ++k) {
+ for (l = k; l < 4; ++l) {
+ int t, x = k, y = l;
+ if (x > y) t = x, x = y, y = t; // make sure x is the smaller
+ x = y * (y+1) / 2 + x;
+ g[j++] = x < PL->len? p[x] : 255;
+ }
+ }
+ }
+ return 0;
+}
if (!(l > begin && end > b->pos)) continue;
}
++n_processed;
- if (vc.flag & VC_QCNT) { // summarize the difference
+ if ((vc.flag & VC_QCNT) && !is_indel) { // summarize the difference
int x = bcf_min_diff(b);
if (x > 255) x = 255;
if (x >= 0) ++qcnt[x];
return ret;
}
+
int bcf_trio_call(const uint32_t *prep, const bcf1_t *b, int *llr, int64_t *gt)
{
int i, j, k;
if (b->gi[i].fmt == bcf_str2int("PL", 2)) break;
if (i == b->n_gi) return -1; // no PL
gl10 = alloca(10 * b->n_smpl);
- if (bcf_gl10(b, gl10) < 0) return -1;
+ if (bcf_gl10(b, gl10) < 0) {
+ if (bcf_gl10_indel(b, gl10) < 0) return -1;
+ }
PL = b->gi + i;
for (i = 0, k = 0; i < 4; ++i)
for (j = i; j < 4; ++j)
#include <stdlib.h>
#include <string.h>
-#ifdef _WIN32
-#define drand48() ((double)rand() / RAND_MAX)
-#endif
-
typedef struct {
void *left, *right;
int depth;