diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py index f0077b2bb7e71439f793049738e980b3ddc665c7..8ea683d80b960ff8d549b56cb7ca8838bd0d7199 100644 --- a/modules/mol/alg/pymod/ligand_scoring.py +++ b/modules/mol/alg/pymod/ligand_scoring.py @@ -720,8 +720,10 @@ def ResidueToGraph(residue, by_atom_index=False): Nodes are labeled with the Atom's :attr:`~ost.mol.AtomHandle.element`. """ nxg = networkx.Graph() - nxg.add_nodes_from([a.name for a in residue.atoms], element=[ - a.element for a in residue.atoms]) + + for atom in residue.atoms: + nxg.add_node(atom.name, element=atom.element) + # 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. nxg.add_edges_from([( diff --git a/modules/mol/alg/tests/test_ligand_scoring.py b/modules/mol/alg/tests/test_ligand_scoring.py index 7054b3ff8874077955cdb0f9815e384d9637f60e..d29f4e616389ba46d920fea16e08b78b90c782c3 100644 --- a/modules/mol/alg/tests/test_ligand_scoring.py +++ b/modules/mol/alg/tests/test_ligand_scoring.py @@ -175,7 +175,6 @@ class TestLigandScoring(unittest.TestCase): assert len(sym) == 6 # Substructure matches - self.skipTest("Substructure matches don't work yet") sym = ost.mol.alg.ligand_scoring._ComputeSymmetries(mdl_g3d, trg_g3d1_sub, substructure_match=True) assert len(sym) == 6 @@ -215,12 +214,18 @@ class TestLigandScoring(unittest.TestCase): self.assertAlmostEqual(rmsd, 0.293972, 5) # Assert that substructure matches work - self.skipTest("Substructure matches don't work yet") trg_g3d1_sub = trg_g3d1.Select("aindex>6019").residues[0] # Skip PA, PB and O[1-3]A and O[1-3]B. - mdl_g3d_sub = mdl_g3d.Select("aindex>1447").residues[0] # Skip PA, PB and O[1-3]A and O[1-3]B. + # mdl_g3d_sub = mdl_g3d.Select("aindex>1447").residues[0] # Skip PA, PB and O[1-3]A and O[1-3]B. with self.assertRaises(NoSymmetryError): SCRMSD(mdl_g3d, trg_g3d1_sub) # no full match + + # But partial match is OK rmsd = SCRMSD(mdl_g3d, trg_g3d1_sub, substructure_match=True) + self.assertAlmostEqual(rmsd, 2.2376232209353475e-06, 8) + + # Ensure it doesn't work the other way around - ie incomplete model is invalid + with self.assertRaises(NoSymmetryError): + SCRMSD(trg_g3d1_sub, mdl_g3d) # no full match def test__compute_scores(self): """Test that _compute_scores works.