orthonym.validation.depiction_match#
Note
Internal API. Names and behaviour may change between releases.
Atom-by-atom comparison of a drawing with the SMILES a name reads back to, for drawings whose standard InChIKey cannot see a hydrogen.
The standard InChIKey does not see the hydrogens of an over-valent halogen: C[Cl-]1CCCCC1 and C[ClH-]1CCCCC1
have one key, and so do C1CC[Cl]CC1 and C1CC[ClH]CC1. A name of such a drawing that reads back to the key can
still hold one hydrogen more or less on the halogen.:func:depiction_matches compares the two graphs with every atom
labelled by its element, isotope, formal charge and hydrogen count, so that difference is seen.
Hydrogen counts follow the OpenSMILES rules: a bracket atom has the hydrogens written in it; an atom outside brackets
takes the hydrogens of the lowest normal valence at or above its bond count, and a halogen’s only normal valence is 1,
so an unbracketed halogen with two or more bonds has none. RDKit gives an unbracketed iodine with two bonds one
hydrogen (its valence list holds 3), and OPSIN writes the λ3-iodanyl radical unbracketed (‘1λ3-iodinan-1-yl’ ->
I1CCCCC1), so RDKit’s count would accept an iodine ‘-yl’ name for an [IH] drawing. Radical electrons are not
compared: both sides take them from the same rule, so they add no evidence (the hydrogens, charge and bonds do).
- orthonym.validation.depiction_match.depiction_key(mol, halogens_only=False)#
A canonical SMILES of
molwith every heavy atom written in brackets with its OpenSMILES hydrogen count, formal charge and isotope; None when RDKit cannot write it. Withhalogens_onlyonly the halogens keep their hydrogen count and charge, every other atom is written bare and every bond single: the graph and the halogens’ hydrogens, for a caller that has the full InChIKey for the rest (a nitro group drawnN(=O)=Oor[N+](=O)[O-]is then one depiction).
- orthonym.validation.depiction_match.depiction_matches(input_mol, read_smiles, halogens_only=False)#
True when
read_smiles(a name’s read-back) is the drawinginput_molatom by atom: one graph with the same element, isotope, formal charge and hydrogen count on every atom (both read without RDKit’s valence check); withhalogens_only, the same graph and the same hydrogen count and charge on every halogen (depiction_key()).