Skip to content

Commit

Permalink
Added another test for rdkit, and also fixed python wrapping from "to…
Browse files Browse the repository at this point in the history
…_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.
  • Loading branch information
chryswoods committed Feb 25, 2023
1 parent 352c338 commit be65079
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/sire/_pythonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions tests/convert/test_rdkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit be65079

Please sign in to comment.