diff --git a/hit.c b/hit.c index cb740fb..d221ce6 100644 --- a/hit.c +++ b/hit.c @@ -294,9 +294,10 @@ void mm_set_mapq(int n_regs, mm_reg1_t *regs) mm_reg1_t *r = ®s[i]; if (r->parent == r->id) { int mapq; - if (r->p && r->p->dp_max2 > 0 && r->p->dp_max > 0) - mapq = (int)(30.0 * (1. - (float)(r->p->dp_max2 * r->subsc) / (r->p->dp_max * r->score)) * logf(r->score)); - else mapq = (int)(30.0 * (1. - (float)r->subsc / r->score) * logf(r->score)); + if (r->p && r->p->dp_max2 > 0 && r->p->dp_max > 0) { + float identity = (float)(r->p->blen - r->p->n_diff - r->p->n_ambi) / (r->p->blen - r->p->n_ambi); + mapq = (int)(identity * 30.0 * (1. - (float)r->p->dp_max2 * r->subsc / r->p->dp_max / r->score) * logf(r->score)); + } else mapq = (int)(30.0 * (1. - (float)r->subsc / r->score) * logf(r->score)); mapq = mapq > 0? mapq : 0; r->mapq = mapq < 60? mapq : 60; } else r->mapq = 0; diff --git a/main.c b/main.c index 69c656d..0b62d0b 100644 --- a/main.c +++ b/main.c @@ -10,7 +10,7 @@ #include "minimap.h" #include "mmpriv.h" -#define MM_VERSION "2.0-r176-pre" +#define MM_VERSION "2.0-r178-pre" void liftrlimit() {