From fa20c71920458e51ee0bdaf646f6b9f1e912224c Mon Sep 17 00:00:00 2001 From: Heng Li Date: Thu, 1 May 2014 14:27:38 -0400 Subject: [PATCH] r742: further control the max bandwidth I am looking at 6kb bandwidth... --- bwamem.c | 4 +++- ksw.c | 2 +- main.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bwamem.c b/bwamem.c index 8e97747..5709586 100644 --- a/bwamem.c +++ b/bwamem.c @@ -381,6 +381,7 @@ int mem_patch_reg(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, } else if (w > opt->w<<2 || r >= PATCH_MAX_R_BW*2) return 0; // more permissive if overlapping on both ref and query // global alignment w += a->w + b->w; + w = w < opt->w<<2? w : opt->w<<2; if (bwa_verbose >= 4) printf("* test potential hit merge with global alignment; w=%d\n", w); bwa_gen_cigar2(opt->mat, opt->o_del, opt->e_del, opt->o_ins, opt->e_ins, w, bns->l_pac, pac, b->qe - a->qb, query + a->qb, a->rb, b->re, &score, 0, 0); q_s = (int)((double)(b->qe - a->qb) / ((b->qe - b->qb) + (a->qe - a->qb)) * (b->score + a->score) + .499); // predicted score from query @@ -1044,9 +1045,10 @@ mem_aln_t mem_reg2aln2(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t i = 0; a.cigar = 0; do { free(a.cigar); + w2 = w2 < opt->w<<2? w2 : opt->w<<2; a.cigar = bwa_gen_cigar2(opt->mat, opt->o_del, opt->e_del, opt->o_ins, opt->e_ins, w2, bns->l_pac, pac, qe - qb, (uint8_t*)&query[qb], rb, re, &score, &a.n_cigar, &NM); if (bwa_verbose >= 4) printf("* Final alignment: w2=%d, global_sc=%d, local_sc=%d\n", w2, score, ar->truesc); - if (score == last_sc) break; // it is possible that global alignment and local alignment give different scores + if (score == last_sc || w2 == opt->w<<2) break; // it is possible that global alignment and local alignment give different scores last_sc = score; w2 <<= 1; } while (++i < 3 && score < ar->truesc - opt->a); diff --git a/ksw.c b/ksw.c index 40e226a..808bd3f 100644 --- a/ksw.c +++ b/ksw.c @@ -510,7 +510,7 @@ int ksw_global2(int qlen, const uint8_t *query, int tlen, const uint8_t *target, if (n_cigar_) *n_cigar_ = 0; // allocate memory n_col = qlen < 2*w+1? qlen : 2*w+1; // maximum #columns of the backtrack matrix - z = n_cigar_ && cigar_? malloc(n_col * tlen) : 0; + z = n_cigar_ && cigar_? malloc((long)n_col * tlen) : 0; qp = malloc(qlen * m); eh = calloc(qlen + 1, 8); // generate the query profile diff --git a/main.c b/main.c index 94904fa..e902a0a 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.8-r741-dirty" +#define PACKAGE_VERSION "0.7.8-r742-dirty" #endif int bwa_fa2pac(int argc, char *argv[]);