rmsd

pytraj.analysis.rmsd.rotation_matrix(traj=None, mask='', ref=0, mass=False, frame_indices=None, top=None, with_rmsd=False)

Compute rotation matrix with/without rmsd

Parameters:

traj : Trajectory-like

ref : {int, Frame}, default 0 (first Frame)

reference

mask : str, default all atoms

mass : bool, default False

if True, rmsfit with mass weighted

frame_indices : {None, array-like}

if not None, compute for given indices

top : Topology, optional

with_rmsd : bool, default False

  • if False, return only rotation matrix.
  • if True, return rotation matrix and rmsd values
Returns:

out : if with_rmsd=False, return numpy array, shape (n_frames, 3, 3)

if with_rmsd=True, return a tuple (mat, rmsd)

Examples

>>> import pytraj as pt
>>> traj = pt.datafiles.load_tz2()
>>> mat = pt.calc_rotation_matrix(traj, mask='@CA')
>>> mat.shape
(101, 3, 3)
pytraj.analysis.rmsd.pairwise_rmsd(traj=None, mask='', metric='rms', top=None, dtype='ndarray', mat_type='full', frame_indices=None)

Calculate pairwise rmsd with different metrics.

Parameters:

traj : Trajectory-like or iterable object

mask : mask

if mask is “”, use all atoms

metric : {‘rms’, ‘dme’, ‘srmsd’, ‘nofit’}

if ‘rms’, perform rms fit if ‘dme’, use distance RMSD if ‘srmsd’, use symmetry-corrected RMSD if ‘nofit’, perform rmsd without fitting

top : Topology, optional, default=None

dtype: ndarray

return type

mat_type : str, {‘full’, ‘half’}

if ‘full’: return 2D array, shape=(n_frames, n_frames) if ‘half’: return 1D array, shape=(n_frames*(n_frames-1)/2, )

Notes

Install libcpptraj with openmp to get benefit from parallel

Examples

>>> import pytraj as pt
>>> traj = pt.datafiles.load_tz2_ortho()
>>> arr = pt.pairwise_rmsd(traj(0, 1000, mask='@CA'))
>>> # calculate pairwise rmsd for all frames using CA atoms, use `dme` (distance RMSD)
>>> # convert to numpy array
>>> arr_np = pt.pairwise_rmsd(traj, "@CA", metric="dme", dtype='ndarray')
>>> # calculate pairwise rmsd for all frames using CA atoms, nofit for RMSD
>>> # convert to numpy array
>>> arr_np = pt.pairwise_rmsd(traj, "@CA", metric="nofit", dtype='ndarray')
>>> # calculate pairwise rmsd for all frames using CA atoms
>>> # use symmetry-corrected RMSD, convert to numpy array
>>> arr_np = pt.pairwise_rmsd(traj, "@CA", metric="srmsd", dtype='ndarray')
>>> # use different dtype
>>> arr_np = pt.pairwise_rmsd(traj, "@CA", metric="srmsd", dtype='dataset')
pytraj.analysis.rmsd.rmsd_perres(traj=None, mask='', ref=0, mass=False, resrange=None, perres_mask=None, perres_center=False, perres_invert=False, frame_indices=None, top=None, dtype='dataset', **kwd)

superpose traj to ref with mask, then calculate nofit rms for residues in resrange with given perresmask

Returns:

out : pytraj.DatasetList, shape=(1+n_residues, n_frames)

out[0]: regular rmsd out[1:]: perres rmsd for all given residues out.values will return corresponding numpy array

pytraj.analysis.rmsd.rmsd_nofit(traj=None, mask='', ref=0, mass=False, frame_indices=None, top=None, dtype='ndarray', **kwd)

compute rmsd without fitting (translating and rotating)

Parameters:

traj : Trajectory-like

mask : str

ref : Frame or int

mass : bool, default False

if True, use mass-weighted

frame_indices : 1D array-like, default None

if given, only perform calculation for those frames

Notes

This method is equal to pytraj.rmsd(traj, mask, ref, nofit=True, ...)

pytraj.analysis.rmsd.rmsd(traj=None, mask='', ref=0, ref_mask='', nofit=False, mass=False, update_coordinate=True, frame_indices=None, top=None, dtype='ndarray')

compute rmsd

Parameters:

traj : Trajectory-like

mask : str or 1D array-like of string or 1D or 2D array-like

Atom mask/indices

ref : {Frame, int}, default=0 (first frame)

Reference frame or index.

ref_mask: str, optional

if given, use it instead of mask

nofit : bool, default False

if False, perform fitting (rotation and translation). if traj is mutable, its coordinates will be updated if True, not fitting.

mass : bool, default False

if True, compute mass-weighted rmsd

update_coordinate : bool, default True

if True, coordinates will be updated. But this only apply to mutable Trajectory if False (same as nomod in cpptraj), no modification

frame_indices : int 1D array-like, default None

if not None, only compute rmsd for given frame indices

top : {Topology, str}, default None, optional

dtype : return data type, default=’ndarray’

Notes

  • if traj and ref has diffrent n_atoms, make sure to update ref.top
  • you can use pytraj.rmsd to superpose structure (use update_coordinate=True)

Examples

>>> import pytraj as pt
>>> traj = pt.datafiles.load_trpcage()
>>> # all atoms, do fitting, using ref=traj[-3]
>>> data = pt.rmsd(traj, ref=-3)
>>> # rmsd for 3 maskes, do fitting, using ref=traj[0] (defaul)
>>> data = pt.rmsd(traj, mask=['@CA', '@C', ':3-18@CA'], dtype='dataset')
>>> # rmsd to first frame, use mass ':3-13' but do not perorm fitting
>>> data= pt.rmsd(traj, ref=traj[0], mask=':3-13', nofit=True)
>>> # use atom indices for mask
>>> data= pt.rmsd(traj, ref=traj[0], mask=range(40), nofit=True)
>>> # compute rmsd (and align) with reference having different atoms
>>> trpcage_traj = pt.datafiles.load_trpcage()[:]
>>> tz2_traj = pt.datafiles.load_tz2()[:1]
>>> data = pt.rmsd(trpcage_traj, mask='@1-10', ref=tz2_traj, ref_mask='@11-20')
>>> data
array([ 2.16203842,  2.28859396,  2.15817654, ...,  2.20767189,
        2.30087764,  1.92654945])
Notes
-----
if ``traj`` is mutable and update_coordinate=True, its coordinates will be updated.
pytraj.analysis.rmsd.symmrmsd(traj, mask='', ref=0, ref_mask=None, fit=True, remap=False, mass=False, top=None, dtype='ndarray', frame_indices=None)

Compute symmetry-corrected RMSD

Parameters:

traj : Trajectory-like

mask : str, default ‘’ (all atoms)

ref : {int, Frame}, default 0 (first frame)

ref_mask : {str, None}, default None

if None, use traj’s mask if given, use it

fit : Bool, default True

if True, do fitting if False, nofit

mass : Bool, default False

if True, compute mass-weighted rmsd if False, no mas-weighted

remap : Bool, default False

if True, frames will be modifed for symmetry as well

dtype : str, default ‘ndarray’

return data type

frame_indices : {None, array-like}, default None

if given, only compute RMSD for those

Examples

>>> import pytraj as pt
>>> traj = pt.load("TYR.nc", "TYR.parm7") 
>>> data = pt.symmrmsd(traj, ref=0) 
Notes
-----
versionadded: 1.0.6