mdtraj on Biowulf

MDTraj is a python library that allows users to manipulate molecular dynamics (MD) trajectories and perform a variety of analyses, including fast RMSD, solvent accessible surface area, hydrogen bonding, etc. A highlight of MDTraj is the wide variety of molecular dynamics trajectory file formats which are supported, including RCSB pdb, GROMACS xtc and trr, CHARMM / NAMD dcd, AMBER binpos, AMBER NetCDF, AMBER mdcrd, TINKER arc and MDTraj HDF5.

The installation of MDTraj on Helix & Biowulf also contains MDAnalysis, another python package for analyzing MD trajectories.

References:

Documentation
Important Notes

Interactive job
Interactive jobs should be used for debugging, graphics, or applications that cannot be run as batch jobs.

Allocate an interactive session and run the program. Sample session:

[user@biowulf]$ sinteractive
salloc.exe: Pending job allocation 46116226
salloc.exe: job 46116226 queued and waiting for resources
salloc.exe: job 46116226 has been allocated resources
salloc.exe: Granted job allocation 46116226
salloc.exe: Waiting for resource configuration
salloc.exe: Nodes cn3144 are ready for job

[user@cn3144 ~]$ module load mdtraj
[user@cn3144 ~]$ python
>>> import mdtraj as md
>>> t = md.load('trajectory.xtc', top='trajectory.pdb')
>>> print t
<mdtraj.Trajectory with 100 frames, 22 atoms at 0x109f0a3d0>
>>> quit()
[user@cn3144 ~]$ exit
salloc.exe: Relinquishing job allocation 46116226
[user@biowulf ~]$

Batch job
Most jobs should be run as batch jobs.

Create a python input script mdtraj.py. This is an example lifted from the MDTraj Introduction page.

#!/usr/bin/env python
import mdtraj as md
t = md.load('trajectory.xtc', top='trajectory.pdb')
print t
print t[1:10]
print t[-1]
print t.xyz.shape
print np.mean(t.xyz)
print t.time[0:10]
t.unitcell_lengths[-1]
t[::2].save('halftraj.h5')
t[0:10].save_dcd('first-ten-frames.dcd')
atom_to_keep = [a.index for a in t.topology.atoms if a.name == 'CA']
t.restrict_atoms(atoms_to_keep)  # this acts inplace on the trajectory
t.save('CA-only.h5')

Create a batch script mdtraj.sh:

#!/bin/bash
module load mdtraj
python mdtraj.py

Submit this job using the Slurm sbatch command.

sbatch [--cpus-per-task=#] [--mem=#] mdtraj.sh
Swarm of Jobs
A swarm of jobs is an easy way to submit a set of independent commands requiring identical resources.

Create a swarmfile (e.g. mdtraj.swarm). For example:

python mdtraj_1.py
python mdtraj_2.py
python mdtraj_3.py
python mdtraj_4.py

Submit this job using the swarm command.

swarm -f mdtraj.swarm [-g #] [-t #] --module mdtraj
where
-g # Number of Gigabytes of memory required for each process (1 line in the swarm command file)
-t # Number of threads/CPUs required for each process (1 line in the swarm command file).
--module mdtraj Loads the mdtraj module for each subjob in the swarm