openff-fragmenter icon indicating copy to clipboard operation
openff-fragmenter copied to clipboard

WBOFragmenter() Segmentation fault

Open and-tos opened this issue 6 months ago • 2 comments
trafficstars

When running WBOFragmenter, for a certain molecule I get the following warnings and then a SEGFAULT error. Unfortunately I cannot share the example, but maybe you have some suggestions on how to avoid the SEGFAULT. Maybe some sort of sanity check of the molecule before passing it to the fragmenter?

frag_engine = WBOFragmenter()
try:
    result = frag_engine.fragment(parent_molecule)
except:
    continue

Warning: Cannot perform Hydrogen sampling with GPU-Omega: GPU-Omega disabled.
Warning: OEMMFFParams::PrepMol() : unable to type atom 17 H on residue UNL-1
Warning: : Force field setup failed due to missing parameters
Warning: OEMMFFParams::PrepMol() : unable to type atom 17 H on residue UNL-1
Warning: : Force field setup failed due to missing parameters

and-tos avatar Apr 24 '25 08:04 and-tos

Hm, I'll need more information to help here. I tried to reproduce by passing in a molecule for which MMFF wouldn't have parameters (so I added tungsten) and while I could get the OEMMFFParams errors, I didn't get a segfault:

from openff.toolkit import Molecule
from openff.fragmenter.fragment import WBOFragmenter
mol = Molecule.from_smiles('CC[W]')
frag_engine = WBOFragmenter()
result = frag_engine.fragment(mol)

yields

Warning: OEMMFFParams::PrepMol() : unable to type atom 2 W on residue UNL-1
Warning: : Force field setup failed due to missing parameters
Warning: OEMMFFParams::PrepMol() : unable to type atom 2 W on residue UNL-1
Warning: : Force field setup failed due to missing parameters
[12:27:19] UFFTYPER: Unrecognized atom type: W_2 (2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jeffreywagner/micromamba/envs/bespokefit/lib/python3.12/site-packages/openff/fragmenter/fragment.py", line 903, in fragment
    result = self._fragment(molecule, target_bond_smarts)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffreywagner/micromamba/envs/bespokefit/lib/python3.12/site-packages/openff/fragmenter/fragment.py", line 998, in _fragment
    molecule = assign_elf10_am1_bond_orders(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffreywagner/micromamba/envs/bespokefit/lib/python3.12/site-packages/openff/fragmenter/chemi.py", line 43, in assign_elf10_am1_bond_orders
    molecule.apply_elf_conformer_selection()
  File "/Users/jeffreywagner/micromamba/envs/bespokefit/lib/python3.12/site-packages/openff/toolkit/topology/molecule.py", line 2497, in apply_elf_conformer_selection
    toolkit_registry.call(
  File "/Users/jeffreywagner/micromamba/envs/bespokefit/lib/python3.12/site-packages/openff/toolkit/utils/toolkit_registry.py", line 266, in call
    raise e
  File "/Users/jeffreywagner/micromamba/envs/bespokefit/lib/python3.12/site-packages/openff/toolkit/utils/toolkit_registry.py", line 262, in call
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffreywagner/micromamba/envs/bespokefit/lib/python3.12/site-packages/openff/toolkit/utils/openeye_wrapper.py", line 2387, in apply_elf_conformer_selection
    raise RuntimeError(
RuntimeError: OpenEye failed to select conformers, but did not return any output. This most commonly occurs when the Molecule does not have enough conformers to select from. Try calling Molecule.apply_elf_conformer_selection() again after running Molecule.generate_conformers() with a much larger value of n_conformers or with make_carboxylic_acids_cis=True.

Can you provide a reproducing case with a publicly available molecule?

j-wags avatar Apr 24 '25 19:04 j-wags

I was able to generate a shareable, minimal example. The two SMILES differ by a methoxy group. The first example without a OMe works, the second, with a OMe crashes.

from openff.toolkit import Molecule
from openff.fragmenter.fragment import WBOFragmenter
 # this works
parent_molecule = Molecule.from_smiles(
    "S(=O)(=O)([N-]c1ccccc1)c1ccccc1", allow_undefined_stereo=True
)
frag_engine = WBOFragmenter()
result = frag_engine.fragment(parent_molecule)

# this does not work
parent_molecule = Molecule.from_smiles(
    "S(=O)(=O)([N-]c1ccccc1)c1c(OC)cccc1", allow_undefined_stereo=True
)
frag_engine = WBOFragmenter()
result = frag_engine.fragment(parent_molecule)

and-tos avatar May 02 '25 10:05 and-tos