orthonym.rules.macrocycle_orientation#
Note
Internal API. Names and behaviour may change between releases.
Numbering of a more-than-ten-membered heteromonocycle for replacement (“a”) nomenclature.
Moved out of rules/heterocycles.py (a FILES entry of the size baseline) with its one helper; the
numbering rule is unchanged except for the suffix set, below.
NUMBERING (the Blue Book): when there is a choice, low locants go to, in this order, the
heteroatoms (a-b), “(c) principal characteristic groups and free valences (suffixes)” (:3256), then the hydro/ene endings. Lactones (the Blue Book): “(1) as heterocyclic pseudoketones by adding the suffix ‘one’, ‘dione’… Method (1) gives preferred IUPAC names”, so the C=O of a ring lactone, lactam and ketone are all ‘-one’ suffix carbons of ONE set.
The defect this fixes: the suffix set handed in held the atoms of the perceived principal group only (the
lactone: its carbonyl carbon, the ring oxygen and the alkyl carbon, which are symmetric between the two
directions), so a second ring C=O (a ketone beside the lactone) never entered the comparison, the ties fell
to the ene locant, and the ring was numbered the other way round: ‘1-oxacyclotetradec-4-ene-2,4-dione’ for
a 14-membered lactone whose double bond is C11=C12 (the 4-ene collides with the 4-one; the oxo/ene guard
held the name back). The suffix set is now exactly the ring carbonyl carbons whenever the principal group sits
on the ring (rules.partial_saturation._ring_carbonyl_carbons: ketone, lactam and lactone carbonyls, “all
named with the -one suffix”); the lactone’s ring oxygen and alkyl carbon are not suffix atoms.
- orthonym.rules.macrocycle_orientation.orient_macrocycle_for_replacement(mol, ring_atoms, principal_group_atoms=None)#
Number a >10-membered heteromonocycle for replacement (“a”) nomenclature.
Returns
(heteroatom_locants, double_bond_locants)where the numbering minimises, in order (IUPAC 2013 /: the heteroatom locant set, then the heteroatoms by element seniority, then the PRINCIPAL CHARACTERISTIC GROUP locant set (c) — the suffix, e.g. the-2,6-dionecarbons), then the ring double-bond locant set.M4: threading
principal_group_atoms(the in-ring suffix-bearing atoms)into the key is the fix for the macrolactam/macrolactone class whose in-ring
enewas numbered on a DIFFERENT direction than the composer’s suffix locants — the two disagreed and the spliced name was internally inconsistent (OPSIN-unparseable → abstain). With the suffix ranked ABOVE unsaturation the numberer picks the same direction the composer uses, so the name round-trips. Emptyprincipal_group_atoms(a bare ring / crown ether) leaves the key unchanged, so the previously-passing cases are byte-identical (no regression), and any residual mismatch still fails the OPSIN validity gate → abstain.The ring is kekulised first so a fully-conjugated macrocycle that RDKit perceives as aromatic (e.g. the V-6 azacyclotrideca-hexaene) yields its localised double bonds instead of zero (the bug that made the old path emit a single bare
ene). Returns(None, None)if the ring cannot be ordered/kekulised, so the caller can fall back safely.