From ca632f907b900d68a7f80a398fb29599c1367393 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 10 Oct 2017 21:22:37 -0400 Subject: [PATCH] r498: fixed a bug when merging like "4I5I" --- align.c | 2 ++ format.c | 5 +++-- main.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/align.c b/align.c index 6046131..9b3e62b 100644 --- a/align.c +++ b/align.c @@ -105,6 +105,7 @@ static void mm_fix_cigar(mm_reg1_t *r, const uint8_t *qseq, const uint8_t *tseq, for (k = l = 0; k < p->n_cigar; ++k) // merge two adjacent operations if they are the same if (k == p->n_cigar - 1 || (p->cigar[k]&0xf) != (p->cigar[k+1]&0xf)) p->cigar[l++] = p->cigar[k]; + else p->cigar[k+1] += p->cigar[k]>>4<<4; // add length to the next CIGAR operator p->n_cigar = l; } if ((p->cigar[0]&0xf) == 1 || (p->cigar[0]&0xf) == 2) { // get rid of leading I or D @@ -157,6 +158,7 @@ static void mm_update_extra(mm_reg1_t *r, const uint8_t *qseq, const uint8_t *ts } } p->dp_max = max; + assert(qoff == r->qe - r->qs && toff == r->re - r->rs); } static void mm_append_cigar(mm_reg1_t *r, uint32_t n_cigar, uint32_t *cigar) // TODO: this calls the libc realloc() diff --git a/format.c b/format.c index ef12397..d72e2d1 100644 --- a/format.c +++ b/format.c @@ -177,12 +177,13 @@ static void write_cs(void *km, kstring_t *s, const mm_idx_t *mi, const mm_bseq1_ tmp[j] = "acgtn"[qseq[q_off + j]]; mm_sprintf_lite(s, "+%s", tmp); q_off += len; - } else if (op == 2 || (op == 3 && len < 4)) { + } else if (op == 2) { for (j = 0, tmp[len] = 0; j < len; ++j) tmp[j] = "acgtn"[tseq[t_off + j]]; mm_sprintf_lite(s, "-%s", tmp); t_off += len; - } else { // op == 3 && len >= 4 + } else { + assert(len >= 2); mm_sprintf_lite(s, "~%c%c%d%c%c", "acgtn"[tseq[t_off]], "acgtn"[tseq[t_off+1]], len, "acgtn"[tseq[t_off+len-2]], "acgtn"[tseq[t_off+len-1]]); t_off += len; diff --git a/main.c b/main.c index d59545e..a03c5c8 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ #include "mmpriv.h" #include "getopt.h" -#define MM_VERSION "2.2-r497-dirty" +#define MM_VERSION "2.2-r498-dirty" #ifdef __linux__ #include