Fixes the atom mapper placing hydrogens on the wrong heavy atom (issue #1032). - #1041
Merged
Merged
Conversation
Collaborator
Author
|
Linked issue #1032 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1041 +/- ##
==========================================
- Coverage 65.69% 65.55% -0.14%
==========================================
Files 121 121
Lines 41015 41073 +58
Branches 10548 10566 +18
==========================================
- Hits 26946 26927 -19
- Misses 11060 11115 +55
- Partials 3009 3031 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
calvinp0
reviewed
Sep 7, 2026
| if not backbone_constraint: | ||
| return candidates | ||
| filtered = [c for c in candidates if all(c.get(k) == v for k, v in backbone_constraint.items())] | ||
| if not filtered: |
Member
There was a problem hiding this comment.
before falling back to unconstrained candidates, could we retyr the backbone search with the template correspondences fixed? like for CH2 + allene -> methylenecyclopropane, it appears there is a valid constraint compatible permutation exists, but the current search misses it.
calvinp0
approved these changes
Sep 7, 2026
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.
When a reaction involves a symmetric fragment, several atom-map candidates tie on every geometric score, so the choice was made arbitrarily and then corrected after the fact,
glue_mapsforced the family template's labeled atoms into position by transposing them, but applied that swap only to the labeled atoms themselves, stranding the hydrogens bonded to them. The result was a map where the carbons are right and their hydrogens are attached to each other's carbon, implying spurious C–H breaks and formations.The fix moves the template constraint upstream so nothing needs patching afterwards, at the two places the arbitrary choice was being made: fragment pairing now breaks ties between isomorphic cuts in favor of the one sharing the most template tags, and backbone-candidate selection filters to candidates satisfying the labeled-atom assignment before they're scored. Both new parameters are optional and default to the previous behavior, so existing callers are unaffected.
On the issue's two reactions the misplaced-hydrogen count goes 8 → 0, and across a 10-reaction probe spanning
Diels_alder_addition, 2+2_cycloaddition, Disproportionation and H_Abstraction, the four cases where the template override previously degraded the map drop to zero — including a degenerate abstraction that main maps as "no reaction at all."