Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal coordinate darting #92

Open
wants to merge 146 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
f538699
removed xyz file requirement
Jul 27, 2017
eab9faf
made modifications
Jul 29, 2017
0b96502
change version number
Aug 1, 2017
b0e3ab9
Merge branch 'master' of https://github.com/MobleyLab/blues into inte…
Aug 1, 2017
5a6be7a
removed extraneous code, added docstrings
Aug 2, 2017
d8a01b3
changed to always compare to reference, still wip
Aug 3, 2017
2951457
debugging positions
Aug 4, 2017
d9d9dc3
tentative fix of inaccurate darting
Aug 8, 2017
9c1aa3e
added temp files
Aug 15, 2017
d4863c6
added other necessary files
Aug 15, 2017
a63d332
added files for tests
Aug 15, 2017
0fe3b81
functional icdarting before cleanup
Nov 8, 2017
2e52f46
removed most print statements
Nov 9, 2017
b35f973
fixed bug with at vs loc selection and when making darts with initial…
Nov 10, 2017
473d1fd
added line to keep bonds, angles the same when darting
Nov 30, 2017
775a4d7
Merge branch 'internal' of https://github.com/MobleyLab/blues
Dec 5, 2017
d42b2dd
modified to work with before/after clauses
Jan 8, 2018
c4c61f9
Merge branch 'before_after' of https://github.com/MobleyLab/blues int…
Jan 8, 2018
d0248bd
changed to appropriately handle systems
Jan 8, 2018
780327a
added restraint file
Jan 8, 2018
084c039
debugging
Jan 30, 2018
c351325
fixed bug with the incorrect positions being used to calculate rotati…
Feb 1, 2018
b06985b
changed another area where superposing wasn't accounted for **might w…
Feb 1, 2018
d4a9aea
changes before restraint overhaul
Feb 2, 2018
dddd9c0
changes to make restraints optional/add parameters for restraint atoms
Feb 6, 2018
28b3410
debugging new options
Feb 8, 2018
31c9d87
fixed issue with set overlap in dartcheck and changed trans/rot dart …
Feb 28, 2018
359158b
added experimental freezing scheme change
Feb 28, 2018
3d8eeb8
debugging water freezing
Mar 1, 2018
943f5d0
fixed error causing waters to not switch correctly
Mar 1, 2018
21209aa
updated options (like freeze_protein)
Mar 2, 2018
8b781aa
fixed pandas issue
Mar 13, 2018
2ddbda4
fixes for darting regions / detailed balance
Mar 22, 2018
0198ca5
added darting test
Mar 28, 2018
215be29
added files for darting test
Mar 28, 2018
7eff20d
fixed files for checking to refereence dart
Mar 28, 2018
e082012
changed to unittest framework
Mar 28, 2018
94de54f
Removed methods that already exist elsewhere and aren't used
Mar 28, 2018
553806f
removed unused import
Mar 28, 2018
791f10c
code cleanup and behavior fixing
Apr 4, 2018
b51381f
commit before compatiblity with chemcoord update
Apr 10, 2018
37e9627
udated to work with py3 and newer chemcoord
Apr 10, 2018
d00c93e
updated yam
Apr 12, 2018
a41f4f7
updated yaml to take chemcoord
Apr 12, 2018
ae06ad9
allow specification of restraint strength
Apr 12, 2018
0460d1f
Cleanup (unused) functions
Apr 12, 2018
58b73d6
added restraints test
Apr 12, 2018
a332645
removed code for changing restraints in base class
Apr 12, 2018
9db6f0c
renamed MolDart to match Move naming convention
Apr 12, 2018
af2ff16
restructured moldart module location
Apr 13, 2018
ffb6cd9
restructured module for moldart
Apr 13, 2018
86c52cc
removed old lambda_restraints variable
Apr 13, 2018
a803acb
exposed setting lambda_restraints in move
Apr 13, 2018
a10a40f
remove debugging code
Apr 13, 2018
bc39af4
Merge pull request #118 from MobleyLab/ic_test
sgill2 Apr 13, 2018
a9a4b67
Merge branch 'internal' of https://github.com/MobleyLab/blues into in…
Apr 13, 2018
a0074ca
debugging travis
Apr 13, 2018
e27d3e0
removed merge header
Apr 13, 2018
446efa7
added future requirement
Apr 13, 2018
87e8b50
fix future requirements
Apr 13, 2018
fc7cf14
fix moldart import statements
Apr 13, 2018
96410ac
add boresch restraint file that didn't carry over from merge
Apr 13, 2018
cb85eb9
added yank requirements for boresch restraints
Apr 13, 2018
ac1228f
fix attribute not being set (due to code changes)
Apr 13, 2018
32cec53
removed restraint force debugging
Apr 14, 2018
55b5502
fixes force type check for boresch restraints
Apr 14, 2018
c10ff36
added experimental option to handle rings
Apr 17, 2018
d6761c7
fixed import statement
Apr 25, 2018
7339d07
remove experimental option
Apr 25, 2018
3af566c
Added transition matrix option to specify transition probabilities
Apr 30, 2018
1673a15
fixed move acceptance ratio factor for mc simulations
May 1, 2018
6cf00ab
removed debug print statements
May 1, 2018
15f4a2d
added transition matrix checks/tests
May 1, 2018
61a464e
removes ncmc_move_output portion
May 22, 2018
7bc1e20
added rigid_ring option as default
May 22, 2018
190858e
Update moldart example
Jun 1, 2018
9db66e2
Fix errror with saving energies to txt file
nathanmlim Jun 12, 2018
3e56b85
Merge conflicts with master
nathanmlim Jun 13, 2018
cb000d5
Add .gitignore file
nathanmlim Jun 13, 2018
e2592d9
Resolve more conflicts with master
nathanmlim Jun 13, 2018
0484870
Skip dart tests and remove old code
nathanmlim Jun 13, 2018
f3197c3
Merge branch 'master' into internal
Jun 20, 2018
5b544d8
updated compatibility with current BLUES
Sep 11, 2018
a44019b
changes before further optimization
Sep 14, 2018
a59ca7e
updated with new chemcoord
Sep 17, 2018
9d5e05e
save changes before more testing
Sep 18, 2018
3b3d297
fixed compatability issues/cleaned up code
Sep 20, 2018
30d1f60
updated moldarting tests for new blues version
Sep 24, 2018
e029579
added wip dart setup tests
Sep 25, 2018
9e63e26
Merge branch 'master' of github.com:MobleyLab/blues into internal
Sep 26, 2018
f220559
update compatibility with pulled code
Sep 26, 2018
93c261f
updated conda package requirements
Sep 26, 2018
4a1a4e8
added conda-forge channel
Sep 27, 2018
4aa7491
update channels to work with travis
Sep 27, 2018
6157d98
updated MoveEngine import from proper script
Sep 27, 2018
0f59c20
updated Logger spelling to match convention
Sep 27, 2018
7f2e879
fixed self reference for class
Sep 27, 2018
8e7a2c5
fixed inheritance and assertion for test
Sep 27, 2018
8836d92
removed depreciated files
Sep 28, 2018
115f8c4
removed depreciated smartdarting code
Sep 28, 2018
b96c780
vectorized setting arrays
Oct 3, 2018
dda9e37
added dart region creation tests
Oct 3, 2018
2298580
added tests for lin algebra functions for moldarting
Oct 3, 2018
0d54349
updated positional argument for test
Oct 3, 2018
2543fd8
fix acceptance ratio handling for moves
Nov 7, 2018
e9cb96d
change moldarting defaults
Nov 7, 2018
60cd42c
added molecular darting sphinx documentation
Nov 13, 2018
e3c2144
fixes for implicit solvent simulations
Jan 11, 2019
434fb7e
update darting to handle multipe modes
Jan 11, 2019
fcef812
fix correction factor debugging
Jan 11, 2019
b551fff
updated tests
Jan 14, 2019
4a62045
remove debug printing statement
Jan 14, 2019
7868683
fixed tabulated function behavior for alchemical_function option
Jan 30, 2019
f636962
handle situation when no crds are used
Jan 30, 2019
51e7b8e
allows changes in the order of defining the darting region
Feb 22, 2019
df3053b
added making darting region class function
Feb 28, 2019
9b04405
updated docstrings for moldart functions
Feb 28, 2019
acc5493
adds ability to check darts from a trajectory
Mar 1, 2019
92801fe
fixed bug with topology loading in _createBuildlist
Mar 1, 2019
6b43578
fixed handlling of multiple trajectories
Mar 2, 2019
44ed7a9
fixed darting region definitions for rot/trans
Mar 11, 2019
77d4571
Improved translational dart handling
Mar 27, 2019
4ab2e78
fixed bug handling translational/dihedral darts
Mar 27, 2019
6b6d38c
fixed translational darting, error handling
Apr 2, 2019
fe7fa97
fixed translational darts / dart overlap reporting
Apr 2, 2019
3c20f14
fix dart reversibility handling
Apr 4, 2019
72fe5bc
fixed handling of other darts when using rotational darts
Apr 5, 2019
f6e0517
more generalized parameters for making darts
Apr 5, 2019
73eb977
Merge branch 'internal' of github.com:MobleyLab/blues into internal
Apr 5, 2019
ac158f5
fixed str handling for _checkTrajectoryDarts
Apr 5, 2019
61722ac
additional parameters for MolDartMove dart specifications
Apr 9, 2019
7ff992c
initial commit to clean up overfit darts
Apr 23, 2019
3e27ac0
remove print statements
Apr 23, 2019
722aaee
generalized restrained atoms for rmsd restraints
Apr 24, 2019
610523b
fixed single dihedral case handling in removeRedundancy()
Apr 30, 2019
133fa09
inital attempt for rigid body simulation
Apr 30, 2019
260b861
added return to rigid function
May 1, 2019
df07b4a
fixed error handling for when svd doesnt converge for rotation
sgill2 May 10, 2019
4147dc1
inital rigid body handling
sgill2 May 13, 2019
adc3de1
fixed case where pos not set
sgill2 May 13, 2019
b77652c
added before portion for rigid body handling
sgill2 May 13, 2019
35551b5
added parameters for debugging moldarting
May 14, 2019
cfe36c4
added options for individual restraint specification
May 15, 2019
cc1fd62
WIP changes for individual pose restraints
sgill2 May 28, 2019
768040b
next fix for fitting multiple poses
sgill2 May 31, 2019
7e5cf97
fix restrained receptor atoms
sgill2 May 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ before_install:

# Add conda-forge channel to top priority
- conda config --add channels conda-forge
- conda config --add channels sgill2

install:
# Create test environment for package
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ BLUES is compatible with MacOSX/Linux with Python>=3.5 (blues<=1.1 still works w
Install [miniconda](http://conda.pydata.org/miniconda.html) according to your system.

## Requirements
Starting from v1.2, you will need the OpenEye toolkits and related tools:
Starting from v1.2, you will need the OpenEye toolkits and related tools to use the `SideChainMove` class:
```bash
conda install -c openeye/label/Orion -c omnia oeommtools packmol

# Requires OpenEye License
conda install -c openeye openeye-toolkits

# Requirements for the MolDartMove class
conda install --yes -c sgill2 chemcoord
conda install -c omnia mdtraj parmed yank openmmtools=0.14.0
conda install --yes -c conda-forge future
```

## Installation
Expand Down
2 changes: 2 additions & 0 deletions blues/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""
# Add imports here
from blues import integrators, moves, reporters, settings, simulation, utils
#from blues import integrators, moves, reporters, settings, simulation, utils, moldart


# Handle versioneer
from ._version import get_versions
Expand Down
109 changes: 109 additions & 0 deletions blues/examples/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"""
example.py: Provides an example script to run BLUES and
benchmark the run on a given platform

Authors: Samuel C. Gill
Contributors: Nathan M. Lim, David L. Mobley

* Benchmarking related code adapted from:
https://github.com/pandegroup/openmm/blob/master/examples/benchmark.py
(Authors: Peter Eastman)
"""

from __future__ import print_function
from blues.moves import RandomLigandRotationMove
from blues.engine import MoveEngine
from blues import utils
from blues.simulation import Simulation, SimulationFactory
import parmed
from simtk import openmm
from optparse import OptionParser
import sys
import logging
from blues.reporters import init_logger, BLUESHDF5Reporter, BLUESStateDataReporter

def runNCMC(platform_name, nstepsNC, nprop, outfname):

#Generate the ParmEd Structure
prmtop = utils.get_data_filename('blues', 'tests/data/eqToluene.prmtop')
inpcrd = utils.get_data_filename('blues', 'tests/data/eqToluene.inpcrd')
struct = parmed.load_file(prmtop, xyz=inpcrd)

#Define some options
opt = { 'temperature' : 300.0, 'friction' : 1, 'dt' : 0.002,
'nIter' : 100, 'nstepsNC' : 10000, 'nstepsMD' : 10000, 'nprop' : 1,
'nonbondedMethod' : 'PME', 'nonbondedCutoff': 10,
'constraints': 'HBonds', 'freeze_distance' : 5.0,
'trajectory_interval' : 2000, 'reporter_interval' : 1000,
'write_move' : False,
'platform' : platform_name,
'outfname' : 't4-toluene'}


logger = init_logger(logging.getLogger(), level=logging.INFO, outfname=opt['outfname'])
opt['Logger'] = logger

#Define the 'model' object we are perturbing here.
# Calculate particle masses of object to be moved
ligand = RandomLigandRotationMove(struct, 'LIG')

# Initialize object that proposes moves.
ligand_mover = MoveEngine(ligand)

# Generate the MD, NCMC, ALCHEMICAL Simulation objects
simulations = SimulationFactory(struct, ligand_mover, **opt)
simulations.createSimulationSet()

# Add reporters to MD simulation.
traj_reporter = openmm.app.DCDReporter(opt['outfname']+'-nc{}.dcd'.format(nstepsNC), opt['trajectory_interval'])
md_progress_reporter = BLUESStateDataReporter(logger, separator="\t", title='md',
reportInterval=opt['reporter_interval'],
step=True, totalSteps=opt['nIter']*opt['nstepsMD'],
time=False, speed=True, progress=True, remainingTime=True)
simulations.md.reporters.append(traj_reporter)
simulations.md.reporters.append(md_progress_reporter)

# Add reporters to NCMC simulation.
ncmc_reporter = BLUESHDF5Reporter(file=opt['outfname']+'-pmoves.h5',
reportInterval=1,
coordinates=True, frame_indices=[1,opt['nstepsNC']],
time=False, cell=True, temperature=False,
potentialEnergy=False, kineticEnergy=False,
velocities=False, atomSubset=None,
protocolWork=True, alchemicalLambda=True,
parameters=opt, environment=True)
ncmc_progress_reporter = BLUESStateDataReporter(logger, separator="\t", title='ncmc',
reportInterval=opt['reporter_interval'],
step=True, totalSteps=opt['nstepsNC'],
time=False, speed=True, progress=True, remainingTime=True)
simulations.nc.reporters.append(ncmc_reporter)
simulations.nc.reporters.append(ncmc_progress_reporter)

# Run BLUES Simulation
blues = Simulation(simulations, ligand_mover, **opt)
blues.run(opt['nIter'])

parser = OptionParser()
parser.add_option('-f', '--force', action='store_true', default=False,
help='run BLUES example without GPU platform')
parser.add_option('-n','--ncmc', dest='nstepsNC', type='int', default=100,
help='number of NCMC steps')
parser.add_option('-p','--nprop', dest='nprop', type='int', default=1,
help='number of propgation steps')
parser.add_option('-o','--output', dest='outfname', type='str', default="blues",
help='Filename for output DCD')
(options, args) = parser.parse_args()



platformNames = [openmm.Platform.getPlatform(i).getName() for i in range(openmm.Platform.getNumPlatforms())]
if 'CUDA' in platformNames:
runNCMC('CUDA', options.nstepsNC, options.nprop, options.outfname)
elif 'OpenCL' in platformNames:
runNCMC('OpenCL',options.nstepsNC, options.nprop, options.outfname)
else:
if options.force:
runNCMC('CPU', options.nstepsNC, options.outfname)
else:
print('WARNING: Could not find a valid CUDA/OpenCL platform. BLUES is not recommended on CPUs.')
print("To run on CPU: 'python blues/example.py -f'")
109 changes: 109 additions & 0 deletions blues/examples/example_moldart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"""
example.py: Provides an example script to run BLUES and
benchmark the run on a given platform

Authors: Samuel C. Gill
Contributors: Nathan M. Lim, David L. Mobley

* Benchmarking related code adapted from:
https://github.com/pandegroup/openmm/blob/master/examples/benchmark.py
(Authors: Peter Eastman)
"""

from __future__ import print_function
from blues.moves import MolDartMove
from blues.engine import MoveEngine
from blues import utils
from blues.simulation import Simulation, SimulationFactory
import parmed
from simtk import openmm
from optparse import OptionParser
import mdtraj as md
import logging, sys
from blues.reporters import init_logger, BLUESHDF5Reporter, BLUESStateDataReporter


def runNCMC(platform_name):
#Define some options
opt = { 'temperature' : 300.0, 'friction' : 1, 'dt' : 0.002,
'nIter' : 10, 'nstepsNC' : 2000, 'nstepsMD' : 5000,
'nonbondedMethod' : 'PME', 'nonbondedCutoff': 10, 'constraints': 'HBonds',
'trajectory_interval' : 1000, 'reporter_interval' : 250,
'platform' : 'CUDA',
'outfname' : 't4-tol',
'write_move' : False,
'nprop':5,
'freeze_distance' : 5.0,
'verbose' : True
}

logger = init_logger(logging.getLogger(), level=logging.INFO, outfname=opt['outfname'])
opt['Logger'] = logger

#Generate the ParmEd Structure
prmtop = utils.get_data_filename('blues', 'tests/data/eqToluene.prmtop')#
inpcrd = utils.get_data_filename('blues', 'tests/data/eqToluene.inpcrd')
struct = parmed.load_file(prmtop, xyz=inpcrd)

#Define the 'model' object we are perturbing here.
# Calculate particle masses of object to be moved
posA = utils.get_data_filename('blues', 'tests/data/posA.pdb')
posB = utils.get_data_filename('blues', 'tests/data/posB.pdb')
traj = md.load(inpcrd, top=prmtop)
fit_atoms = traj.top.select("protein")

ligand = MolDartMove(structure=struct, resname='LIG',
pdb_files=[posA, posB],
fit_atoms=fit_atoms,
restrained_receptor_atoms=[1605, 1735, 1837],
rigid_ring=True
)

# Initialize object that proposes moves.
ligand_mover = MoveEngine(ligand)

# Generate the MD, NCMC, ALCHEMICAL Simulation objects
simulations = SimulationFactory(struct, ligand_mover, **opt)
simulations.createSimulationSet()

# Add reporters to MD simulation.
#traj_reporter = openmm.app.DCDReporter(opt['outfname']+'-nc{}.dcd'.format(opt['nstepsNC']), 1)
from blues.reporters import NetCDF4Reporter
traj_reporter = NetCDF4Reporter(opt['outfname']+'-nc{}.nc'.format(opt['nstepsNC']), 1000)
md_progress_reporter = openmm.app.StateDataReporter(sys.stdout, separator="\t",
reportInterval=opt['reporter_interval'],
step=True, totalSteps=opt['nIter']*opt['nstepsMD'],
time=True, speed=True, progress=True,
elapsedTime=True, remainingTime=True)
simulations.md.reporters.append(traj_reporter)
simulations.md.reporters.append(md_progress_reporter)

# Add reporters to NCMC simulation.
ncmc_progress_reporter = openmm.app.StateDataReporter(sys.stdout, separator="\t",
reportInterval=opt['reporter_interval'],
step=True, totalSteps=opt['nstepsNC'],
time=True, speed=True, progress=True,
elapsedTime=True, remainingTime=True)
#simulations.nc.reporters.append(traj_reporter)
simulations.nc.reporters.append(ncmc_progress_reporter)

blues = Simulation(simulations, ligand_mover, **opt)
blues.run(opt['nIter'])

parser = OptionParser()
parser.add_option('-f', '--force', action='store_true', default=False,
help='run BLUES example without GPU platform')
(options, args) = parser.parse_args()

platformNames = [openmm.Platform.getPlatform(i).getName() for i in range(openmm.Platform.getNumPlatforms())]

if 'OpenCL' in platformNames:
runNCMC('OpenCL')
elif 'CUDA' in platformNames:
runNCMC('CUDA')
else:
if options.force:
runNCMC('CPU')
else:
print('WARNING: Could not find a valid CUDA/OpenCL platform. BLUES is not recommended on CPUs.')
print("To run on CPU: 'python blues/example.py -f'")
35 changes: 35 additions & 0 deletions blues/examples/example_sidechain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from blues.moves import SideChainMove
from blues.engine import MoveEngine
from blues.simulation import *
from blues.settings import *

# Parse a YAML configuration, return as Dict
cfg = Settings('sidechain_cuda.yaml').asDict()
structure = cfg['Structure']

#Select move type
sidechain = SideChainMove(structure, [1])
#Iniitialize object that selects movestep
sidechain_mover = MoveEngine(sidechain)

#Generate the openmm.Systems outside SimulationFactory to allow modifications
systems = SystemFactory(structure, sidechain.atom_indices, cfg['system'])

#Generate the OpenMM Simulations
simulations = SimulationFactory(systems, sidechain_mover, cfg['simulation'], cfg['md_reporters'], cfg['ncmc_reporters'])

# Run BLUES Simulation
blues = BLUESSimulation(simulations, cfg['simulation'])
blues.run()

#Analysis
import mdtraj as md
import numpy as np

traj = md.load_netcdf('vacDivaline-test/vacDivaline.nc', top='tests/data/vacDivaline.prmtop')
indicies = np.array([[0, 4, 6, 8]])
dihedraldata = md.compute_dihedrals(traj, indicies)
with open("vacDivaline-test/dihedrals.txt", 'w') as output:
for value in dihedraldata:
output.write("%s\n" % str(value)[1:-1])

8 changes: 6 additions & 2 deletions blues/integrators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import simtk
from openmmtools.integrators import AlchemicalNonequilibriumLangevinIntegrator

import inspect
# Energy unit used by OpenMM unit system
_OPENMM_ENERGY_UNIT = simtk.unit.kilojoules_per_mole

Expand Down Expand Up @@ -122,6 +122,10 @@ def __init__(self,
nsteps_neq=nsteps_neq)

self._prop_lambda = self._get_prop_lambda(prop_lambda)
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
inputs = dict([(i, values[i]) for i in args if i is not 'self'])
self.int_kwargs = inputs

# add some global variables relevant to the integrator
kB = simtk.unit.BOLTZMANN_CONSTANT_kB * simtk.unit.AVOGADRO_CONSTANT_NA
Expand Down Expand Up @@ -246,4 +250,4 @@ def reset(self):
self.setGlobalVariableByName("perturbed_pe", 0.0)
self.setGlobalVariableByName("unperturbed_pe", 0.0)
self.setGlobalVariableByName("prop", 1)
super(AlchemicalExternalLangevinIntegrator, self).reset()
super(AlchemicalExternalLangevinIntegrator, self).reset()
1 change: 1 addition & 0 deletions blues/moldart/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from blues.moldart import chemcoord, darts, lin_math, move
Loading