mdtraj.rmsd

mdtraj.rmsd(target, reference, frame=0, atom_indices=None, parallel=True, precentered=False)

Compute RMSD of all conformations in target to a reference conformation. Note, this will center the conformations in place.

Parameters:

target : md.Trajectory

For each conformation in this trajectory, compute the RMSD to a particular ‘reference’ conformation in another trajectory object.

reference : md.Trajectory

The object containing the reference conformation to measure distances to.

frame : int

The index of the conformation in reference to measure distances to.

atom_indices : array_like, or None

The indices of the atoms to use in the RMSD calculation. If not supplied, all atoms will be used.

ref_atom_indices : array_like, or None

Use these indices for the reference trajectory. If not supplied, the atom indices will be the same as those for target.

parallel : bool

Use OpenMP to calculate each of the RMSDs in parallel over multiple cores.

precentered : bool, default=False

Assume that the conformations are already centered at the origin, and that the “rmsd_traces” have been computed, as is done by Trajectory.center_coordinates. The “rmsd_traces” are intermediate calculations needed for the RMSD calculation which can be computed independently on each trajectory. Note that this has the potential to be unsafe; if you use Trajectory.center_coordinates and then modify the trajectory’s coordinates, the center and traces will be out of date and the RMSDs will be incorrect.

Returns:

rmsds : np.ndarray, shape=(target.n_frames,)

A 1-D numpy array of the optimal root-mean-square deviations from the frame-th conformation in reference to each of the conformations in target.

Notes

This function uses OpenMP to parallelize the calculation across multiple cores. To control the number of threads launched by OpenMP, you can set the environment variable OMP_NUM_THREADS.

Examples

>>> import mdtraj as md                                      
>>> rmsds = md.rmsd(trajectory, trajectory, 0)               
>>> print rmdsds                                             
array([ 0.0,  0.03076187,  0.02549562, ...,  0.06230228,
    0.00666826,  0.24364147])

The calculation is slightly faster if you precenter the trajectory

>>> trajectory.center_coordinates()
>>> rmsds = md.rmsd(trajectory, trajectory, 0, precentered=True)