Module Scientific.Visualization.VMD

This module provides definitions of simple 3D graphics objects and scenes containing them, in a form that can be fed to the molecular visualization program VMD. Scenes can either be written as VMD script files, or visualized directly by running VMD.

There are a few attributes that are common to all graphics objects:

material

a Material object defining color and surface properties

comment

a comment string that will be written to the VRML file

reuse

a boolean flag (defaulting to false). If set to one, the object may share its VRML definition with other objects. This reduces the size of the VRML file, but can yield surprising side effects in some cases.

This module is almost compatible with the modules VRML and VRML2, which provide visualization by VRML browsers. There is no Polygon objects, and the only material attribute supported is diffuse_color. Note also that loading a scene with many cubes into VMD is very slow, because each cube is represented by 12 individual triangles.

Example:

from VMD import *
scene = Scene([])
scale = ColorScale(10.)
for x in range(11):
    color = scale(x)
    scene.addObject(Cube(Vector(x, 0., 0.), 0.2,
                         material=Material(diffuse_color = color)))
scene.view()

Functions


Class Scene: VMD scene

A VMD scene is a collection of graphics objects that can be written to a VMD script file or fed directly to VMD.

Constructor: Scene(objects=None, **|options|)

objects

a list of graphics objects or None for an empty scene

options

options as keyword arguments. The only option available is "scale", whose value must be a positive number which specifies a scale factor applied to all coordinates of geometrical objects except for molecule objects, which cannot be scaled.

Methods:

Class Molecules: Molecules from a PDB file

Constructor: Molecules(pdb_file)


Class Sphere: Sphere

Constructor: Sphere(center, radius, **|attributes|)

center

the center of the sphere (a vector)

radius

the sphere radius (a positive number)

attributes

any graphics object attribute


Class Cube: Cube

Constructor: Cube(center, edge, **|attributes|)

center

the center of the cube (a vector)

edge

the length of an edge (a positive number)

attributes

any graphics object attribute

The edges of a cube are always parallel to the coordinate axes.


Class Cylinder: Cylinder

Constructor: Cylinder(point1, point2, radius, faces=(1, 1, 1), **|attributes|)

point1, point2

the end points of the cylinder axis (vectors)

radius

the radius (a positive number)

attributes

any graphics object attribute

faces

a sequence of three boolean flags, corresponding to the cylinder hull and the two circular end pieces, specifying for each of these parts whether it is visible or not.


Class Cone: Cone

Constructor: Cone(point1, point2, radius, face=1, **|attributes|)

point1, point2

the end points of the cylinder axis (vectors). point1 is the tip of the cone.

radius

the radius (a positive number)

attributes

any graphics object attribute

face

a boolean flag, specifying if the circular bottom is visible


Class Line: Line

Constructor: Line(point1, point2, **|attributes|)

point1, point2

the end points of the line (vectors)

attributes

any graphics object attribute


Class Arrow: Arrow

An arrow consists of a cylinder and a cone.

Constructor: Arrow(point1, point2, radius, **|attributes|)

point1, point2

the end points of the arrow (vectors). point2 defines the tip of the arrow.

radius

the radius of the arrow shaft (a positive number)

attributes

any graphics object attribute


Class Material: Material for graphics objects

A material defines the color and surface properties of an object.

Constructor: Material(**|attributes|)

The accepted attributes are "ambient_color", "diffuse_color", "specular_color", "emissive_color", "shininess", and "transparency". Only "diffuse_color" is used, the others are permitted for compatibility with the VRML modules.