orthonym.assembly.fragment_key#

Note

Internal API. Names and behaviour may change between releases.

The structural half of the name_substituent memo key, kept for the naming scope (lane/l17 item 13).

substituent_enumerator._substituent_memo_key runs for every name_substituent call, hit or miss (15,177 calls on 200 PIN-tier rows, 135,429 on the 15 slowest; 6.7% of the PIN-tier time of the first and 12% of the second), and half of its calls repeat an earlier call on the same molecule object and the same fragment. Most of its time was RDKit: MolFragmentToSmiles of the fragment, the walks over the bonds of the fragment atoms and the parse of the output order.

What the key holds that is a function of the molecule’s graph, the fragment and the attachment atom alone is kept under molcache.cached_by_key for the scope: the rooted fragment SMILES, its output order (and the two properties RDKit leaves on the molecule), the external bond orders and the free valence. The entry is stamped with what an in-place edit of the molecule could change and the graph does not hold: the graph key (memo_keys.mol_graph_key, which the key holds anyway), and the _CIPCode of the fragment atoms and bonds (the canonical ranking of the fragment reads it). A hit puts the two output-order properties back as the MolFragmentToSmiles call it replaces would have left them. ORTHONYM_MOLCACHE=verify recomputes every hit and raises on a difference; off and a call outside a naming scope (or on an RWMol) run the unrestricted code, which is the key as it was.

The key is the same tuple as before, component for component; the frozen reference of tests/unit/assembly/test_substituent_memo_key_equal.py compares it.

orthonym.assembly.fragment_key.structural_parts(mol, frag_atoms, attach_idx)#

(smi, attach_in_frag, ext_free_valence, atom_cips, bond_cips, ext_bond_orders, graph_key) of the key, or None when RDKit left no atom output order (the key then skips the cache), for a molecule that is cached in the scope (molcache.caches).

orthonym.assembly.fragment_key.structural_parts_unrestricted(mol, frag_atoms, attach_idx)#

structural_parts() with no cache: the key’s structural half as it was computed before the cache.

orthonym.assembly.fragment_key.key_parts(mol, frag_atoms, attach_idx)#

The structural half of the name_substituent memo key (see:func:structural_parts): from the scope’s cache where the molecule is cached there, else computed as it always was.