Exemple #1
0
def sidechain_example(yaml_file):
    # Parse a YAML configuration, return as Dict
    cfg = Settings(yaml_file).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])
Exemple #2
0
def runNCMC(platform_name, relaxstepsNC, themdsteps):
    #Define some options

    opt = {
        'temperature': 300.0,
        'friction': 1,
        'dt': 0.002,
        'nIter': 50000,
        'nstepsNC': relaxstepsNC,
        'nstepsMD': themdsteps,
        'nonbondedMethod': 'PME',
        'nonbondedCutoff': 10,
        'constraints': 'HBonds',
        'trajectory_interval': 1000,
        'reporter_interval': 1000,
        'platform': platform_name,
        'verbose': False,
        'write_ncmc': False
    }

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

    #Define the 'model' object we are perturbing here.
    # Calculate particle masses of object to be moved

    ligand = SideChainMove(struct, [1])

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

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

    blues = Simulation(simulations, ligand_mover, **opt)
    #add the reporter here
    blues.md_sim.reporters.append(
        openmm.app.dcdreporter.DCDReporter('accept.dcd', 1000))
    blues.runNCMC()
Exemple #3
0
    def setUp(self):
        # Obtain topologies/positions
        prmtop = utils.get_data_filename('blues', 'tests/data/vacDivaline.prmtop')
        inpcrd = utils.get_data_filename('blues', 'tests/data/vacDivaline.inpcrd')
        self.struct = parmed.load_file(prmtop, xyz=inpcrd)


        #self.atom_indices = utils.atomIndexfromTop('LIG', structure.topology)
        self.functions = { 'lambda_sterics' : 'step(0.199999-lambda) + step(lambda-0.2)*step(0.8-lambda)*abs(lambda-0.5)*1/0.3 + step(lambda-0.800001)',
                           'lambda_electrostatics' : 'step(0.2-lambda)- 1/0.2*lambda*step(0.2-lambda) + 1/0.2*(lambda-0.8)*step(lambda-0.8)' }
        self.opt = { 'temperature' : 300.0, 'friction' : 1, 'dt' : 0.002,
                'nIter' : 10, 'nstepsNC' : 10, 'nstepsMD' : 50,
                'nonbondedMethod' : 'PME', 'nonbondedCutoff': 10, 'constraints': 'HBonds',
                'trajectory_interval' : 10, 'reporter_interval' : 10, 'outfname' : 'vacDivaline',
                'platform' : None,
                'verbose' : False }
        self.sidechain = SideChainMove(self.struct, [1])
        self.mover = MoveEngine(self.sidechain)
Exemple #4
0
class SideChainTester(unittest.TestCase):
    """
    Test the SmartDartMove.move() function.
    """
    def setUp(self):
        # Obtain topologies/positions
        prmtop = utils.get_data_filename('blues', 'tests/data/vacDivaline.prmtop')
        inpcrd = utils.get_data_filename('blues', 'tests/data/vacDivaline.inpcrd')
        self.struct = parmed.load_file(prmtop, xyz=inpcrd)


        #self.atom_indices = utils.atomIndexfromTop('LIG', structure.topology)
        self.functions = { 'lambda_sterics' : 'step(0.199999-lambda) + step(lambda-0.2)*step(0.8-lambda)*abs(lambda-0.5)*1/0.3 + step(lambda-0.800001)',
                           'lambda_electrostatics' : 'step(0.2-lambda)- 1/0.2*lambda*step(0.2-lambda) + 1/0.2*(lambda-0.8)*step(lambda-0.8)' }
        self.opt = { 'temperature' : 300.0, 'friction' : 1, 'dt' : 0.002,
                'nIter' : 10, 'nstepsNC' : 10, 'nstepsMD' : 50,
                'nonbondedMethod' : 'PME', 'nonbondedCutoff': 10, 'constraints': 'HBonds',
                'trajectory_interval' : 10, 'reporter_interval' : 10, 'outfname' : 'vacDivaline',
                'platform' : None,
                'verbose' : False }
        self.sidechain = SideChainMove(self.struct, [1])
        self.mover = MoveEngine(self.sidechain)

    def test_getRotBondAtoms(self):

        vals = [v for v in self.sidechain.rot_atoms[1].values()][0]
        self.assertEqual(len(vals), 11)
        #Ensure it selects 1 rotatable bond in Valine
        self.assertEqual(len(self.sidechain.rot_bonds), 1)

    def test_sidechain_move(self):
        simulations = SimulationFactory(self.struct, self.mover, **self.opt)
        simulations.createSimulationSet()


        nc_context = simulations.nc.context
        self.sidechain.move(nc_context, verbose=False)
Exemple #5
0
    def setUp(self):
        # Obtain topologies/positions
        prmtop = utils.get_data_filename('blues',
                                         'tests/data/vacDivaline.prmtop')
        inpcrd = utils.get_data_filename('blues',
                                         'tests/data/vacDivaline.inpcrd')
        self.struct = parmed.load_file(prmtop, xyz=inpcrd)

        self.sidechain = SideChainMove(self.struct, [1])
        self.engine = MoveEngine(self.sidechain)
        self.engine.selectMove()

        self.system_cfg = {
            'nonbondedMethod': app.NoCutoff,
            'constraints': app.HBonds
        }
        self.systems = SystemFactory(self.struct, self.sidechain.atom_indices,
                                     self.system_cfg)

        self.cfg = {
            'dt': 0.002 * unit.picoseconds,
            'friction': 1 * 1 / unit.picoseconds,
            'temperature': 300 * unit.kelvin,
            'nIter': 1,
            'nstepsMD': 1,
            'nstepsNC': 4,
            'alchemical_functions': {
                'lambda_sterics':
                'step(0.199999-lambda) + step(lambda-0.2)*step(0.8-lambda)*abs(lambda-0.5)*1/0.3 + step(lambda-0.800001)',
                'lambda_electrostatics':
                'step(0.2-lambda)- 1/0.2*lambda*step(0.2-lambda) + 1/0.2*(lambda-0.8)*step(lambda-0.8)'
            }
        }

        self.simulations = SimulationFactory(self.systems, self.engine,
                                             self.cfg)
Exemple #6
0
from blues.moves import SideChainMove
from blues.moves import MoveEngine
from blues.simulation import *
import json
from blues.settings import *
from blues.simulation import *
import json
from blues.settings import *

# Parse a YAML configuration, return as Dict
cfg = Settings('sidechain_cudayaml').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
Exemple #7
0
def runNCMC(platform_name, nstepsNC, nprop, outfname):

    #Generate the ParmEd Structure
    prmtop = utils.get_data_filename('blues', 'tests/data/vacDivaline.prmtop')
    inpcrd = utils.get_data_filename('blues', 'tests/data/vacDivaline.inpcrd')
    struct = parmed.load_file(prmtop, xyz=inpcrd)
    print('Structure: %s' % struct.topology)

    #Define some options
    opt = {
        'temperature': 300.0,
        'friction': 1,
        'dt': 0.004,
        'hydrogenMass': 3.024,
        'nIter': 100,
        'nstepsNC': nstepsNC,
        'nstepsMD': 1000,
        'nprop': nprop,
        'nonbondedMethod': 'PME',
        'nonbondedCutoff': 10,
        'constraints': 'HBonds',
        'trajectory_interval': 100,
        'reporter_interval': 250,
        'ncmc_traj': None,
        'write_move': False,
        'platform': platform_name,
        'outfname': 'vacDivaline',
        'verbose': False
    }
    #Define the 'model' object we are perturbing here.
    # Calculate particle masses of object to be moved
    ligand = SideChainMove(struct, [1])

    # 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.
    trajfile = outfname + '-nc{}.dcd'.format(nstepsNC)
    traj_reporter = openmm.app.DCDReporter(trajfile,
                                           opt['trajectory_interval'])
    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(progress_reporter)

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

    #Analysis
    import mdtraj as md
    import numpy as np
    traj = md.load_dcd(trajfile, top='protein.pdb')
    indicies = np.array([[0, 4, 6, 8]])
    dihedraldata = md.compute_dihedrals(traj, indicies)
    with open("dihedrals-%iNC.txt" % (nstepsNC), 'w') as output:
        for value in dihedraldata:
            output.write("%s\n" % str(value)[1:-1])