Пример #1
0
def makeHMM(Trajectories, topology):
    top = md.load_prmtop(topology)
    alpha_carbons = [a.index for a in top.atoms if a.name == 'CA']
    filenames = sorted(glob(Trajectories))
    first_frame = md.load_frame(filenames[0], 0, top=top)

    f = SuperposeFeaturizer(alpha_carbons, first_frame)
    dataset = []
    for fragment in filenames:
        for chunk in md.iterload(fragment, chunk=100, top=top):
            dataset.append(f.partial_transform(chunk))
    hmm = GaussianHMM(n_states=8)
    hmm.fit(dataset)
    print(hmm.timescales_)
    return hmm
Пример #2
0
def makeHMM(Trajectories, topology):
    top = md.load_prmtop(topology)
    alpha_carbons = [a.index for a in top.atoms if a.name == 'CA']
    filenames = sorted(glob(Trajectories))
    first_frame = md.load_frame(filenames[0], 0, top=top)

    f = SuperposeFeaturizer(alpha_carbons, first_frame)
    dataset = []
    for fragment in filenames:
            for chunk in md.iterload(fragment, chunk=100, top=top):
                dataset.append(f.partial_transform(chunk))
    hmm = GaussianHMM(n_states=8)
    hmm.fit(dataset)
    print(hmm.timescales_)
    return hmm
Пример #3
0
from glob import glob

filenames = sorted(glob("05_Prod_*.nc"))
topology = md.load_prmtop(glob("*nowat.prmtop")[0])

first_frame = md.load_frame(filenames[0], 0, top=topology)
indices = [
    atom.index for atom in topology.atoms
    if atom.element.symbol in ['C', 'O', 'N']
]
featurizer = SuperposeFeaturizer(indices, first_frame)
sequences = []

for fragment in filenames:
    for chunk in md.iterload(fragment, chunk=100, top=topology):
        sequences.append(featurizer.partial_transform(chunk))

lag_times = [1, 20, 50, 100, 200, 400]
hmm_ts0 = {}
hmm_ts1 = {}
n_states = [n for n in range(2, 11, 2)]

for n in n_states:
    hmm_ts0[n] = []
    hmm_ts1[n] = []
    for lag_time in lag_times:
        #pdb.set_trace()
        strided_data = [
            s[i::lag_time] for s in sequences for i in range(lag_time)
        ]
        hmm = GaussianHMM(n_states=n, n_init=1).fit(strided_data)
Пример #4
0
from glob import glob




filenames = sorted(glob("05_Prod_*.nc"))
topology = md.load_prmtop(glob("*nowat.prmtop")[0])

first_frame = md.load_frame(filenames[0], 0, top=topology)
indices = [atom.index for atom in topology.atoms if atom.element.symbol in ['C', 'O', 'N']]
featurizer = SuperposeFeaturizer(indices, first_frame)
sequences = []

for fragment in filenames:
    for chunk in md.iterload(fragment, chunk = 100, top = topology):
        sequences.append(featurizer.partial_transform(chunk))

lag_times = [1, 20, 50, 100, 200, 400]
hmm_ts0 = {}
hmm_ts1 = {}
n_states = [n for n in range(2,11,2)]


for n in n_states:
    hmm_ts0[n] = []
    hmm_ts1[n] = []
    for lag_time in lag_times:
        #pdb.set_trace()
        strided_data = [s[i::lag_time] for s in sequences for i in range(lag_time)]
        hmm = GaussianHMM(n_states=n, n_init=1).fit(strided_data)
        timescales = hmm.timescales_ * lag_time