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

Fragmentation issue because of stereochem when the bond involves Sulfur

Open rvkrishnan30 opened this issue 4 years ago • 3 comments

Hi,

I bumped into the following issue while processing this sulfoxide compound ("O=S(c1ccc(Nc2nc(OCC3CCCCC3)c4c([nH]cn4)n2)cc1)C"). Dissecting the code looks like it builds fragments around all rotatable bonds without issue but raises the error when the bond involves sulfur. Please let me know if I am missing something trivial or if this is an edge case.

I also tried without specifying allow_undefined_stereo=True while loading the molecule but that immediately returned UndefinedStereochemistryError

UndefinedStereochemistryError: Unable to make OFFMol from RDMol: Unable to make OFFMol from SMILES: RDMol has unspecified stereochemistry. Undefined chiral centers are:
 - Atom S (index 1)

I am using fragmenter version: '0.1.2'

sample_mol = Molecule.from_smiles("O=S(c1ccc(Nc2nc(OCC3CCCCC3)c4c([nH]cn4)n2)cc1)C", allow_undefined_stereo=True)
result = frag_engine.fragment(sample_mol)
Warning (not error because allow_undefined_stereo=True): Unable to make OFFMol from RDMol: RDMol has unspecified stereochemistry. RDMol name: Undefined chiral centers are:
 - Atom S (index 18)

Warning (not error because allow_undefined_stereo=True): Unable to make OFFMol from RDMol: RDMol has unspecified stereochemistry. Undefined chiral centers are:
 - Atom S (index 7)

A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
Warning (not error because allow_undefined_stereo=True): Unable to make OFFMol from RDMol: RDMol has unspecified stereochemistry. Undefined chiral centers are:
 - Atom S (index 8)

A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
Warning (not error because allow_undefined_stereo=True): Unable to make OFFMol from RDMol: RDMol has unspecified stereochemistry. Undefined chiral centers are:
 - Atom S (index 11)

A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
Warning (not error because allow_undefined_stereo=True): Unable to make OFFMol from RDMol: RDMol has unspecified stereochemistry. Undefined chiral centers are:
 - Atom S (index 12)

A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
Warning (not error because allow_undefined_stereo=True): Unable to make OFFMol from RDMol: RDMol has unspecified stereochemistry. Undefined chiral centers are:
 - Atom S (index 13)

A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
Warning (not error because allow_undefined_stereo=True): Unable to make OFFMol from RDMol: RDMol has unspecified stereochemistry. Undefined chiral centers are:
 - Atom S (index 1)

A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
A new stereocenter formed at atom 19
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-18-e154dd498291> in <module>
----> 1 result = frag_engine.fragment(cdk2_31_from_smi)

~/miniconda3/envs/py39/lib/python3.9/site-packages/openff/fragmenter/fragment.py in fragment(self, molecule, target_bond_smarts, toolkit_registry)
    914         with global_toolkit_registry(toolkit_registry):
    915
--> 916             result = self._fragment(molecule, target_bond_smarts)
    917
    918             result.provenance["toolkits"] = [

~/miniconda3/envs/py39/lib/python3.9/site-packages/openff/fragmenter/fragment.py in _fragment(self, molecule, target_bond_smarts)
   1017         wbo_rotor_bonds = self._get_rotor_wbo(molecule, rotatable_bonds)
   1018
-> 1019         fragments = {
   1020             bond: self._build_fragment(
   1021                 molecule,

~/miniconda3/envs/py39/lib/python3.9/site-packages/openff/fragmenter/fragment.py in <dictcomp>(.0)
   1018
   1019         fragments = {
-> 1020             bond: self._build_fragment(
   1021                 molecule,
   1022                 stereochemistry,

~/miniconda3/envs/py39/lib/python3.9/site-packages/openff/fragmenter/fragment.py in _build_fragment(cls, parent, parent_stereo, parent_groups, parent_rings, bond_tuple, parent_wbo, threshold, heuristic, cap, **kwargs)
   1202         while fragment is not None and wbo_difference > threshold:
   1203
-> 1204             fragment, has_new_stereocenter = cls._add_next_substituent(
   1205                 parent,
   1206                 parent_stereo,

~/miniconda3/envs/py39/lib/python3.9/site-packages/openff/fragmenter/fragment.py in _add_next_substituent(cls, parent, parent_stereo, parent_groups, parent_rings, atoms, bonds, target_bond, heuristic)
   1407             neighbour_atom_and_bond = cls._select_neighbour_by_wbo(parent, atoms)
   1408         elif heuristic == "path_length":
-> 1409             neighbour_atom_and_bond = cls._select_neighbour_by_path_length(
   1410                 parent, atoms, target_bond
   1411             )

~/miniconda3/envs/py39/lib/python3.9/site-packages/openff/fragmenter/fragment.py in _select_neighbour_by_path_length(cls, molecule, atoms, target_bond)
   1262         target_indices = [get_atom_index(molecule, atom) for atom in target_bond]
   1263
-> 1264         path_lengths_1, path_lengths_2 = zip(
   1265             *(
   1266                 (

ValueError: not enough values to unpack (expected 2, got 0)

rvkrishnan30 avatar Nov 05 '21 16:11 rvkrishnan30

Thanks for the report and the reproducing example, @rvkrishnan30!

I ran this on my computer and also got the error. I also arbitrarily assigned stereochemistry to the sulfur and it ran successfully:

sample_mol = Molecule.from_smiles("O=[S@](c1ccc(Nc2nc(OCC3CCCCC3)c4c([nH]cn4)n2)cc1)C", allow_undefined_stereo=True)
result = frag_engine.fragment(sample_mol)

So, I think that this is either a bug, or we should update the docs to say that molecules must have all their stereo defined. I'll assume that it's a bug for now and we can see if our understanding changes as we fix it.

j-wags avatar Nov 06 '21 00:11 j-wags

@rvkrishnan30 as @j-wags mentions fragmenter expects that all stereochemistry be defined before feeding in a molecule, otherwise you will get undefined behaviour.

@j-wags feel free to on a PR - either to check for undefined stereo or add to the docs.

SimonBoothroyd avatar Nov 06 '21 08:11 SimonBoothroyd

Thank you @j-wags and @SimonBoothroyd. I'll make a note of it so we assign stereochemistry before passing a molecule to the fragmenter.

rvkrishnan30 avatar Nov 15 '21 14:11 rvkrishnan30