orthonym.rules.isotope_search#
Note
Internal API. Names and behaviour may change between releases.
What the isotope placement search asks OPSIN, and what it does not need to.
The search of rules.isotopes builds a candidate name for every pair of an insertion offset and a
locant and reads each back (OPSIN, then the comparison with the input). The offsets are every letter of
the skeleton name and the locants every number up to the size of the molecule, so the pairs grow with
both: a CD3 of a five-component mixture was 40,000 candidates, 56 s, and not one of them was read. The
refused ones tell where the rest are refused, and this module is that knowledge, drawn from OPSIN 2.9.0
itself (jvm_bridge.refusal_kind reads its message):
An isotope descriptor is one grammar symbol (
isotopeSpecification,regexTokens.xml), whatever nuclide and locants it cites. A name OPSIN cannot tokenise with a descriptor and a locant at an offset (“<name> is unparsable…”) cannot be tokenised with another locant there: the offset is dead for every locant.The locants of a descriptor are looked up in the one fragment of the part of the name that follows it (
StructureBuildingMethods.applyIsotopeSpecifications,Fragment.getAtomByLocantOrThrow: “Could not find the atom with locant N.”); a letter locant with a numeral (‘O12’,Fragment.getAtomByLocant) needs the atom of that number. Almost every fragment numbers its atoms 1..n, so the locants above the first one OPSIN does not find are not found either, and the offset is capped there. That is NOT a rule of OPSIN: its data has fragments with gaps in their integer locants, measured in 2.9.0:(34-2H1)gorgostaneis read and(29-2H1)gorgostaneis not (the side chain of gorgostane has 33 and 34 and no 29-32); rotenane and aurone read(21-2H1)after 8 and 9 (the “2^1” of a substituent position); arginine reads(99-13C)(the guanidino carbon) and not(6-13C). A cap is taken only when the first:data:GAP_WINDOW locants above the first absent one, and the limit of the search, are refused for a missing locant too: that sees the gaps of gorgostane, rotenane and aurone (the widest measured, 13) and not the far locant of arginine. Orthonym names no gorgostane, rotenane or aurone parent, and a search reaches arginine’s 99 only for a molecule of 99 heavy atoms with its guanidino carbon labelled; a candidate pruned by mistake is a name lost, never a wrong one, since what is asked is read back as ever. A natural-product parent that Orthonym comes to name is to be added to the test that pins this (tests/unit/rules/test_isotope_search.py).
Neither rule changes what a candidate is read as: it only leaves out candidates a refusal of the same
kind has already shown OPSIN cannot read. A refusal of any other kind, a refusal that names another locant
than the one asked, a name whose twin spelling is read instead (validation.twin_spellings), an OPSIN that
is not the pinned 2.9.0 release the rules were drawn from (ORTHONYM_OPSIN=main floats with its
branch, ORTHONYM_OPSIN_JAR is anything), and anything OPSIN cannot say leave every candidate in the
search.
- orthonym.rules.isotope_search.GAP_WINDOW = 16#
How many locants above the first one a part lacks are asked before the part is taken to have no more (the widest gap measured in OPSIN 2.9.0: aurone’s 8 -> 21, 13; rotenane’s 9 -> 21, 12; gorgostane’s 29 -> 33, 4).
- orthonym.rules.isotope_search.pinned_opsin()#
The rules above hold for the OPSIN in use: the pinned 2.9.0 release jar.
- orthonym.rules.isotope_search.direct_refusal_kind(candidate, token=None)#
How OPSIN refused
candidate(jvm_bridge.refusal_kind: ‘grammar’, ‘locant’, ‘other’), when its refusal of the name as written is the whole story and the rules of this module hold for it.None when OPSIN reads it; when a twin spelling of it is read instead (
validation.twin_spellings: the read-back asks the twin when OPSIN refuses the name); when OPSIN cannot say or is not the pinned release (pinned_opsin()); and, for a refusal of a locant, when it is not the locanttoken(a descriptor that cites several locants is refused for the first one the part lacks, which need not be the one the search asked about).
- orthonym.rules.isotope_search.locants_absent_above(skel, off, descriptor_of, first_absent, limit, suffix='')#
Is every one of the:data:GAP_WINDOW locants above
first_absent(the first one OPSIN did not find atoff), and thelimit, refused for a locant OPSIN does not find too? False when OPSIN reads one of them or refuses it for another reason: the part has a gap in its numbering, and no cap is known.
- orthonym.rules.isotope_search.integer_locant_reach(skel, off, descriptor_of, limit, suffix='')#
Where OPSIN reads a descriptor that cites the locants
1,2,… (each followed bysuffix:"'"for the primed locants of a ring assembly) at offsetoffofskel, asked in order up tolimit:(dead, cap).dead: no descriptor is read at the offset;cap: the highest locant of the series the part has (0 when it has none), None when nothing is known.descriptor_of(token)spells the descriptor of one locant token.
- class orthonym.rules.isotope_search.LocantReach(skel, limit, descriptor_of)#
Bases:
objectThe offsets and locants of one placement search that OPSIN has shown it cannot read.
descriptor_of(locant)spells the descriptor of the search for one locant,limitis the highest integer locant the search tries. The search asks:meth:beyond before it builds a candidate and tells:meth:learn about every one that was not read back.A refusal of the grammar at an offset makes the offset dead for every locant. The refusal of an integer locant for want of the locant (the first absent one) refuses that locant again in the next spelling of the descriptor. The locants above it are refused once the:data:GAP_WINDOW locants above it have been asked by the search itself and were all refused for a missing locant, and so is the limit: the integer locants of a fragment are 1..n with the exceptions this module states, and a locant that is read, or refused for another reason, above the first absent one leaves the offset uncapped. So a search that ends within the window asks nothing it would not have asked. A locant with a numeral (‘O12’) comes before the integers in the search and is as many as the atoms of the molecule, so the first one asked at an offset reads the integers there (
integer_locant_reach()). Nothing is learnt, and nothing is beyond reach, where the rules of this module do not hold (pinned_opsin()).- dead: set#
- caps: Dict[int, int]#
- absent: Dict[int, int]#
- refused: Dict[int, set]#
- gapped: set#
- static number_of(locant)#
The numeral a locant cites: the integer itself, the digits of ‘N7’; None for no locant, a bare letter, or a composite locant of a phane amplificant (‘1^4’,
rules.isotope_phane_locants).
- beyond(off, locant)#
Has OPSIN been shown unable to read a descriptor that cites
locantatoff?
- learn(off, locant, candidate, spelling=0)#
Learn from
candidate(the first spelling of the descriptor oflocantatoff), which was not read back: how OPSIN refused it (direct_refusal_kind()). A refusal of another kind (a valency, a bond assignment) says the locant exists, and learns nothing, unless it is a locant above the first absent one (a gap).
- orthonym.rules.isotope_search.fixed_h_inchi(mol)#
MolToInchi(mol, options="/FixedH"), remembered by the canonical isomeric CXSMILES ofmol: what the canonical SMILES leaves out and InChI reads (the radical electrons,|^1:0|) is in the key (‘[CH2]CC(=O)O’ with and without a radical electron are one SMILES and two InChIs). Raises what InChI raises.