orthonym.rules.isotope_compare#
Note
Internal API. Names and behaviour may change between releases.
How the read-back of an isotope candidate compares OPSIN’s parse with the input (IUPAC 2013,,.
rules.isotopes._isotope_round_trips accepts a name only when OPSIN reads it as the input with its
isotopes. Two kinds of input are not read as drawn, and the comparison has to say when the reading is still
the input:
a molecule with radical electrons: its names cite a free valence and are read with OPSIN’s
-r(RADICAL_READING), and the reading has to carry the radical centres of the input (radical_centres_agree);a molecule with a guanidine or an amidine: a name that does not say where the double bond sits is read as the tautomer OPSIN prefers (
tautomer_of). Such a reading is accepted only for the tautomers the Blue Book names without saying where the double bond is (in_one_amidine_group), and only in a pass of its own that the decorator makes when no reading as drawn was found (tautomer_passes), so no name it builds without that pass changes.
- orthonym.rules.isotope_compare.RADICAL_READING: ContextVar = <ContextVar name='orthonym_isotope_radical_reading' default=False>#
the candidates of the decorator are then read with OPSIN’s
-r, and not otherwise (validation/read_back_policy.py: a name is read back with-ronly when the input structure has radical electrons). GENERAL METHODOLOGY (the Blue Book): “Radicals are named by modifying a parent hydride name to signal the subtraction or addition of one or more hydrogen atoms”; a name with a free valence (‘[(2H3)methoxy]sulfinyl’) does not parse without-r, so a labelled radical had no candidate that read back.- Type:
Set by
rules.isotopes._decorate_labelledwhile it names a molecule that has radical electrons
- orthonym.rules.isotope_compare.radical_centres_agree(original, parsed_smiles)#
True iff the reading
parsed_smilesdoes not contradict the radical centres oforiginal. The full InChIKey sees neither radical electrons nor bond orders, and OPSIN’s SMILES of a name with a free valence leaves an atom that has a valence of its own closed-shell:validation.radical_identityis the one definition of the comparison (the radical profile and the graph without stereo). Its verdict is “ok” (the same chemical radicals), “mismatch”, or “n/a”: neither side carries a chemical radical, so the checks of the caller decide. RDKit gives radical electrons to a bare metal atom (‘[99Tc]’ of a mixture, ‘[65Zn]’), which are not chemical radicals,radical_identity): such an input has the verdict “n/a” and its names stand or fall on the full key and the isotope layer alone, as at the default read.
- orthonym.rules.isotope_compare.tautomer_of(parsed, original, known=None)#
True iff
parsedisoriginaldrawn as one of its tautomers: the same atoms, charges, nuclides and bonds (_tautomer_graph), the same number of hydrogens, and ordinary hydrogens on other atoms (so other bond orders). The same hydrogens on the same atoms are not this (a Kekule form or a bond-shift isomer,rules.isotopes._kekule_forms_of_one_compoundjudges those).A guanidine whose name does not say which nitrogen carries the double bond is read by OPSIN as the tautomer other than the drawn one (‘N’-aryl-N-[(11C)methyl]-N-aryl-guanidine’ as
ArNC(N(Ar)[11CH3])=Nfor the input’sArN=C(N)N(Ar)[11CH3]): the same compound by the standard InChIKey, which the caller still requires, and by every position a nuclide is cited at, because the nuclides are part of the key above (a deuterium on a heteroatom is an atom of it, so one moved to another heteroatom is another key). The fixed-hydrogen InChI the caller makes first is never equal for two tautomers: it records where the hydrogens are.knownis_known(original); which tautomers a name may stand for isin_one_amidine_group.
- orthonym.rules.isotope_compare.in_one_amidine_group(parsed, original)#
True iff the two drawings of one compound (
tautomer_of) differ only on the nitrogens of one guanidine or amidine group: every atom that has another number of hydrogens or another double bond is a non-aromatic nitrogen bonded to one non-aromatic carbon that has two or more nitrogens.- That is the class whose name the Blue Book writes without saying where the double bond sits.
(heading ‘Guanidine and its derivatives’, the Blue Book): “Hydrocarbyl derivatives
are named as substituted guanidines. When the position of the double bond is unknown, the preferred IUPAC name uses a minimum number of primes.” (‘Substituted amidines’,:34375): “Because of tautomerism, the locants N, N’, etc. are used when only one substituent is present on each imidamide group.” The tautomers of an amide and its imidic acid, of a ring NH of an azole, of a keto and an enol form, are named for the drawn tautomer (indicated hydrogen, ‘one’), so a name read as another tautomer of those is not the name of the input and no rule makes it neutral.
- orthonym.rules.isotope_compare.TAUTOMER_READING: ContextVar = <ContextVar name='orthonym_isotope_tautomer_reading' default=None>#
possibleis True when the input has a hydrogen that moves (a mobile-hydrogen group of its standard InChI),acceptis True in the pass that reads a tautomer of the input as the input,refusedis set when a name that reads as a tautomer was refused. None outside a decorator call: a direct use of the read-back accepts no tautomer.- Type:
The state of the passes of one decorator call (
tautomer_passes)
- orthonym.rules.isotope_compare.tautomer_passes(original)#
The state of the passes of one decorator call over
original.
- orthonym.rules.isotope_compare.tautomer_accepted(parsed, original)#
True iff
parsedreads as the input because it is a tautomer of it within one guanidine or amidine group (in_one_amidine_group) and the pass accepts that. A tautomer refused is recorded (refused): the decorator makes the pass that accepts it only then. Only an input with a mobile hydrogen has a tautomer, so any other costs nothing here.