From 8301222174a88db697c8cc1cd1c287ab3f4a7a5d Mon Sep 17 00:00:00 2001 From: Heng Li Date: Wed, 27 Sep 2017 21:54:07 -0400 Subject: [PATCH] r448: fixed a bug when computing PE quality --- main.c | 2 +- pe.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index dca31d3..17b7b11 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ #include "mmpriv.h" #include "getopt.h" -#define MM_VERSION "2.2-r446-dirty" +#define MM_VERSION "2.2-r448-dirty" #ifdef __linux__ #include diff --git a/pe.c b/pe.c index 7b587be..f74dddd 100644 --- a/pe.c +++ b/pe.c @@ -108,7 +108,8 @@ void mm_pair(void *km, int max_gap_ref, int pe_bonus, int sub_diff, int match_sc last[a[i].rev] = i; } } - radix_sort_64(sc.a, sc.a + sc.n); + if (sc.n > 1) + radix_sort_64(sc.a, sc.a + sc.n); if (sc.n > 0 && max > 0) { // found at least one pair int n_sub = 0, mapq_pe; @@ -129,7 +130,7 @@ void mm_pair(void *km, int max_gap_ref, int pe_bonus, int sub_diff, int match_sc ++n_sub; if (sc.n > 1) { int mapq_pe_alt; - mapq_pe_alt = (int)(6.02f * (max - sc.a[1]) / match_sc - 4.343f * logf(n_sub)); // n_sub > 0 because it counts the optimal, too + mapq_pe_alt = (int)(6.02f * (max - sc.a[sc.n - 2]) / match_sc - 4.343f * logf(n_sub)); // n_sub > 0 because it counts the optimal, too mapq_pe = mapq_pe < mapq_pe_alt? mapq_pe : mapq_pe_alt; } if (r[0]->mapq < mapq_pe) r[0]->mapq = (r[0]->mapq + mapq_pe) / 2;