Alanine RMSD analysis¶

Uses MDAnalysis to analyze the alanine trajectory produced by docs/episodes/scripts/03-simulaciones-clasicas_simple.py. This mirrors the scripts in https://github.com/JordiVillaFreixa/Pau_TFG_DAO/tree/main/analysis.

Table of contents¶

  • Alanine RMSD analysis
  • Alanine RMSD analysis
  • Step 1

Step 1¶

In [ ]:
from pathlib import Path
import os
import MDAnalysis as mda
from MDAnalysis.analysis import rms
import pandas as pd
import matplotlib.pyplot as plt

COURSE_DIR = Path(os.environ.get('COURSE_DIR','~/Concepcion26')).expanduser()
topo = COURSE_DIR / 'data' / 'alanine-dipeptide.pdb'
traj = COURSE_DIR / 'results' / '03-simulaciones-clasicas' / 'simple' / 'traj.dcd'
for path in (topo,traj):
    if not path.exists():
        raise FileNotFoundError(f'Missing {path} - run 03-simulaciones-clasicas_simple.py first')

u = mda.Universe(topo,traj)
rmsd = rms.RMSD(u, select='backbone', ref_frame=0)
rmsd.run()
df = pd.DataFrame(rmsd.results.rmsd, columns=['Frame','Time (ps)','Backbone']).iloc[:,1:]
fig,ax=plt.subplots()
ax.plot(df['Time (ps)'],df['Backbone'], label='Backbone')
ax.set_xlabel('Time (ps)')
ax.set_ylabel('RMSD (Å)')
ax.set_title('Alanine backbone RMSD vs time')
ax.grid(True)
fig.tight_layout()
fig.savefig('index_rmsd.png')
print(df.head())