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)[source]¶ Apply transformation to atoms, see
applyTransformation()
for details.
-
-
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 anAtomPointer
instance, transformation will be applied to the corresponding coordinate set in the associatedAtomGroup
.
-
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 (RMSD) between reference and target coordinates.
In [1]: ens = loadEnsemble('p38_X-ray.ens.npz') In [2]: ens.getRMSDs() Out[2]: array([0.7443987 , 0.74355378, 0.52185433, 0.58234161, 0.60268166, 0.6058487 , 0.71975176, 0.623668 , 0.74741889, 0.66964248, 0.63922048, 0.48018414, 0.53282063, 0.47197335, 0.75506619, 0.54868585, 0.83162589, 0.4899734 , 0.69835376, 0.73231431, 0.68858523, 0.4887872 , 0.68812647, 0.60303834, 0.72827758, 0.64168995, 0.51724041, 0.51122994, 0.64718648, 0.84399607, 0.78766045, 0.70309442, 0.82324608, 1.19563446, 0.60984379, 1.14440721, 0.71835052, 0.62561277, 0.74182964, 0.57545409, 0.99768239, 0.94804052, 0.85688493, 0.98495959, 0.58343183, 0.62465345, 0.64857577, 0.90593991, 0.82633783, 0.95481028, 0.88755069, 0.84396965, 0.84801322, 1.10951102, 0.70119389, 0.72610628, 0.87768385, 0.77452275, 0.82542571, 0.88260941, 0.96339073, 0.64103974, 0.92523088, 1.08523834, 0.4338322 , 0.42430438, 0.48606473, 0.64939189, 0.88422234, 0.72883815, 0.91364907, 0.96761307, 1.23918934, 0.58593841, 0.65549624, 0.81060749, 0.7961006 ]) In [3]: calcRMSD(ens) Out[3]: array([0.7443987 , 0.74355378, 0.52185433, 0.58234161, 0.60268166, 0.6058487 , 0.71975176, 0.623668 , 0.74741889, 0.66964248, 0.63922048, 0.48018414, 0.53282063, 0.47197335, 0.75506619, 0.54868585, 0.83162589, 0.4899734 , 0.69835376, 0.73231431, 0.68858523, 0.4887872 , 0.68812647, 0.60303834, 0.72827758, 0.64168995, 0.51724041, 0.51122994, 0.64718648, 0.84399607, 0.78766045, 0.70309442, 0.82324608, 1.19563446, 0.60984379, 1.14440721, 0.71835052, 0.62561277, 0.74182964, 0.57545409, 0.99768239, 0.94804052, 0.85688493, 0.98495959, 0.58343183, 0.62465345, 0.64857577, 0.90593991, 0.82633783, 0.95481028, 0.88755069, 0.84396965, 0.84801322, 1.10951102, 0.70119389, 0.72610628, 0.87768385, 0.77452275, 0.82542571, 0.88260941, 0.96339073, 0.64103974, 0.92523088, 1.08523834, 0.4338322 , 0.42430438, 0.48606473, 0.64939189, 0.88422234, 0.72883815, 0.91364907, 0.96761307, 1.23918934, 0.58593841, 0.65549624, 0.81060749, 0.7961006 ]) In [4]: calcRMSD(ens.getCoords(), ens.getCoordsets(), ens.getWeights()) Out[4]: array([0.7443987 , 0.74355378, 0.52185433, 0.58234161, 0.60268166, 0.6058487 , 0.71975176, 0.623668 , 0.74741889, 0.66964248, 0.63922048, 0.48018414, 0.53282063, 0.47197335, 0.75506619, 0.54868585, 0.83162589, 0.4899734 , 0.69835376, 0.73231431, 0.68858523, 0.4887872 , 0.68812647, 0.60303834, 0.72827758, 0.64168995, 0.51724041, 0.51122994, 0.64718648, 0.84399607, 0.78766045, 0.70309442, 0.82324608, 1.19563446, 0.60984379, 1.14440721, 0.71835052, 0.62561277, 0.74182964, 0.57545409, 0.99768239, 0.94804052, 0.85688493, 0.98495959, 0.58343183, 0.62465345, 0.64857577, 0.90593991, 0.82633783, 0.95481028, 0.88755069, 0.84396965, 0.84801322, 1.10951102, 0.70119389, 0.72610628, 0.87768385, 0.77452275, 0.82542571, 0.88260941, 0.96339073, 0.64103974, 0.92523088, 1.08523834, 0.4338322 , 0.42430438, 0.48606473, 0.64939189, 0.88422234, 0.72883815, 0.91364907, 0.96761307, 1.23918934, 0.58593841, 0.65549624, 0.81060749, 0.7961006 ])
-
calcTransformation
(mobile, target, weights=None)[source]¶ Returns 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, orAtomic
instances, e.g.AtomGroup
,Chain
, orSelection
.
-
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 theAtomGroup
, 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.- by (
-
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:
-
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.