From 543a65c4e127aa3d6c143a6bd50e128201f25784 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Fri, 19 Nov 2010 19:49:27 +0000 Subject: [PATCH] * samtools-0.1.10 (r841) * fixed a bug in pileup when the first CIGAR operation is D * fixed a bug in view with range query --- bam_index.c | 3 +++ bam_pileup.c | 6 +++--- bamtk.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bam_index.c b/bam_index.c index 1ad2e93..f60a6f8 100644 --- a/bam_index.c +++ b/bam_index.c @@ -608,6 +608,9 @@ bam_iter_t bam_iter_query(const bam_index_t *idx, int tid, int beg, int end) } } free(bins); + if (n_off == 0) { + free(off); return iter; + } { bam1_t *b = (bam1_t*)calloc(1, sizeof(bam1_t)); int l; diff --git a/bam_pileup.c b/bam_pileup.c index 55e51e2..3e26f74 100644 --- a/bam_pileup.c +++ b/bam_pileup.c @@ -79,12 +79,12 @@ static inline int resolve_cigar2(bam_pileup1_t *p, uint32_t pos, cstate_t *s) is_head = 1; if (c->n_cigar == 1) { // just one operation, save a loop if (_cop(cigar[0]) == BAM_CMATCH) s->k = 0, s->x = c->pos, s->y = 0; - } else { // find the first match + } else { // find the first match or deletion for (k = 0, s->x = c->pos, s->y = 0; k < c->n_cigar; ++k) { int op = _cop(cigar[k]); int l = _cln(cigar[k]); - if (op == BAM_CMATCH) break; - else if (op == BAM_CDEL || op == BAM_CREF_SKIP) s->x += l; + if (op == BAM_CMATCH || op == BAM_CDEL) break; + else if (op == BAM_CREF_SKIP) s->x += l; else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) s->y += l; } assert(k < c->n_cigar); diff --git a/bamtk.c b/bamtk.c index f3b09d6..6d4eb76 100644 --- a/bamtk.c +++ b/bamtk.c @@ -9,7 +9,7 @@ #endif #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.1.10-7 (r840)" +#define PACKAGE_VERSION "0.1.10-8 (r841)" #endif int bam_taf2baf(int argc, char *argv[]); -- 2.39.2