Beispiel #1
0
def test_eigtransform_2():
    model = MarkovStateModel(n_timescales=2)
    traj = [4, 3, 0, 0, 0, 1, 2, 1, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 0]
    model.fit([traj])

    transformed_0 = model.eigtransform([traj], mode='clip')
    # clip off the first two states (not ergodic)
    assert transformed_0[0].shape == (len(traj) - 2, model.n_timescales)

    transformed_1 = model.eigtransform([traj], mode='fill')
    assert transformed_1[0].shape == (len(traj), model.n_timescales)
    assert np.all(np.isnan(transformed_1[0][:2, :]))
    assert not np.any(np.isnan(transformed_1[0][2:]))
Beispiel #2
0
def test_12():
    # test eigtransform
    model = MarkovStateModel(n_timescales=1)
    model.fit([[4, 3, 0, 0, 0, 1, 2, 1, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 0]])
    assert model.mapping_ == {0: 0, 1: 1, 2: 2}
    assert len(model.eigenvalues_) == 2
    t = model.eigtransform([[0, 1]], right=True)
    assert t[0][0] == model.right_eigenvectors_[0, 1]
    assert t[0][1] == model.right_eigenvectors_[1, 1]

    s = model.eigtransform([[0, 1]], right=False)
    assert s[0][0] == model.left_eigenvectors_[0, 1]
    assert s[0][1] == model.left_eigenvectors_[1, 1]
Beispiel #3
0
def test_12():
    # test eigtransform
    model = MarkovStateModel(n_timescales=1)
    model.fit([[4, 3, 0, 0, 0, 1, 2, 1, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 0]])
    assert model.mapping_ == {0: 0, 1: 1, 2: 2}
    assert len(model.eigenvalues_) == 2
    t = model.eigtransform([[0, 1]], right=True)
    assert t[0][0] == model.right_eigenvectors_[0, 1]
    assert t[0][1] == model.right_eigenvectors_[1, 1]

    s = model.eigtransform([[0, 1]], right=False)
    assert s[0][0] == model.left_eigenvectors_[0, 1]
    assert s[0][1] == model.left_eigenvectors_[1, 1]
Beispiel #4
0
def test_eigtransform_2():
    model = MarkovStateModel(n_timescales=2)
    traj = [4, 3, 0, 0, 0, 1, 2, 1, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 0]
    model.fit([traj])

    transformed_0 = model.eigtransform([traj], mode='clip')
    # clip off the first two states (not ergodic)
    assert transformed_0[0].shape == (len(traj) - 2, model.n_timescales)

    transformed_1 = model.eigtransform([traj], mode='fill')
    assert transformed_1[0].shape == (len(traj), model.n_timescales)
    assert np.all(np.isnan(transformed_1[0][:2, :]))
    assert not np.any(np.isnan(transformed_1[0][2:]))
# In[160]:

####Evaluate the thermodynamics and kinetics from the microstate MSM
#the first dynamic eigenvector is associated to the slowest transitions in the dataset
#we can understand the physical meaning of the first eigenmode through sampling the conformations
micro_msm_lagtime = 4
msm = MarkovStateModel(
    lag_time=micro_msm_lagtime,
    reversible_type='transpose',
    n_timescales=3,
    ergodic_cutoff='off'
)  #lag time should be chosen such that the model becomes Markovian
#n_timescale specify the number of dynamic mode (the 1st one is the 2nd eigenvector of TPM) that outputs
msm.fit(microstate_sequences.labels_)
msm_eigen_trajs = msm.eigtransform(microstate_sequences.labels_)
sampling_along_msm_eigenmode(
    resultdir, msm_eigen_trajs, microstate_sequences.labels_, trajectory_dir,
    traj_list_array, pdb_name,
    1)  #1:the slowest transition,play with the eigenmodes
print(
    "the timescale associated with the slowest collective motion in the system is: %d ps"
    % (msm.timescales_[0]))
print(
    "using vmd to open msm-1-dynamic-mode.xtc, to intepret the slowest dynamic mode of the system"
)

# In[161]:

##Draw the potential of mean force, newly added
pi_0 = msm.populations_[np.concatenate(