From d460f2ec9e86cf66e475f2ffcbbe81b84210eeef Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sat, 23 Feb 2013 14:48:54 -0500 Subject: [PATCH] bugfix in multi-threaded bwa-mem --- bwamem.c | 4 ++-- fastmap.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bwamem.c b/bwamem.c index 5bd495c..5202fb4 100644 --- a/bwamem.c +++ b/bwamem.c @@ -707,14 +707,14 @@ static void *worker2(void *data) worker_t *w = (worker_t*)data; int i; if (!(w->opt->flag&MEM_F_PE)) { - for (i = 0; i < w->n; i += w->step) { + for (i = w->start; i < w->n; i += w->step) { mem_mark_primary_se(w->opt, w->regs[i].n, w->regs[i].a); mem_sam_se(w->opt, w->bns, w->pac, &w->seqs[i], &w->regs[i], 0, 0); free(w->regs[i].a); } } else { int n = 0; - for (i = 0; i < w->n>>1; i += w->step) { // not implemented yet + for (i = w->start; i < w->n>>1; i += w->step) { // not implemented yet n += mem_sam_pe(w->opt, w->bns, w->pac, w->pes, i, &w->seqs[i<<1], &w->regs[i<<1]); free(w->regs[i<<1|0].a); free(w->regs[i<<1|1].a); } diff --git a/fastmap.c b/fastmap.c index d52a315..1d6ed04 100644 --- a/fastmap.c +++ b/fastmap.c @@ -24,8 +24,9 @@ int main_mem(int argc, char *argv[]) bseq1_t *seqs; opt = mem_opt_init(); - while ((c = getopt(argc, argv, "PHk:c:v:s:r:")) >= 0) { + while ((c = getopt(argc, argv, "PHk:c:v:s:r:t:")) >= 0) { if (c == 'k') opt->min_seed_len = atoi(optarg); + else if (c == 't') opt->n_threads = atoi(optarg), opt->n_threads = opt->n_threads > 1? opt->n_threads : 1; else if (c == 'P') opt->flag |= MEM_F_NOPAIRING; else if (c == 'H') opt->flag |= MEM_F_HARDCLIP; else if (c == 'c') opt->max_occ = atoi(optarg); @@ -37,6 +38,7 @@ int main_mem(int argc, char *argv[]) fprintf(stderr, "\n"); fprintf(stderr, "Usage: bwa mem [options] \n\n"); fprintf(stderr, "Options: -k INT minimum seed length [%d]\n", opt->min_seed_len); + fprintf(stderr, " -t INT number of threads [%d]\n", opt->n_threads); fprintf(stderr, " -c INT skip seeds with more than INT occurrences [%d]\n", opt->max_occ); fprintf(stderr, " -s INT look for internal seeds inside a seed with less than INT occ [%d]\n", opt->split_width); fprintf(stderr, " -r FLOAT look for internal seeds inside a seed longer than {-k} * FLOAT [%g]\n", opt->split_factor);