openforcefield / openff-toolkit

The Open Forcefield Toolkit provides implementations of the SMIRNOFF format, parameterization engine, and other tools. Documentation available at http://open-forcefield-toolkit.readthedocs.io
http://openforcefield.org
MIT License
301 stars 88 forks source link

Generating conformers with some single ions in OpenEye results in additional ghost atoms #1892

Open lilyminium opened 2 weeks ago

lilyminium commented 2 weeks ago

Describe the bug

I thought this was an interesting if very low priority bug somewhere in OpenFF <-> OpenEye communication. On some single atom ions, OpenEye generates conformer coordinates in the wrong shape, likely additional hydrogens but I haven't looked into it.

To Reproduce

from openff.toolkit import Molecule
from openff.toolkit.utils import OpenEyeToolkitWrapper

mol = Molecule.from_smiles("[S-2]")
mol.generate_conformers(toolkit_registry=OpenEyeToolkitWrapper())

Output

Warning: Could not add explicit hydrogens in 

---------------------------------------------------------------------------
InvalidConformerError                     Traceback (most recent call last)
Cell In[22], line 1
----> 1 mol.generate_conformers(toolkit_registry=OpenEyeToolkitWrapper())

File ~/micromamba/envs/openff-nagl-test/lib/python3.10/site-packages/openff/toolkit/topology/molecule.py:2282, in FrozenMolecule.generate_conformers(self, toolkit_registry, n_conformers, rms_cutoff, clear_existing, make_carboxylic_acids_cis)
   2280 elif isinstance(toolkit_registry, ToolkitWrapper):
   2281     toolkit = toolkit_registry
-> 2282     return toolkit.generate_conformers(  # type: ignore[attr-defined]
   2283         self,
   2284         n_conformers=n_conformers,
   2285         rms_cutoff=rms_cutoff,
   2286         clear_existing=clear_existing,
   2287         make_carboxylic_acids_cis=make_carboxylic_acids_cis,
   2288     )
   2289 else:
   2290     raise InvalidToolkitRegistryError(
   2291         "Invalid toolkit_registry passed to generate_conformers. Expected ToolkitRegistry or ToolkitWrapper. "
   2292         f"Got {type(toolkit_registry)}"
   2293     )

File ~/micromamba/envs/openff-nagl-test/lib/python3.10/site-packages/openff/toolkit/utils/openeye_wrapper.py:2201, in OpenEyeToolkitWrapper.generate_conformers(self, molecule, n_conformers, rms_cutoff, clear_existing, make_carboxylic_acids_cis)
   2198     molecule._conformers = list()
   2200 for conformer in molecule2._conformers:
-> 2201     molecule._add_conformer(conformer)
   2203 if make_carboxylic_acids_cis:
   2204     molecule._make_carboxylic_acids_cis(toolkit_registry=self)

File ~/micromamba/envs/openff-nagl-test/lib/python3.10/site-packages/openff/toolkit/topology/molecule.py:3036, in FrozenMolecule._add_conformer(self, coordinates)
   3021 """
   3022 Add a conformation of the molecule
   3023 
   (...)
   3033     The index of this conformer
   3034 """
   3035 if coordinates.shape != (self.n_atoms, 3):
-> 3036     raise InvalidConformerError(
   3037         "molecule.add_conformer given input of the wrong shape: "
   3038         f"Given {coordinates.shape}, expected {(self.n_atoms, 3)}"
   3039     )
   3041 if isinstance(coordinates, Quantity):
   3042     if not coordinates.units.is_compatible_with(unit.angstrom):

InvalidConformerError: molecule.add_conformer given input of the wrong shape: Given (3, 3), expected (1, 3)

Computing environment (please complete the following information):

Additional context