From 322e5a16e5a28ac98a7573f45befdfa4e2e764e0 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sat, 16 Sep 2017 18:11:43 -0400 Subject: [PATCH] minor tweaks to python --- misc.c | 4 ++-- python/minimap2.pyx | 18 +++++++----------- setup.py | 3 ++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/misc.c b/misc.c index f7b13d3..a846d1e 100644 --- a/misc.c +++ b/misc.c @@ -90,7 +90,7 @@ double cputime() #include #include -double cputime() +double cputime(void) { struct rusage r; getrusage(RUSAGE_SELF, &r); @@ -98,7 +98,7 @@ double cputime() } #endif /* WIN32 || _WIN32 */ -double realtime() +double realtime(void) { struct timeval tp; struct timezone tzp; diff --git a/python/minimap2.pyx b/python/minimap2.pyx index 6aa1a81..9c72d4a 100644 --- a/python/minimap2.pyx +++ b/python/minimap2.pyx @@ -79,13 +79,14 @@ cdef class ThreadBuffer: cdef class Aligner: cdef cminimap2.mm_idx_t *_idx - cdef public cminimap2.mm_idxopt_t idx_opt - cdef public cminimap2.mm_mapopt_t map_opt + cdef cminimap2.mm_idxopt_t idx_opt + cdef cminimap2.mm_mapopt_t map_opt def __cinit__(self, fn_idx_in, preset=None, k=None, w=None, min_cnt=None, min_chain_score=None, min_dp_score=None, bw=None, best_n=None, n_threads=3, fn_idx_out=None): - cdef cminimap2.mm_idx_reader_t *r; - - self._config(preset) + cminimap2.mm_set_opt(NULL, &self.idx_opt, &self.map_opt) # set the default options + if preset is not None: + cminimap2.mm_set_opt(preset, &self.idx_opt, &self.map_opt) # apply preset + self.map_opt.flag |= 4 # always perform alignment self.idx_opt.batch_size = 0x7fffffffffffffffL # always build a uni-part index if k is not None: self.idx_opt.k = k if w is not None: self.idx_opt.w = w @@ -95,6 +96,7 @@ cdef class Aligner: if bw is not None: self.map_opt.bw = bw if best_n is not None: self.best_n = best_n + cdef cminimap2.mm_idx_reader_t *r; if fn_idx_out is None: r = cminimap2.mm_idx_reader_open(fn_idx_in, &self.idx_opt, NULL) else: @@ -108,12 +110,6 @@ cdef class Aligner: if self._idx is not NULL: cminimap2.mm_idx_destroy(self._idx) - cdef _config(self, preset=None): - cminimap2.mm_set_opt(NULL, &self.idx_opt, &self.map_opt) # set the default options - if preset is not None: - cminimap2.mm_set_opt(preset, &self.idx_opt, &self.map_opt) # preset - self.map_opt.flag |= 4 # always perform alignment - def map(self, seq, buf=None): cdef cminimap2.mm_reg1_t *regs cdef cminimap2.mm_hitpy_t h diff --git a/setup.py b/setup.py index 3627c85..e7acda1 100644 --- a/setup.py +++ b/setup.py @@ -22,5 +22,6 @@ setup( 'ksw2_extd2_sse.c', 'ksw2_exts2_sse.c', 'ksw2_extz2_sse.c', 'ksw2_ll_sse.c', 'kthread.c', 'map.c', 'misc.c', 'sdust.c', 'sketch.c'], extra_compile_args = ['-msse4'], # WARNING: ancient x86_64 CPUs don't have SSE4 - include_dirs = ['.'])]) + include_dirs = ['.'], + libraries = ['z', 'm', 'pthread'])]) )