Skip to content

Commit

Permalink
Moving loading and save sigs to rust
Browse files Browse the repository at this point in the history
move json parsing and init to rust
working on loading sigs
enable pickling for signatures
sort mins and abunds
remove dead code
remove refs
  • Loading branch information
luizirber committed Dec 30, 2019
1 parent 3e71e9a commit 6adfda9
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 645 deletions.
2 changes: 2 additions & 0 deletions include/sourmash.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ uint32_t kmerminhash_ksize(KmerMinHash *ptr);

uint64_t kmerminhash_max_hash(KmerMinHash *ptr);

SourmashStr kmerminhash_md5sum(KmerMinHash *ptr);

void kmerminhash_merge(KmerMinHash *ptr, const KmerMinHash *other);

bool kmerminhash_is_compatible(const KmerMinHash *ptr, const KmerMinHash *other);
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def build_native(spec):
'sourmash = sourmash.__main__:main'
]
},
"install_requires": ["screed>=0.9", "ijson>=2.5.1", "khmer>=2.1", 'numpy',
"cffi",
"install_requires": ["screed>=0.9", "khmer>=2.1", "cffi", 'numpy',
'matplotlib', 'scipy', "deprecation>=2.0.6"],
"setup_requires": [
"setuptools>=38.6.0",
Expand Down
3 changes: 2 additions & 1 deletion sourmash/_minhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def hash_murmur(kmer, seed=MINHASH_DEFAULT_SEED):


class MinHash(RustObject):
__dealloc_func__ = lib.kmerminhash_free

def __init__(
self,
n,
Expand Down Expand Up @@ -98,7 +100,6 @@ def __init__(
self._objptr = lib.kmerminhash_new(
n, ksize, is_protein, dayhoff, hp, seed, int(max_hash), track_abundance
)
self.__dealloc_func__ = lib.kmerminhash_free

if mins:
if track_abundance:
Expand Down
3 changes: 2 additions & 1 deletion sourmash/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,14 +1036,14 @@ def watch(args):
ksize = tree_mh.ksize

E = MinHash(ksize=ksize, n=args.num_hashes, is_protein=is_protein, dayhoff=dayhoff, hp=hp)
streamsig = sig.SourmashSignature(E, filename='stdin', name=args.name)

notify('Computing signature for k={}, {} from stdin', ksize, moltype)

def do_search():
search_fn = SearchMinHashesFindBest().search

results = []
streamsig = sig.SourmashSignature(E, filename='stdin', name=args.name)
for leaf in tree.find(search_fn, streamsig, args.threshold):
results.append((streamsig.similarity(leaf.data),
leaf.data))
Expand Down Expand Up @@ -1081,6 +1081,7 @@ def do_search():

if args.output:
notify('saving signature to {}', args.output.name)
streamsig = sig.SourmashSignature(E, filename='stdin', name=args.name)
sig.save_signatures([streamsig], args.output)


Expand Down
6 changes: 3 additions & 3 deletions sourmash/sig/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def describe(args):
with_abundance = 1
md5 = sig.md5sum()
name = sig.name()
filename = sig.d.get('filename', '')
license = sig.d['license']
filename = sig.filename
license = sig.license

if w:
w.writerow(locals())
Expand Down Expand Up @@ -454,7 +454,7 @@ def rename(args):
select_moltype=moltype)

for sigobj in siglist:
sigobj.d['name'] = args.name
sigobj._name = args.name
outlist.append(sigobj)

if args.output:
Expand Down
Loading

0 comments on commit 6adfda9

Please sign in to comment.