Skip to content

Commit

Permalink
fix for genome-grist alpha test
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Apr 24, 2021
1 parent 7852fa1 commit 808ae37
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/sourmash/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ def gather(args):
query.minhash.scaled, int(args.scaled))
query.minhash = query.minhash.downsample(scaled=args.scaled)

# flatten if needed @CTB do we need this here?
if query.minhash.track_abundance:
query.minhash = query.minhash.flatten()

# empty?
if not len(query.minhash):
error('no query hashes!? exiting.')
Expand Down
9 changes: 8 additions & 1 deletion src/sourmash/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def location(self):
def signatures(self):
return iter(self._signatures)

def __bool__(self):
return bool(self._signatures)

def __len__(self):
return len(self._signatures)

Expand Down Expand Up @@ -329,6 +332,9 @@ def __init__(self, zf, selection_dict=None,
self.selection_dict = selection_dict
self.traverse_yield_all = traverse_yield_all

def __bool__(self):
return bool(self.zf)

def __len__(self):
return len(list(self.signatures()))

Expand Down Expand Up @@ -464,7 +470,8 @@ def gather(self, query, *args, **kwargs):
result = IndexSearchResult(cont, match, location)

# calculate intersection of this "best match" with query, for removal.
match_mh = match.minhash.downsample(scaled=scaled)
# @CTB note flatten
match_mh = match.minhash.downsample(scaled=scaled).flatten()
intersect_mh = query_mh.intersection(match_mh)

# Prepare counter for finding the next match by decrementing
Expand Down
4 changes: 4 additions & 0 deletions src/sourmash/lca/lca_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ def load(cls, db_name):
xopen = gzip.open

with xopen(db_name, 'rt') as fp:
if fp.read(1) != '{':
raise ValueError(f"'{db_name}' is not an LCA database file.")
fp.seek(0)

load_d = {}
try:
load_d = json.load(fp)
Expand Down
2 changes: 1 addition & 1 deletion src/sourmash/sourmash_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _load_database(filename, traverse_yield_all, *, cache_size=None):
debug_literal(f"_load_databases: FAIL on fn {desc}.")
debug_literal(traceback.format_exc())

if db:
if db is not None:
loaded = True
break

Expand Down

0 comments on commit 808ae37

Please sign in to comment.