molsysmt.basic.view#
- molsysmt.basic.view(molecular_system=None, selection='all', structure_indices='all', viewer='MolSysViewer', syntax='MolSysMT', skip_digestion=False)[source]#
Visualizing a molecular system.
This function displays a molecular system using an external interactive 3D visualization library inside a Jupyter notebook. The visualization backend can be selected by the viewer argument.
- Parameters:
molecular_system (molecular system, default=None) – Molecular system in any supported MolSysMT format.
selection (str, list, tuple, or numpy.ndarray, default='all') – Selection string or boolean/integer array specifying elements.
structure_indices (int, list, tuple, or numpy.ndarray, default='all') – Structure indices (0-based) to include or process.
viewer (str, default='MolSysViewer') – Viewer backend used to create the interactive representation.
syntax (str, default='MolSysMT') – Selection syntax used to evaluate selection (e.g., ‘MolSysMT’, ‘MDTraj’).
skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.
- Returns:
Visualization widget returned by the selected viewer. For ‘MolSysViewer’, this is a molsysviewer.MolSysView instance. 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, including a malformed selection or an out-of-range element or structure index.
ModuleNotFoundError – If the requested viewer backend is not available in the current environment.
Notes
Supported molecular-system forms are described in Items and Forms.
Selection syntaxes and valid query expressions are described in Selection syntaxes.
Selections and structure indices are validated before the viewer backend is created.
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"') <molsysviewer.viewer.MolSysView object at 0x...>
Select an alternative backend (requires nglview):
>>> 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.