Last active
May 30, 2016 19:37
-
-
Save orbeckst/94b2aa910eb9dbfddbe9ef6dacc4e384 to your computer and use it in GitHub Desktop.
How to calculate RMSF with MDAnalysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import MDAnalysis as mda | |
u = mda.Universe("topol.tpr", "trj.xtc") | |
ca = u.select_atoms("name CA") | |
means = np.zeros((len(ca), 3)) | |
sumsq = np.zeros_like(means) | |
for k, ts in enumerate(u.trajectory): | |
sumsq += (k/(k+1.0)) * (ca.positions - means)**2 | |
means[:] = (k*means + ca.positions)/(k+1.0) | |
rmsf = np.sqrt(sumsq.sum(axis=1)/(k+1.0)) | |
matplotlib.pyplot.plot(ca.residues.resids, rmsf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment