From: peterjc
Date: Wed, 24 Apr 2013 11:00:03 +0000 (+0100)
Subject: Correct BIN check for CIGAR less reads
X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=commitdiff_plain;h=698a60f0225ea0d46364522db77a559d64b3052a
Correct BIN check for CIGAR less reads
This should mimic the logic in the import code. Any such reads
should also be unmapped.
---
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);