next up previous contents
Next: Remote connection objects Up: Function and Class Previous: Display objects

Molecule objects

 

The following objects are used to store and represent the molecules in VMD, including their static data as well as their dynamic data. Items which have a specific section listed for them are explained in detail in that section.

  
Table 6.3: VMD molecule objects, part 1.

  
Table 6.4: VMD molecule objects, part 2.

Animation

 

Description

Animation is a base class for all Molecule objects in VMD . It is responsible for storing the dynamic data for molecule -- those items which vary with time, instead of remaining constant. Animation

stores an animation list, and has controls to add new data to the end of the list, as well as to position a current frame pointer in the list. Each time a Molecule is prepared (by calling it's virtual prepare routine since Molecule is derived from Displayable ), the current position in the animation list is updated.

The Animation consists of basically an array of Timestep

objects. Each Timestep contains the data for the molecule for a single step in the trajectory of the system.

Constructors

Enumerations, lists or character name arrays

The AnimDir enumeration lists the different directions in which the animation can be moving:

The AnimPos enumeration lists different positions in the list to which the animation position can jump, or can have new elements inserted or deleted:

The AnimFrames enumeration lists the different ways in which frames can be added or deleted. It is either ALL, or SELECTION.

The AnimStyle enumeration lists the different ways in which animation can be done:

Internal data structures

Nonvirtual member functions

Method of use

Adding new frames:

To add new frames, do the following:
  1. Set the method for appending, either at the end, or beginning, or before or after some current frame.
  2. Call the append routine.

Updating the current position:

The anim_update routine changes the current position based on the current animation direction and style. It also sets flags indicating whether the current frame was changed any. It will return the index of the new current frame, which can be used to get the actual Timestep object for that frame.

Suggestions for future changes/additions

Right now, this is very top-level base class for Molecule , even higher than the BaseMolecule level. The functionality here could probably be rolled into BaseMolecule , so that a single class would have info about the structure and size of the molecule is was storing dynamic data for. Basically, it's backwards to have Animate above BaseMolecule .

Atom

 

Description

An Atom object stores the data for a single atom in a molecule. Each atom has the following information:

Each BaseMolecule contains a list of these Atom objects.

Constructors

Enumerations, lists or character name arrays

Each atom has a set of `extra' data values, other than it's position. The codes used as indices for these extra data values are:

The BackboneType enumeration lists the different types of backbone bonds which may exist:

The ResidueType enumeration lists the different classes of residues which this atom may be a part of:

Internal data structures

Nonvirtual member functions

Method of use

To create a new Atom , you specify all the names in the constructor, and then add the bonds to the atom one at a time using the add_bond routine. Later, when the molecular structure has been analyzed, the flags indicating the residue type, fragment index, etc. must be set (they are currently public members, so they can be accessed directly).

BaseMolecule

 

Description

BaseMolecule is the second-highest level in the class hierarchy for Molecule objects; it is derived from Animation , and is used to store the static information for the molecule, which is the basic information about the structure and contents of the system which do not change with time. BaseMolecule has no ability to read in this information itself, instead it provides routines which derived classes call in order to add new molecules, bonds, etc. to the molecule. BaseMolecule has no responsibility for graphically displaying the molecule, either; that is left to the DrawMolecule class, which is derived from BaseMolecule and Displayable .

You do not ever create a BaseMolecule instance directly, instead you create an instance of a class derived from Molecule , for which BaseMolecule is a base class (among others). When initially created, a new BaseMolecule is empty, with zero atoms and zero bonds. The derived classes contain the actual code to read in the molecular structure from a file or from a network connection, and they add the components to the internal storage via routines in BaseMolecule . When all the structure is completely read in, then routine are called in BaseMolecule

to analyze the structure, and calculate such things as what atoms are in what residues, how many residues there are, what are the backbone bonds, etc. In fact, a molecule contains these structural features which are either directly added to BaseMolecule , or calculated by BaseMolecule after the basic structure is read in:

After the atoms and bonds are added to the BaseMolecule , then the connectivity is analyzed and the names of the atoms are used to find the backbone bonds, the residues in the system, and the fragments. Atoms, bonds, residues, and other components are numbered 0 ... N-1 in their respective lists.

One other item which BaseMolecule stores is the unique molecule ID number, which is assigned when the molecule is created. Each new molecule in VMD gets assigned an integer ID. The assigned ID values increase by one as each new system is loaded. The commands used to affect the molecules use these ID numbers to determine which molecule the command should affect. The name of the molecule displayed in the Molecule on-screen menu form has this ID number appended to the end of it.

Constructors

Enumerations, lists or character name arrays

The MoleculeType enumeration lists the different type of molecules which VMD understands. When the structure is analyzed, the type of molecule is determined. The types are:

Internal data structures

Nonvirtual member functions

Virtual member functions

Method of use

A new molecule is first created by using `new' with the proper subclass of Molecule ( Molecule is the `standard' class to use for all molecule objects in VMD ; classes derived from Molecule are specialized to read in data from different sources, while classes above the Molecule

level only deal with some of the information required to store and display and animate a structure.). Then, after the new instance is assigned to a Molecule pointer, then the create() virtual function should be called. This will actually result in all the action being done, for example data files will be read or network connections will be established. The version of create() in BaseMolecule should be called after the molecule has been read in by the derived classes. It analyzes the structure and finds the backbone bonds, fragments, etc. When create() is finished, the molecule is ready to go. If create() does not return TRUE, however, the creation failed (i.e. the files could not be opened), and the new molecule will still be empty.

DrawMolecule

 

Description

DrawMolecule is derived from BaseMolecule , and is the next level in the Molecule class hierarchy. It embodies the level of control and functionality responsible for creating a graphical image of the molecule. It is derived from Displayable (actually, from Displayable3D), and so will be part of the Scene that will be drawn by a DisplayDevice .

Each DrawMolecule keeps a list of DrawMolItem objects; each DrawMolItem is also a Displayable , and is responsible for a single representation of the molecule. Each representation contains a display list used to draw a single view of the molecule. To define a single representation, each DrawMolItem contains one instance each of the following objects:

When a new DrawMolecule is created (i.e. when a new Molecule

is created), it is added as a child Displayable to a global MoleculeList object. Thus, you can rotate just the MoleculeList , and this will rotate all the molecules at the same time. When a molecule is first displayed, it is scaled and translated to fit within a -1 ... 1 size box centered around the origin. In order to have all the molecules be the proper size in relation to each other, and to preserve the spatial position of the molecules, only one molecule is used to determine the scaling and translation positions, and the others then use those same scaling and translation values.

Each DrawMolItem added to this object are added as child Displayable objects of DrawMolecule , and so scaling and rotating the molecule will do so to all the DrawMolItem objects at the same time.

Constructors

Internal data structures

Nonvirtual member functions

Virtual member functions

Method of use

The user should never create a DrawMolecule directly; it should instead be used as a base class for Molecule .

Molecule

 

Description

This is the class used generally throughout VMD to represent and access a molecule. It is derived from several base classes which provide the storage and control over the molecule's structure ( BaseMolecule ), animation list ( Animation ), and graphical display ( DrawMolecule ). It still does not contain the abilities to read in new molecular data from different sources, instead these are in classes derived from Molecule . This class is used as the basic class that all other parts of VMD \ are aware of, since once a molecule is read in from some source, it acts just like any other molecule.

The one level of extra functionality which is provided directly by the Molecule class is the ability to read in new coordinate frames from an external coordinate file, either a PDB or a DCD file.

Constructors

Internal data structures

Nonvirtual member functions

Virtual member functions

Method of use

New molecules are created in VMD in the CmdMolNew object, which is a particular Command -derived object. When a new molecule is to be created, the type of molecule source and necessary data are specified (such as filenames, remote computer names, etc) and given to the constructor of a specialized subclass of Molecule . The resulting (empty) molecule is assigned to a Molecule * pointer variable, and then the virtual create routine is called. After this, the molecule is added to the MoleculeList , and any extra actions are taken such as requesting for more coordinate files to be read, etc.

Timestep

 

Description

The Timestep class is used to hold the dynamic data for a Molecule

for a single step in a trajectory. It hold the coordinates, velocities, energies, etc. that vary with time. As each new Timestep is read in from some source (a file, or from a network connection) it is added to the animation list for the associated molecule; this list is maintained by the Animation object, from which each Molecule is derived.

Almost all the items in this class are public, so they may be retrieved quickly by other objects in VMD . This is not such a great design, however; see the notes below about future changes.

Constructors

Enumerations, lists or character name arrays

There are a number of globally defined macros in this class which are used as indices into the data arrays stored by this object. They are:

  1. Energy Data Indices:

  2. Per-Atom Data Indices:

  3. Per-Patch Data Indices:

Internal data structures

Nonvirtual member functions

Method of use

A new Timestep is created each time new coordinate data needs to be added to the end of the animation list. Use the following steps:

  1. Create a new instance: Timestep *ts = new Timestep(atoms, dt);

  2. Copy coordinate and energy data into the proper arrays, by accessing the public data items described above.

  3. If there is patch data, first call create_patch_storage with the number of patches (to allocate storage), and then copy the patch data into the array which is returned by the function.

  4. After all data is entered, the last step is to call the init routine. This goes through all the stored quantities (x, y, z position, atoms/patch, etc) and calculates the maximum and minimum values. It also finds the position of the center of volume, and the proper scaling factor.

Suggestions for future changes/additions

This could perhaps benefit from having a NameList store the different quantities, with a specific name associated with each quantity. Then, instead of having to hard-code into Timestep what data is being stored, you could just have a routine to add new items with a given name to the object, and other routines to access data by providing the proper name and index (or maybe just provide the name, and have returned the proper array storing the data).



next up previous contents
Next: Remote connection objects Up: Function and Class Previous: Display objects



Andrew Dalke
Wed May 15 02:25:03 CDT 1996