Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 12 additions & 4 deletions rmgpy/molecule/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2681,13 +2681,21 @@ def get_smallest_set_of_smallest_rings(self, symmetrized=False):
return_mapping=False,
save_order=True,
ignore_bond_orders=True)

rdkit_mol.UpdatePropertyCache(strict=False)
ranks = list(Chem.CanonicalRankAtoms(rdkit_mol, breakTies=True))
rank_to_idx = {rank: idx for idx, rank in enumerate(ranks)}
new_order = [rank_to_idx[i] for i in range(rdkit_mol.GetNumAtoms())]
canonical_mol = Chem.RenumberAtoms(rdkit_mol, new_order)
if symmetrized:
ring_info = Chem.GetSymmSSSR(rdkit_mol)
ring_info = Chem.GetSymmSSSR(canonical_mol)
else:
ring_info = Chem.GetSSSR(rdkit_mol)
ring_info = Chem.GetSSSR(canonical_mol)

for ring in ring_info:
atom_ring = [self.atoms[idx] for idx in ring]
# Map the new canonical indices back to the original RMG atom indices
original_idx_ring = [new_order[idx] for idx in ring]
atom_ring = [self.atoms[idx] for idx in original_idx_ring]

sorted_ring = self.sort_cyclic_vertices(atom_ring)
sssr.append(sorted_ring)
if symmetrized:
Expand Down
4 changes: 2 additions & 2 deletions test/rmgpy/molecule/moleculeTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3172,8 +3172,8 @@ def test_get_all_polycyclic_vertices(self):
""")
polycyclic_vertices = mol.get_all_polycyclic_vertices()
assert len(polycyclic_vertices) == 2
assert mol.atoms[0] is mol.get_all_polycyclic_vertices()[0]
assert mol.atoms[1] is mol.get_all_polycyclic_vertices()[1]
assert mol.atoms[0] is mol.get_all_polycyclic_vertices()[1]
assert mol.atoms[1] is mol.get_all_polycyclic_vertices()[0]

# Spirocyclic molecule
mol = Molecule().from_adjacency_list("""
Expand Down
Loading