### Navigation

- index
- modules |
- next |
- previous |
- MDAnalysis 0.7.7 documentation »
- 3. Analysis modules »

# 3.11. Calculating root mean square quantities — `MDAnalysis.analysis.rms`

Author: | Oliver Beckstein
Year: | 2012
Copyright: | GNU Public License v2

New in version 0.7.7.

The module contains code to analyze root mean square quantities such as the RMSD or RMSF (not implemented yet).

This module uses the fast QCP algorithm [Theobald2005] to calculate the root mean square distance (RMSD) between two coordinate sets (as implemented in `MDAnalysis.core.qcprot.CalcRMSDRotationalMatrix()`).

When using this module in published work please cite [Theobald2005].

See also

`MDAnalysis.analysis.align`
  aligning structures based on RMSD
`MDAnalysis.core.qcprot`
  implements the fast RMSD algorithm.

## 3.11.1. Functions

`MDAnalysis.analysis.rms.``rmsd`(a, b, weights=None)

  Returns RMSD between two coordinate sets a and b.

  a and b are arrays of the coordinates of N atoms of shape N*3 as generated by, e.g., `MDAnalysis.core.AtomGroup.AtomGroup.coordinates()`.

  The weights can be an array of length N, containing e.g. masses for a weighted RMSD calculation.

  The function uses Douglas Theobald’s fast QCP algorithm [Theobald2005] to calculate the RMSD.

  Example::

        >>> u = Universe(PSF,DCD)
        >>> bb = u.selectAtoms('backbone')
        >>> A = bb.coordinates()  # coordinates of first frame
        >>> u.trajectory[-1]      # forward to last frame
        >>> B = bb.coordinates()  # coordinates of last frame
        >>> rmsd(A,B)
        6.8342494129169804

## 3.11.2. Analysis classes

class `MDAnalysis.analysis.rms.``RMSD`(traj, reference=None, select='all', filename='rmsd.dat', mass_weighted=False, tol_mass=0.1, ref_frame=0)

  Class to perform RMSD analysis on a trajectory.

  Run the analysis with `RMSD.run()`, which stores the results in the array `RMSD.rmsd`:

      frame    time (ps)    RMSD (A)

  This class uses Douglas Theobald’s fast QCP algorithm [Theobald2005] to calculate the RMSD.

  New in version 0.7.7.

  Setting up the RMSD analysis.

  The RMSD will be computed between select and reference for all frames in the trajectory in universe.

  Arguments : | traj universe (`MDAnalysis.Universe` object) that contains a trajectory reference reference coordinates; `MDAnalysis.Universe` object; if `None` the traj is used (uses the current time step of the object) [`None`] select The selection to operate on; can be one of: any valid selection string for `selectAtoms()` that produces identical selections in mobile and reference; or a dictionary `{'mobile':sel1, 'reference':sel2}` (the `MDAnalysis.analysis.align.fasta2select()` function returns such a dictionary based on a ClustalW or STAMP sequence alignment); or a tuple `(sel1, sel2)` When using 2. or 3. with sel1 and sel2 then these selections can also each be a list of selection strings (to generate a AtomGroup with defined atom order as described under Ordered selections). filename If set, filename can be used to write the results with `RMSD.save()` [`None`] mass_weighted do a mass-weighted RMSD fit tol_mass Reject match if the atomic masses for matched atoms differ by more than tol_mass [0.1] ref_frame frame index to select frame from reference [0]

  `rmsd`

    Results are stored in this N×3 `numpy.ndarray` array, (frame, time (ps), RMSD (Å)).

  `run`(**kwargs)

    Perform RMSD analysis on the trajectory.

    A number of parameters can be changed from the defaults. The result is stored as the array `RMSD.rmsd`.

    Keywords : | start, stop, step start and stop frame index with step size: analyse `trajectory[start:stop:step]` [`None`] mass_weighted do a mass-weighted RMSD fit tol_mass Reject match if the atomic masses for matched atoms differ by more than tol_mass ref_frame frame index to select frame from reference

  `save`(filename=None)

    Save RMSD from `RMSD.rmsd` to text file filename.

    If filename is not supplied then the default provided to the constructor is used.

    The data are saved with `numpy.savetxt()`.

### Navigation

- index
- modules |
- next |
- previous |
- MDAnalysis 0.7.7 documentation »
- 3. Analysis modules »