Skip to content

How Clean Up Structure decides what to move

Clean Up Structure sets standard bond lengths and drawing angles. The passes below run in order; the thresholds decide which atoms move.

Ibuprofen as a bond-line structure, twice. On the left, drawn by hand: the ring is lopsided, the bonds have different lengths, and the chain angles vary. On the right, after Clean Up Structure: the ring is a regular hexagon, every bond has the same length, and the chains zigzag at 120 degrees.
Ibuprofen before and after Structure > Clean Up Structure.

Structure > Clean Up Structure adjusts atom positions in five passes, applied to each connected molecule separately:

  1. Rings. A ring of three to eight atoms that shares no atom with another ring becomes a regular polygon with standard bond lengths. It keeps its center and its turn on the page, and the groups on each ring atom move with that atom. Fused and bridged rings are not reshaped, and neither is a ring whose double bond has an E or Z label (a trans double bond in a small ring, which a regular polygon would draw cis).
  2. Bond lengths. Starting from the atom with the most neighbors, each chain bond that differs by more than 2% from the standard bond length of the document is set to that length. Everything beyond the bond moves with it, so the bonds farther out keep their lengths and angles. A bond in a fused or bridged ring system is changed only when it differs by more than 15%, and then it is pulled most of the way toward the standard length, because such drawings have deliberately longer and shorter bonds.
  3. Straightening. At an atom with exactly two bonds that are within 8° of a straight line, the neighbors are aligned on a single axis.
  4. Angles. Angles are set to the drawing’s standard, not the 3D one: 120° along a chain and at a branch point with three bonds, and 180° at a linear center such as an alkyne carbon. The smaller side of the molecule turns as a whole, so the rest of the drawing stays where it is. An angle within 2° of its target is left as it is. A substituent on a ring is placed on the outer bisector of its two ring bonds. Atoms with four or more bonds, and the angles inside rings, are not changed. A Lewis structure in the square layout (drawn hydrogens or lone pairs, with bonds at 90° and 180°) keeps all of its angles; only the other passes apply to it.
  5. Overlap repair. Atoms closer together than about a third of a bond length are pushed apart. An atom exactly on top of a bonded neighbor is moved a full bond length away, at a new angle.
  • The molecule itself: the same atoms, bonds, and stereocenters. Wedges and hashes keep their meaning, because a side of the molecule turns as a whole.
  • A drawing that is already clean: running the command again changes nothing.
  • Hydrogen bonds and dotted bonds, and the gap they span. They do not join two molecules into one, so each molecule is tidied on its own and neither is pulled toward the other. In Molkit Script, cleanup a leaves a molecule that is hydrogen-bonded to a where it is.

For small slips only, use Structure > Straighten Bonds instead: it changes no bond length and no angle beyond the slip.