molsysmt.basic.view#

molsysmt.basic.view(molecular_system=None, selection='all', structure_indices='all', standard=True, with_water_as=None, with_ions_as=None, viewer='NGLView', syntax='MolSysMT', skip_digestion=False)[source]#

Visualizing a molecular system.

This function displays a molecular system using an external interactive 3D visualization library (viewer) inside a Jupyter notebook. The visualization can be customized by selecting specific atoms or structures, choosing representations for water and ions, and applying a standardized visual layout.

Parameters:
  • molecular_system (molecular system, optional) – Molecular system to be displayed. It can be in any of the supported forms. If None, an empty viewer is returned.

  • selection (str, tuple, list or numpy.ndarray, default='all') – Selection of atoms to be shown. It can be a list/array of 0-based indices, or a query string using one of the supported selection syntaxes. The default ‘all’ includes all atoms in the system.

  • structure_indices (int, tuple, list, numpy.ndarray or 'all', default='all') – 0-based indices of structures to be shown. The default ‘all’ includes all structures.

  • standard (bool, default=True) – Whether to apply a default standardized visual layout. This includes representations and color schemes for typical biomolecular systems.

  • with_water_as ({'licorice', 'surface', None}, default=None) – Representation used for water molecules. If None, water is not displayed.

  • with_ions_as ({'licorice', 'balls', 'balls and sticks', None}, default=None) – Representation used for ions. If None, ions are not displayed.

  • viewer ({'NGLView'}, default='NGLView') – Viewer backend to use for visualization. Currently, only ‘NGLView’ is supported.

  • syntax (str, default='MolSysMT') – Syntax used to interpret the selection string. See Selection syntaxes for details.

  • skip_digestion (bool, default=False) –

    Whether to skip MolSysMT’s internal argument digestion mechanism.

    MolSysMT includes a built-in digestion system that validates and normalizes function arguments. This process checks types, shapes, and values, and automatically adjusts them when possible to meet expected formats.

    Setting skip_digestion=True disables this process, which may improve performance in workflows where inputs are already validated. Use with caution: only set this to True if you are certain all input arguments are correct and consistent.

Returns:

Visualization widget returned by the selected viewer. For ‘NGLView’, this is an nglview.NGLWidget instance.

Return type:

object

Raises:
  • NotSupportedFormError – If the molecular system is provided in an unsupported form.

  • ArgumentError – If one or more input arguments are invalid.

Notes

  • Supported molecular-system forms are described in Forms.

  • Selection syntaxes and valid query expressions are described in Selection syntaxes.

  • Currently, the only supported viewer is ‘NGLView’.

  • The standardized visual layout includes cartoon representations for proteins, licorice for

ligands, and appropriate color schemes. See View for details.

See also

molsysmt.basic.select()

Selecting atoms or elements from a molecular system.

Examples

The following example illustrates how to visualize only the protein component of a molecular system:

>>> import molsysmt as msm
>>> molecular_system = msm.systems['T4 lysozyme L99A']['181l.h5msm']
>>> msm.basic.view(molecular_system, selection='molecule_type=="protein"', viewer='NGLView')
NGLWidget()

Tutorial with more examples

See the following tutorial for a practical demonstration of how to use this function, along with additional examples: View

Added in version 1.0.0.