import numpy as np
import matplotlib.pyplot as pp
from msmbuilder.example_datasets import fetch_alanine_dipeptide
from msmbuilder.cluster import KCenters
from msmbuilder.msm import ContinuousTimeMSM, MarkovStateModel
from msmbuilder.msm import implied_timescales
trajectories = fetch_alanine_dipeptide()['trajectories']
heavy_inds = trajectories[0].topology.select_atom_indices('heavy')
trajectories = [t.atom_slice(heavy_inds) for t in trajectories]
cluster = KCenters(metric='rmsd', n_clusters=25)
sequences = cluster.fit_transform(trajectories)
print(cluster.summarize())
lag_times = [1, 4, 8, 12]
n_timescales = 10
msm_timescales = implied_timescales(sequences, lag_times, n_timescales=n_timescales, msm=MarkovStateModel(verbose=False))
for i in range(n_timescales):
pp.plot(lag_times, msm_timescales[:, i], 'o-')
pp.title('Discrete-time MSM Relaxation Timescales')
pp.semilogy()
pp.show()
ctmsm_timescales = implied_timescales(sequences, lag_times, n_timescales=n_timescales, msm=ContinuousTimeMSM(verbose=True))
for i in range(n_timescales):
pp.plot(lag_times, ctmsm_timescales[:, i], 'o-')
pp.title('Continuous-Time MSM Relaxation Timescales')
pp.semilogy()
pp.show()
(implied-timescales.ipynb; implied-timescales_evaluated.ipynb; implied-timescales.py)