diff --git a/index.c b/index.c index 937c452..cd14d30 100644 --- a/index.c +++ b/index.c @@ -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; } diff --git a/misc.c b/misc.c index 3f8bf52..9a85fec 100644 --- a/misc.c +++ b/misc.c @@ -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)