Transformations

This module defines a class for identifying contacts.

class Transformation(*args)[source]

A class for storing a transformation matrix.

Either 4x4 transformation matrix, or rotation matrix and translation vector must be provided at instantiation.

apply(atoms)

Apply transformation to atoms, see applyTransformation() for details.

getMatrix()

Returnss a copy of the 4x4 transformation matrix whose top left is rotation matrix and last column is translation vector.

getRotation()

Returns rotation matrix.

getTranslation()

Returns translation vector.

setRotation(rotation)

Set rotation matrix.

setTranslation(translation)

Set translation vector.

applyTransformation(transformation, atoms)[source]

Returns atoms after applying transformation. If atoms is a Atomic instance, it will be returned after transformation is applied to its active coordinate set. If atoms is an AtomPointer instance, transformation will be applied to the corresponding coordinate set in the associated AtomGroup.

alignCoordsets(atoms, weights=None)[source]

Returns atoms after superposing coordinate sets onto its active coordinate set. Transformations will be calculated for atoms and applied to its AtomGroup, when applicable. Optionally, atomic weights can be passed for weighted superposition.

calcRMSD(reference, target=None, weights=None)[source]

Returns root-mean-square deviation(s) (RMSD) between reference and target coordinates.

calcTransformation(mobile, target, weights=None)[source]

Returnss a Transformation instance which, when applied to the atoms in mobile, minimizes the weighted RMSD between mobile and target. mobile and target may be NumPy coordinate arrays, or Atomic instances, e.g. AtomGroup, Chain, or Selection.

superpose(mobile, target, weights=None)[source]

Returns mobile, after its RMSD minimizing superposition onto target, and the transformation that minimizes the RMSD.

moveAtoms(atoms, **kwargs)[source]

Move atoms to a new location or by an offset. This method will change the active coordinate set of the atoms. Note that only one of to or by keyword arguments is expected.

Move protein so that its centroid is at the origin, [0., 0., 0.]:

In [1]: from prody import *

In [2]: from numpy import ones, zeros

In [3]: protein = parsePDB('1ubi')

In [4]: calcCenter(protein).round(3)
Out[4]: array([ 30.173,  28.658,  15.262])

In [5]: moveAtoms(protein, to=zeros(3))

In [6]: calcCenter(protein).round(3)
Out[6]: array([ 0.,  0., -0.])

Move protein so that its mass center is at the origin:

In [7]: protein.setMasses(ones(len(protein)))

In [8]: protein.carbon.setMasses(12)

In [9]: protein.nitrogen.setMasses(14)

In [10]: protein.oxygen.setMasses(16)

In [11]: moveAtoms(protein, to=zeros(3), weights=protein.getMasses())

In [12]: calcCenter(protein, weights=protein.getMasses()).round(3)
Out[12]: array([-0., -0.,  0.])

Move protein so that centroid of Cα atoms is at the origin:

In [13]: moveAtoms(protein.ca, to=zeros(3), ag=True)

In [14]: calcCenter(protein).round(3)
Out[14]: array([-0.268, -0.343, -0.259])

In [15]: calcCenter(protein.ca).round(3)
Out[15]: array([ 0., -0., -0.])

Move protein by 10 A along each direction:

In [16]: moveAtoms(protein, by=ones(3) * 10)

In [17]: calcCenter(protein).round(3)
Out[17]: array([ 9.732,  9.657,  9.741])

In [18]: calcCenter(protein.ca).round(3)
Out[18]: array([ 10.,  10.,  10.])
Parameters:
  • by (numpy.ndarray) – an offset array with shape ([1,] 3) or (n_atoms, 3) or a transformation matrix with shape (4, 4)
  • to (numpy.ndarray) – a point array with shape ([1,] 3)
  • ag (bool) – when atoms is a AtomSubset, apply translation vector (to) or transformation matrix to the AtomGroup, default is False
  • weights (numpy.ndarray) – array of atomic weights with shape (n_atoms[, 1])

When to argument is passed, calcCenter() function is used to calculate centroid or mass center.

wrapAtoms(frame, unitcell=None, center=array([ 0., 0., 0.]))[source]

Wrap atoms into an image of the system simulated under periodic boundary conditions. When frame is a Frame, unitcell information will be retrieved automatically.

Note

This function will wrap all atoms into the specified periodic image, so covalent bonds will be broken.

Parameters:
  • frame (Frame, AtomGroup, numpy.ndarray) – a frame instance or a coordinate set
  • unitcell (numpy.ndarray) – orthorhombic unitcell array with shape (3,)
  • center (numpy.ndarray) – coordinates of the center of the wrapping cell, default is the origin of the Cartesian coordinate system
printRMSD(reference, target=None, weights=None, log=True, msg=None)[source]

Print RMSD to the screen. If target has multiple coordinate sets, minimum, maximum and mean RMSD values are printed. If log is True (default), RMSD is written to the standard error using package logger, otherwise standard output is used. When msg string is given, it is printed before the RMSD value. See also calcRMSD() function.