vibesketch.document.clean

Clean up the drawing: standard bond lengths and angles, everything else kept.

Cleaning works on the canvas (KET) in place. Each molecule gets the coordinates vibesketch.chem.clean.clean_2d() computes, with bonds of the length Ketcher draws with; arrows, plus signs, text and every atom and bond property stay as they were, and molecules stay where they were drawn.

Moving atoms can change what a wedge means, so the wedges are re-derived and every molecule is checked: its canonical isomeric SMILES, read back from the cleaned canvas the way the rest of vibe-sketch reads it, must equal the one before. The wedges are tried in this order:

  1. as drawn, on the same bonds;

  2. all wedges and hashes swapped, for a layout that came out mirrored;

  3. swapped only at the stereocentres whose CIP label changed;

  4. placed afresh by RDKit (WedgeMolBonds).

A molecule for which none of them keeps the stereochemistry is left as drawn and reported, as is anything that is not a plain structure (query atoms, R-groups, polymer brackets).

Functions

clean(document)

document with its drawing cleaned; the normalized layer is re-derived.

clean_ket(ket)

A copy of ket with every molecule cleaned, and what was done.

Classes

CleanReport([cleaned, left])

What cleaning did.

class vibesketch.document.clean.CleanReport(cleaned=0, left=<factory>)

Bases: object

What cleaning did.

Parameters:
cleaned: int = 0

Molecules that got standard coordinates.

left: list[str]

Why molecules were left as drawn, one line each.

vibesketch.document.clean.clean(document)

document with its drawing cleaned; the normalized layer is re-derived.

The structures do not change, so species keep their ids, names and conformers.

Parameters:

document (Document)

Return type:

tuple[Derivation, CleanReport]

vibesketch.document.clean.clean_ket(ket)

A copy of ket with every molecule cleaned, and what was done.

Parameters:

ket (dict[str, Any])

Return type:

tuple[dict[str, Any], CleanReport]