Visualization Utilities#

Utility functions to visualize atom arrays with py3Dmol in Jupyter notebooks.

atomworks.io.utils.visualize.view(structure: AtomArray | AtomArrayStack, *, zoom_to_selection: dict[str, int | str] | None = None, show_hover: bool = True, show_unoccupied: bool = False, show_cartoon: bool = True, show_surface: bool = True, width: int = 600, height: int = 400, ligand_linewidth: float = 0.2, polymer_sidechain_linewidth: float = 0.05, min_polymer_size: int = 1, colors: list[str] = ['#888888', '#FAC72C', '#29B0C1', '#AAC32F', '#EC72A4', '#4499E7', '#DCDCDC', '#E44A3E', '#65B37C', '#4FB9AF', '#FFE0AC', '#FFC6B2', '#FFACB7', '#D59AB5', '#9596C6', '#6686C5', '#4B5FAA', '#222222']) view[source]#

Visualize an AtomArray structure using py3Dmol for display in jupyter notebooks.

Parameters:
  • structure (-) – The atomic structure to be visualized.

  • zoom_to_selection (-) –

    A dictionary specifying the selection to zoom into. Defaults to None. Here are some examples:

    • {‘serial’: 35} - will zoom to the atom with index 35 in the atom array

    • {‘chain’: ‘A’, ‘resi’: 35} - will zoom to the residue id 35 in chain A

    • `{‘chain’: ‘C’} - will zoom to the entire chain C

    !WARNING! If the selection is wrong, the visualization will be empty.

  • show_hover (-) – Whether to enable hover functionality to display atom details. Defaults to True.

  • show_unoccupied (-) – Whether to show unoccupied atoms. Defaults to False.

  • show_cartoon (-) – Whether to show the cartoon. Defaults to True.

  • show_surface (-) – Whether to show the surface. Defaults to False.

  • width (-) – The width of the visualization window. Defaults to 400.

  • height (-) – The height of the visualization window. Defaults to 300.

  • ligand_linewidth (-) – The linewidth for ligand representation. Defaults to 0.2.

  • polymer_sidechain_linewidth (-) – The linewidth for polymer sidechain representation. Defaults to 0.05.

  • min_polymer_size (-) – The minimum size for a chain to be displayed as a polymer. Defaults to 1.

  • colors (-) – A list of colors to cycle through for different chains. Defaults to IPD_PYMOL_COLORS.

Returns:

The py3Dmol view object for the structure visualization.

Return type:

py3Dmol.view