From 698a60f0225ea0d46364522db77a559d64b3052a Mon Sep 17 00:00:00 2001 From: peterjc Date: Wed, 24 Apr 2013 12:00:03 +0100 Subject: [PATCH] Correct BIN check for CIGAR less reads This should mimic the logic in the import code. Any such reads should also be unmapped. --- bam_index.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bam_index.c b/bam_index.c index f250907..8c0d854 100644 --- a/bam_index.c +++ b/bam_index.c @@ -193,7 +193,11 @@ bam_index_t *bam_index_core(bamFile fp) return NULL; } if (c->tid >= 0) { - recalculated_bin = bam_reg2bin(c->pos, bam_calend(c, bam1_cigar(b))); + if (c->n_cigar) { + recalculated_bin = bam_reg2bin(c->pos, bam_calend(c, bam1_cigar(b))); + } else { + recalculated_bin = bam_reg2bin(c->pos, c->pos + 1); + } if (c->bin != recalculated_bin) { fprintf(stderr, "[bam_index_core] read '%s' mapped to '%s' at POS %d to %d has BIN %d but should be %d\n", bam1_qname(b), h->target_name[c->tid], c->pos + 1, bam_calend(c, bam1_cigar(b)), c->bin, recalculated_bin); -- 2.39.2