Alanine radius of gyration¶
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¶
Step 1¶
In [ ]:
from pathlib import Path
import os
import MDAnalysis as mda
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'
if not topo.exists() or not traj.exists():
raise FileNotFoundError(f'Missing data - run 03-simulaciones-clasicas_simple.py first')
u = mda.Universe(topo,traj)
protein = u.select_atoms('protein')
rg=[]
time=[]
for ts in u.trajectory:
time.append(ts.time)
rg.append(protein.radius_of_gyration())
df = pd.DataFrame({'Time (ps)':time,'R_g (Å)':rg})
fig,ax=plt.subplots()
ax.plot(df['Time (ps)'],df['R_g (Å)'])
ax.set_xlabel('Time (ps)')
ax.set_ylabel('Radius of gyration (Å)')
ax.set_title('Alanine gyration radius')
ax.grid(True)
fig.tight_layout()
fig.savefig('index_rg.png')
print(df.head())