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
309 stars 90 forks source link

find_rotatable_bonds is biased toward input kekule form/bond orders #907

Open j-wags opened 3 years ago

j-wags commented 3 years ago

Describe the bug

This molecule is symmetric, so it should have either 0 or 8 rotatable bonds.

image

The toolkit (both backends) reports that it has 4.

from openff.toolkit.topology import Molecule
mol = Molecule.from_smiles('[O-]C=CC=CC=CC=CC=O', allow_undefined_stereo=True)
print(len(mol.find_rotatable_bonds()))

4

Desired fixes

Computing environment (please complete the following information):

Additional context

The initial implementation, which works quite well for most cases, is here: https://github.com/openforcefield/openff-toolkit/pull/506

j-wags commented 3 years ago

On the plus side, both backends do seem to do the right thing for the resonance forms of amide bonds

from openff.toolkit.topology import Molecule
mol = Molecule.from_smiles('CNC(=O)C')
mol.visualize()
mol.chemical_environment_matches('[!$(*#*)&!D1:1]-&!@[!$(*#*)&!D1:2]')
mol2 = Molecule.from_smiles('C/[N+]=C(\[O-])C')
mol2.visualize()
mol.find_rotatable_bonds()
Screen Shot 2021-07-14 at 1 20 35 PM