schrodinger.ui.sketcher_extensions module

schrodinger.ui.sketcher_extensions.set_structure(sk: sketcher, st: Structure)
Parameters:
  • sk – given sketcher instance

  • st – Structure to set into the sketcher

schrodinger.ui.sketcher_extensions.get_structure(sk: sketcher, sanitize: bool = False, include_selected_props: bool = False) → Optional[Structure]
Parameters:
  • sk – given sketcher instance

  • sanitize – whether to sanitize the extracted structure

  • include_selected_props – whether to include selected atom properties

Returns:

extracted Structure object with 3D coordinates, or if available, 3D coordinates aligned to sketcher input 3D coordinates. If an error occurs, a messagebox will pop and None returned.

schrodinger.ui.sketcher_extensions.get_cg_structure(sk: CoarseGrainedSketcher) → Structure
Parameters:

sk – given CG sketcher instance

Returns:

extracted Structure object with 2D coordinates

Raises:

ValueError – if the provided sketcher is not a CG sketcher or if the coarse-grained license is not available

schrodinger.ui.sketcher_extensions.set_cg_structure(sk, st)

Load a coarse-grained structure into the sketcher.

Clears the canvas and places particles and bonds from st. Toolbar particle type buttons are merged: existing buttons survive; new particle types from st receive new buttons without a dialog.

2D layout is computed from the bond graph via RDKit so that ring systems are correctly depicted. Stored 3D coordinates are not used directly as their projection to 2D causes placement collisions.

Parameters:
  • sk (sketcher.CoarseGrainedSketcher) – CoarseGrained sketcher instance

  • st (Structure) – CG structure to load

Raises:
  • ValueError – if sk is not a CoarseGrainedSketcher

  • sketcher.StdException – if the serialized structure is malformed or missing required coarse-grained atom properties

schrodinger.ui.sketcher_extensions.compute_cg_pixel_positions(st)

Compute RDKit 2D pixel positions for each atom in st.

Uses prepare_cg_for_rdkit to assign proxy elements, then runs rdDepictor.Compute2DCoords so that ring systems are correctly laid out. The Y axis is inverted to match the sketcher’s Qt coordinate system (positive Y downward).

Parameters:

st (Structure) – CG structure

Returns:

tuple of (px_x, px_y) lists, one entry per atom in st.atom order (0-indexed, matching RDKit atom indices)

Return type:

tuple(list(float), list(float))