From 4adc34eccb6e18c53cbd6668c83f33bf4b0704a4 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 18 Feb 2014 10:32:24 -0500 Subject: [PATCH] r435: bugfix - base not complemented on the rev --- bwa.c | 7 +++++-- main.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bwa.c b/bwa.c index aec04d8..d08899b 100644 --- a/bwa.c +++ b/bwa.c @@ -93,6 +93,7 @@ uint32_t *bwa_gen_cigar(const int8_t mat[25], int q, int r, int w_, int64_t l_pa int i; int64_t rlen; kstring_t str; + const char *int2base; *n_cigar = 0; *NM = -1; if (l_query <= 0 || rb >= re || (rb < l_pac && re > l_pac)) return 0; // reject if negative length or bridging the forward and reverse strand @@ -127,6 +128,7 @@ uint32_t *bwa_gen_cigar(const int8_t mat[25], int q, int r, int w_, int64_t l_pa {// compute NM int k, x, y, u, n_mm = 0, n_gap = 0; str.l = str.m = *n_cigar * 4; str.s = (char*)cigar; // append MD to CIGAR + int2base = rb < l_pac? "ACGTN" : "TGCAN"; for (k = 0, x = y = u = 0; k < *n_cigar; ++k) { int op, len; cigar = (uint32_t*)str.s; @@ -134,7 +136,8 @@ uint32_t *bwa_gen_cigar(const int8_t mat[25], int q, int r, int w_, int64_t l_pa if (op == 0) { // match for (i = 0; i < len; ++i) { if (query[x + i] != rseq[y + i]) { - kputw(u, &str); kputc("ACGTN"[rseq[y+i]], &str); + kputw(u, &str); + kputc(int2base[rseq[y+i]], &str); ++n_mm; u = 0; } else ++u; } @@ -142,7 +145,7 @@ uint32_t *bwa_gen_cigar(const int8_t mat[25], int q, int r, int w_, int64_t l_pa } else if (op == 2) { // deletion kputw(u, &str); kputc('^', &str); for (i = 0; i < len; ++i) - kputc("ACGTN"[rseq[y+i]], &str); + kputc(int2base[rseq[y+i]], &str); u = 0; y += len, n_gap += len; } else if (op == 1) x += len, n_gap += len; // insertion diff --git a/main.c b/main.c index 86de68e..55d43cf 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.6a-dev-r434" +#define PACKAGE_VERSION "0.7.6a+dev-r435" #endif int bwa_fa2pac(int argc, char *argv[]);