Skip to content

Commit

Permalink
refactor return signature of load_dbs_and_sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Mar 6, 2021
1 parent 5e66db9 commit c43c6e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/sourmash/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def search_databases(query, databases, threshold, do_containment, best_only,
ignore_abundance, unload_data=False):
results = []
found_md5 = set()
for (obj, filename, filetype) in databases:
for (obj, filename) in databases:
search_iter = obj.search(query, threshold=threshold,
do_containment=do_containment,
ignore_abundance=ignore_abundance,
Expand Down Expand Up @@ -84,7 +84,7 @@ def _find_best(dblist, query, threshold_bp):
threshold_bp = int(threshold_bp / query_scaled) * query_scaled

# search across all databases
for (obj, filename, filetype) in dblist:
for (obj, filename) in dblist:
for cont, match, fname in obj.gather(query, threshold_bp=threshold_bp):
assert cont # all matches should be nonzero.

Expand Down
10 changes: 6 additions & 4 deletions src/sourmash/sourmash_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ def load_dbs_and_sigs(filenames, query, is_similarity_query, *, cache_size=None)
Load one or more SBTs, LCAs, and/or signatures.
Check for compatibility with query.
This is basically a user-focused wrapping of _load_databases.
"""
query_ksize = query.minhash.ksize
query_moltype = get_moltype(query)
Expand All @@ -281,7 +283,7 @@ def load_dbs_and_sigs(filenames, query, is_similarity_query, *, cache_size=None)
siglist = _select_sigs(db, moltype=query_moltype, ksize=query_ksize)
siglist = filter_compatible_signatures(query, siglist, 1)
linear = LinearIndex(siglist, filename=filename)
databases.append((linear, filename, False))
databases.append((linear, filename))

n_signatures += len(linear)

Expand All @@ -291,7 +293,7 @@ def load_dbs_and_sigs(filenames, query, is_similarity_query, *, cache_size=None)
is_similarity_query):
sys.exit(-1)

databases.append((db, filename, 'SBT'))
databases.append((db, filename))
notify('loaded SBT {}', filename, end='\r')
n_databases += 1

Expand All @@ -304,7 +306,7 @@ def load_dbs_and_sigs(filenames, query, is_similarity_query, *, cache_size=None)
notify('loaded LCA {}', filename, end='\r')
n_databases += 1

databases.append((db, filename, 'LCA'))
databases.append((db, filename))

# signature file
elif dbtype == DatabaseType.SIGLIST:
Expand All @@ -316,7 +318,7 @@ def load_dbs_and_sigs(filenames, query, is_similarity_query, *, cache_size=None)
sys.exit(-1)

linear = LinearIndex(siglist, filename=filename)
databases.append((linear, filename, 'signature'))
databases.append((linear, filename))

notify('loaded {} signatures from {}', len(linear),
filename, end='\r')
Expand Down

0 comments on commit c43c6e8

Please sign in to comment.