From c4ef6cb9d3d77e26a3ba630833dd897698845a51 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Wed, 30 May 2018 04:06:08 +0000 Subject: [PATCH] Use buffers for abunds too --- sourmash/minhash.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sourmash/minhash.py b/sourmash/minhash.py index f3b599040b..d6f3efe27d 100644 --- a/sourmash/minhash.py +++ b/sourmash/minhash.py @@ -178,13 +178,14 @@ def __len__(self): return self._methodcall(lib.kmerminhash_get_mins_size) def get_mins(self, with_abundance=False): + size = self._methodcall(lib.kmerminhash_get_mins_size) + mins_ptr = self._methodcall(lib.kmerminhash_get_mins) + if with_abundance and self.track_abundance: - return {self._methodcall(lib.kmerminhash_get_min_idx, idx): - self._methodcall(lib.kmerminhash_get_abund_idx, idx) - for idx in range_type(len(self))} + abunds_ptr = self._methodcall(lib.kmerminhash_get_abunds) + return dict(zip(memoryview(ffi.buffer(mins_ptr, 8 * size)).cast('Q').tolist(), + memoryview(ffi.buffer(abunds_ptr, 8 * size)).cast('Q').tolist())) else: - size = self._methodcall(lib.kmerminhash_get_mins_size) - mins_ptr = self._methodcall(lib.kmerminhash_get_mins) return memoryview(ffi.buffer(mins_ptr, 8 * size)).cast('Q').tolist() def get_hashes(self):