orthonym.decomposition.fragment_assembly#

Note

Internal API. Names and behaviour may change between releases.

Fragment assembly module for decomposition engine.

Combines individually-named fragments into correct multi-component IUPAC names. Assembly patterns differ by bond type: - Esters: “alkyl alkanoate” (e.g., “ethyl acetate”) - Amides: “N-[substituent][acid-amide]” (e.g., “N-methylacetamide”) - Glycosides: basic concatenation (full naming deferred to a phase)

Each assembler handles name transformations: - acid name -> “-ate” form for esters - acid name -> “-amide” form for amides - acid name -> “-yl” (acyl) form for N-acyl naming - alcohol name -> alkyl prefix form

orthonym.decomposition.fragment_assembly.assemble_fragment_name(bond_type, fragment_names, style='pin', fragment_smiles=None, parent_smiles=None)#

Assemble fragment names into a multi-component IUPAC name.

Dispatches to bond-type-specific assemblers.

Parameters:
  • bond_type (str) – Type of bond that was cleaved (“ester”, “amide”, “glycosidic”, “carbamate”).

  • fragment_names (Dict[str, str]) – Dict mapping fragment roles to their names. For esters: {“acid”: “acetic acid”, “alkyl”: “ethanol”} For amides: {“acid”: “acetic acid”, “amine”: “methylamine”} For glycosides: {“sugar”: “…”, “aglycone”: “…”}

  • style (str) – Naming style (“pin” for preferred IUPAC names).

  • fragment_smiles (Dict[str, str] | None) – Optional dict mapping fragment roles to their SMILES, keyed by the same side keys as fragment_names. a phase /: only the glycoside assembler consumes this (the sugar-skeleton deriver and the aglycone seniority guard both need structure); all other assemblers ignore it, keeping them byte-identical.

Returns:

Assembled multi-component name, or None if assembly fails.

Return type:

str | None

Examples

>>> assemble_fragment_name("ester", {"acid": "acetic acid", "alkyl": "ethanol"})
'ethyl acetate'
>>> assemble_fragment_name("amide", {"acid": "acetic acid", "amine": "methylamine"})
'N-methylacetamide'