# mdtraj.rmsd

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

  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, default=0) – 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.

    - superpose (bool, default=True) – Whether to use the Theobald QCP method to calculate RMSD. If True, the QCP method is used, which inherently superposes the structure based on the atom_indices selection. If False, the Theolbald QCP method is not used and the RMSD is directly calculated pairwise with no optimization and additional no superposition done. The precentered option is ignored. Users are expected to manually superpose and/or image their trajectories using Trajectory.image_molecules() and/or Trajectory.make_molecules_whole() and/or Trajectory.superpose().

  Examples

      >>> import mdtraj as md
      >>> rmsds = md.rmsd(trajectory, trajectory, 0)
      >>> print rmsds
      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)

  The default option aligns the trajectory to the reference based on selection indicated by atom_indices and ref_atom_indices. If you want to manually align the trajectory to a different selection (or not at all), use md.superpose() and the superpose=False option.

      >>> trajectory.superpose(trajectory, 0, atom_slice=trajectory.top.select('protein and not element H'))
      >>> rmsds = md.rmsd(trajectory, trajectory, superpose=False)

  See also

  `Trajectory.center_coordinates`

  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`.

  Returns:

    rmsds – 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.

  Return type:

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