From c0adadf70095e5336ea1134c91747953d10ab079 Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavier.robin@unibas.ch>
Date: Wed, 24 Apr 2024 11:26:21 +0200
Subject: [PATCH] fix: prevent combination of global chain mapping and
 full_bs_search=False

These are two independent ways to speed up the processing but they
make no sense in combination and could lead to unexpected effects.
---
 modules/mol/alg/pymod/ligand_scoring.py | 33 ++++++++++---------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py
index b389e4ae1..d360d4eb1 100644
--- a/modules/mol/alg/pymod/ligand_scoring.py
+++ b/modules/mol/alg/pymod/ligand_scoring.py
@@ -265,6 +265,7 @@ class LigandScorer:
                            `unassigned_*_ligands` property will be
                            `model_representation` and is indistinguishable from
                            cases where the binding site was not modeled at all.
+                           Ignored when `global_chain_mapping` is True.
     :type full_bs_search: :class:`bool`
     """
     def __init__(self, model, target, model_ligands=None, target_ligands=None,
@@ -1802,28 +1803,20 @@ class LigandScorer:
             key = (target_ligand.handle.hash_code, model_ligand.handle.hash_code)
 
         if key not in self._repr:
-            reprs = list()
             ref_bs = self.get_target_binding_site(target_ligand)
-            if self.full_bs_search:
-                if self.global_chain_mapping:
-                    reprs = self.chain_mapper.GetRepr(
-                        ref_bs, self.model, inclusion_radius=self.lddt_lp_radius,
-                        global_mapping = self._model_mapping)
-                else:
-                    reprs = self.chain_mapper.GetRepr(
-                        ref_bs, self.model, inclusion_radius=self.lddt_lp_radius,
-                        topn=self.binding_sites_topn)
+            if self.global_chain_mapping:
+                reprs = self.chain_mapper.GetRepr(
+                    ref_bs, self.model, inclusion_radius=self.lddt_lp_radius,
+                    global_mapping = self._model_mapping)
+            elif self.full_bs_search:
+                reprs = self.chain_mapper.GetRepr(
+                    ref_bs, self.model, inclusion_radius=self.lddt_lp_radius,
+                    topn=self.binding_sites_topn)
             else:
-                if self.global_chain_mapping:
-                    reprs = self.chain_mapper.GetRepr(ref_bs, self.model,
-                                                     inclusion_radius=self.lddt_lp_radius,
-                                                     chem_mapping_result = self.get_get_repr_input(model_ligand),
-                                                     global_mapping = self._model_mapping)
-                else:
-                    reprs = self.chain_mapper.GetRepr(ref_bs, self.model,
-                                                      inclusion_radius=self.lddt_lp_radius,
-                                                      topn=self.binding_sites_topn,
-                                                      chem_mapping_result = self.get_get_repr_input(model_ligand))
+                reprs = self.chain_mapper.GetRepr(ref_bs, self.model,
+                                                  inclusion_radius=self.lddt_lp_radius,
+                                                  topn=self.binding_sites_topn,
+                                                  chem_mapping_result = self.get_get_repr_input(model_ligand))
             self._repr[key] = reprs
             if len(reprs) == 0:
                 # whatever is in there already has precedence
-- 
GitLab