From 9ddc4b1ca129542211bb2959111a6234a49ae0f0 Mon Sep 17 00:00:00 2001 From: Xavier Robin <xavier.robin@unibas.ch> Date: Wed, 31 May 2023 11:16:21 +0200 Subject: [PATCH] fix: compute chain mapping only once --- modules/mol/alg/pymod/ligand_scoring.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py index bd305432f..3d9467bf6 100644 --- a/modules/mol/alg/pymod/ligand_scoring.py +++ b/modules/mol/alg/pymod/ligand_scoring.py @@ -278,6 +278,7 @@ class LigandScorer: # lazily precomputed variables self._binding_sites = {} + self.__model_mapping = None @property def chain_mapper(self): @@ -291,6 +292,13 @@ class LigandScorer: resnum_alignments=self.resnum_alignments) return self._chain_mapper + @property + def _model_mapping(self): + """Get the global chain mapping for the model.""" + if self.__model_mapping is None: + self.__model_mapping = self.chain_mapper.GetMapping(self.model) + return self.__model_mapping + @staticmethod def _extract_ligands(entity): """Extract ligands from entity. Return a list of residues. @@ -453,10 +461,9 @@ class LigandScorer: # Find the representations if self.global_chain_mapping: - mapping_res = self.chain_mapper.GetMapping(self.model) self._binding_sites[ligand.hash_code] = self.chain_mapper.GetRepr( ref_bs, self.model, inclusion_radius=self.lddt_lp_radius, - global_mapping = mapping_res) + global_mapping = self._model_mapping) else: self._binding_sites[ligand.hash_code] = self.chain_mapper.GetRepr( ref_bs, self.model, inclusion_radius=self.lddt_lp_radius, -- GitLab