From ca664e4d539d8d3fb9057108bc65c5439697b762 Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavier.robin@unibas.ch>
Date: Wed, 26 Jul 2023 13:46:18 +0200
Subject: [PATCH] feat: SCHWED-5954 report type of isomorphism

---
 modules/mol/alg/pymod/ligand_scoring.py      | 13 +++++++++++--
 modules/mol/alg/tests/test_ligand_scoring.py |  6 +++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py
index 2a462b78d..41e906649 100644
--- a/modules/mol/alg/pymod/ligand_scoring.py
+++ b/modules/mol/alg/pymod/ligand_scoring.py
@@ -1466,7 +1466,11 @@ class LigandScorer:
                             "target ligand (different stoichiometry)")
 
         # Could not be assigned to any ligand - must be different
-        return ("identity", "Ligand was not found in the target (by isomorphism)")
+        if self.substructure_match:
+            iso = "subgraph isomorphism"
+        else:
+            iso = "full graph isomorphism"
+        return ("identity", "Ligand was not found in the target (by %s)" % iso)
 
     def _find_unassigned_target_ligand_reason(self, ligand, assignment="lddt_pli", check=True):
         # Is this a target ligand?
@@ -1519,8 +1523,13 @@ class LigandScorer:
                 # Could have been assigned but was assigned to a different ligand
                 return ("stoichiometry", "Ligand was assigned to an other "
                         "model ligand (different stoichiometry)")
+
         # Could not be assigned to any ligand - must be different
-        return ("identity", "Ligand was not found in the model (by isomorphism)")
+        if self.substructure_match:
+            iso = "subgraph isomorphism"
+        else:
+            iso = "full graph isomorphism"
+        return ("identity", "Ligand was not found in the model (by %s)" % iso)
 
 
 def _ResidueToGraph(residue, by_atom_index=False):
diff --git a/modules/mol/alg/tests/test_ligand_scoring.py b/modules/mol/alg/tests/test_ligand_scoring.py
index de7abda0c..7207a3225 100644
--- a/modules/mol/alg/tests/test_ligand_scoring.py
+++ b/modules/mol/alg/tests/test_ligand_scoring.py
@@ -572,7 +572,7 @@ class TestLigandScoring(unittest.TestCase):
             'L_NA': {1: ('binding_site',
                          'No residue in proximity of the target ligand')},
             'L_OXY': {1: ('identity',
-                          'Ligand was not found in the target (by isomorphism)')},
+                          'Ligand was not found in the target (by full graph isomorphism)')},
             'L_MG_2': {1: ('stoichiometry',
                            'Ligand was assigned to an other target ligand (different stoichiometry)')},
             "L_CMO": {1: ('disconnected',
@@ -580,13 +580,13 @@ class TestLigandScoring(unittest.TestCase):
         }
         assert sc.unassigned_target_ligands == {
             'G': {1: ('identity',
-                      'Ligand was not found in the model (by isomorphism)')},
+                      'Ligand was not found in the model (by full graph isomorphism)')},
             'H': {1: ('model_representation',
                       'No representation of the reference binding site was found in the model')},
             'J': {1: ('stoichiometry',
                       'Ligand was assigned to an other model ligand (different stoichiometry)')},
             'K': {1: ('identity',
-                      'Ligand was not found in the model (by isomorphism)')},
+                      'Ligand was not found in the model (by full graph isomorphism)')},
             'L_NA': {1: ('binding_site',
                          'No residue in proximity of the target ligand')},
             "L_CMO": {1: ('disconnected',
-- 
GitLab