From bd50ec078d1eb515413bdc0bedb68c4621e1c21e Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Sat, 24 Feb 2024 06:07:48 +0200 Subject: [PATCH 1/6] Removed maximumIsotopicAtoms from the documentation and examples This feature was never merged into main and causes RMG to crush if specified Also removed here from the rmg2to3 script --- documentation/source/users/rmg/input.rst | 1 - documentation/source/users/rmg/modules/isotopes.rst | 4 ---- examples/rmg/MR_test/input.py | 2 -- examples/rmg/commented/input.py | 2 -- scripts/rmg2to3.py | 1 - 5 files changed, 10 deletions(-) diff --git a/documentation/source/users/rmg/input.rst b/documentation/source/users/rmg/input.rst index e9198d568d4..152b93060b2 100644 --- a/documentation/source/users/rmg/input.rst +++ b/documentation/source/users/rmg/input.rst @@ -1021,7 +1021,6 @@ all of RMG's reaction families. :: maximumRadicalElectrons=2, maximumSingletCarbenes=1, maximumCarbeneRadicals=0, - maximumIsotopicAtoms=2, allowSingletO2 = False, speciesCuttingThreshold=20, ) diff --git a/documentation/source/users/rmg/modules/isotopes.rst b/documentation/source/users/rmg/modules/isotopes.rst index fda03e0fc9f..e567a1fc6d4 100644 --- a/documentation/source/users/rmg/modules/isotopes.rst +++ b/documentation/source/users/rmg/modules/isotopes.rst @@ -49,10 +49,6 @@ not match the same depository reactions, leading to inconsistent kinetics. If degeneracy errors arise when generating reactions from scratch, try using this option to see if it reduces errors in degeneracy. -The arguement ``--maximumIsotopicAtoms [integer]`` limits the number of enriched -atoms in any isotopologue in the model. This is beneficial for decreasing model -size, runtime of model creation and runtime necessary for analysis. - Adding kinetic isotope effects which are described in this paper can be obtained through the argument ``--kineticIsotopeEffect simple``. Currently this is the only supported method, though this can be extended to other effects. diff --git a/examples/rmg/MR_test/input.py b/examples/rmg/MR_test/input.py index 39f9e4d0fcf..1079a64d81c 100644 --- a/examples/rmg/MR_test/input.py +++ b/examples/rmg/MR_test/input.py @@ -305,7 +305,5 @@ #If this is false or missing, RMG will throw an error if the more less-stable form of O2 is entered #which doesn't react in the RMG system. normally input O2 as triplet with SMILES [O][O] #allowSingletO2=False, - # maximum allowed number of non-normal isotope atoms: - #maximumIsotopicAtoms=2, ) diff --git a/examples/rmg/commented/input.py b/examples/rmg/commented/input.py index 0d6c78b5fea..3eb24f5e37e 100644 --- a/examples/rmg/commented/input.py +++ b/examples/rmg/commented/input.py @@ -287,8 +287,6 @@ # If this is false or missing, RMG will throw an error if the more less-stable form of O2 is entered # which doesn't react in the RMG system. normally input O2 as triplet with SMILES [O][O] # allowSingletO2=False, - # maximum allowed number of non-normal isotope atoms: - # maximumIsotopicAtoms=2, ) # optional block allows thermo to be estimated through quantum calculations diff --git a/scripts/rmg2to3.py b/scripts/rmg2to3.py index a2e9a3db005..211dbfdfac7 100644 --- a/scripts/rmg2to3.py +++ b/scripts/rmg2to3.py @@ -1796,7 +1796,6 @@ # rmgpy.tools.isotopes 'useOriginalReactions': 'use_original_reactions', 'kineticIsotopeEffect': 'kinetic_isotope_effect', - 'maximumIsotopicAtoms': 'maximum_isotopic_atoms', # rmgpy.tools.loader 'generateImages': 'generate_images', 'useJava': 'use_java', From da2921f428f5c0bd49bee5596e1a5c8ebf777f1f Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Wed, 7 Feb 2024 11:28:15 +0200 Subject: [PATCH 2/6] Added the maximumAdditionalFusedRings constraint to the docs --- documentation/source/users/rmg/input.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/documentation/source/users/rmg/input.rst b/documentation/source/users/rmg/input.rst index 152b93060b2..79049b909c3 100644 --- a/documentation/source/users/rmg/input.rst +++ b/documentation/source/users/rmg/input.rst @@ -1021,6 +1021,7 @@ all of RMG's reaction families. :: maximumRadicalElectrons=2, maximumSingletCarbenes=1, maximumCarbeneRadicals=0, + maximumFusedRings=3, allowSingletO2 = False, speciesCuttingThreshold=20, ) @@ -1030,6 +1031,8 @@ from either the input file, seed mechanisms, or reaction libraries to bypass the 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. + By default, the ``allowSingletO2`` flag is set to ``False``. See :ref:`representing_oxygen` for more information. Note that ``speciesCuttingThreshold`` is set by default to 20 heavy atoms. This means that if a species containing From 17fc2a2b0af1dee8a843d21b9a2dd2b555e86ffe Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Wed, 7 Feb 2024 13:17:25 +0200 Subject: [PATCH 3/6] Added get_ring_count_in_largest_fused_ring_system() to Molecule --- rmgpy/molecule/molecule.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/rmgpy/molecule/molecule.py b/rmgpy/molecule/molecule.py index 1a32f07adde..475a23c0802 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -3002,6 +3002,35 @@ def get_desorbed_molecules(self): return desorbed_molecules + 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. + """ + cython.declare(polycycles=list, sssr=list, sssr_sets=list, ring_counts=list) + cython.declare(polycycle=list, ring=list) + + polycycles = self.get_polycycles() + if not polycycles: + return 0 + + sssr = self.get_smallest_set_of_smallest_rings() + if not sssr: + return 0 + + sssr_sets = [set(r) for r in sssr] + + ring_counts = list() + for polycycle in polycycles: + poly_set = set(polycycle) + ring_count = 0 + for ring_set in sssr_sets: + if ring_set.issubset(poly_set): + ring_count += 1 + ring_counts.append(ring_count) + + return max(ring_counts) if ring_counts else 0 + + # this variable is used to name atom IDs so that there are as few conflicts by # using the entire space of integer objects atom_id_counter = -2 ** 15 From 732a01eeb8c33fbd81e5303541ef45e6e9b0aac8 Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Sat, 2 Mar 2024 19:47:15 +0200 Subject: [PATCH 4/6] Tests: Molecule.get_ring_count_in_largest_fused_ring_system() --- test/rmgpy/molecule/moleculeTest.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/rmgpy/molecule/moleculeTest.py b/test/rmgpy/molecule/moleculeTest.py index 9621d6fc7d4..7d6622665e0 100644 --- a/test/rmgpy/molecule/moleculeTest.py +++ b/test/rmgpy/molecule/moleculeTest.py @@ -3043,3 +3043,14 @@ def test_remove_van_der_waals_bonds(self): assert len(mol.get_all_edges()) == 2 mol.remove_van_der_waals_bonds() assert len(mol.get_all_edges()) == 1 + + def test_get_ring_count_in_largest_fused_ring_system(self): + """Test that we can count the rings in the largest fused ring system.""" + mol = Molecule(smiles="CCCC") + assert mol.get_ring_count_in_largest_fused_ring_system() == 0 + mol = Molecule(smiles="c1ccccc1") + assert mol.get_ring_count_in_largest_fused_ring_system() == 0 + mol = Molecule(smiles="c12ccccc1cccc2") + assert mol.get_ring_count_in_largest_fused_ring_system() == 2 + mol = Molecule(smiles="C[C]1C2C(=O)C3CC4C(=O)C=C2CC143") + assert mol.get_ring_count_in_largest_fused_ring_system() == 4 From b0b49ff94044b8fe89d2aec8ebee3c8984007274 Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Wed, 7 Feb 2024 12:56:47 +0200 Subject: [PATCH 5/6] Minor: Style modification in constraints.py --- rmgpy/constraints.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rmgpy/constraints.py b/rmgpy/constraints.py index d00d1ca43bf..be7f950f4ce 100644 --- a/rmgpy/constraints.py +++ b/rmgpy/constraints.py @@ -31,6 +31,7 @@ from rmgpy.species import Species + def pass_cutting_threshold(species): """ Pass in either a `Species` or `Molecule` object and checks whether it passes @@ -58,6 +59,7 @@ def pass_cutting_threshold(species): return False + def fails_species_constraints(species): """ Pass in either a `Species` or `Molecule` object and checks whether it passes From 8aabf21bc958b25cc52e224ba7c1add04acf055b Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Wed, 7 Feb 2024 12:57:15 +0200 Subject: [PATCH 6/6] Added the maximumFusedRings species constraint --- rmgpy/constraints.py | 5 +++++ rmgpy/rmg/input.py | 1 + 2 files changed, 6 insertions(+) diff --git a/rmgpy/constraints.py b/rmgpy/constraints.py index be7f950f4ce..2f2aa56c5ea 100644 --- a/rmgpy/constraints.py +++ b/rmgpy/constraints.py @@ -141,4 +141,9 @@ def fails_species_constraints(species): if struct.get_singlet_carbene_count() > 0 and struct.get_radical_count() > max_carbene_radicals: return True + max_fused_rings = species_constraints.get('maximumFusedRings', -1) + if max_fused_rings != -1 and struct.is_cyclic(): + if struct.get_ring_count_in_largest_fused_ring_system() > max_fused_rings: + return True + return False diff --git a/rmgpy/rmg/input.py b/rmgpy/rmg/input.py index 8c34e815d45..c818b22e2c2 100644 --- a/rmgpy/rmg/input.py +++ b/rmgpy/rmg/input.py @@ -1415,6 +1415,7 @@ def generated_species_constraints(**kwargs): 'maximumRadicalElectrons', 'maximumSingletCarbenes', 'maximumCarbeneRadicals', + 'maximumFusedRings', 'allowSingletO2', 'speciesCuttingThreshold', ]