From cbb6d034f4e2cc1548f69cd86b9badab9a3402f8 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Wed, 18 Feb 2009 22:23:27 +0000 Subject: [PATCH] * samtools-0.1.2-9 * fixed a bug in bam_fetch, caused by completely contained adjacent chunks --- bam_index.c | 10 +++++++--- bamtk.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bam_index.c b/bam_index.c index 8c25552..59deca0 100644 --- a/bam_index.c +++ b/bam_index.c @@ -410,16 +410,20 @@ int bam_fetch(bamFile fp, const bam_index_t *idx, int tid, int beg, int end, voi free(bins); { bam1_t *b; - int ret, n_seeks; + int l, ret, n_seeks; uint64_t curr_off; b = (bam1_t*)calloc(1, sizeof(bam1_t)); ks_introsort(off, n_off, off); - // resolve overlaps between adjecent blocks; this may happen due to the merge in indexing + // resolve completely contained adjacent blocks + for (i = 1, l = 0; i < n_off; ++i) + if (off[l].v < off[i].v) + off[++l] = off[i]; + n_off = l + 1; + // resolve overlaps between adjacent blocks; this may happen due to the merge in indexing for (i = 1; i < n_off; ++i) if (off[i-1].v >= off[i].u) off[i-1].v = off[i].u; { // merge adjacent blocks #if defined(BAM_TRUE_OFFSET) || defined(BAM_VIRTUAL_OFFSET16) - int l; for (i = 1, l = 0; i < n_off; ++i) { #ifdef BAM_TRUE_OFFSET if (off[l].v + BAM_MIN_CHUNK_GAP > off[i].u) off[l].v = off[i].v; diff --git a/bamtk.c b/bamtk.c index f9df678..950eae0 100644 --- a/bamtk.c +++ b/bamtk.c @@ -3,7 +3,7 @@ #include "bam.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.1.2-8" +#define PACKAGE_VERSION "0.1.2-9" #endif int bam_taf2baf(int argc, char *argv[]); -- 2.39.2