-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #470 from choderalab/bryce-exp
SAMS sampler and other improvements
- Loading branch information
Showing
13 changed files
with
810 additions
and
315 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import matplotlib.pyplot as plt | ||
import seaborn as sns | ||
import numpy as np | ||
import os, sys | ||
from netCDF4 import Dataset | ||
from glob import glob | ||
|
||
|
||
if __name__ == '__main__': | ||
directory = sys.argv[1] | ||
files = sorted(glob(os.path.join(os.getcwd(), directory, '*.nc'))) | ||
files = [x for x in files if 'checkpoint' not in x] | ||
f, axarr = plt.subplots(2, 3, sharex=False, sharey=False, figsize=(16, 8)) | ||
for i, filename in enumerate(files): | ||
phase = filename.split('-')[1].rstrip('.nc') | ||
ncfile = Dataset(filename, 'r') | ||
logZ = ncfile.groups['online_analysis'].variables['logZ_history'] | ||
n_iterations, n_states = logZ.shape | ||
print(n_iterations, n_states) | ||
axarr[i, 0].plot(logZ, '.') | ||
axarr[i, 0].set_xlabel('iteration') | ||
axarr[i, 0].set_ylabel('logZ / kT') | ||
axarr[i, 0].set_title('%s_%s' % (phase, directory)) | ||
#axarr[i, 1].plot(np.transpose(np.transpose(logZ[:-2]) - logZ[:-2, 0]), '.') | ||
#axarr[i, 1].set_xlabel('iteration') | ||
#axarr[i, 1].set_ylabel('logZ / kT') | ||
states = ncfile.variables['states'] | ||
n_iterations, n_replicas = states.shape | ||
axarr[i, 1].plot(states, '.') | ||
axarr[i, 1].set_xlabel('iteration') | ||
axarr[i, 1].set_ylabel('thermodynamic state') | ||
axarr[i, 1].axis([0, n_iterations, 0, n_states]) | ||
gamma = ncfile.groups['online_analysis'].variables['gamma_history'] | ||
axarr[i, 2].plot(gamma, '.') | ||
axarr[i, 2].set_xlabel('iteration') | ||
axarr[i, 2].set_ylabel('gamma') | ||
|
||
f.tight_layout() | ||
f.savefig('%s.png' % directory, dpi=300) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
from simtk import unit | ||
from openmmtools import mcmc | ||
from perses.dispersed.relative_setup import HybridTopologyFactory, HybridSAMSSampler | ||
import logging | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
if __name__ == '__main__': | ||
mcl1tp = np.load('/home/ballen/PycharmProjects/perses/examples/cdk2-example/cdk2_sams_hbonds/cdk2topology_proposals.npy').item() | ||
factory = HybridTopologyFactory(mcl1tp['complex_topology_proposal'], mcl1tp['complex_old_positions'], | ||
mcl1tp['complex_new_positions']) | ||
chss = HybridSAMSSampler(mcmc_moves=mcmc.LangevinDynamicsMove(timestep=2.0 * unit.femtosecond, | ||
collision_rate=5.0 / unit.picosecond, | ||
n_steps=1000, | ||
reassign_velocities=False, | ||
n_restart_attempts=6), | ||
hybrid_factory=factory) | ||
chss.setup(n_states=100, temperature=300.0 * unit.kelvin, | ||
storage_file='/media/ballen/overflow/perses/complex_test_100.nc', checkpoint_interval=1) | ||
chss.minimize() | ||
chss.equilibrate(10) | ||
chss.extend(10000) | ||
print("DONE FINALLY!!!") |
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
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
Oops, something went wrong.