Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions test/rmgpy/data/thermoTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,11 +2102,11 @@ def test_is_bicyclic1(self):
The test molecule is bicyclic, we expect is_bicyclic()
returns True.
"""
smiles = "C1=CCC2C1=C2"
mol = Molecule().from_smiles(smiles)
polyring = mol.get_disparate_cycles()[1][0]

assert is_bicyclic(polyring)
for smiles in ["C1=CCC2C1=C2", "C1=CC2C=CC1=CC2", "C1=CC2C=CC=1C=C2"]:
mol = Molecule().from_smiles(smiles)
polyrings = mol.get_disparate_cycles()[1]
assert len(polyrings) == 1
assert is_bicyclic(polyrings[0])

def test_is_bicyclic2(self):
"""
Expand Down Expand Up @@ -2272,6 +2272,32 @@ def test_bicyclic_decomposition_for_polyring_using_alkane_tricyclic(self):
expected_aromatic_bond_num_in_bicyclics = [0, 0, 0]
assert aromatic_bond_num_in_bicyclics == expected_aromatic_bond_num_in_bicyclics

def test_deterministic_bicyclic_decomposition(self):
"""
Test that the decomposition of a polyring into bicyclics and then into single rings
is deterministic. This is important because the thermo estimation depends on the
order of the rings. Currently this is not guaranteed, so if this test fails, we
just skip it.

See https://github.com/ReactionMechanismGenerator/RMG-Py/issues/2562
"""
mol = Molecule(smiles="C1=CC2C=CC=1C=C2")
polyrings = mol.get_disparate_cycles()[1]
assert len(polyrings) == 1
assert rmgpy.data.thermo.is_bicyclic(polyrings[0])
polyring = polyrings[0]
submol = rmgpy.data.thermo.convert_ring_to_sub_molecule(polyring)[0]
rings = rmgpy.data.thermo.split_bicyclic_into_single_rings(submol)
assert len(rings) == 2
ring_smiles = [ring.to_smiles() for ring in rings]
for smiles in ring_smiles:
assert smiles in ["C1C=CC=C=C1", "C1C=CCC=C1"]
# Ensure that the order is the same every time
try:
assert ring_smiles == ["C1C=CC=C=C1", "C1C=CCC=C1"]
except AssertionError as e:
pytest.skip(f"Skipping because not yet deterministic (#2562): {e}")

def test_combine_cycles(self):
"""
This method tests the combine_cycles method, which simply joins two lists
Expand Down
Loading