Skip to content

Conversation

@alongd
Copy link
Member

@alongd alongd commented Dec 12, 2025

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 maximumFusedRings key 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

Copy link

Copilot AI left a 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 in Molecule class to count rings within fused ring systems
  • Added maximumFusedRings constraint to species constraint system with appropriate validation
  • Cleaned up documentation by removing references to the unimplemented maximumIsotopicAtoms constraint

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.
Copy link

Copilot AI Dec 12, 2025

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)."

Suggested change
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).

Copilot uses AI. Check for mistakes.
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.
Copy link

Copilot AI Dec 12, 2025

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.

Suggested change
``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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants