Example #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])
Example #2
0
def ligrot_example(yaml_file):
    # Parse a YAML configuration, return as Dict
    cfg = Settings(yaml_file).asDict()
    structure = cfg['Structure']

    #Select move type
    ligand = RandomLigandRotationMove(structure, 'LIG')
    #Iniitialize object that selects movestep
    ligand_mover = MoveEngine(ligand)

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

    #Freeze atoms in the alchemical system to speed up alchemical calculation
    systems.alch = systems.freeze_radius(structure, systems.alch, **cfg['freeze'])

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

    # Run BLUES Simulation
    blues = BLUESSimulation(simulations, cfg['simulation'])
    blues.run()
Example #3
0
from blues.moves import WaterTranslationMove, MoveEngine
from blues.simulation import *
import json
from blues.settings import Settings

# Parse a YAML configuration, return as Dict
opt = Settings('water_cuda.yaml').asDict()
structure = opt['Structure']
print(json.dumps(opt, sort_keys=True, indent=2, skipkeys=True, default=str))

# Select move type
water = WaterTranslationMove(structure,
                             water_name='WAT',
                             protein_selection='index 9',
                             radius=2 * unit.nanometers)

# Initialize object that selects movestep
water_mover = MoveEngine(water)

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

# Restrain atoms in the MD and alchemical system
systems.md = systems.restrain_positions(structure, systems.md,
                                        **opt['restraints'])
systems.alch = systems.restrain_positions(structure, systems.alch,
                                          **opt['restraints'])

# Generate the OpenMM Simulations
simulations = SimulationFactory(systems, water_mover, opt['simulation'],
                                opt['md_reporters'], opt['ncmc_reporters'])
Example #4
0
from WaterTranslation import WaterTranslation
from blues.moves import MoveEngine
from blues.simulation import *
import json
from blues.settings import Settings

opt = Settings('example.yaml').asDict()
structure = opt['Structure']
#restart = parmed.amber.Rst7('NPT_MD.rst7')
#structure.positions = restart.positions
#structure.box = restart.box
print(json.dumps(opt, sort_keys=True, indent=2, skipkeys=True, default=str))

#Select move type
ligand = WaterTranslationMove(structure, water_name='WAT')

#Iniitialize object that selects movestep
ligand_mover = MoveEngine(ligand)

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

# Uncomment this section freeze atoms in the system
# Used for MD or BLUES production runs of the C60 buckyball and the water box with dividing graphene sheets
#systems.md = systems.freeze_atoms(structure, systems.md, **opt['freeze'])
#systems.alch = systems.freeze_atoms(structure, systems.alch, **opt['freeze'])

# Uncomment this section to restrain atoms in the MD and alchemical system
# Used for MD and BLUES production runs of MUP-1 and HSP90 protein-ligand systems to restrain all of the alpha carbons and the ligands
#systems.md = systems.restrain_positions(structure, systems.md, **opt['restraints'])
#systems.alch = systems.restrain_positions(structure, systems.alch, **opt['restraints'])
Example #5
0
    def test_blues_simulationRunYAML(self):
        yaml_cfg = """
            output_dir: .
            outfname: ala-dipep-vac
            logger:
              level: info
              stream: True

            system:
              nonbonded: NoCutoff
              constraints: HBonds

            simulation:
              dt: 0.002 * picoseconds
              friction: 1 * 1/picoseconds
              temperature: 400 * kelvin
              nIter: 1
              nstepsMD: 4
              nstepsNC: 4

            md_reporters:
              stream:
                title: md
                reportInterval: 1
                totalSteps: 4 # nIter * nstepsMD
                step: True
                speed: True
                progress: True
                remainingTime: True
                currentIter : True
            ncmc_reporters:
              stream:
                title: ncmc
                reportInterval: 1
                totalSteps: 4 # Use nstepsNC
                step: True
                speed: True
                progress: True
                remainingTime: True
                protocolWork : True
                alchemicalLambda : True
                currentIter : True
        """
        print('Testing Simulation.run() from YAML')
        yaml_cfg = Settings(yaml_cfg)
        cfg = yaml_cfg.asDict()

        simulations = SimulationFactory(self.systems, self.engine,
                                        cfg['simulation'], cfg['md_reporters'],
                                        cfg['ncmc_reporters'])

        blues = BLUESSimulation(simulations)
        before_iter = blues._md_sim.context.getState(
            getPositions=True).getPositions(asNumpy=True)
        blues.run()
        after_iter = blues._md_sim.context.getState(
            getPositions=True).getPositions(asNumpy=True)
        #Check that our system has run dynamics
        pos_compare = np.not_equal(before_iter, after_iter).all()
        self.assertTrue(pos_compare)
        os.remove('ala-dipep-vac.log')
from mup_WaterTranslationRotation import WaterTranslationRotationMove
from blues.moves import MoveEngine
from blues.simulation import *
import json
from blues.settings import Settings

opt = Settings('mup.yaml').asDict()
structure = opt['Structure']
restart = parmed.amber.Rst7(
    '/oasis/tscc/scratch/bergazin/water/mup_NPT_MD.rst7'
)  #change to dir where rst is
#restart = parmed.amber.Rst7('/oasis/tscc/scratch/bergazin/water/MUP-1/NCMCsteps_variation_trials/1000_NCMCsteps_trials/t1/t1.rst7')

structure.positions = restart.positions
#structure.velocities = restart.velocities
structure.box = restart.box
print("structure.box", structure.box)
print(json.dumps(opt, sort_keys=True, indent=2, skipkeys=True, default=str))

#Select move type
ligand = WaterTranslationRotationMove(structure, water_name='WAT')

#Iniitialize object that selects movestep
ligand_mover = MoveEngine(ligand)

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

#Freeze atoms in the alchemical system
#systems.md = systems.freeze_atoms(structure, systems.md, **opt['freeze'])
#systems.alch = systems.freeze_atoms(structure, systems.alch, **opt['freeze'])
Example #7
0
    def test_blues_simulationRunYAML(self, tmpdir, structure, tol_atom_indices, system_cfg, engine):
        yaml_cfg = """
            output_dir: .
            outfname: tol-test
            logger:
              level: info
              stream: True

            system:
              nonbondedMethod: PME
              nonbondedCutoff: 8.0 * angstroms
              constraints: HBonds

            simulation:
              dt: 0.002 * picoseconds
              friction: 1 * 1/picoseconds
              temperature: 300 * kelvin
              nIter: 1
              nstepsMD: 2
              nstepsNC: 2
              platform: CPU

            md_reporters:
              stream:
                title: md
                reportInterval: 1
                totalSteps: 2 # nIter * nstepsMD
                step: True
                speed: True
                progress: True
                remainingTime: True
                currentIter : True
            ncmc_reporters:
              stream:
                title: ncmc
                reportInterval: 1
                totalSteps: 2 # Use nstepsNC
                step: True
                speed: True
                progress: True
                remainingTime: True
                protocolWork : True
                alchemicalLambda : True
                currentIter : True
        """
        print('Testing Simulation.run() from YAML')
        yaml_cfg = Settings(yaml_cfg)
        cfg = yaml_cfg.asDict()
        cfg['output_dir'] = tmpdir
        # os.getenv is equivalent, and can also give a default value instead of `None`
        PLATFORM = os.getenv('OMM_PLATFORM', 'CPU')
        cfg['simulation']['platform'] = PLATFORM
        systems = SystemFactory(structure, tol_atom_indices, cfg['system'])
        simulations = SimulationFactory(systems, engine, cfg['simulation'], cfg['md_reporters'], cfg['ncmc_reporters'])

        blues = BLUESSimulation(simulations)
        blues._md_sim.minimizeEnergy()
        blues._alch_sim.minimizeEnergy()
        blues._ncmc_sim.minimizeEnergy()
        before_iter = blues._md_sim.context.getState(getPositions=True).getPositions(asNumpy=True)
        blues.run()
        after_iter = blues._md_sim.context.getState(getPositions=True).getPositions(asNumpy=True)
        #Check that our system has run dynamics
        pos_compare = np.not_equal(before_iter, after_iter).all()
        assert pos_compare
Example #8
0
    def test_blues_simulationRunYAML(self, tmpdir, structure, tol_atom_indices,
                                     system_cfg, engine):
        yaml_cfg = """
            output_dir: .
            outfname: tol-test
            logger:
              level: info
              stream: True

            system:
              nonbondedMethod: PME
              nonbondedCutoff: 8.0 * angstroms
              constraints: HBonds

            simulation:
              dt: 0.002 * picoseconds
              friction: 1 * 1/picoseconds
              temperature: 300 * kelvin
              nIter: 1
              nstepsMD: 2
              nstepsNC: 2
              platform: CPU

            md_reporters:
              stream:
                title: md
                reportInterval: 1
                totalSteps: 2 # nIter * nstepsMD
                step: True
                speed: True
                progress: True
                remainingTime: True
                currentIter : True
            ncmc_reporters:
              stream:
                title: ncmc
                reportInterval: 1
                totalSteps: 2 # Use nstepsNC
                step: True
                speed: True
                progress: True
                remainingTime: True
                protocolWork : True
                alchemicalLambda : True
                currentIter : True
        """
        print('Testing Simulation.run() from YAML')
        yaml_cfg = Settings(yaml_cfg)
        cfg = yaml_cfg.asDict()
        cfg['output_dir'] = tmpdir
        # os.getenv is equivalent, and can also give a default value instead of `None`
        PLATFORM = os.getenv('OMM_PLATFORM', 'CPU')
        cfg['simulation']['platform'] = PLATFORM
        systems = SystemFactory(structure, tol_atom_indices, cfg['system'])
        simulations = SimulationFactory(systems, engine, cfg['simulation'],
                                        cfg['md_reporters'],
                                        cfg['ncmc_reporters'])

        blues = BLUESSimulation(simulations)
        blues._md_sim.minimizeEnergy()
        blues._alch_sim.minimizeEnergy()
        blues._ncmc_sim.minimizeEnergy()
        before_iter = blues._md_sim.context.getState(
            getPositions=True).getPositions(asNumpy=True)
        blues.run()
        after_iter = blues._md_sim.context.getState(
            getPositions=True).getPositions(asNumpy=True)
        #Check that our system has run dynamics
        pos_compare = np.not_equal(before_iter, after_iter).all()
        assert pos_compare
Example #9
0
from WaterTranslation import WaterTranslation
from blues.moves import MoveEngine
from blues.simulation import *
import json
from blues.settings import Settings

opt = Settings('equilibration.yaml').asDict()
structure = opt['Structure']
#restart = parmed.amber.Rst7('NPT_MD.rst7')

structure.positions = restart.positions
structure.box = restart.box
print(json.dumps(opt, sort_keys=True, indent=2, skipkeys=True, default=str))

#Select move type
ligand = WaterTranslationMove(structure, water_name='WAT')

#Iniitialize object that selects movestep
ligand_mover = MoveEngine(ligand)

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

# Uncomment this section freeze atoms in the system
# Used for MD or BLUES production runs of the C60 buckyball and the water box with dividing graphene sheets
#systems.md = systems.freeze_atoms(structure, systems.md, **opt['freeze'])
#systems.alch = systems.freeze_atoms(structure, systems.alch, **opt['freeze'])

# Uncomment this section to restrain atoms in the MD and alchemical system
# Used for MD and BLUES production runs of MUP-1 and HSP90 protein-ligand systems to restrain all of the alpha carbons and the ligands
#systems.md = systems.restrain_positions(structure, systems.md, **opt['restraints'])