Repository navigation
Preserve chirality when merging explicit Hs in MergeQueryHs - #9676
Open
barlowa124 wants to merge 2 commits into
Open
barlowa124 wants to merge 2 commits into
barlowa124 wants to merge 2 commits into
Conversation
Merging an explicit H neighbor into a chiral atom's query dropped the chiral tag entirely: updateProps() copies the property dictionary but not d_chiralTag, so the tag was lost when the atom was replaced by a QueryAtom. The merged query then matched both enantiomers. Carry the chiral tag across the replacement, and flip the tag when removing the H bonds changes the parity of the remaining bond order -- the same fixup removeHs() already performs per removal. Fixes rdkit#9675 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issue
Fixes #9675
What does this implement/fix? Explain your changes.
MolOps::mergeQueryHsdropped chirality when an explicit H neighbor of a tetrahedral stereo center was merged into the parent's query. Two things combine here.When the parent atom was not already a query atom, it was replaced by a
QueryAtomviaupdateProps(). That call copies the property dictionary but notd_chiralTag, so the tag was lost outright.And removing the H bonds changes the order of the remaining bonds about the center, which can flip the parity the tag encodes.
removeHs()already compensates for this per removal (getPerturbationOrder+invertChirality). The merge path did not.The change carries the tag across the replacement and applies the same parity fixup, computed over the kept bonds plus the removed bonds appended in original order.
The reported L-alanine case now keeps a chiral tag on the merged atom, and with
useChiralityon the query matchesC[C@@H](N)C(=O)Owhile rejectingC[C@H](N)C(=O)O. A regression test covers both assertions.Any other comments?
graphmolMolOpsTestpasses all 116 test cases andmolopsTestsCatchpasses 16/16, run withRDBASEset. The Python-side check from the issue was not run (no py312 bindings on this machine). The C++ test asserts the same behavior.