Perceive connectivity from Mayer bond orders (mol_from_dft) - #953
Open
kfir4444 wants to merge 1 commit into
Open
Perceive connectivity from Mayer bond orders (mol_from_dft)#953kfir4444 wants to merge 1 commit into
kfir4444 wants to merge 1 commit into
Conversation
This was referenced Aug 10, 2026
| The first entry is ``None`` if the molecule could not be perceived, both entries are ``None`` | ||
| if the log file does not contain Mayer bond orders. | ||
| """ | ||
| from arc.parser.parser import parse_bond_orders, parse_geometry |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## mayer_bond_orders_g16_route #953 +/- ##
===============================================================
- Coverage 63.62% 63.60% -0.02%
===============================================================
Files 114 114
Lines 38443 38505 +62
Branches 10052 10071 +19
===============================================================
+ Hits 24461 24493 +32
- Misses 11061 11076 +15
- Partials 2921 2936 +15
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:
|
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.
Stack 3/5 — based on #952 (which is based on #951). This is the substantive PR of the stack.
What
in
arc.species.converter. Both molecules preserve the log file's atom order and may hold several disconnected fragments (use.split()).mol— the perceived molecule with its bond orders.single_bond_mol— the same Mayer-derived connectivity with every bond set to order 1. Useful for connectivity-only isomorphism, and available even where no valid Lewis structure exists — e.g. a bridging H at a TS, which is genuinely bivalent in the graph.Returns
(None, None)when the log has no Mayer bond orders, so callers can fall back.How
perceive_molecule_from_xyz()gains two optional arguments, both defaulting to today's behaviour:bondsreplaces the distance-matrix step and is authoritative. The fragment count follows from it rather than fromn_fragments, and_add_interfragment_bonds()is suppressed — otherwise genuinely separate fragments would be glued back together by the nearest-atom heuristic.bond_ordersseeds multiple bonds throughround_bond_order()(≥ 2.5 → 3, ≥ 1.5 → 2, else 1; thresholds sit midway between formal bond orders because computed orders of delocalized bonds fall between them). The seeded structure is kept only ifis_mol_valid()accepts it; otherwise the existinggenerate_lewis_structure()A* search runs on the same connectivity.So the computed bond orders are honoured wherever they are chemically consistent, and can never yield an invalid molecule.
Results on the fixtures
OCc1ccon1— the correct isoxazole Kekulé structure, from Mayer orders of 1.56 (C=N), 1.60 (C=C) and 1.20 (C–C)C=C(C)COOCC(=C)C— both C=C preservedC=O(Mayer 2.14)C.[OH]at the default threshold; at 0.3 the single-bond graph shows the H bridging C and OThe aromatic ring is the case worth noting: a distance-based criterion has no way to assign those bond orders.
Implementation note
converter.pymust import the parser lazily inside the function body —arc/parser/parser.pyimportsstr_to_xyzfromconverter, so a module-level import is circular. This is the same idiomstr_to_xyzitself already uses.Testing
pytest arc/species/— 303 passed. New tests covermol_from_dftagainst all four logs above, atom-order preservation, the single-bond copy having an identical edge set with all orders 1, andperceive_molecule_from_xyz(bonds=...)overriding the distance heuristic.🤖 Generated with Claude Code