orthonym.validation.opsin_roundtrip#
Note
Internal API. Names and behaviour may change between releases.
OPSIN round-trip diagnostic tool.
: Provides opsin_parse, opsin_roundtrip_check, and opsin_parse_both_versions for validating generated IUPAC names against the OPSIN parser.
Uses subprocess to invoke the OPSIN CLI JAR. Requires Java runtime and OPSIN JAR file(s) in the project root.
- orthonym.validation.opsin_roundtrip.opsin_parse(name, jar_version='2.9.0')#
Parse an IUPAC name with OPSIN CLI JAR.
- Parameters:
name (str) – IUPAC name to parse.
jar_version (str) – OPSIN version to use (default “2.9.0”).
- Returns:
SMILES string if OPSIN successfully parsed the name, or None if parsing failed.
- Return type:
str | None
- orthonym.validation.opsin_roundtrip.opsin_atom_locant_map(name, mol, jar_version='2.9.0')#
Re-anchor an IUPAC name’s numbering onto mol’s atoms via OPSIN.
Parses name with
-o extendedsmito obtain OPSIN’s OWN per-atom locants (the authoritative numbering the name will be read back with), then maps those atoms onto mol by constitutional (stereo-insensitive) subgraph isomorphism. Returns{mol_atom_idx: locant_token}(tokens in the injector’s accepted format) or None when it cannot be built (OPSIN unavailable/rejecting, atom-count/parse mismatch, or no isomorphism).This is the
re-anchor + auditprimitive (the contributor guide a project rule): the map is derived FROM the name+structure, never trusted from a builder’s internal numbering, and the caller RT-verifies any name decorated with it.
- orthonym.validation.opsin_roundtrip.opsin_roundtrip_check(smiles, name, jar_version='2.9.0')#
Full round-trip validation: name -> OPSIN -> SMILES -> InChI comparison.
- Parameters:
smiles (str) – Original SMILES string.
name (str) – Generated IUPAC name to validate.
jar_version (str) – OPSIN version to use.
- Returns:
Dict with keys – - passed: bool – True if InChI matches - opsin_smiles: str or None – SMILES from OPSIN - inchi_match: bool – whether InChI strings match - error: str or None – error description if failed
- Return type:
dict
- orthonym.validation.opsin_roundtrip.opsin_parse_both_versions(name)#
Cross-validate name against OPSIN 2.8.0 and 2.9.0.
Per: Test against both versions to identify version-specific parsing differences.
- Parameters:
name (str) – IUPAC name to parse.
- Returns:
Dict with keys – -: str or None – SMILES from OPSIN 2.8.0 -: str or None – SMILES from OPSIN 2.9.0 - agree: bool – whether both versions produce the same result
- Return type:
dict