Skip to content

Commit

Permalink
wip picklist
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Jul 24, 2022
1 parent e94f2f8 commit 6500ed9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/sourmash/index/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def _selection_as_rust(selection: Selection):
if v is not None:
if key == "ksize":
rustcall(lib.selection_set_ksize, ptr, v)

elif key == "moltype":
hash_function = None
if v.lower() == "dna":
Expand All @@ -97,19 +98,28 @@ def _selection_as_rust(selection: Selection):
hash_function = lib.HASH_FUNCTIONS_MURMUR64_DAYHOFF
elif v.lower() == "hp":
hash_function = lib.HASH_FUNCTIONS_MURMUR64_HP

rustcall(lib.selection_set_moltype, ptr, hash_function)

elif key == "num":
...
raise NotImplementedError("num")

elif key == "scaled":
...
raise NotImplementedError("scaled")

elif key == "containment":
...
raise NotImplementedError("containment")

elif key == "abund":
rustcall(lib.selection_set_abund, ptr, bool(v))

elif key == "picklist":
...
picklist_ptr = v._as_rust()
rustcall(lib.selection_set_picklist, ptr, picklist_ptr)

else:
raise KeyError(f"Unsupported key {key} for Selection in rust")

return ptr

class Index(ABC):
Expand Down
18 changes: 18 additions & 0 deletions src/sourmash/picklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,24 @@ def filter(self, it):
if self.__contains__(ss):
yield ss

def _as_rust(self):
from ._lowlevel import ffi, lib
from .utils import rustcall, decode_str

ptr = lib.picklist_new()

rustcall(lib.picklist_set_coltype, ptr, self.coltype)
rustcall(lib.picklist_set_pickfile, ptr, self.pickfile)
rustcall(lib.picklist_set_column_name, ptr, self.column_name)
rustcall(lib.picklist_set_pickstyle, ptr, self.pickstyle)

#self.preprocess_fn = preprocess[coltype]
#self.pickset = None
#self.found = set()
#self.n_queries = 0

return ptr


def passes_all_picklists(ss, picklists):
"does the signature 'ss' pass all of the picklists?"
Expand Down

0 comments on commit 6500ed9

Please sign in to comment.