Analysis Reference

Trajectory analysis is the heart of MDTraj. These functions can be used to run a variety of analyses on mdtraj.Trajectory objects. It’s usually as simple as

>>> import mdtraj as md
>>> t = md.load('trajectory.pdb')
>>> print(md.compute_phi(t))

Root-mean-square deviation (RMSD)

rmsd(target, reference[, frame, …]) Compute RMSD of all conformations in target to a reference conformation.
lprmsd(target, reference[, frame, …]) Compute Linear-Programming Root-Mean-Squared Deviation (LP-RMSD) of all conformations in target to a reference conformation.
Trajectory.superpose(reference[, frame, …]) Superpose each conformation in this trajectory upon a reference

Hydrogen Bonding

baker_hubbard(traj[, freq, exclude_water, …]) Identify hydrogen bonds based on cutoffs for the Donor-H…Acceptor distance and angle.
kabsch_sander(traj) Compute the Kabsch-Sander hydrogen bond energy between each pair of residues in every frame.
wernet_nilsson(traj[, exclude_water, …]) Identify hydrogen bonds based on cutoffs for the Donor-H…Acceptor distance and angle according to the criterion outlined in [1].

Secondary Structure

compute_dssp(traj[, simplified]) Compute Dictionary of protein secondary structure (DSSP) secondary structure assignments

Surface Area, Radius of Gyration and Inertia

shrake_rupley(traj[, probe_radius, …]) Compute the solvent accessible surface area of each atom or residue in each simulation frame.
compute_rg(traj[, masses]) Compute the radius of gyration for every frame.
compute_inertia_tensor(traj) Compute the inertia tensor of a trajectory.

Distances

compute_distances(traj, atom_pairs[, …]) Compute the distances between pairs of atoms in each frame.
compute_displacements(traj, atom_pairs[, …]) Compute the displacement vector between pairs of atoms in each frame of a trajectory.
compute_neighbors(traj, cutoff, query_indices) Find (spatially) neighboring atoms in a trajectory.
compute_contacts(traj[, contacts, scheme, …]) Compute the distance between pairs of residues in a trajectory.
compute_drid(traj[, atom_indices]) Distribution of reciprocal interatomic distances (DRID) representation
compute_center_of_mass(traj) Compute the center of mass for each frame.
geometry.squareform(distances, residue_pairs) Reshape the contact distance to square contact maps
compute_rdf(traj[, pairs, r_range, …]) Compute radial distribution functions for pairs in every frame.

Bond Angles and Dihedrals

compute_angles(traj, angle_indices[, …]) Compute the bond angles between the supplied triplets of indices in each frame of a trajectory.
compute_dihedrals(traj, indices[, periodic, opt]) Compute the dihedral angles between the supplied quartets of atoms in each frame in a trajectory.
compute_phi(traj[, periodic, opt]) Calculate the phi torsions of a trajectory.
compute_psi(traj[, periodic, opt]) Calculate the psi torsions of a trajectory.
compute_chi1(traj[, periodic, opt]) Calculate the chi1 torsions of a trajectory.
compute_chi2(traj[, periodic, opt]) Calculate the chi2 torsions of a trajectory.
compute_chi3(traj[, periodic, opt]) Calculate the chi3 torsions of a trajectory.
compute_chi4(traj[, periodic, opt]) Calculate the chi4 torsions of a trajectory.
compute_omega(traj[, periodic, opt]) Calculate the omega torsions of a trajectory.

NMR Observables

compute_J3_HN_C(traj[, model]) Calculate the scalar coupling between HN and C_prime.
compute_J3_HN_CB(traj[, model]) Calculate the scalar coupling between HN and C_beta.
compute_J3_HN_HA(traj[, model]) Calculate the scalar coupling between HN and H_alpha.
chemical_shifts_shiftx2(trj[, pH, temperature]) Predict chemical shifts of a trajectory using ShiftX2.
chemical_shifts_ppm(trj) Predict chemical shifts of a trajectory using ppm.
chemical_shifts_spartaplus(trj[, rename_HN]) Predict chemical shifts of a trajectory using SPARTA+.
reindex_dataframe_by_atoms(trj, frame) Reindex chemical shift output to use atom number (serial) indexing.

Thermodynamic Quantities

dipole_moments(traj, charges) Calculate the dipole moments of each frame in a trajectory.
static_dielectric(traj, charges, temperature) Calculate the static dielectric constant from a trajectory.
isothermal_compressability_kappa_T(traj, …) Calculate the isothermal compressability.
thermal_expansion_alpha_P(traj, temperature, …) Calculate the thermal expansion coefficient.
density(traj[, masses]) Calculate the mass density of each frame in a trajectory.

Order Parameters

compute_nematic_order(traj[, indices]) Compute the nematic order parameter of a group in every frame.
compute_directors