no poor hits with -a; reduce mapq for 2nd primary

This commit is contained in:
Heng Li 2013-02-25 10:54:12 -05:00
parent 4dc982a3c7
commit 514563bd0a
1 changed files with 4 additions and 0 deletions

View File

@ -623,12 +623,16 @@ void mem_sam_se(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, b
kstring_t str;
str.l = str.m = 0; str.s = 0;
if (a->n > 0) {
int mapq0 = -1;
for (k = 0; k < a->n; ++k) {
bwahit_t h;
if (a->a[k].secondary >= 0 && !(opt->flag&MEM_F_ALL)) continue;
if (a->a[k].secondary >= 0 && a->a[k].score < a->a[a->a[k].secondary].score * .5) continue;
mem_alnreg2hit(&a->a[k], &h);
h.flag |= extra_flag;
h.qual = a->a[k].secondary >= 0? 0 : mem_approx_mapq_se(opt, &a->a[k]);
if (k == 0) mapq0 = h.qual;
else if (h.qual > mapq0) h.qual = mapq0;
bwa_hit2sam(&str, opt->mat, opt->q, opt->r, opt->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);