vibesketch.chem.clean¶
Clean up a drawn structure: standard bond lengths and angles, the drawing kept.
A hand-drawn structure has bonds of uneven length and angles that are almost 120°. Cleaning replaces its coordinates with a standard depiction, every bond the same length and every angle the textbook one, that still looks like what was drawn:
Standard layouts. RDKit’s depictor, RDKit’s depictor told to mimic the drawing’s inter-atom distances (
Compute2DCoordsMimicDistmat), and CoordGen each propose a layout with exact bond lengths and angles.The drawing’s choices. In two dimensions an acyclic single bond can only be drawn one of two ways: the neighbours of its two atoms on the same side of the bond (a U-turn) or on opposite sides (a zig-zag). For every such bond, each layout is made to agree with the drawing by mirroring the smaller side across the bond. A mirror keeps every length and angle, and no other bond’s choice depends on it, so the bonds are settled one at a time and in any order.
Placement. Each layout is rotated, or mirrored, onto the drawing by least squares (W. Kabsch, Acta Cryst. A32, 922-923 (1976)) and put where the drawing was. The layout with the fewest overlapping atoms, then the smallest deviation from the drawing, wins.
Stereochemistry is not this module’s concern: chiral tags and double-bond
geometry are inputs to the layouts, and the caller re-derives the wedges and
checks the result (vibesketch.document.clean).
Functions
|
Standard coordinates for |
Classes
|
New 2D positions for a molecule's atoms, in its atom order. |
- class vibesketch.chem.clean.Cleaned(xy, deviation, layout)¶
Bases:
objectNew 2D positions for a molecule’s atoms, in its atom order.
- vibesketch.chem.clean.clean_2d(mol, *, bond_length=1.0)¶
Standard coordinates for
molthat follow its drawn 2D conformer.molis one connected molecule with its drawing as conformer 0 and its stereochemistry assigned. The result has every bondbond_lengthlong and sits where the drawing was.Nonewhen there is nothing to clean (a lone atom) or no layout could be made.