3dmol format#

Aliases#

3dmol

Implementation: Py3DMolFormat

Overview#

Interactive py3Dmol visualization for one System frame.

py3Dmol is a Jupyter/Python wrapper for 3Dmol.js for interactive 3D molecular visualization.

This write-only in-memory adapter returns a configured py3Dmol viewer for use in Jupyter notebooks. It does not serialize a data format. The optional py3Dmol dependency is required.

Quick examples#

The examples use the preferred alias 3dmol; any alias listed above is equivalent.

import dpdata

# Load or construct the system to write
system = dpdata.System("input_file")

# Write geometry-only data
converted = system.to("3dmol")

Conversions#

Convert from System to this format#

dpdata.System.to(fmt: Literal['3dmol'], f_idx: 'int' = 0, size: 'tuple[int]' = (300, 300), style: 'dict' = {'stick': {}, 'sphere': {'radius': 0.4}}, **kwargs)
dpdata.System.to_3dmol(f_idx: 'int' = 0, size: 'tuple[int]' = (300, 300), style: 'dict' = {'stick': {}, 'sphere': {'radius': 0.4}}, **kwargs)

Show 3D structure of a frame in jupyter.

Parameters:
f_idxint

frame index to show

sizetuple[int]

(width, height) of the widget

styledict

style of 3DMol. Read 3DMol documentation for details.

**kwargsdict

other parameters

Examples

>>> system.to_3dmol()

Convert from LabeledSystem to this format#

dpdata.LabeledSystem.to(fmt: Literal['3dmol'], f_idx: 'int' = 0, size: 'tuple[int]' = (300, 300), style: 'dict' = {'stick': {}, 'sphere': {'radius': 0.4}}, **kwargs)
dpdata.LabeledSystem.to_3dmol(f_idx: 'int' = 0, size: 'tuple[int]' = (300, 300), style: 'dict' = {'stick': {}, 'sphere': {'radius': 0.4}}, **kwargs)

Show 3D structure of a frame in jupyter.

Parameters:
f_idxint

frame index to show

sizetuple[int]

(width, height) of the widget

styledict

style of 3DMol. Read 3DMol documentation for details.

**kwargsdict

other parameters

Examples

>>> system.to_3dmol()