Skip to content

Commit

Permalink
Use buffers for abunds too
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed May 30, 2018
1 parent 3c9f4dd commit c4ef6cb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sourmash/minhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c4ef6cb

Please sign in to comment.