Skip to content

Problem generating conformer when stereochemistry explicitly defined #669

Open
@trevorgokey

Description

@trevorgokey

Describe the bug
Generating a conformer for this SMILES fails in both OE/RD, but it seems like all stereocenters are specified:

from  openforcefield.topology.molecule import Molecule
mol = Molecule.from_smiles('C=CCn1c([C@@H]2C[C@@H]3CC[C@@H]2O3)nnc1N1CCN(c2ccccc2)CC1')
mol.generate_conformers()

For RDKit, it silently fails (and is the reason I am submitting this bug report):

~/projects/openforcefield/openforcefield/topology/molecule.py in generate_conformers(self, toolkit_registry, n_conformers, rms_cutoff, clear_existing)
   2604                 n_conformers=n_conformers,
   2605                 rms_cutoff=rms_cutoff,
-> 2606                 clear_existing=clear_existing,
   2607             )
   2608         elif isinstance(toolkit_registry, ToolkitWrapper):

~/projects/openforcefield/openforcefield/utils/toolkits.py in call(self, method_name, raise_exception_types, *args, **kwargs)
   4413                     for exception_type in raise_exception_types:
   4414                         if isinstance(e, exception_type):
-> 4415                             raise e
   4416                     errors.append((toolkit, e))
   4417 

~/projects/openforcefield/openforcefield/utils/toolkits.py in call(self, method_name, raise_exception_types, *args, **kwargs)
   4409                 method = getattr(toolkit, method_name)
   4410                 try:
-> 4411                     return method(*args, **kwargs)
   4412                 except Exception as e:
   4413                     for exception_type in raise_exception_types:

~/projects/openforcefield/openforcefield/utils/toolkits.py in generate_conformers(self, molecule, n_conformers, rms_cutoff, clear_existing)
   2854             molecule._conformers = list()
   2855 
-> 2856         for conformer in molecule2._conformers:
   2857             molecule._add_conformer(conformer)
   2858 

TypeError: 'NoneType' object is not iterable

and for OE we have some logic in the TK I don't fully understand:

       # Set atom stereochemistry now that all connectivity is in place
       for atom, oeatom in zip(molecule.atoms, oemol_atoms):
           if not atom.stereochemistry:
               continue

           # Set arbitrary initial stereochemistry
           neighs = [n for n in oeatom.GetAtoms()]
           oeatom.SetStereo(neighs, oechem.OEAtomStereo_Tetra,
                            oechem.OEAtomStereo_Right)

           # Flip chirality if stereochemistry isincorrect
           oeatom_stereochemistry = OpenEyeToolkitWrapper._openeye_cip_atom_stereochemistry(
               oemol, oeatom)
           if oeatom_stereochemistry != atom.stereochemistry:
               # Flip the stereochemistry
               oeatom.SetStereo(neighs, oechem.OEAtomStereo_Tetra,
                                oechem.OEAtomStereo_Left)
               # Verify it matches now as a sanity check
               oeatom_stereochemistry = OpenEyeToolkitWrapper._openeye_cip_atom_stereochemistry(
                   oemol, oeatom)
               if oeatom_stereochemistry != atom.stereochemistry:
                   raise Exception(
                       'Programming error: OpenEye atom stereochemistry assumptions failed.'
                   )

It throws the above exception during conformer generation (openforcefield/openforcefield/utils/toolkits.py:1377)

Is there something I am missing about this molecule that makes stereochemistry ambiguous/difficult to generate a conformer for? I'll think about it more, but wanted to post for extra eyes.

Expected output

For RDKit, a more descriptive error. For OE, a description of the assumptions that were in place that failed.

Additional context
The SMILES above with chirality specified was generated from RDKit isomer enumeration based on C=CCN1C(C2CC3CCC2O3)=NN=C1N1CCN(C2=CC=CC=C2)CC1 which is an entry in the Enamine REAL dataset.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions