From b7addd31513fd301bc3f44fff9bcdf87239523db Mon Sep 17 00:00:00 2001 From: Petr Danecek Date: Wed, 20 Jul 2022 13:08:36 +0100 Subject: [PATCH] Support 0 coordinate in BCF The 0 coordinate is valid in VCF specification, but the round-trip VCF -> BCF -> VCF turns MT:0 into MT:4294967296. Add a check to detect this overflow. See #1475 and https://github.com/samtools/bcftools/issues/1753 --- vcf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vcf.c b/vcf.c index ab2477861..012db0934 100644 --- a/vcf.c +++ b/vcf.c @@ -1413,6 +1413,7 @@ static inline int bcf_read1_core(BGZF *fp, bcf1_t *v) if (ks_resize(&v->indiv, indiv_len ? indiv_len : 1) != 0) return -2; v->rid = le_to_i32(x + 8); v->pos = le_to_u32(x + 12); + if ( v->pos==UINT32_MAX ) v->pos = -1; // this is for telomere coordinate, e.g. MT:0 v->rlen = le_to_i32(x + 16); v->qual = le_to_float(x + 20); v->n_info = le_to_u16(x + 24);