orthonym.validation.pin_spelling#
Note
Internal API. Names and behaviour may change between releases.
Spelling checks of a pin_verified name, independent of the round trip.
A round trip proves the molecule, never the spelling: OPSIN reads pyrido[1,2-b]pyridazin-6-one
and even 9H-pyrido[1,2-b]pyridazin-6-one back to the same structure as the PIN
6H-pyrido[1,2-b]pyridazin-6-one. The label pin_verified also claims that the spelling is
the Blue Book PIN form. Each check here decides one spelling rule from two inputs only: the
structure (an RDKit Mol) and the name read lexically. A check never calls the engine’s naming
code or OPSIN, so it cannot inherit a defect of the code that built the name.
Interface (binding for every lane that adds a check):
*SpellingFailure – rule (the Blue Book rule id the name breaks) and detail.
*register() – @register("") on a function fn(mol, name) -> SpellingFailure | None.
Several functions may share one rule id. A function returns a failure only when it has decided that the name breaks its rule; pass and abstain (a name or structure the reader cannot read with certainty) both return None. A check may say more (DT3 step B): it returns:data:PASS when it read the name and decided that the rule holds,:data:ABSTAIN when it could not read what the rule is about, and None keeps its old meaning, “no failure, and the check does not say whether it decided” (an UNDECIDED check in
pin_spelling_report()). A label never reads the difference: PASS, ABSTAIN and None are all “no failure”.
*check_pin_spelling() – every registered check on (mol, name); the list of failures.
*pin_spelling_report() – the same run, kept check by check as PASS / FAIL / ABSTAIN /
UNDECIDED, with the coverage of the name (
spelling.coverage: the units of the name whose parent a reader models, of all the units). A pass of a check on a name no reader models is not evidence, and the report is what says so.
The built-in checks live in the modules of:data:BUILTIN_CHECK_MODULES, imported on first use. A lane adds a check by adding its module there.
The caller (Orthonym._tier_row_and_pin_form) runs the checks on a name it would label
pin_verified; a non-empty result lowers the label (the default tier then declines the name,
the wider tiers keep it as systematic_verified) and never changes the name.
- orthonym.validation.pin_spelling.PASS = 'pass'#
what one check said about one name (
pin_spelling_report()). A check returns PASS when it read the name and decided that its rule holds, ABSTAIN when it could not read what the rule is about, aSpellingFailurefor FAIL; None is the old contract, which does not say whether the check decided (UNDECIDED).
- class orthonym.validation.pin_spelling.SpellingFailure(rule, detail)#
Bases:
objectA name breaks the Blue Book rule
rule(for example"");detailsays how.- rule: str#
- detail: str#
- orthonym.validation.pin_spelling.BUILTIN_CHECK_MODULES = ('orthonym.validation.spelling.checks_ring_prefix', 'orthonym.validation.spelling.checks_hydrogen', 'orthonym.validation.spelling.checks_marks', 'orthonym.validation.spelling.checks_locants', 'orthonym.validation.spelling.checks_parent', 'orthonym.validation.spelling.checks_phane', 'orthonym.validation.spelling.checks_assembly', 'orthonym.validation.spelling.checks_prefixes', 'orthonym.validation.spelling.checks_pseudohalide', 'orthonym.validation.spelling.checks_carbamothioic', 'orthonym.validation.spelling.checks_multiplier_elision', 'orthonym.validation.spelling.checks_one_carbon_parent', 'orthonym.validation.spelling.checks_heterone', 'orthonym.validation.spelling.checks_placement', 'orthonym.validation.spelling.checks_identical_prefixes', 'orthonym.validation.spelling.checks_thioperoxol', 'orthonym.validation.spelling.checks_amine_parent', 'orthonym.validation.spelling.checks_group_count', 'orthonym.validation.spelling.checks_acid_cyanide', 'orthonym.validation.spelling.checks_polyol_ester', 'orthonym.validation.spelling.checks_chalcone', 'orthonym.validation.spelling.checks_amide_chains', 'orthonym.validation.spelling.checks_skeletal_chain', 'orthonym.validation.spelling.checks_natural_products', 'orthonym.validation.spelling.checks_p_oxoacid_parent')#
modules whose import registers the built-in checks
- orthonym.validation.pin_spelling.register(rule_id)#
Decorator: register
fn(mol, name) -> SpellingFailure | Noneunderrule_id.
- orthonym.validation.pin_spelling.registered_rules()#
The rule ids that have at least one check.
- orthonym.validation.pin_spelling.check_pin_spelling(mol, name, *, strict=False)#
Every registered check on
(mol, name): the list of:class:SpellingFailure.A check that raises is a defect of the check, not of the name: it is logged and counts as an abstention, so a reader bug can never lower a label by itself.
strict=Truere-raises instead (the validation runs and the tests use it, so a crash is seen there). Without a structure or a name there is nothing to check, and no check module is loaded.
- class orthonym.validation.pin_spelling.CheckOutcome(rule, check, verdict, failure=None)#
Bases:
objectOne check’s verdict on one name (
failureis set for FAIL only).- rule: str#
- check: str#
- verdict: str#
- failure: SpellingFailure | None = None#
- class orthonym.validation.pin_spelling.SpellingReport(outcomes, coverage)#
Bases:
objectEvery check on one name, check by check, and the coverage of the name (
coverageis None when the marks of the name do not pair, so no reader can read it).- outcomes: tuple#
- coverage: object | None#
- property failures: list#
- count(verdict)#
- orthonym.validation.pin_spelling.pin_spelling_report(mol, name, *, strict=False)#
check_pin_spelling()kept check by check (PASS / FAIL / ABSTAIN / UNDECIDED) with the coverage ofname(validation.spelling.coverage.name_coverage). It runs the same checks the same way and changes no label: a name with no structure or no name has no outcome.