Skip to content

Commit

Permalink
add warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jthorton committed Dec 3, 2024
1 parent 3ecd5a0 commit 72f6bf5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gufe/components/smallmoleculecomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# For details, see https://github.com/OpenFreeEnergy/gufe

import logging
import warnings

# openff complains about oechem being missing, shhh
logger = logging.getLogger("openff.toolkit")
Expand Down Expand Up @@ -282,6 +283,9 @@ def _from_dict(cls, d: dict):
try:
a.SetHybridization(_INT_TO_HYBRIDIZATION[atom[7]])
except IndexError:
warnings.warn("The atom hybridization data was not found and has been set to unspecified. This can be"
" fixed by recreating the SmallMoleculeComponent from the rdkit molecule after running "
"sanitization.")
pass

em.AddAtom(a)
Expand Down
3 changes: 2 additions & 1 deletion gufe/tests/test_smallmoleculecomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ def test_from_dict_missing_hybridization(self, phenol):
# remove the hybridization atomic info which should be at index 7
new_atoms.append(tuple([atom_info for i, atom_info in enumerate(atom) if i != 7]))
phenol_dict["atoms"] = new_atoms
new_phenol = SmallMoleculeComponent.from_dict(phenol_dict)
with pytest.warns(match="The atom hybridization data was not found and has been set to unspecified."):
new_phenol = SmallMoleculeComponent.from_dict(phenol_dict)
# they should be different objects due to the missing hybridization info
assert new_phenol != phenol
# make sure the rdkit objects are different
Expand Down

0 comments on commit 72f6bf5

Please sign in to comment.