r505: a bit code simplification

This commit is contained in:
Heng Li 2017-10-11 21:54:32 -04:00
parent 3073f4a758
commit 9862a75cd3
2 changed files with 18 additions and 26 deletions

42
align.c
View File

@ -391,22 +391,18 @@ static void mm_align1(void *km, const mm_mapopt_t *opt, const mm_idx_t *mi, int
rs0 = (int32_t)a[r->as].x + 1 - (int32_t)(a[r->as].y>>32&0xff); rs0 = (int32_t)a[r->as].x + 1 - (int32_t)(a[r->as].y>>32&0xff);
qs0 = (int32_t)a[r->as].y + 1 - (int32_t)(a[r->as].y>>32&0xff); qs0 = (int32_t)a[r->as].y + 1 - (int32_t)(a[r->as].y>>32&0xff);
rs1 = qs1 = 0; rs1 = qs1 = 0;
if (r->as > 0 && a[r->as - 1].x>>32 == a[r->as].x>>32) { for (i = r->as - 1, l = 0; i >= 0 && a[i].x>>32 == a[r->as].x>>32; --i) { // inspect nearby seeds
for (i = r->as - 1, l = 0; i >= 0; --i) { int32_t x = (int32_t)a[i].x + 1 - (int32_t)(a[i].y>>32&0xff);
int32_t x, y; int32_t y = (int32_t)a[i].y + 1 - (int32_t)(a[i].y>>32&0xff);
if (a[i].x>>32 != a[r->as].x>>32) break; if (x < rs0 && y < qs0) {
x = (int32_t)a[i].x + 1 - (int32_t)(a[i].y>>32&0xff); if (++l > opt->min_cnt) {
y = (int32_t)a[i].y + 1 - (int32_t)(a[i].y>>32&0xff); l = rs0 - x > qs0 - y? rs0 - x : qs0 - y;
if (x < rs0 && y < qs0) { rs1 = rs0 - l, qs1 = qs0 - l;
if (++l > opt->min_cnt) { break;
l = rs0 - x > qs0 - y? rs0 - x : qs0 - y;
rs1 = rs0 - l, qs1 = qs0 - l;
break;
}
} }
} }
} }
if (qs > 0 && rs > 0) { // actually this is always true if (qs > 0 && rs > 0) {
l = qs < opt->max_gap? qs : opt->max_gap; l = qs < opt->max_gap? qs : opt->max_gap;
qs1 = qs1 > qs - l? qs1 : qs - l; qs1 = qs1 > qs - l? qs1 : qs - l;
qs0 = qs0 < qs1? qs0 : qs1; // at least include qs0 qs0 = qs0 < qs1? qs0 : qs1; // at least include qs0
@ -420,18 +416,14 @@ static void mm_align1(void *km, const mm_mapopt_t *opt, const mm_idx_t *mi, int
re0 = (int32_t)a[r->as + r->cnt - 1].x + 1; re0 = (int32_t)a[r->as + r->cnt - 1].x + 1;
qe0 = (int32_t)a[r->as + r->cnt - 1].y + 1; qe0 = (int32_t)a[r->as + r->cnt - 1].y + 1;
re1 = mi->seq[rid].len, qe1 = qlen; re1 = mi->seq[rid].len, qe1 = qlen;
if (r->as + r->cnt < n_a && a[r->as + r->cnt].x>>32 == a[r->as].x>>32) { for (i = r->as + r->cnt, l = 0; i < n_a && a[i].x>>32 == a[r->as].x>>32; ++i) { // inspect nearby seeds
for (i = r->as + r->cnt, l = 0; i < n_a; ++i) { int32_t x = (int32_t)a[i].x + 1;
int32_t x, y; int32_t y = (int32_t)a[i].y + 1;
if (a[i].x>>32 != a[r->as].x>>32) break; if (x > re0 && y > qe0) {
x = (int32_t)a[i].x + 1; if (++l > opt->min_cnt) {
y = (int32_t)a[i].y + 1; l = x - re0 > y - qe0? x - re0 : y - qe0;
if (x > re0 && y > qe0) { re1 = re0 + l, qe1 = qe0 + l;
if (++l > opt->min_cnt) { break;
l = x - re0 > y - qe0? x - re0 : y - qe0;
re1 = re0 + l, qe1 = qe0 + l;
break;
}
} }
} }
} }

2
main.c
View File

@ -6,7 +6,7 @@
#include "mmpriv.h" #include "mmpriv.h"
#include "getopt.h" #include "getopt.h"
#define MM_VERSION "2.2-r504-dirty" #define MM_VERSION "2.2-r505-dirty"
#ifdef __linux__ #ifdef __linux__
#include <sys/resource.h> #include <sys/resource.h>