# Reference for Module MMTK

MMTK is the base module of the Molecular Modelling Toolkit. It contains the most common objects and all submodules. As a convenience to the user, it also imports some commonly used objects from other libraries:

- `Vector` from `Scientific.Geometry`

- `Translation` and `Rotation` from `Scientific.Geometry.Transformation`

- `copy` and `deepcopy` from `copy`

- `stdin`, `stdout`, and `stderr` from `sys`

## Functions

- save()

  Writes object to a newly created file with the name filename, for later retrieval by `load()`.

- load()

  Loads the file indicated by filename, which must have been produced by `save()`, and returns the object stored in that file.

# Submodules:

- Module MMTK.Biopolymers

- Module MMTK.ChargeFit

- Module MMTK.ChemicalObjects

- Module MMTK.Collection

- Module MMTK.DCD

- Module MMTK.Deformation

- Module MMTK.Dynamics

- Module MMTK.Environment

- Module MMTK.Field

- Module MMTK.ForceFields

- Module MMTK.FourierBasis

- Module MMTK.Geometry

- Module MMTK.Minimization

- Module MMTK.MolecularSurface

- Module MMTK.NormalModes

- Module MMTK.NucleicAcids

- Module MMTK.PDB

- Module MMTK.ParticleProperties

- Module MMTK.Proteins

- Module MMTK.Random

- Module MMTK.Solvation

- Module MMTK.Subspace

- Module MMTK.Trajectory

- Module MMTK.Units

- Module MMTK.Universe

- Module MMTK.Visualization

- Module MMTK.Visualization_win32

## Class ParticleScalar: Scalar property defined for each particle

A subclass of MMTK.ParticleProperties.ParticleProperty.

ParticleScalar objects can be added to each other and multiplied with scalars.

Methods:

- maximum()

  Returns the highest value for any particle.

- minimum()

  Returns the smallest value for any particle.

- applyFunction(function)

  Applies function to each value and returns the result as a new ParticleScalar object.

## Class ParticleVector: Vector property defined for each particle

A subclass of MMTK.ParticleProperties.ParticleProperty.

ParticleVector objects can be added to each other and multiplied with scalars or MMTK.ParticleScalar objects; all of these operations result in another ParticleVector object. Multiplication with a vector or another ParticleVector object yields a MMTK.ParticleScalar object containing the dot products for each particle. Multiplications that treat ParticleVectors as vectors in a 3N-dimensional space are implemented as methods.

Methods:

- length()

  Returns a ParticleScalar containing the length of the vector for each particle.

- norm()

  Returns the norm of the ParticleVector seen as a 3N-dimensional vector.

- dotProduct(other)

  Returns the dot product with other (a ParticleVector) treating both operands as 3N-dimensional vectors.

- massWeightedDotProduct(other)

  Returns the mass-weighted dot product with other (a ParticleVector object) treating both operands as 3N-dimensional vectors.

- dyadicProduct(other)

  Returns a MMTK.ParticleTensor object representing the dyadic product with other (a ParticleVector).

## Class Configuration: Configuration of a universe

A subclass of MMTK.ParticleVector.

Its instances represent a configuration of a universe, consisting of positions for all atoms (like in a ParticleVector) plus the geometry of the universe itself, e.g. the cell shape for periodic universes.

## Class ParticleTensor: Rank-2 tensor property defined for each particle

A subclass of MMTK.ParticleProperties.ParticleProperty.

ParticleTensor objects can be added to each other and multiplied with scalars or MMTK.ParticleScalar objects; all of these operations result in another ParticleTensor object.

## Class Atom: Atom

A subclass of MMTK.ChemicalObjects.ChemicalObject.

Constructor: Atom(element, **|properties|)

element

  a string (not case sensitive) specifying the chemical element

properties

  optional keyword properties:

  - position: the atom position (a vector)

  - name: the atom name (a string)

Methods:

- setPosition(position)

  Changes the position to position.

- position(conf=`None`)

  Returns the position in configuration conf. If conf is `None`, use the current configuration. If the atom has not been assigned a position, the return value is `None`.

- setMass(mass)

  Set the atom mass to mass.

- bondedTo()

  Returns a list of all atoms to which a chemical bond exists.

## Class Collection: Collection of chemical objects

A subclass of MMTK.Collection.GroupOfAtoms and MMTK.Visualization.Viewable.

Collections permit the grouping of arbitrary chemical objects (atoms, molecules, etc.) into one object for the purpose of analysis or manipulation.

Constructor: Collection(objects=None)

objects

  a chemical object or a sequence of chemical objects that define the initial content of the collection.

Collections permit length inquiry, item extraction by indexing, and iteration, like any Python sequence object. Two collections can be added to yield a collection that contains the combined elements.

Methods:

- addObject(object)

  Adds object to the collection. If object is another collection or a list, all of its elements are added.

- removeObject(object)

  Removes object from the collection. If object is a collection or a list, each of its elements is removed. The object to be removed must be an element of the collection.

- selectShell(point, r1, r2=`0.0`)

  Return a collection of all elements whose distance from point is between r1 and r2.

- selectBox(p1, p2)

  Return a collection of all elements that lie within a box whose corners are given by p1 and p2.

- objectList(klass=`None`)

  Returns a list of all objects in the collection. If klass is not None, only objects whose class is equal to klass are returned.

- atomList()

  Returns a list containing all atoms of all objects in the collection.

- numberOfAtoms()

  Returns the total number of atoms in the objects of the collection.

- universe()

  Returns the universe of which the objects in the collection are part. If no such universe exists, the return value is `None`.

- map(function)

  Applies function to all objects in the collection and returns the list of the results. If the results are chemical objects, a Collection object is returned instead of a list.

- distanceConstraintList()

  Returns the list of distance constraints.

- numberOfDistanceConstraints()

  Returns the number of distance constraints.

- setBondConstraints(universe=`None`)

  Sets distance constraints for all bonds.

- removeDistanceConstraints(universe=`None`)

  Removes all distance constraints.

## Class Molecule: Molecule

A subclass of MMTK.ChemicalObjects.ChemicalObject.

Molecules consist of atoms and groups linked by bonds.

Constructor: Molecule(species, **|properties|)

species

  a string (not case sensitive) that specifies the molecule name in the chemical database

properties

  optional keyword properties:

  - position: the center-of-mass position (a vector)

  - configuration: the name of a configuration listed in the database definition of the molecule, which is used to initialize the atom positions. If no configuration is specified, the configuration named "default" will be used, if it exists. Otherwise the atom positions are undefined.

  - name: the atom name (a string)

Methods:

- findHydrogenPositions()

  Find reasonable positions for hydrogen atoms that have no position assigned.

  This method uses a heuristic approach based on standard geometry data. It was developed for proteins and DNA and may not give good results for other molecules. It raises an exception if presented with a topology it cannot handle.

## Class PartitionedCollection: Collection with cubic partitions

A subclass of MMTK.Collection.

A PartitionedCollection differs from a plain Collection by sorting its elements into small cubic cells. This makes adding objects slower, but geometrical operations like selectShell become much faster for a large number of objects.

Constructor: PartitionedCollection(partition_size, objects=None)

partition_size

  the edge length of the cubic cells

objects

  a chemical object or a sequence of chemical objects that define the initial content of the collection.

Methods:

- partitions()

  Returns a list of cubic partitions. Each partition is specified by a tuple containing two vectors (describing the diagonally opposite corners) and the list of objects in the partition.

- pairsWithinCutoff(cutoff)

  Returns a list containing all pairs of objects in the collection whose center-of-mass distance is less than cutoff.

## Class PartitionedAtomCollection: Partitioned collection of atoms

A subclass of MMTK.PartitionedCollection.

PartitionedAtomCollection objects behave like PartitionedCollection atoms, except that they store only atoms. When a composite chemical object is added, its atoms are stored instead.

Constructor: PartitionedAtomCollection(partition_size, objects=None)

partition_size

  the edge length of the cubic cells

objects

  a chemical object or a sequence of chemical objects that define the initial content of the collection.

## Class InfiniteUniverse: Infinite (unbounded and nonperiodic) universe.

A subclass of MMTK.Universe.Universe.

Constructor: InfiniteUniverse(forcefield=None)

forcefield

  a force field object, or `None` for no force field

## Class Complex: Complex

A subclass of MMTK.ChemicalObjects.ChemicalObject.

A complex is an assembly of molecules that are not connected by chemical bonds.

Constructor: Complex(species, **|properties|)

species

  a string (not case sensitive) that specifies the complex name in the chemical database

properties

  optional keyword properties:

  - position: the center-of-mass position (a vector)

  - configuration: the name of a configuration listed in the database definition of the complex

  - name: the atom name (a string)

## Class AtomCluster: An agglomeration of atoms

A subclass of MMTK.ChemicalObjects.ChemicalObject.

An atom cluster acts like a molecule without any bonds or atom properties. It can be used to represent a group of atoms that are known to form a chemical unit but whose chemical properties are not sufficiently known to define a molecule.

Constructor: AtomCluster(atoms, **|properties|)

atoms

  a list of atom objects

properties

  optional keyword properties:

  - position: the center-of-mass position (a vector)

  - name: the atom name (a string)

## Class OrthorhombicPeriodicUniverse: Periodic universe with orthorhombic elementary cell.

A subclass of MMTK.Universe.Universe.

Constructor: OrthorhombicPeriodicUniverse(shape, forcefield=None)

shape

  a sequence of length three specifying the edge lengths along the x, y, and z directions

forcefield

  a force field object, or `None` for no force field

Methods:

- scaleSize(factor)

  Multiplies all edge lengths by factor.

- setVolume(volume)

  Multiplies all edge lengths by the same factor such that the cell volume becomes volume.

## Class CubicPeriodicUniverse: Periodic universe with cubic elementary cell.

A subclass of MMTK.Universe.Universe.

shape

  a number specifying the edge length along the x, y, and z directions

forcefield

  a force field object, or `None` for no force field Constructor: CubicPeriodicUniverse(shape, forcefield=None)