From be65079039798de348b3c9a7650be697ae471ff3 Mon Sep 17 00:00:00 2001 From: Christopher Woods Date: Sat, 25 Feb 2023 14:05:48 +0000 Subject: [PATCH] Added another test for rdkit, and also fixed python wrapping from "to_r_d_kit" to "to_rdkit" This is a minor change that works locally. To save the CI, I will pull this into the next PR that I do to devel once I've developed the next feature. --- src/sire/_pythonize.py | 7 +++++-- tests/convert/test_rdkit.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/sire/_pythonize.py b/src/sire/_pythonize.py index 78180c2b6..9c1727991 100644 --- a/src/sire/_pythonize.py +++ b/src/sire/_pythonize.py @@ -89,6 +89,9 @@ def _pythonize(C, delete_old: bool = True) -> None: # converted to _mcs_matches by the code below) new_attr = new_attr.replace("MCSmatches", "Mcs_matches") + # change "RDKit" to "Rdkit" + new_attr = new_attr.replace("RDKit", "Rdkit") + # change "MCS" into "Mcs" (it will then be converted to _mcs by # the code below) new_attr = new_attr.replace("MCS", "Mcs") @@ -140,7 +143,7 @@ def _pythonize_modules(modules, delete_old: bool = True): import inspect try: - for (key, cls) in inspect.getmembers(MOD, inspect.isclass): + for key, cls in inspect.getmembers(MOD, inspect.isclass): _pythonize(cls, delete_old=delete_old) except Exception as e: print(e) @@ -276,7 +279,7 @@ def use_new_api(): Base, CAS, Cluster, - Convert, # does not need pythonizing, but importing will make it visible + Convert, # does not need pythonizing, but importing will make it visible Error, ID, Maths, diff --git a/tests/convert/test_rdkit.py b/tests/convert/test_rdkit.py index 459cb9295..09f563947 100644 --- a/tests/convert/test_rdkit.py +++ b/tests/convert/test_rdkit.py @@ -53,3 +53,27 @@ def test_hybridization(): else: print("WEIRD BONDS", n, bonds) assert False + + +def test_hybridization2(): + mol = sr.smiles("CN1C=NC2=C1C(=O)N(C(=O)N2C)C") + + expected = [ + "SP3", + "SP2", + "SP2", + "SP2", + "SP2", + "SP2", + "SP2", + "SP2", + "SP2", + "SP2", + "SP2", + "SP2", + "SP3", + "SP3", + ] + + for atom, e in zip(mol.atoms(), expected): + assert atom.property("hybridization").to_rdkit() == e