Skip to content
Snippets Groups Projects
Verified Commit 9ddc4b1c authored by Xavier Robin's avatar Xavier Robin
Browse files

fix: compute chain mapping only once

parent b5ec0d9e
No related branches found
No related tags found
No related merge requests found
...@@ -278,6 +278,7 @@ class LigandScorer: ...@@ -278,6 +278,7 @@ class LigandScorer:
# lazily precomputed variables # lazily precomputed variables
self._binding_sites = {} self._binding_sites = {}
self.__model_mapping = None
@property @property
def chain_mapper(self): def chain_mapper(self):
...@@ -291,6 +292,13 @@ class LigandScorer: ...@@ -291,6 +292,13 @@ class LigandScorer:
resnum_alignments=self.resnum_alignments) resnum_alignments=self.resnum_alignments)
return self._chain_mapper 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 @staticmethod
def _extract_ligands(entity): def _extract_ligands(entity):
"""Extract ligands from entity. Return a list of residues. """Extract ligands from entity. Return a list of residues.
...@@ -453,10 +461,9 @@ class LigandScorer: ...@@ -453,10 +461,9 @@ class LigandScorer:
# Find the representations # Find the representations
if self.global_chain_mapping: if self.global_chain_mapping:
mapping_res = self.chain_mapper.GetMapping(self.model)
self._binding_sites[ligand.hash_code] = self.chain_mapper.GetRepr( self._binding_sites[ligand.hash_code] = self.chain_mapper.GetRepr(
ref_bs, self.model, inclusion_radius=self.lddt_lp_radius, ref_bs, self.model, inclusion_radius=self.lddt_lp_radius,
global_mapping = mapping_res) global_mapping = self._model_mapping)
else: else:
self._binding_sites[ligand.hash_code] = self.chain_mapper.GetRepr( self._binding_sites[ligand.hash_code] = self.chain_mapper.GetRepr(
ref_bs, self.model, inclusion_radius=self.lddt_lp_radius, ref_bs, self.model, inclusion_radius=self.lddt_lp_radius,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment