diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py index 5fd5aa78db6a14f62cc5d106633e22856cdd9f8a..ff0fbfb78d5fd1583d0f4a298ee8efc7f4e822ba 100644 --- a/modules/mol/alg/pymod/ligand_scoring.py +++ b/modules/mol/alg/pymod/ligand_scoring.py @@ -725,7 +725,7 @@ class LigandScorer: return self._lddt_pli_details -def ResidueToGraph(residue, by_atom_index=False): +def _ResidueToGraph(residue, by_atom_index=False): """Return a NetworkX graph representation of the residue. :param residue: the residue from which to derive the graph @@ -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.mass`. + Nodes are labeled with the Atom's lowercase :attr:`~ost.mol.AtomHandle.element`. """ nxg = networkx.Graph() for atom in residue.atoms: - nxg.add_node(atom.name, element=atom.mass) + nxg.add_node(atom.name, element=atom.element.lower()) # 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. @@ -844,8 +844,8 @@ def _ComputeSymmetries(model_ligand, target_ligand, substructure_match=False, """ # Get the Graphs of the ligands - model_graph = ResidueToGraph(model_ligand, by_atom_index=by_atom_index) - target_graph = ResidueToGraph(target_ligand, by_atom_index=by_atom_index) + 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) @@ -891,4 +891,4 @@ class NoSymmetryError(Exception): pass -__all__ = ["LigandScorer", "ResidueToGraph", "SCRMSD", "NoSymmetryError"] +__all__ = ["LigandScorer", "SCRMSD", "NoSymmetryError"] diff --git a/modules/mol/alg/tests/test_ligand_scoring.py b/modules/mol/alg/tests/test_ligand_scoring.py index 1b2d1b2447a20a4fc9ccba9c517784175da4fdee..37aa4c51423d3c9ea4fb2d7b029e7e18c862c018 100644 --- a/modules/mol/alg/tests/test_ligand_scoring.py +++ b/modules/mol/alg/tests/test_ligand_scoring.py @@ -137,13 +137,13 @@ class TestLigandScoring(unittest.TestCase): """ mdl_lig = io.LoadEntity(os.path.join('testfiles', "P84080_model_02_ligand_0.sdf")) - graph = _ResidueToGraph(mdl_lig.residues[0]) + graph = ligand_scoring._ResidueToGraph(mdl_lig.residues[0]) assert len(graph.edges) == 34 assert len(graph.nodes) == 32 # Check an arbitrary node assert [a for a in graph.adj["14"].keys()] == ["13", "29"] - graph = _ResidueToGraph(mdl_lig.residues[0], by_atom_index=True) + graph = ligand_scoring._ResidueToGraph(mdl_lig.residues[0], by_atom_index=True) assert len(graph.edges) == 34 assert len(graph.nodes) == 32 # Check an arbitrary node