]> git.donarmstrong.com Git - samtools.git/commitdiff
Correct BIN check for CIGAR less reads
authorpeterjc <p.j.a.cock@googlemail.com>
Wed, 24 Apr 2013 11:00:03 +0000 (12:00 +0100)
committerpeterjc <p.j.a.cock@googlemail.com>
Wed, 24 Apr 2013 11:00:03 +0000 (12:00 +0100)
This should mimic the logic in the import code. Any such reads
should also be unmapped.

bam_index.c

index f250907039156c5559d92bfff9254ef0d8c401c8..8c0d85414ba36475b68e9c98f79e02af7678377c 100644 (file)
@@ -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);