sort positions in each bucket

This commit is contained in:
Heng Li 2017-04-12 13:31:12 -04:00
parent 1bf3ae6752
commit 9947c953cf
2 changed files with 7 additions and 1 deletions

View File

@ -49,7 +49,7 @@ const uint64_t *mm_idx_get(const mm_idx_t *mi, uint64_t minier, int *n)
if (h == 0) return 0;
k = kh_get(idx, h, minier>>mi->b<<1);
if (k == kh_end(h)) return 0;
if (kh_key(h, k)&1) {
if (kh_key(h, k)&1) { // special casing when there is only one k-mer
*n = 1;
return &kh_val(h, k);
} else {
@ -123,6 +123,7 @@ static void worker_post(void *g, long i, int tid)
int k;
for (k = 0; k < n; ++k)
b->p[start_p + k] = b->a.a[start_a + k].y;
radix_sort_64(&b->p[start_p], &b->p[start_p + n]); // sort by position; needed as in-place radix_sort_128x() is not stable
kh_val(h, itr) = (uint64_t)start_p<<32 | n;
start_p += n;
}

5
misc.c
View File

@ -21,6 +21,11 @@ double realtime()
}
#include "ksort.h"
#define sort_key_128x(a) ((a).x)
KRADIX_SORT_INIT(128x, mm128_t, sort_key_128x, 8)
#define sort_key_64(x) (x)
KRADIX_SORT_INIT(64, uint64_t, sort_key_64, 8)
KSORT_INIT_GENERIC(uint32_t)