r343: bugfix in mem - wrong mate info for unmap

SAM generation is always among the nastiest bits. I would need to refactor at
some point (hardly happening).
This commit is contained in:
Heng Li 2013-03-08 12:40:31 -05:00
parent 017be45407
commit 274c0ac96c
3 changed files with 17 additions and 4 deletions

View File

@ -670,9 +670,13 @@ void bwa_hit2sam(kstring_t *str, const int8_t mat[25], int q, int r, int w, cons
if (mid == rid) {
int64_t p0 = p->rb < bns->l_pac? p->rb : (bns->l_pac<<1) - 1 - p->rb;
int64_t p1 = m->rb < bns->l_pac? m->rb : (bns->l_pac<<1) - 1 - m->rb;
kputw(p0 - p1 + (p0 > p1? 1 : -1), str);
kputw(p0 - p1 + (p0 > p1? 1 : p0 < p1? -1 : 0), str);
} else kputw(0, str);
kputc('\t', str);
} else if (m && is_mapped(p)) { // then copy the position
kputsn("\t=\t", 3, str);
kputuw(pos - bns->anns[rid].offset + 1, str);
kputsn("\t0\t", 3, str);
} else kputsn("\t*\t0\t0\t", 7, str);
if (p->flag&0x100) { // for secondary alignments, don't write SEQ and QUAL
kputsn("*\t*", 3, str);
@ -760,7 +764,12 @@ void mem_sam_se(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, b
else if (h.qual > mapq0) h.qual = mapq0;
bwa_hit2sam(&str, opt->mat, opt->q, opt->r, p->w, bns, pac, s, &h, opt->flag&MEM_F_HARDCLIP, m);
}
} else bwa_hit2sam(&str, opt->mat, opt->q, opt->r, opt->w, bns, pac, s, 0, opt->flag&MEM_F_HARDCLIP, m);
} else {
bwahit_t h;
memset(&h, 0, sizeof(bwahit_t));
h.rb = h.re = -1; h.flag = extra_flag;
bwa_hit2sam(&str, opt->mat, opt->q, opt->r, opt->w, bns, pac, s, &h, opt->flag&MEM_F_HARDCLIP, m);
}
s->sam = str.s;
}

View File

@ -306,7 +306,11 @@ no_pairing:
if (a[i].n && a[i].a[0].score >= opt->T) {
mem_alnreg2hit(&a[i].a[0], &h[i]);
bwa_fix_xref(opt->mat, opt->q, opt->r, opt->w, bns, pac, (uint8_t*)s[i].seq, &h[i].qb, &h[i].qe, &h[i].rb, &h[i].re);
} else h[i].rb = h[i].re = -1;
} else {
memset(&h[i], 0, sizeof(bwahit_t));
h[i].rb = h[i].re = -1;
h[i].flag = 1<<(6+i) | 1;
}
}
mem_sam_se(opt, bns, pac, &s[0], &a[0], 0x41, &h[1]);
mem_sam_se(opt, bns, pac, &s[1], &a[1], 0x81, &h[0]);

2
main.c
View File

@ -3,7 +3,7 @@
#include "utils.h"
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "0.7.0-r342-beta"
#define PACKAGE_VERSION "0.7.0-r343-beta"
#endif
int bwa_fa2pac(int argc, char *argv[]);