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, outcome=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.
outcome (Dict[str, str] | None) – Optional mapping the assembler may fill to say more than
Nonedoes. The ester and carbamate assemblers setoutcome['unproven']to the name the string rule built from the alcohol’s own name when they could not prove a group word (the split is then UNPROVEN,engine._try_single_bond_decompose). The name is never returned: the return value isNoneall the same.
- 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'
- orthonym.decomposition.fragment_assembly.split_front_stereo(name)#
(‘(2S)-’, ‘2-…’) for a name that opens with a stereodescriptor block, else (‘’, name).
“NAMING OF STEREOISOMERS” (the Blue Book): the descriptors of the parent “are placed
at the front of the complete name when related to the parent structure” – so an N-block that is put in front of the name of its parent follows the block, never stands between the block and the parent: ‘(2S)-N-methyl-2-…butanamide’, not ‘N-methyl(2S)-2-…butanamide’.
- orthonym.decomposition.fragment_assembly.n_prefix_breaks_citation_order(n_prefixes, name)#
True when
'N-<n_prefixes>' + nameis not in the Blue Book’s citation order (see the comment above):namebegins with a stereodescriptor block, or its first alphanumerically ordered prefix (_first_ordered_prefixof the token after its first locant set) sorts before an N-prefix or equals it. Equal means the same Roman letters, the same own locants,:3517, decides identical letters by “the lowest locant(s) at the first point of difference”: ‘4-(2-methylbutyl)-N-(3-methylbutyl)- aniline (PIN)’,:3523) and the same configuration symbols: identical prefixes are cited once with a multiplicative prefix: ‘N,2-dimethyl…’), and a tie the book does not break cannot be ordered by the concatenation either way. Where the token does not show where its prefix ends (no vocabulary word begins it), the whole token is compared, and a token that begins with the N-prefix’s letters counts as the same prefix. The keys are the engine’s own keys (prefix_citation_sort_key).