orthonym.assembly#

Note

Internal API. Names and behaviour may change between releases.

Assembly module - Name fragment ordering and string construction.

This module combines name fragments into complete IUPAC names: - Prefix generation (substituents, ordered alphabetically) - Suffix generation (principal group) - Parent name construction - Stereodescriptor formatting

orthonym.assembly.assemble_name(features, style='pin', _composing_ion=False)#

Assemble complete IUPAC name from molecular features.

PUBLIC API + RECURSION-SAFE WRAPPER (a phase drift fix, 2026-04-23).

Each invocation gets its own CandidatePool scope per IUPAC “selection of a preferred parent structure is based on the seniority of classes” — applied per-molecule, single-pass. The wrapper pushes a fresh pool on the per-thread stack before delegating to the body, and pops it in a finally clause so every exit path (normal return, early return, exception) restores the previous pool for the calling frame.

This fixes the byte-identical drift discovered in Plan 04 where recursive name_compound calls (N-oxide handler, fragment naming, substituent enumeration, decomposition fallback) shared a single thread-local pool with the outer molecule, causing inner candidates to pollute pool[0] and beat the outer molecule’s correct candidate under selection_mode=’first_applicable’. See: internal notes.

Parameters:
  • features (Any) – MolecularFeatures object with extracted features

  • style (str) – Naming style (“pin”, “general”, “cas”)

  • _composing_ion (bool) – Internal recursion guard. When True, ion aspect composition is skipped to prevent infinite loops. Do not set manually – it is used by _try_ion_aspect_composition.

Returns:

Complete IUPAC name string

Return type:

str