127 def __init__(self, model, target, model_ligands, target_ligands,
128 resnum_alignments=False, rename_ligand_chain=False,
129 substructure_match=False, coverage_delta=0.2,
130 max_symmetries=1e5, bs_radius=4.0, lddt_lp_radius=15.0,
131 model_bs_radius=25, binding_sites_topn=100000,
132 full_bs_search=False, min_pep_length = 6,
133 min_nuc_length = 4, pep_seqid_thr = 95.,
135 mdl_map_pep_seqid_thr = 0.,
136 mdl_map_nuc_seqid_thr = 0.,
138 trg_seqres_mapping=None):
140 super().
__init__(model, target, model_ligands, target_ligands,
141 resnum_alignments = resnum_alignments,
142 rename_ligand_chain = rename_ligand_chain,
143 substructure_match = substructure_match,
144 coverage_delta = coverage_delta,
145 max_symmetries = max_symmetries,
146 min_pep_length = min_pep_length,
147 min_nuc_length = min_nuc_length,
148 pep_seqid_thr = pep_seqid_thr,
149 nuc_seqid_thr = nuc_seqid_thr,
150 mdl_map_pep_seqid_thr = mdl_map_pep_seqid_thr,
151 mdl_map_nuc_seqid_thr = mdl_map_nuc_seqid_thr,
153 trg_seqres_mapping = trg_seqres_mapping)
176 "No residues were in proximity of the "
178 self.
state_decoding[11] = (
"model_binding_site",
"Binding site was not"
179 " found in the model, i.e. the binding site"
180 " was not modeled or the model ligand was "
181 "positioned too far in combination with "
182 "full_bs_search=False.")
184 "Unknown error occured in SCRMSDScorer")
186 def _compute(self, symmetries, target_ligand, model_ligand):
187 """ Implements interface from parent
190 best_rmsd_result = {
"rmsd":
None,
192 "bs_ref_res": list(),
193 "bs_ref_res_mapped": list(),
194 "bs_mdl_res_mapped": list(),
196 "target_ligand": target_ligand,
197 "model_ligand": model_ligand,
198 "chain_mapping": dict(),
200 "inconsistent_residues": list()}
202 representations = self.
_get_repr(target_ligand, model_ligand)
204 msg =
"Computing BiSyRMSD with %d chain mappings" % len(representations)
205 (LogWarning
if len(representations) > 10000
else LogInfo)(msg)
207 for r
in representations:
209 target_ligand, transformation=r.transform)
211 if best_rmsd_result[
"rmsd"]
is None or \
212 rmsd < best_rmsd_result[
"rmsd"]:
213 best_rmsd_result = {
"rmsd": rmsd,
215 "bs_ref_res": r.substructure.residues,
216 "bs_ref_res_mapped": r.ref_residues,
217 "bs_mdl_res_mapped": r.mdl_residues,
218 "bb_rmsd": r.bb_rmsd,
219 "target_ligand": target_ligand,
220 "model_ligand": model_ligand,
221 "chain_mapping": r.GetFlatChainMapping(),
222 "transform": r.transform,
223 "inconsistent_residues":
224 r.inconsistent_residues}
226 target_ligand_state = 0
227 model_ligand_state = 0
230 if best_rmsd_result[
"rmsd"]
is not None:
231 best_rmsd = best_rmsd_result[
"rmsd"]
239 target_ligand_state = 10
240 elif len(representations) == 0:
243 return (best_rmsd, pair_state, target_ligand_state, model_ligand_state,
285 ref_residues_hashes = set()
286 ignored_residue_hashes = {target_ligand.hash_code}
287 for ligand_at
in target_ligand.atoms:
288 close_atoms = self.
targettarget.FindWithin(ligand_at.GetPos(),
290 for close_at
in close_atoms:
292 ref_res = close_at.GetResidue()
293 h = ref_res.handle.GetHashCode()
294 if h
not in ref_residues_hashes
and \
295 h
not in ignored_residue_hashes:
296 with ligand_scoring_base._SinkVerbosityLevel(1):
299 h = ref_res.handle.GetHashCode()
300 ref_residues_hashes.add(h)
301 elif ref_res.is_ligand:
302 msg = f
"Ignoring ligand {ref_res.qualified_name} "
303 msg +=
"in binding site of "
304 msg += str(target_ligand.qualified_name)
306 ignored_residue_hashes.add(h)
307 elif ref_res.chem_type == mol.ChemType.WATERS:
310 msg = f
"Ignoring residue {ref_res.qualified_name} "
311 msg +=
"in binding site of "
312 msg += str(target_ligand.qualified_name)
314 ignored_residue_hashes.add(h)
317 if ref_residues_hashes:
322 for r
in ch.residues:
323 if r.handle.GetHashCode()
in ref_residues_hashes:
324 ref_bs.AddResidue(r, mol.ViewAddFlag.INCLUDE_ALL)
325 if len(ref_bs.residues) == 0:
326 raise RuntimeError(
"Failed to add proximity residues to "
327 "the reference binding site entity")
341 for at
in mdl_ligand.atoms:
342 with ligand_scoring_base._SinkVerbosityLevel(1):
345 for close_at
in close_atoms:
346 chains.add(close_at.GetChain().GetName())
349 LogVerbose(
"%d chains are in proximity of the model ligand: %s" % (
350 len(chains),
", ".join(chains)))
354 query +=
','.join([mol.QueryQuoteName(x)
for x
in chains])
358 chem_mapping = list()
360 chem_mapping.append([x
for x
in m
if x
in chains])