r178: fixed integer overflow in mapq calculation

This commit is contained in:
Heng Li 2017-07-16 21:45:39 -04:00
parent f42790398d
commit 38aa66fa30
2 changed files with 5 additions and 4 deletions

7
hit.c
View File

@ -294,9 +294,10 @@ void mm_set_mapq(int n_regs, mm_reg1_t *regs)
mm_reg1_t *r = &regs[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;

2
main.c
View File

@ -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()
{