From 1d2abe08cfb158d862d8a2ec00f482decb6afad6 Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavalias-github@xavier.robin.name>
Date: Mon, 30 Jan 2023 15:44:40 +0100
Subject: [PATCH] fix: SCHWED-5783 element case is unspecified in OST

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

diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py
index 3ff13d926..5fd5aa78d 100644
--- a/modules/mol/alg/pymod/ligand_scoring.py
+++ b/modules/mol/alg/pymod/ligand_scoring.py
@@ -738,12 +738,12 @@ def ResidueToGraph(residue, by_atom_index=False):
     :type by_atom_index: :class:`bool`
     :rtype: :class:`~networkx.classes.graph.Graph`
 
-    Nodes are labeled with the Atom's :attr:`~ost.mol.AtomHandle.element`.
+    Nodes are labeled with the Atom's :attr:`~ost.mol.AtomHandle.mass`.
     """
     nxg = networkx.Graph()
 
     for atom in residue.atoms:
-        nxg.add_node(atom.name, element=atom.element)
+        nxg.add_node(atom.name, element=atom.mass)
 
     # This will list all edges twice - once for every atom of the pair.
     # But as of NetworkX 3.0 adding the same edge twice has no effect, so we're good.
diff --git a/modules/mol/alg/tests/test_ligand_scoring.py b/modules/mol/alg/tests/test_ligand_scoring.py
index 335242008..1546ae688 100644
--- a/modules/mol/alg/tests/test_ligand_scoring.py
+++ b/modules/mol/alg/tests/test_ligand_scoring.py
@@ -167,6 +167,11 @@ class TestLigandScoring(unittest.TestCase):
         sym = ost.mol.alg.ligand_scoring._ComputeSymmetries(mdl_g3d, trg_g3d1, by_atom_index=True)
         assert len(sym) == 72
 
+        # Test that we can match ions read from SDF
+        sdf_lig = io.LoadEntity(os.path.join('testfiles', "1r8q_ligand_0.sdf"))
+        sym = ost.mol.alg.ligand_scoring._ComputeSymmetries(trg_mg1, sdf_lig.residues[0], by_atom_index=True)
+        assert len(sym) == 1
+
         # Test that it works with views and only consider atoms in the view
         # Skip PA, PB and O[1-3]A and O[1-3]B in target and model
         # We assume atom index are fixed and won't change
-- 
GitLab