X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=samtools.git;a=blobdiff_plain;f=bam_index.c;h=51c27014da0f9f010b563db92112f71d7ad6bdd6;hp=328f011c16ccf4a9a558702317ecdecfbcc5212a;hb=ced7709f121a00d5049d99ee8576037994aab1d1;hpb=cd828d5407c7f3fecbf48e8a3524cf6f0b86527c 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;