int i,j,nals=0;
for (i=0; i<sizeof(int); i++)
if ( mask&1<<i) nals++;
-
if ( b->n_alleles <= nals ) return;
// update ALT, in principle any of the alleles can be removed
bcf_ginfo_t gt;
// check the presence of the GT FMT
if ((s = strstr(b->fmt, ":GT")) == 0) return 0; // no GT or GT is already the first
- if (s[3] != '\0' && s[3] != ':') return 0; // :GTX in fact
+ assert(s[3] == '\0' || s[3] == ':'); // :GTX in fact
tmp = bcf_str2int("GT", 2);
for (i = 0; i < b->n_gi; ++i)
if (b->gi[i].fmt == tmp) break;
// move GT to the first
for (; i > 0; --i) b->gi[i] = b->gi[i-1];
b->gi[0] = gt;
- memmove(b->fmt + 3, b->fmt, s + 1 - b->fmt);
+ if ( s[3]==0 )
+ memmove(b->fmt + 3, b->fmt, s - b->fmt); // :GT
+ else
+ memmove(b->fmt + 3, b->fmt, s - b->fmt + 1); // :GT:
b->fmt[0] = 'G'; b->fmt[1] = 'T'; b->fmt[2] = ':';
return 0;
}
kputs(samples[i], &s); kputc('\0', &s);
}
}
- if (j < n) fprintf(stderr, "<%s> %d samples in the list but not in BCF.", __func__, n - j);
+ if (j < n)
+ {
+ fprintf(stderr, "<%s> %d samples in the list but not in BCF.", __func__, n - j);
+ exit(1);
+ }
kh_destroy(str2id, hash);
h = calloc(1, sizeof(bcf_hdr_t));
*h = *h0;