Background

Trajectory Tools

Simple python scripts (and Gromacs commands) for manipulating MD trajectories.

Back to ARNy Plotter

Info & Extraction

frame_info.py Print trajectory metadata (frame count, timestep, box, atoms).
$ python frame_info.py --top structure.pdb --traj trajectory.xtc
Download
extract_frames.py Extract a frame range with optional stride.
$ python extract_frames.py --top structure.pdb --traj trajectory.xtc --start 0 --stop 100 --stride 2 --output subset.xtc
Download
extract_pdb.py Save a single frame as a PDB file.
$ python extract_pdb.py --top structure.pdb --traj trajectory.xtc --frame 42 --output frame42.pdb
Download
Extract first frame of a trajectory.
$ python -c "import mdtraj as md; t=md.load('trajectory.dcd', top='topology.pdb'); t[0].save_pdb('first_frame.pdb')"

Selection & Filtering

select_by_rmsd.py Keep frames below/above an RMSD threshold.
$ python select_by_rmsd.py --top structure.pdb --traj trajectory.xtc --ref native.pdb --threshold 3.0 --mode below --output filtered.xtc
Download
select_nucleic_trajectory.py Extract only nucleic acid atoms from a trajectory.
$ python select_nucleic_trajectory.py
Download
find_closest_frames_all_trajectories.py Find frames closest to target Q-RMSD combinations across trajectories.
$ python find_closest_frames_all_trajectories.py
Download

Conversion & Re-encoding

convert_traj.py Convert trajectory format (e.g. TRR to XTC).
$ python convert_traj.py
Download
convert_traj_with_selection.py Convert format with atom selection filter.
$ python convert_traj_with_selection.py
Download
reencode_trajectory.py Re-encode with new stride/selection to reduce file size.
$ python reencode_trajectory.py --top structure.pdb --traj trajectory.xtc --stride 10 --output resampled.xtc
Download
merge_trajectories.py Concatenate multiple trajectories (mdtraj).
$ python merge_trajectories.py
Download

Alignment & Reordering

align_trajectory.py Align all frames to a reference (least-squares fit).
$ python align_trajectory.py --top structure.pdb --traj trajectory.xtc --ref native.pdb --output aligned.xtc
Download
traj_reorder_index_atoms.py Reorder atoms in trajectory based on a mapping file.
$ python traj_reorder_index_atoms.py
Download

GROMACS Commands

Convert trajectory Convert trajectory format (e.g. TRR to XTC).
$ gmx trjconv -s topol.tpr -f traj.trr -o traj.xtc
Convert structure Convert structure format (e.g. GRO to PDB).
$ gmx editconf -f structure.gro -o structure.pdb
Extract time range Extract frames between time -b and -e (ps), with step -dt.
$ gmx trjconv -s topol.tpr -f traj.xtc -o subset.xtc -b 1000 -e 5000 -dt 10
Remove PBC jumps Prevent molecules from jumping across periodic boundaries.
$ gmx trjconv -s topol.tpr -f traj.xtc -o nojump.xtc -pbc nojump
Center + fix PBC Center the solute in the box and make whole molecules.
$ echo "RNA System" | gmx trjconv -s topol.tpr -f traj.xtc -o centered.xtc -center -pbc mol
Fit to reference Remove overall rotation and translation by fitting to a reference.
$ echo "RNA System" | gmx trjconv -s topol.tpr -f centered.xtc -o fitted.xtc -fit rot+trans
Strip solvent Keep only the solute (remove water and ions).
$ echo "RNA" | gmx trjconv -s topol.tpr -f traj.xtc -o nosolvent.xtc

Amber / cpptraj

Convert to XTC Convert an Amber NetCDF trajectory to XTC format.
$ cpptraj -p system.parm7 -y traj.nc -x traj.xtc
Extract first frame as PDB Save the first frame as a PDB topology file.
$ cpptraj -p system.parm7 -y traj.nc -x structure.pdb onlyframes 1

All scripts require MDAnalysis and/or mdtraj.

Back to ARNy Plotter Documentation