Repository navigation
Stop OpenEyeToolkitWrapper from erroring on planar trivalent nitrogens if they have trivalent carbon neighbors - #2231
Conversation
for more information, see https://pre-commit.ci
…elax-oe-nitrogen-stereo
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
|
Fingers crossed that the docs build issues are transient - I'll try a rebuild after the long weekend. |
Yoshanuikabundi
left a comment
There was a problem hiding this comment.
I've found one class of false negatives introduced by this change, but am unsure how much of a dealbreaker this is. Otherwise, LGTM! The DrugBank entries removed from the test files is very pleasing. The tests look right to me and pass.
New false negative
(by false negative, I mean an inarguably chiral molecule that is allowed to be constructed with ambiguous stereochemistry without the allow_undefined_stereo switch turned on)
If it's important that all chiral molecules be detected, then I believe this change introduces a failure mode in the form of bridgehead amines in conjugated systems such as Troger's base. This is a bridgehead, which makes it pyramidal, but is still bonded to an sp2 carbon, so I believe it would be detected as chiral before this change but slip by after this change. As this change is advertised as reducing overpolicing, it might be surprising or undesirable that it introduces a false negative.
You can see this by adding
# Troger's base (bridgehead conjugated tertiary amine)
("c1(ccc3c(c1)C[N@]4c2ccc(cc2C[N@]3C4)C)C", ["S", "R"], None),
("c1(ccc3c(c1)CN4c2ccc(cc2CN3C4)C)C", [None, None], "unspecified stereochemistry"),to the test_smiles_nitrogen_chirality_skip parametrization and changing [expected_stereo] to expected_stereo in the test body. The first new line succeeds both before and after the change, and the second succeeds only before the change.
My only proffered alternative (that I'm not sure is in scope or rises to the level of a suggestion) is that we could go further. There's an argument that basically all tertiary amines are achiral, as the planar ones are planar and the pyramidal ones interconvert rapidly. This seems to be what's suggested by the "spec for undefined chemistry" issue's table (#146, line with SMILES N(Cl)(F)C).
We could follow RDKit's example and specify that a chiral tertiary nitrogen must either be in a 3-membered ring or be a bridgehead.
|
Thanks for the thorough look! I've spent a while on this, and while these are good ideas, I think we should lock in the reasonable gains here and leave the bigger improvements for later. A big thing to note is that native RDKit doesn't consider the nitrogens in Troger's base to be stereogenic (reproducing case below), even though they're meaningful stereocenters (tertiary N with a conjugated bond is never considered a stereocenter, bridgehead or not rdkit#7434). So while this PR introduces a false negative in I think we can do better, but in a subsequent PR. It's tempting to reimplement RDKit's rules in OETKW, but it's not clear to me that it's an unambiguous win given the complexity around user expectations and the philosophy of each ecosystem. For now I'll add the tests you suggested, with the undefined-stereo Troger's base case marked as a Reproducing case (RDKit 2026.03.1)from rdkit import Chem
from openff.toolkit import Molecule
from openff.toolkit.utils import RDKitToolkitWrapper
troger = "c1(ccc3c(c1)CN4c2ccc(cc2CN3C4)C)C"
print(list(Chem.FindPotentialStereo(Chem.MolFromSmiles(troger)))) # []
Molecule.from_smiles(troger, toolkit_registry=RDKitToolkitWrapper()) # no UndefinedStereochemistryError
# Even specified N stereo is dropped:
m = Molecule.from_smiles("c1(ccc3c(c1)C[N@]4c2ccc(cc2C[N@]3C4)C)C", toolkit_registry=RDKitToolkitWrapper())
print([a.stereochemistry for a in m.atoms if a.symbol == "N"]) # [None, None] |
for more information, see https://pre-commit.ci
…elax-oe-nitrogen-stereo # Conflicts: # openff/toolkit/_tests/test_toolkits.py
|
This is ready to merge as-is. But I'll try to fix tests first. |
|
Closed/reopened to kick CI |
OpenEyeToolkitWrapper.from_openeyenot raise an undefined-stereo error/warning for planar Ns if they have at least one trivalent carbon neighbor (This isn't a perfect solution but does cover a large fraction of the annoying over-policing of nitrogen stereo by OETKW)