From eff7027e755d90a6120ef090188313674868f5b5 Mon Sep 17 00:00:00 2001 From: bieniekmat Date: Sun, 27 Oct 2024 17:06:30 +0000 Subject: [PATCH] When more than 2 molecules are used with TIES, the tried strategies are breaking down. Specifically, some of them have no suggestions, meaning that no pairs are removed even though the net q has not been reached. --- ties/topology_superimposer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ties/topology_superimposer.py b/ties/topology_superimposer.py index dc04a5f..7e243f2 100644 --- a/ties/topology_superimposer.py +++ b/ties/topology_superimposer.py @@ -1394,11 +1394,13 @@ def _smart_netqtol_pair_picker(self, strategy): diff_sorted = self._sort_pairs_into_categories_qnettol(diff_q_pairs, best_cases_num=len(self)) # for other strategies, take the key directly, but only if there is one - if diff_sorted[strategy]: + if strategy in diff_sorted: pairs_in_category = diff_sorted[strategy] - else: + + if strategy not in diff_sorted or len(pairs_in_category) == 0: # if there is no option in that category, revert to greedy pairs_in_category = diff_sorted['greedy'] + return pairs_in_category[0] def _sort_pairs_into_categories_qnettol(self, pairs, best_cases_num=6):