orthonym.validation.twin_spellings#

Note

Internal API. Names and behaviour may change between releases.

Twin spellings: a Blue Book PIN spelling that OPSIN 2.9.0 has no grammar for, checked through a spelling of the same structure that OPSIN reads.

A twin is a token-level rewrite of the PIN spelling into a general-nomenclature spelling that names the same structure. It proves the structure and never the spelling: the producer that builds the PIN spelling owns its correctness, and the twin replaces only the OPSIN read-back. A name ships through its twin when OPSIN rejects the name, the twin reads to the input’s FULL InChIKey (namer._shipped_name_round_trip: the radical and the protonation site are checked too) and OPSIN gives no APPEARS_AMBIGUOUS warning for the twin. The twin is never shipped.

Why the ambiguity check: Citation of locants (the Blue Book) “if any locants are essential for defining the structure of the parent structure…, then all locants must be cited”. A twin that OPSIN reads only by choosing among readings does not prove the structure of the name it stands for.

The families (the rules of:data:TWIN_RULES, in table order):

  • bridge_sulfano, bridge_disulfano, bridge_azano: Divalent bridges,

    (the Blue Book-14110): “The following names are now recommended as

    preselected (see bridge prefixes: ‘sulfano’, –S–;’disulfano’, –SS–;… ‘azano’, –NH–” and “The bridge prefixes ‘epithio’, ‘epidithio’, ‘episeleno’, ‘epitelluro’, and ‘epimino’… may be used in general nomenclature” (:14097); the PIN example ‘1,4-dihydro-1,4- sulfanonaphthalene (PIN)’ stands under CYCLIC ETHERS, SULFIDES, SELENIDES AND TELLURIDES (:28063). The twins are ‘epithio’, ‘epidithio’ and ‘epimino’. ‘selano’ and ‘tellano’ have no twin: OPSIN reads ‘episeleno’ and ‘epitelluro’ as a [SeH2] / [TeH2] bridge, another structure. A bridge cited more than once (‘1,4:5,8-’ before the prefix) has no twin rule: ‘disulfano’ is the name of the –S–S– bridge (:14105), so it cannot stand for two –S– bridges.

  • interior_phenalene: Numbering of interior carbon atoms (the Blue Book),

    (:12658): “The locant for the interior atom is that of the peripheral atom with a

    superscript number corresponding to the number of bonds between the two atoms. The previous rule … recommended that interior atoms follow the highest numbered peripheral atom adding Roman letters in sequence to the appropriate peripheral number.” The interior atom of phenalene is ‘3a^1’ (the former ‘9b’), as in ‘1,3a^1,4,9-tetraazaphenalene (PIN)’,:14470, example:14491). OPSIN reads the former locant: ‘1,9b,4,9-tetraazaphenalene’. The numbering of the peripheral atoms is the same in both, so the twin is the same structure; the rule applies to a name of the parent ‘phenalene’ only.

  • aminiumyl_azaniumyl: “Cationic substituent groups” (the Blue Book), method (1):42296 “all prefix names are formed by adding the suffixes ‘yl’, ‘ylidene’, etc. to the cation name” and:42299 “Method (1) leads to preferred IUPAC names”, with the cation name ‘N,N,N-trimethylmethanaminium (PIN)’ (:41438); (:42473) ‘(N,N-dimethylmethanaminiumyl)acetate (PIN)’, whose general-nomenclature name is ‘(trimethylammoniumyl)acetate’. OPSIN reads no ‘-aminiumyl’ prefix and reads the azane-based spelling ‘(trimethylazaniumyl)acetate’. The rule is the one group of the book’s own example, a nitrogen with three methyl groups: cation_to_prefix spells it so at the default tier (pin_spellings_on()); a nitrogen with other groups has no rule (its name stays ‘…azaniumyl’, recorded as no PIN).

  • isotope_letter_once: (heading NAMES,:43824, example:43830) “In a name consisting of one word, the isotopic descriptor is placed before the name, with an appropriate locant”, ‘(N-2H2)aniline (PIN)’: a letter locant is cited once for a nuclide that is multiplied. OPSIN reads the letter once per atom: ‘(N,N-2H2)aniline’.

  • isotope_count_one: (heading Omission of locants,:44184) “ethan(2H)ol (PIN) (as in ethanol)”, (:44214) ‘(1-2H1)ethan-1-(2H)ol (PIN)’, (heading

    ORDER OF NUCLIDE SYMBOLS,:43832; the rule:43834) ‘methan(2H,18O)ol (PIN)’ (:43840): a

    hydrogen nuclide that needs neither a count nor a locant is cited bare. OPSIN reads such a nuclide with a count: ‘(2H1)’. A hydrogen nuclide with a locant in its descriptor (‘(O-2H)acetic acid’) is read as written and is not rewritten, and the (2H) / (3H) that follows a locant, primed or not (‘naphthalen-2(3H)-one’, ‘[1,1’-biphenyl]-4’(2H)-one’), is the added-hydrogen mark.

  • assembly_diyl_enclosed: (the Blue Book) cites the central group of a concatenated multiplicative group first, before its multiplying prefix, and a ring assembly group stands as the book writes it (‘10,10’- [[1,1’-biphenyl]-4,4’-diylbis(oxy)]di(decanoic acid) (PIN)’,:6126): ‘[1,1’-biphenyl]-4,4’-diylbis(methylene) diacetate’ is the same group before ‘bis(methylene)’. OPSIN reads the group only when it is enclosed once more: ‘([1,1’-biphenyl]-4,4’-diyl)bis(methylene) diacetate’. The twin encloses a bracketed ring assembly group, its locants and its ‘diyl’ (or ‘triyl’) that stands in front of a multiplying prefix.

  • polyester_acyloxy (validation.polyester_twin): method (1), the functional-class polyol polyester name ‘propane-1,2,3-triyl 1,2-diacetate 3-propanoate (PIN)’ (the Blue Book) and its acyloxy spelling ‘1,3-bis[acetyloxy]-2-[propanoyloxy]propane’, substitutive nomenclature of the same ester,:31968). OPSIN reads the second and not the first. A half ester of a polybasic acid has no acyloxy spelling OPSIN reads, and its name does not ship.

  • preselected_cage (validation.preselected_cage_twin): (the Blue Book) ‘bicyclo[4.2.1]nonasilane (preselected name)’ (:23618) and its general-nomenclature spelling by skeletal replacement ‘nonasilabicyclo[4.2.1]nonane’, which OPSIN reads; the preselected name of a von Baeyer or spiro system of one noncarbon element.

  • halido_o (validation.halido_twin): (the Blue Book) ‘trichlorido(methyl)titanium’ (:39789) and the long-established ligand spelling ‘trichloro(methyl)titanium’,:39761,:39767), which OPSIN reads; the additive names of the transition-metal producer, without a hapto descriptor.

  • uide_lambda (validation.uide_twin): ANIONS FORMED BY ADDITION OF HYDRIDE IONS (the Blue Book), method (1) ‘diphenyliodanuide (PIN)’ and its method (2) spelling ‘diphenyl-lambda3-iodanide’ (:41110), which OPSIN reads. The family is structure-blind like the others but is not a rewrite of the name alone: the lambda number is the one method (2) pairs with an unmarked -uide name of the element, so it lives in its own module and is reached from twin_round_trip(); a general tier ships a name through its twin for this family and the next.

  • thioperoxol_sulfenic, thioperoxol_peroxol (validation.thioperoxol_twin): THE SUFFIXES ‘SO-THIOPEROXOL’, AND CHALOGEN ANALOGUES (the Blue Book), ‘CH3-S-OH methane-SO-thioperoxol (PIN) (not methanesulfenic acid)’ (:24326); Basic functional suffixes (:17456), “-OS-thioperoxol for -OSH” is ‘peroxol’ modified by functional replacement (:17460). The twin of ‘-SO-thioperoxol’ is ‘-sulfenic acid’, that of ‘-OS-thioperoxol’ is ‘-peroxol’ read against the structure with the sulfur an oxygen; OPSIN has no grammar for either suffix at any tier. The default tier ships them through the twin; a general tier ships the name OPSIN reads itself, ‘(hydroxysulfanyl)methane’, and the twin only for the anion of -S-OH, which has no such name, and as the safety net of a molecule that only the PIN path names (validation.thioperoxol_twin).

  • anhydride_acids (validation.anhydride_acids): Di- and polyanhydrides (the Blue Book) ‘diacetic butanedioic dianhydride (PIN)’ (:32386). No twin spelling of such a name exists (OPSIN reads a two-word anhydride only), so the check reads each acid word as <acid> acid and builds the poly-anhydride from those acids; it ships a name at the default tier only.

  • long_count (validation.long_count_read_back): Basic multiplicative prefixes (the Blue Book),

    Derivation of basic numerical terms (:2811), Hydrocarbons (:7984) ‘heptacontane (PIN)’. OPSIN

    has a numerical term up to 50 and none above, so a name with a count word of 51 and more has no OPSIN reading and no twin spelling. The reconstructor builds the structure from the text of the name (the parent chain, its multiple bonds, its prefixes) and the constitution must be the input’s, at every tier that ships a name OPSIN cannot read.

orthonym.validation.twin_spellings.descriptor_spans(name)#

(start, end) of every isotopic descriptor of name: a parenthesised group of nuclide items that no locant precedes.

orthonym.validation.twin_spellings.bare_hydrogen_groups(name)#

(start, end) of every descriptor of name that cites a hydrogen nuclide without count and locant, the groups of the rule isotope_count_one.

orthonym.validation.twin_spellings.TWIN_RULES: Tuple[Tuple[str, Callable[[str], str]], ...] = (('bridge_sulfano', <function _bridge_rule.<locals>.<lambda>>), ('bridge_disulfano', <function _bridge_rule.<locals>.<lambda>>), ('bridge_azano', <function _bridge_rule.<locals>.<lambda>>), ('interior_phenalene', <function _interior_phenalene>), ('isotope_letter_once', <function _letter_once>), ('isotope_count_one', <function _count_one>), ('aminiumyl_azaniumyl', <function _aminiumyl_azaniumyl>), ('assembly_diyl_enclosed', <function _assembly_diyl_enclosed>), ('polyester_acyloxy', <function polyester_twin>), ('halido_o', <function halido_twin>), ('preselected_cage', <function preselected_cage_twin>), ('chalcocarbonic_acid_locant', <function _acid_locant>), ('axial_locant', <function axial_locant_twin>))#

(rule id, rewrite) in the order the rules apply; each rewrite is pure and deterministic

orthonym.validation.twin_spellings.twin_of(name)#

(twin, rule ids in table order) of name, or None when no rule applies.

orthonym.validation.twin_spellings.twin_round_trip(name, smiles)#

The applied rule ids joined by + when the twin of name reads to the FULL InChIKey of smiles and OPSIN reads it once; else None (no twin, a twin of another structure, an unavailable OPSIN, an ambiguous reading). A halogen -uide name and a thioperoxol name have a family of their own (validation.uide_twin, validation.thioperoxol_twin), a poly-anhydride name is read through its acids (validation.anhydride_acids) and a name with a count word above 50 is read by the reconstructor (validation.long_count_read_back). This is the check of the default tier: a thioperoxol name ships through its twin there always, at a general tier only the anion does, and a neutral name as the safety net (general_tier_twin_round_trip()).

orthonym.validation.twin_spellings.component_order_twin(name)#

The adduct name with its first component, and that component’s proportion, moved to the end; None when name is not an adduct name of matching proportions.

“Organic adducts” (the Blue Book): “the individual components are cited in the order of seniority

of classes (see “, and radicals head, so a radical component is cited first (‘phenylboranylidene—bromomethane (1/1)’). OPSIN reads a leading radical word as a substituent prefix of the rest (“believes there to be 1 components”) and reads the same components in the other order (‘bromomethane—phenylboranylidene (1/1)’). The order of the components carries no structure, so the twin names the same mixture; with two radical components the twin still starts with one and is not read.

orthonym.validation.twin_spellings.component_order_twins(name)#

Every rotation of the components of the adduct name name (with their proportions), the first component moved to the end first: a radical component cited in the middle (‘pyridine—methylarsanylidene—…’, the seniority order of within the classes) is last in one of them. Empty when name is not an adduct name of matching proportions or has more than:data:_MAX_ROTATED components.

orthonym.validation.twin_spellings.component_order_round_trip(name, smiles)#

COMPONENT_ORDER_RULE when OPSIN rejects name, the OPSIN in use reads adducts with a radical component (opsin_capabilities.radical_adduct_enabled; never OPSIN 2.9.0) and the twin of component_order_twin() reads to the input’s full InChIKey with the same radical graph and protonation sites (namer._shipped_name_round_trip) and to exactly the drawn structure (adducts._parse_reproduces_depiction: the key does not see where a charge or a hydron sits); else None.

orthonym.validation.twin_spellings.general_tier_twin_round_trip(name, smiles)#

The twin families a general tier ships a name through: a name no OPSIN grammar reads at any tier and for which the engine has no other spelling (the halogen -uide names, validation.uide_twin), and an additive organometallic name with ‘chlorido’ ligands, validation.halido_twin, whose Blue Book ligand word no OPSIN grammar reads either); the other families spell the form OPSIN reads there. The anion of -S-OH, a thioperoxolate name, belongs here too: the engine has no other spelling for it (validation.thioperoxol_twin). A neutral thioperoxol name has one, the name by prefixes that OPSIN reads (‘(hydroxysulfanyl)methane’): it ships through its twin only inside thioperoxol_twin.last_resort_scope, for a molecule that has no other name. The rule id, or None. A name with a count word above 50 has no other spelling either, and OPSIN has no numerical term for it: the reconstructor reads it (validation.long_count_read_back). The preselected name of a cage of one noncarbon element (‘bicyclo[2.2.1]heptasilane’, validation.preselected_cage_twin) ships here too: it has no PIN, the Blue Book, a compound without carbon), it is the name (:23614) selects, the ‘a’ name being only “for use in general nomenclature”, and no OPSIN grammar reads it. A biaryl axis cited with its locant (‘(1M)-’, validation.axis_identity) ships here too: the name without the axis leaves a stereogenic unit out, and no OPSIN reads a locant before an axial descriptor (dan2097/opsin#356).

orthonym.validation.twin_spellings.opsin_spelling(name, radical=False)#

The spelling to give OPSIN to read the structure of name: name, or its twin when OPSIN rejects name and reads the twin. For the checks of a builder that read the name it is about to return (the tautomer of the drawing, the stereo of a prefix); radical is True for a name with a free valence (a prefix), which OPSIN reads with its radical setting on. The validity gate still refuses a twin OPSIN reads as ambiguous (twin_round_trip()).

orthonym.validation.twin_spellings.twin_opsin_parse(name)#

OPSIN’s SMILES for the twin of name at a default-tier call; None at a wider tier, when no rule applies, when OPSIN rejects the twin or reads it as ambiguous (twin_round_trip()). The isotope placement search reads its candidates through this.

orthonym.validation.twin_spellings.twin_gate_ships(name, smiles, general_tier=False)#

The twin branch of the validity gate: True, with the outcome twin_verified:<rules> (acid_split_verified:<rule> for a poly-anhydride, reconstructed:<rule> for a name the reconstructor reads) recorded for name, when:func:twin_round_trip verifies the twin of name. A general tier (general_tier) ships only a name of:func:general_tier_twin_round_trip through its twin.

orthonym.validation.twin_spellings.twin_outcome_holds(name, smiles)#

None unless the gate recorded a twin outcome for exactly this string; else whether the twin still reads back to smiles (the OPSIN parse is memoized: no new JVM call).

orthonym.validation.twin_spellings.twin_offer_holds(name, smiles)#

Whether the twin of name, an offer no gate has seen yet (an isotope-labelled name is gated at the exit of the call), reads back to smiles; False at a wider tier.

orthonym.validation.twin_spellings.publish_tier_flags(wider)#

Publish the tier of a naming call for the producers: ps_tier_ctx as the call’s own flag and, for a wider tier, wider_tier_ctx (metrics.provenance). The (variable, token) pairs are returned for the caller to reset when its call ends.

orthonym.validation.twin_spellings.pin_spellings_on()#

True where the producers spell the Blue Book PIN form: a default-tier call. A wider tier (wider_tier_ctx) spells the general form OPSIN reads.