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
319 stars 93 forks source link

Warnings generated by OpenEye toolkits can be excessive/confusing/misleading #1044

Open mattwthompson opened 3 years ago

mattwthompson commented 3 years ago

Describe the bug

Reproduction

In [1]: from openff.toolkit.topology.molecule import Molecule

In [2]: mol = Molecule.from_smiles('CC=CC=CC(=O)OC1=CC=CC=C1C(=O)O', allow_undefined_stereo=True)
Warning (not error because allow_undefined_stereo=True): OEMol has unspecified stereochemistry. oemol.GetTitle():
Problematic bonds are: [<openeye.oechem.OEBondBase; proxy of <Swig Object of type 'OEChem::OEBondBase *' at 0x11e1c7960> >, <openeye.oechem.OEBondBase; proxy of <Swig Object of type 'OEChem::OEBondBase *' at 0x11e1cda80> >]

In [3]: mol.generate_conformers(n_conformers=1)
Warning: : Failed due to unspecified stereochemistry

In [4]: mol.n_conformers
Out[4]: 1

In [5]: mol.conformers[0]
Out[5]:
Quantity(value=array([[-2.30594444, -1.75135124, -3.48313022],
       [-2.54317665, -0.54324794, -2.63773489],
       [-1.73977768, -0.17122722, -1.63036156],
       [-1.97937584,  1.00191224, -0.81790221],
       [-1.16758895,  1.3621223 ,  0.18638656],
       [-1.37643135,  2.55530024,  1.04099178],
       [-2.33007193,  3.30592847,  0.87718451],
       [-0.37927055,  2.6723206 ,  1.99214149],
       [-0.54210973,  3.78750134,  2.81845474],
       [-1.28138351,  3.65863013,  3.99430442],
       [-1.45559835,  4.75964022,  4.83278847],
       [-0.89062071,  5.98954153,  4.49542904],
       [-0.15139963,  6.11838531,  3.3195436 ],
       [ 0.02281564,  5.01736689,  2.48106289],
       [ 0.79816675,  5.17367887,  1.25826538],
       [ 1.46357596,  4.28658581,  0.71636975],
       [ 0.71678895,  6.43313694,  0.75013441],
       [-2.80400872, -2.61910057, -3.04003692],
       [-2.68335104, -1.62572944, -4.50291014],
       [-1.23345554, -1.96176231, -3.53953886],
       [-3.42485547,  0.04619151, -2.8779676 ],
       [-0.86125511, -0.76810515, -1.39823592],
       [-2.86083508,  1.5878315 , -1.0626545 ],
       [-0.28621441,  0.77284825,  0.42606768],
       [-1.72429335,  2.70346379,  4.26318741],
       [-2.0312233 ,  4.65939903,  5.7483139 ],
       [-1.02642536,  6.84675837,  5.14836311],
       [ 0.28396326,  7.08196068,  3.06725001],
       [ 1.23525405,  6.5485301 , -0.07462908]]), unit=angstrom)

Specifically the output in block 3 is confusing and could be misleading to a newer user - what failed? Why is it a warning if something failed? I got a conformer back and it looks reasonable (in visualization, not just eyeballing coordinates). It's not obvious to the user that these are emitted by OpenEye or how they should be interpreted (or ignored).

Computing environment (please complete the following information):

Additional context I couldn't find an open issue about this, but I recall discussions about handling OpenEye output existing already. #596 is related but targeting a different idea.

mattwthompson commented 6 days ago

What @hmacdope wrote up here can hide these warnings from STDOUT/STDERR: https://github.com/asapdiscovery/asapdiscovery/issues/327

from openeye import oechem

errfs = oechem.oeofstream("openeye_My_Workflow_log.txt")
oechem.OEThrow.SetOutputStream(errfs)
oechem.OEThrow.SetLevel(oechem.OEErrorLevel_MIN)

This workaround is needed since they're emitted from OEChem's C++ layer not the standard Python logging locations

Two caveats (from me):

  1. This might blow away other actual errors so it’s a little dangerous to use outside of a case like this in which everything else is working
  2. There might be a better level than _MIN to use: https://docs.eyesopen.com/toolkits/python/oechemtk/OESystemConstants/OEErrorLevel.html#OESystem::OEErrorLevel

Hugo also says, referencing https://github.com/asapdiscovery/asapdiscovery/issues/281

Beware of trying to use OpenEye logging with OMEGA confgen in the same process as well. I did tell OpenEye about this, they may have fixed it in latest release.