markovmodel / PyEMMA

🚂 Python API for Emma's Markov Model Algorithms 🚂
http://pyemma.org
GNU Lesser General Public License v3.0
307 stars 118 forks source link

To generate pdbs of each clusters at a particular timescale #1537

Closed Bazzinga18 closed 1 year ago

Bazzinga18 commented 2 years ago

Hii, i want to generate pdbs of each microstate at a particular timescale, please help me out. I already tried few codes as i am new to python and pyemma it takes so much time for me to understand, and i am not able to generate the pdb:

clustering = pyemma.coordinates.cluster_kmeans(Y,k=15, fixed_seed=1)
dtrajs = clustering.dtrajs
its = pyemma.msm.its(dtrajs, lags=1000, nits=10, errors='bayes')
pyemma.plots.plot_implied_timescales(its, units='ms', dt=0.4)
msm = pyemma.msm.bayesian_markov_model(dtrajs, lag=20, dt_traj='0.4 ns')
eigenval = msm.eigenvalues()
L=msm.eigenvectors_left(6)
ev0=L[0,:].real
EV = ev0.tolist()
pyemma.coordinates.save_traj(EV, indexes, outfile='ev01.pdb', top=pdb)

so i want to ask what should be the indexes here if i want to generate pdbs at the slowest timeperiod i.e., at ev0? thanks

clonker commented 2 years ago

EV is not the right input parameter to save_traj, please see the documentation. You'll want to sample frames for each discrete states (for example with pyemma.util.discrete_trajectories.sample_indexes_by_state) and then based on these indices save trajectories.

Bazzinga18 commented 2 years ago

Okay and what about indexes?

clonker commented 2 years ago

Hi, you can give it a numpy array of shape arr.shape == (1, 2) with arr[0, 0] = trajectory_index and arr[0, 1]= frame_index. This you can call in a loop with different output filenames or use save_trajs.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.