This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.cross_validation import ShuffleSplit | |
from msmbuilder.msm import MarkovStateModel | |
import numpy as np | |
# just generating random dtrajs: replace these lines with actual data | |
n_states = 500 | |
traj_length = 10000 | |
n_trajs = 100 | |
dtrajs = [np.random.randint(0, n_states, traj_length) for _ in range(n_trajs)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n_threads = 32 | |
from simtk.openmm import app | |
import simtk.openmm as mm | |
import openmmtools | |
from simtk.unit import * | |
from openmmtools.integrators import kB | |
import mdtraj as md | |
from msmbuilder.example_datasets import AlanineDipeptide | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import numpy.random as npr | |
import pyemma | |
# generate random trajectories, where each trajectory has a random length between 100 and 1000. | |
# since the trajectories have different lengths, we will by likely to see an error if `hmm` somehow | |
# scrambles the trajectory indices. | |
dtrajs_A = [npr.randint(0,100,x) for x in npr.randint(100,1000,8)] | |
dtrajs_B = [npr.randint(100,200,x) for x in npr.randint(100,1000,9)] | |
dtrajs_C = [npr.randint(200,300,x) for x in npr.randint(100,1000,10)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import simtk.unit | |
import simtk.openmm as mm | |
print('OpenMM version: ', mm.version.full_version) | |
from openmmtools.constants import kB | |
import matplotlib | |
matplotlib.use('agg') | |
import matplotlib.pyplot as plt | |
from simtk.openmm import app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_total_energy(context): | |
state = context.getState(getEnergy=True) | |
ke, pe = state.getKineticEnergy(), state.getPotentialEnergy() | |
return ke + pe | |
def measure_shadow_work(simulation, n_steps): | |
'''Given a `simulation` that uses an integrator that accumulates heat exchange with bath, | |
apply the integrator for n_steps and return the change in energy - the heat. | |
''' | |
get_energy = lambda : get_total_energy(simulation.context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib | |
matplotlib.use('agg') | |
import matplotlib.pyplot as plt | |
from tqdm import tqdm | |
from simtk import unit | |
from simtk import openmm as mm | |
from simtk.openmm import app | |
from openmmtools.testsystems import WaterBox | |
from openmmtools.integrators import GHMCIntegrator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openmmtools.integrators import GHMCIntegrator, GradientDescentMinimizationIntegrator | |
integrators = [GHMCIntegrator(), GradientDescentMinimizationIntegrator()] | |
step_type_dict = { | |
0 : "{target} <- {expr}", | |
1: "{target} <- {expr}", | |
2: "{target} <- sum({expr})", | |
3: "constrain positions", | |
4: "constrain velocities", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# without velocity randomization | |
np.random.seed(0) | |
plt.figure(figsize=(6,3)) | |
protocol_length = 25 | |
x_1 = np.arange(protocol_length) | |
x_2 = np.arange(protocol_length) + protocol_length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from autograd.scipy.misc import logsumexp | |
from autograd import grad | |
from autograd import numpy as np | |
import pymbar | |
def compute_perturbed_free_energies(mbar, u_ln): | |
states_with_samples = (mbar.N_k > 0) | |
log_q_k = mbar.f_k[states_with_samples] - mbar.u_kn[states_with_samples].T | |
log_denominator_n = logsumexp(log_q_k, b=mbar.N_k[states_with_samples], axis=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
""" | |
Benchmark DHFR in explicit solvent with minimal CustomIntegrators that include Gaussian random numbers or not. | |
""" | |
import time | |
from simtk import openmm, unit | |
from openmmtools import testsystems |
OlderNewer