-
Notifications
You must be signed in to change notification settings - Fork 249
Added a species constraint for the max number of rings fused together (revived) #2868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This feature was never merged into main and causes RMG to crush if specified Also removed here from the rmg2to3 script
89486d1 to
8aabf21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new species constraint maximumFusedRings to limit the complexity of ring systems in generated species, allowing users to exclude molecules with complex fused rings without restricting species based solely on molecular weight. The implementation correctly distinguishes between monocycles (single rings) and fused ring systems (multiple rings sharing edges), returning 0 for monocycles and the actual ring count for fused systems.
Key changes:
- Implemented
get_ring_count_in_largest_fused_ring_system()method inMoleculeclass to count rings within fused ring systems - Added
maximumFusedRingsconstraint to species constraint system with appropriate validation - Cleaned up documentation by removing references to the unimplemented
maximumIsotopicAtomsconstraint
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rmgpy/molecule/molecule.py | Adds new method to count rings in largest fused ring system using existing polycycle and SSSR methods |
| rmgpy/constraints.py | Integrates the new constraint check with early return optimization for acyclic molecules |
| rmgpy/rmg/input.py | Adds maximumFusedRings to list of valid species constraints |
| test/rmgpy/molecule/moleculeTest.py | Adds unit test covering acyclic, monocyclic, and fused ring molecules |
| documentation/source/users/rmg/input.rst | Documents the new constraint and removes unimplemented maximumIsotopicAtoms reference |
| examples/rmg/commented/input.py | Removes unimplemented maximumIsotopicAtoms from example |
| examples/rmg/MR_test/input.py | Removes unimplemented maximumIsotopicAtoms from example |
| documentation/source/users/rmg/modules/isotopes.rst | Removes documentation for unimplemented maximumIsotopicAtoms constraint |
| scripts/rmg2to3.py | Removes conversion mapping for unimplemented maximumIsotopicAtoms constraint |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| def get_ring_count_in_largest_fused_ring_system(self) -> int: | ||
| """ | ||
| Get the number of rings in the largest fused ring system in the molecule. |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring should clarify that monocycles (single rings) return 0 since they are not considered fused ring systems. Consider updating the docstring to: "Get the number of rings in the largest fused ring system in the molecule. Returns 0 if the molecule has no fused rings (only monocycles or no rings)."
| Get the number of rings in the largest fused ring system in the molecule. | |
| Get the number of rings in the largest fused ring system in the molecule. | |
| Returns 0 if the molecule has no fused rings (only monocycles or no rings). |
| Note that this should be done with caution, since the constraints will still apply to subsequent | ||
| products that form. | ||
|
|
||
| ``maximumFusedRings`` is the maximum number of rings in any fused ring system in the species. |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constraint name 'maximumFusedRings' suggests it counts fused rings (rings sharing edges), but the implementation also counts spirocyclic rings (rings sharing a single atom) since get_polycycles() returns both types. Consider clarifying in the documentation whether spirocyclic rings are intentionally included in this constraint, or if the behavior should be restricted to only fused rings.
| ``maximumFusedRings`` is the maximum number of rings in any fused ring system in the species. | |
| ``maximumFusedRings`` is the maximum number of rings in any fused or spirocyclic ring system in the species (i.e., it counts both fused rings, which share edges, and spirocyclic rings, which share a single atom). |
Motivation or Problem
(reviving abandoned PR #2606)
Sometimes users know they are not interested in ring growth in their model, yet RMG spends significant time on suggesting species with complex fused rings. Using the maximum heavy atoms constraints isn't always helpful since other species with the same Mw could be relevant for the model.
Description of Changes
Added a
maximumFusedRingskey to the constraints dict.A new method was implemented in Molecule along with a test.
Testing
A unit test was added.
FWIW, the feature was also tested locally by generating a model that previously gave many fused ring structures and verifying that they are absent now.
Reviewer Tips
Note that a previously non-implemented constraint was removed from the docs