From 115656427de0e26b9a6ec678d3ce0333828f69fb Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavier.robin@unibas.ch>
Date: Tue, 24 Jan 2023 16:49:48 +0100
Subject: [PATCH] feat: SCHWED-5783 raise if ligands are not connected

---
 modules/mol/alg/pymod/ligand_scoring.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py
index 3b7a20f71..51187eb5d 100644
--- a/modules/mol/alg/pymod/ligand_scoring.py
+++ b/modules/mol/alg/pymod/ligand_scoring.py
@@ -834,6 +834,11 @@ def _ComputeSymmetries(model_ligand, target_ligand, substructure_match=False,
     model_graph = ResidueToGraph(model_ligand, by_atom_index=by_atom_index)
     target_graph = ResidueToGraph(target_ligand, by_atom_index=by_atom_index)
 
+    if not networkx.is_connected(model_graph):
+        raise RuntimeError("Disconnected graph for model ligand %s" % model_ligand)
+    if not networkx.is_connected(target_graph):
+        raise RuntimeError("Disconnected graph for target ligand %s" % target_ligand)
+
     # Note the argument order (model, target) which differs from spyrmsd.
     # This is because a subgraph of model is isomorphic to target - but not the opposite
     # as we only consider partial ligands in the reference.
-- 
GitLab