From 282130a64e990de68b246c75442507b42fc995d1 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 21 Oct 2014 12:57:49 -0400 Subject: [PATCH] r940: fixed a bug - missing primary hit --- README-alt.md | 6 ++++-- bwamem.c | 9 +++++---- main.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README-alt.md b/README-alt.md index d46b38f..e57313f 100644 --- a/README-alt.md +++ b/README-alt.md @@ -88,7 +88,9 @@ alignments and assigns mapQ following these two rules: In theory, non-ALT alignments from step 1 should be identical to alignments against a reference genome with ALT contigs. In practice, the two types of -alignments may differ in rare cases due to seeding heuristics. +alignments may differ in rare cases due to seeding heuristics. When an ALT hit +is significantly better than non-ALT hits, BWA-MEM may miss seeds on the +non-ALT hits. This happens more often for contig mapping. If we don't care about ALT hits, we may skip postprocessing (step 2). Nonetheless, postprocessing is recommended as it improves mapQ and gives more @@ -134,7 +136,7 @@ not to high resolution for now. ### Evaluating ALT Mapping -(To come later...) +(Coming soon...) ## Problems and Future Development diff --git a/bwamem.c b/bwamem.c index 3fd008f..4f585c6 100644 --- a/bwamem.c +++ b/bwamem.c @@ -980,14 +980,14 @@ void mem_reg2sam(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, extern char **mem_gen_alt(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, mem_alnreg_v *a, int l_query, const char *query); kstring_t str; kvec_t(mem_aln_t) aa; - int k; + int k, l; char **XA = 0; if (!(opt->flag & MEM_F_ALL)) XA = mem_gen_alt(opt, bns, pac, a, s->l_seq, s->seq); kv_init(aa); str.l = str.m = 0; str.s = 0; - for (k = 0; k < a->n; ++k) { + for (k = l = 0; k < a->n; ++k) { mem_alnreg_t *p = &a->a[k]; mem_aln_t *q; if (p->score < opt->T) continue; @@ -999,9 +999,10 @@ void mem_reg2sam(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, q->XA = XA? XA[k] : 0; q->flag |= extra_flag; // flag secondary if (p->secondary >= 0) q->sub = -1; // don't output sub-optimal score - if (k && p->secondary < 0) // if supplementary + if (l && p->secondary < 0) // if supplementary q->flag |= (opt->flag&MEM_F_NO_MULTI)? 0x10000 : 0x800; - if (k && !p->is_alt && q->mapq > aa.a[0].mapq) q->mapq = aa.a[0].mapq; + if (l && !p->is_alt && q->mapq > aa.a[0].mapq) q->mapq = aa.a[0].mapq; + ++l; } if (aa.n == 0) { // no alignments good enough; then write an unaligned record mem_aln_t t; diff --git a/main.c b/main.c index 07a9d00..65b9817 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.10-r939-dirty" +#define PACKAGE_VERSION "0.7.10-r940-dirty" #endif int bwa_fa2pac(int argc, char *argv[]);