From: Heng Li Date: Wed, 2 Feb 2011 16:28:24 +0000 (+0000) Subject: * fixed an out-of-boundary bug X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=commitdiff_plain;h=fee22b6b728d3f0115bec76f7b0e15cad330b7c0 * fixed an out-of-boundary bug * improved sorting order checking in index --- diff --git a/bam2bcf.c b/bam2bcf.c index 46f534e..98acb5d 100644 --- a/bam2bcf.c +++ b/bam2bcf.c @@ -79,7 +79,7 @@ int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t } bca->bases[n++] = q<<5 | (int)bam1_strand(p->b)<<4 | b; // collect annotations - r->qsum[b] += q; + if (b < 4) r->qsum[b] += q; ++r->anno[0<<2|is_diff<<1|bam1_strand(p->b)]; min_dist = p->b->core.l_qseq - 1 - p->qpos; if (min_dist > p->qpos) min_dist = p->qpos; diff --git a/bam_index.c b/bam_index.c index 328f011..51c2701 100644 --- a/bam_index.c +++ b/bam_index.c @@ -217,8 +217,15 @@ bam_index_t *bam_index_core(bamFile fp) } merge_chunks(idx); fill_missing(idx); - if (ret >= 0) - while ((ret = bam_read1(fp, b)) >= 0) ++n_no_coor; + if (ret >= 0) { + while ((ret = bam_read1(fp, b)) >= 0) { + ++n_no_coor; + if (c->tid >= 0 && n_no_coor) { + fprintf(stderr, "[bam_index_core] the alignment is not sorted: reads without coordinates prior to reads with coordinates.\n"); + exit(1); + } + } + } if (ret < -1) fprintf(stderr, "[bam_index_core] truncated file? Continue anyway. (%d)\n", ret); free(b->data); free(b); idx->n_no_coor = n_no_coor;