orthonym.rules.ring_selection#

Note

Internal API. Names and behaviour may change between releases.

Ring system type classification, scoring, and selection per IUPAC.

Provides the foundation for correct principal ring system selection. Implements: - type hierarchy (RingSystemType enum) - general criteria (ring_system_score tuple) - Principal ring system selection (select_principal_ring_system)

These are pure functions that can be tested independently before integration.

Reference: IUPAC 2013 Blue Book, (Selection of Preferred Ring System)

class orthonym.rules.ring_selection.RingSystemType(*values)#

Bases: IntEnum

type hierarchy. Lower value = more senior.

IUPAC 2013: 1. Spiro ring systems 2. Cyclic phane parent hydrides 3. Fused ring systems 4. Bridged fused ring systems 5. Von Baeyer ring systems 6. Linear phane parent hydrides 7. Ring assemblies

MONOCYCLIC is not in but needed as fallback for simple rings.

SPIRO = 1#
CYCLIC_PHANE = 2#
FUSED = 3#
BRIDGED_FUSED = 4#
VON_BAEYER = 5#
LINEAR_PHANE = 6#
RING_ASSEMBLY = 7#
MONOCYCLIC = 8#
orthonym.rules.ring_selection.classify_ring_system_type(mol, ring_system_atoms)#

Classify a ring system into its type.

Reuses existing detection functions from the codebase, operating on a sub-molecule built from the ring system atoms when necessary.

Classification priority (same as _classify_complex_ring in composer.py): 1. Spiro junction detected -> SPIRO 2. Fused core + extra bridges -> BRIDGED_FUSED 3. Ortho-fused or ortho-peri-fused -> FUSED 4. Bicyclo or polycyclic bridged -> VON_BAEYER 5. Fallback -> MONOCYCLIC

Parameters:
  • mol (Mol) – RDKit Mol object (full molecule)

  • ring_system_atoms (Set[int]) – Set of atom indices belonging to this ring system

Returns:

RingSystemType enum value

Return type:

RingSystemType

orthonym.rules.ring_selection.ring_system_score(mol, system_atoms)#

Memoised per (mol object, ring-system atom set) within one naming call (Lever E, 2026-09-12). The key also carries what the score reads from the live molecule (element, aromatic flag and charge of the system’s atoms; type and aromatic flag of its bonds), so an in-place edit forces a recompute. See:func:_ring_system_score_impl for the scoring.

orthonym.rules.ring_selection.OFFER_OTHER_TIE_RING: ContextVar = <ContextVar name='orthonym_offer_other_tie_ring' default=0>#

0, or while the OTHER ring of a ring=CH-ring tie is offered as the parent (Orthonym._try_other_tie_ring_rescue): 1 below the PIN (decided False: the tie is not decided by the criteria of the book), 2 as the name that builds without that record (the label of the tier lowers what it cannot verify in full)

orthonym.rules.ring_selection.ring_assembly_outranks(mol, chosen_system)#

True when a ring assembly of mol is senior, as one ring system, to chosen_system.

(the Blue Book): “Seniority criteria for ring assemblies are based on the

appropriate criteria for rings and ring systems given in “, so an assembly stands in the seniority of ring systems as one system whose rings and skeletal atoms are the sums of its components (assembly.complex_ring_group.assembly_units); with equal criteria the type order of

(:19536) puts the fused ring system before the ring assembly, as the printed pair

‘benzo[8]annulene (PIN) > 1,1’-biphenyl (PIN) [fused ring system (c) > ring assembly (g)]’ (:19563) shows. ‘[1,1’-biphenyl]’ (2 rings, 12 skeletal atoms) is senior to naphthalene (2 rings, 10 skeletal atoms) by “ The senior ring or ring system has the greater number of skeletal atoms” (:19469), so the parent of a naphthalene with a biphenylyl group is the biphenyl and not the naphthalene. The score of each assembly is compared with the score of the chosen system; a tie is not senior.

The caller decides whether (a principal characteristic group, a chain) leaves the choice to.

orthonym.rules.ring_selection.record_junior_ring_parent(features, name)#

Take the PIN label away from name, a name the ring cascade built on the principal ring system of features, when a ring assembly that the name cites as a prefix is senior to that parent.

: a ring assembly is one ring system in the seniority of ring systems, and the parent of a molecule with no principal characteristic group (and no chain as the parent) is the senior ring or ring system: ‘[1,1’-biphenyl]’ (2 rings, 12 atoms) is senior to naphthalene (2 rings, 10 atoms). The cascade takes no assembly as one unit, so ‘2-([1,1’-biphenyl]-4-yl)naphthalene’ is a valid systematic name and not the PIN (ring_assembly_outranks()). Only the molecule that is named, not a part of it, and only a name that cites an assembly: a name that splits an assembly into its parts is the case of the spelling check (validation.spelling.checks_assembly), which already decides it.

orthonym.rules.ring_selection.select_principal_ring_system(mol, ring_systems, principal_group_atoms=None)#

Select the most senior ring system from a list of candidates.

Uses ring_system_score to compare candidates. The system with the minimum score tuple is the most senior hierarchy).

Parameters:
  • mol (Mol) – RDKit Mol object

  • ring_systems (List[Set[int]]) – List of sets, each set contains atom indices in one ring system (from get_ring_systems)

Returns:

Tuple of sorted atom indices of the most senior ring system, or empty tuple if no ring systems provided

Return type:

Tuple[int, …]

orthonym.rules.ring_selection.select_principal_ring_system_with_groups(features)#

select_principal_ring_system of the molecule, then: a ring system with more principal characteristic groups than the senior one is the parent instead (parent_selection. ring_system_with_most_groups).