From a44a5710b759f6608da35681e5905340ebc8da57 Mon Sep 17 00:00:00 2001 From: David Doty Date: Fri, 24 Jun 2022 10:36:37 -0700 Subject: [PATCH] fixes #181: rna_duplex_multiple causes KeyError with parallel=True --- nuad/vienna_nupack.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nuad/vienna_nupack.py b/nuad/vienna_nupack.py index 608f501f..3957e534 100644 --- a/nuad/vienna_nupack.py +++ b/nuad/vienna_nupack.py @@ -329,14 +329,14 @@ def rna_duplex_multiple(seq_pairs: Sequence[Tuple[str, str]], for i, energy, seq_pair in zip(idxs_to_calculate, energies_to_calculate, seq_pairs_to_calculate): energies[i] = energy if cache: - key = (seq_pair, temperature, parameters_filename) - _rna_duplex_cache[key] = energy - # clear out oldest cache key if _rna_duplex_queue is full if len(_rna_duplex_queue) == _rna_duplex_queue.maxlen: lru_item = _rna_duplex_queue[0] - del _rna_duplex_cache[lru_item] + if lru_item in _rna_duplex_cache: + del _rna_duplex_cache[lru_item] + key = (seq_pair, temperature, parameters_filename) + _rna_duplex_cache[key] = energy _rna_duplex_queue.append(key) return energies