AutoREACTER v0.3: Functional group detection refactor and reaction library expansion - #103
Open
janitha-mahanthe wants to merge 175 commits into
Open
AutoREACTER v0.3: Functional group detection refactor and reaction library expansion#103janitha-mahanthe wants to merge 175 commits into
janitha-mahanthe wants to merge 175 commits into
Conversation
Introduces scaffold code for upcoming reaction workflow features: a new `ReactionProgression` processor module with a configurable `MAX_LOOP` constant and placeholder `reaction_progression` method, plus an `index_based_functional_groups_detector` placeholder in `FunctionalGroupsDetector`. These changes establish integration points without altering current behavior yet.
Introduce a new `species_pool.py` module with a `PoolSpecies` dataclass to represent reaction pool entries, including monomer flags, SMILES, RDKit molecule objects, and template atom indices. Add `_populate_mols(pool)` to build RDKit molecules from monomer SMILES and initialize `template_idxes` from atom indices, centralizing species preparation logic for downstream reaction processing.
Expand `PoolSpecies` docstring to list its key attributes, and clarify `_populate_mols` documentation to note that it fills both `mol` and `template_idxes` for monomer species derived from SMILES.
- Add fg_1_indexes and fg_2_indexes fields to FunctionalGroupInfo for storing matched atom indices - Expand functional group library with epoxy-amine polymerization entries (diepoxy, primary amine, secondary amine) with improved SMARTS and documentation - Update reaction_rules.json with required_fgs field for epoxy_polymerization - Add _add_progessive_chemistries stub in detected_chemistry_filter.py - Add warning_asci.py with ASCII warning banner for reaction progression beta loop
Copy loop monomer roles before extending them, and strip atom maps/isotopes from product molecules before sanitizing or generating SMILES.
Clean up whitespace, trailing spaces, and newlines throughout the file. Reorganize section comments for better clarity (e.g., rename '--- PUBLIC ---' and '--- PIPELINE STEPS (PRIVATE) ---' to more descriptive headers). Reorder `_detect_duplicates` and `_flatten_fg_indexes` methods. Add missing newline at end of file.
Refactors _get_product_index into _get_product_idxs, which now also returns the (possibly trimmed) product molecule. When a reaction produces multiple disconnected fragments, only the largest heavy-atom fragment is kept and product atom indices are remapped accordingly. Also fixes _clean_product to operate on a copy so the original molecule is not mutated, and updates _get_product_smiles to use the cleaned copy. Adds a glycine test example JSON.
Delete placeholder/incomplete files: empty functional_groups_rules.json, reaction_rules.json, detected_chemistry_filter.py (contained unfinished logic with syntax errors), and species_pool.py.
Introduces DeduplicationDetector, which converts LAMMPS molecule-template files to NetworkX graphs and uses graph isomorphism (matching atom and bond types) to identify duplicate pre/post reaction pairs.
Reworks deduplication to compare coupled pre/post graphs using normalized atom/bond labels, adds separate LAMMPS and RDKit comparison caches, and introduces RDKit molecule graph conversion for in-memory reaction metadata. Reaction progression now accumulates reactions across iterations, disables duplicates via dedup checks, skips inactive reactions downstream, and uses a session-level monotonic reaction ID counter so generated reaction CSV IDs remain globally unique across loop passes. Also updates LUNAR config to a concrete local root path and refreshes notebook debug output.
Clean up imports, variable names, docstrings, and formatting throughout reaction_progression.py. Replace debug prints with informative log messages, improve inline comments, and apply consistent style (trailing newline, line-length wrapping).
- Move MAX_LOOP constant below imports for clarity - Add MolSanitizeException import and improve sanitization error logging - Instantiate DeduplicationDetector once in __init__ instead of per-loop - Initialize all_prepared_reactions from session state to support resumption - Rename _set_is_monomer_flag to _set_is_looped_flag with proper scoping - Rename _length_of_active_reactions to _count_active_reactions with explicit parameter - Add _store_reactions helper to reduce duplication - Sync session.monomer_roles and session.reaction_metadata incrementally - Fix loop break condition to use pre-iteration pool size - Condense docstrings throughout
Updates the progression loop to track reactions through a single `all_prepared_reactions` list, keep `session.reaction_metadata` synchronized before and after deduplication, and base loop-break checks on the updated pool. It also simplifies list initialization typing, rewrites the method docstring for clarity, adds per-iteration reaction count logging, and replaces early return with a clean loop break followed by a single final return.
Introduces is_duplicate_pair() for topology-only comparison of (reactant, product) graph pairs without coupling them into a single graph or requiring cross-phase atom mapping. Updates compare_graphs_mol() to use this simpler approach and adds index_source parameter supporting 'template' or 'first_shell' atom-index selection. Also clears the new seen_reaction_pairs cache in reset_seen_reactions().
Remove redundant AddHs calls and mol copies for mol_reactant_1/2 in forced-reaction mode, and add swapped ordering for same-reactant cases so both orientations are tried.
Add comprehensive unit tests and refactor input parser and detectors
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.
This pull request introduces AutoREACTER v0.3, featuring a major overhaul of the reaction progression system, advanced index-based detection, and significantly expanded polymer reaction libraries.
[0.3.0] - 2026-08-21
Added
reaction_iteration_depthto control how many reaction-product iterations are attempted. The default value is5, and the loop can be disabled by settingreaction_iteration_depthtofalse.arx.session()to expose the active AutoREACTER session for workflow inspection.Changed
Fixed
Removed
Closes #27, closes #28, closes #30, closes #63, closes #64, closes #101, closes #104, closes #105, closes #106.