API Reference¶
Module chemview.widget
¶
-
class
RepresentationViewer
(self, width=500, height=500)¶ RepresentationViewer is an IPython notebook widget useful to display 3d scenes through webgl.
Example:
from IPython.display import display rv = RepresentationViewer() rv.add_representation('point', {'coordinates': coordinates, 'colors': colors, 'sizes': sizes}) display(rv)
-
add_representation
(self, rep_type, options)¶ Add a 3D representation to the viewer. See User Guide for a complete description of the representations available.
Returns: An unique hexadecimal identifier for the representation. Return type: str
-
-
class
TrajectoryControls
(self, n_frames, fps=30)¶ Play/Pause controls useful for playing trajectories.
Example:
You can connect a callback to be executed every time the frame changes.
from IPython.display import display controls = TrajectoryControls(10) # 10 frames def callback(frame): print("Current frame %d" % frame) controls.on_frame_change(callback) display(controls)
-
frame
¶ Current frame
-
n_frames
¶ Total number of frames
-
fps
¶ Frames per second (defaults to 30)
-
on_frame_change
(self, callback)¶ Connect a callback to be executed every time the frame attribute changes.
-
Module chemview.viewer
¶
-
class
MolecularViewer
(self, coordinates, topology, width=500, height=500)¶ Create a Molecular Viewer widget to be displayed in IPython notebook.
Parameters: - coordinates (np.ndarray) – A numpy array containing the 3D coordinates of the atoms to be displayed
- topology (dict) – A dict specifying the topology as described in the User Guide.
-
points
(self, size=1.0)¶ Display the system as points.
Parameters: size (float) – the size of the points.
-
lines
(self)¶ Display the system bonds as lines.
-
wireframe
(self, pointsize=0.2)¶ Display atoms as points of size pointsize and bonds as lines.
-
ball_and_sticks
(self, ball_radius=0.05, stick_radius=0.02)¶ Display the system using a ball and stick representation.
-
line_ribbon
(self)¶ Display the protein secondary structure as a white lines that passes through the backbone chain.
-
cylinder_and_strand
(self)¶ Display the protein secondary structure as a white, solid tube and the alpha-helices as yellow cylinders.
-
add_isosurface
(self, function, isolevel=0.3, resolution=32, style='wireframe', color=16777215)¶ Add an isosurface to the current scene.
Parameters: - function (callable) – A function that takes x, y, z coordinates as input and is broadcastable using numpy. Typically simple
functions that involve standard arithmetic operations and functions
such as
x**2 + y**2 + z**2
ornp.exp(x**2 + y**2 + z**2)
will work. If not sure, you can first pass the function throughnumpy.vectorize
. Example:mv.add_isosurface(np.vectorize(f))
- isolevel (float) – The value for which the function should be constant.
- resolution (int) – The number of grid point to use for the surface. An high value will give better quality but lower performance.
- style (str) – The surface style, choose between
solid
,wireframe
andtransparent
. - color (int) – The color given as an hexadecimal integer. Example:
0xffffff
is white.
- function (callable) – A function that takes x, y, z coordinates as input and is broadcastable using numpy. Typically simple
functions that involve standard arithmetic operations and functions
such as
Module chemview.trajectory
¶
-
class
TrajectoryViewer
(self, coordinate_frames, topology, width=500, height=500)¶ Display a trajectory in the IPython notebook.
Parameters: - coordinate_frames (list) – A list containing the positions of the atoms (as np.ndarray) for each frame.
- topology (dict) – A dictionary specifying the topology
See also