Skip to content

Commit

Permalink
fix(mi): fix interval lookup cache
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Nov 12, 2024
1 parent 6dffbb2 commit 6943a1b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions strkit/mi/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ def overlapping_loci_dict_of_dict(

global _overlapping_dict_cache

if dict_cache_key in _overlapping_dict_cache:
c_dict, c_keys, c_lhs = _overlapping_dict_cache[dict_cache_key]
full_cache_key = f"{dict_cache_key}--{contig}"

if full_cache_key in _overlapping_dict_cache:
c_dict, c_keys, c_lhs = _overlapping_dict_cache[full_cache_key]
else:
c_dict = d[contig]
c_keys = tuple(c_dict.keys())
c_lhs = tuple(map(lambda k: k[0], c_keys))
if dict_cache_key is not None:
_overlapping_dict_cache[dict_cache_key] = c_dict, c_keys, c_lhs
if full_cache_key is not None:
_overlapping_dict_cache[full_cache_key] = c_dict, c_keys, c_lhs

i = bisect.bisect_left(c_lhs, end) # use _left since end is exclusive

Expand Down

0 comments on commit 6943a1b

Please sign in to comment.