warmup.promote_parameter('trajectory_interval',
                         promoted_name='w_trajectory_interval',
                         default=0,
                         description='Trajectory saving interval')
warmup.promote_parameter('reporter_interval',
                         promoted_name='w_reporter_interval',
                         default=0,
                         description='Reporter saving interval')
warmup.promote_parameter('outfname',
                         promoted_name='w_outfname',
                         default='warmup',
                         description='Equilibration suffix name')
warmup.promote_parameter('center', promoted_name='center', default=True)

# NPT Equilibration stage
equil = OpenMMnptCube('equil', title='equil')
equil.promote_parameter('time',
                        promoted_name='eq_psec',
                        default=20.0,
                        description='Length of MD run in picoseconds')
equil.promote_parameter('restraints',
                        promoted_name='eq_restraints',
                        default="noh ligand",
                        description='Select mask to apply restraints')
equil.promote_parameter('restraintWt',
                        promoted_name='eq_restraintWt',
                        default=0.1,
                        description='Restraint weight in kcal/(mol A^2')
equil.promote_parameter('trajectory_interval',
                        promoted_name='eq_trajectory_interval',
                        default=0,
示例#2
0
Outputs:
--------
ofs: Outputs the constant temperature and pressure system
"""

job.classification = [['NPT']]
job.tags = [tag for lists in job.classification for tag in lists]

ifs = OEMolIStreamCube("SystemReader", title="System Reader")
ifs.promote_parameter("data_in",
                      promoted_name="system",
                      title='System Input File',
                      description="System input file")

npt = OpenMMnptCube('npt')
npt.promote_parameter('time',
                      promoted_name='picosec',
                      default=10.0,
                      description='Length of MD run in picoseconds')
npt.promote_parameter('temperature',
                      promoted_name='temperature',
                      default=300.0,
                      description='Selected temperature in K')
npt.promote_parameter('pressure',
                      promoted_name='pressure',
                      default=1.0,
                      description='Selected pressure in atm')

# Restraints
npt.promote_parameter('restraints',
warmup.promote_parameter('reporter_interval',
                         promoted_name='w_reporter_interval',
                         default=0,
                         description='Reporter saving interval')
warmup.promote_parameter('outfname',
                         promoted_name='w_outfname',
                         default='warmup',
                         description='Equilibration suffix name')

# The system is equilibrated at the right pressure and temperature in 3 stages
# The main difference between the stages is related to the restraint force used
# to keep the ligand and protein in their starting positions. A relatively strong force
# is applied in the first stage while a relatively small one is applied in the latter

# NPT Equilibration stage 1
equil1 = OpenMMnptCube('equil1', title='equil1')
equil1.promote_parameter('time',
                         promoted_name='eq1_psec',
                         default=100.0,
                         description='Length of MD run in picoseconds')
equil1.promote_parameter('restraints',
                         promoted_name='eq1_restraints',
                         default="noh (ligand or protein)",
                         description='Select mask to apply restarints')
equil1.promote_parameter('restraintWt',
                         promoted_name='eq1_restraintWt',
                         default=2.0,
                         description='Restraint weight')
equil1.promote_parameter('trajectory_interval',
                         promoted_name='eq1_trajectory_interval',
                         default=0,
warmupComplex.promote_parameter('reporter_interval',
                                promoted_name='w_reporter_interval',
                                default=0,
                                description='Reporter saving interval')
warmupComplex.promote_parameter('outfname',
                                promoted_name='w_outfname',
                                default='warmup',
                                description='Equilibration suffix name')

# The system is equilibrated at the right pressure and temperature in 3 stages
# The main difference between the stages is related to the restraint force used
# to keep the ligand and protein in their starting positions. A relatively strong force
# is applied in the first stage while a relatively small one is applied in the latter

# NPT Equilibration stage 1
equil1Complex = OpenMMnptCube('equil1Complex', title='equil1Complex')
equil1Complex.promote_parameter('time',
                                promoted_name='eq1_psec',
                                default=20.0,
                                description='Length of MD run in picoseconds')
equil1Complex.promote_parameter('restraints',
                                promoted_name='eq1_restraints',
                                default="noh (ligand or protein)",
                                description='Select mask to apply restarints')
equil1Complex.promote_parameter('restraintWt',
                                promoted_name='eq1_restraintWt',
                                default=2.0,
                                description='Restraint weight')
equil1Complex.promote_parameter('trajectory_interval',
                                promoted_name='eq1_trajectory_interval',
                                default=0,
示例#5
0
 def setUp(self):
     self.cube = OpenMMnptCube('NPT')
     self.runner = CubeTestRunner(self.cube)
     self.runner.start()
示例#6
0
class NPTCubeTester(unittest.TestCase):
    """
    Test the OpenMM NPT cube
    Example inputs from `openmm_orion/examples/data`
    """
    def calculate_VT(self, oe_mol):
        # Extract starting MD data from OEMol
        mdData = utils.MDData(oe_mol)
        structure = mdData.structure
        topology = mdData.topology
        positions = mdData.positions
        velocities = mdData.velocities
        box = mdData.box

        volume = box[0][0] * box[1][1] * box[2][2]

        # OpenMM system
        system = structure.createSystem(nonbondedMethod=eval("app.%s" % self.cube.args.nonbondedMethod),
                                        nonbondedCutoff=self.cube.args.nonbondedCutoff * unit.angstroms,
                                        constraints=eval("app.%s" % self.cube.args.constraints))
        # OpenMM Integrator
        integrator = openmm.LangevinIntegrator(self.cube.args.temperature * unit.kelvin,
                                               1.0 / unit.picoseconds, 0.002 * unit.picoseconds)

        # Add Force Barostat to the system
        system.addForce(openmm.MonteCarloBarostat(self.cube.args.pressure * unit.atmospheres,
                                                  self.cube.args.temperature*unit.kelvin, 25))

        # Set Simulation
        simulation = app.Simulation(topology, system, integrator)

        # Set Positions
        simulation.context.setPositions(positions)

        # Set Velocities
        simulation.context.setVelocities(velocities)

        # Set Box dimensions
        simulation.context.setPeriodicBoxVectors(box[0], box[1], box[2])

        # Collect the OpenMM state energy info
        state = simulation.context.getState(getEnergy=True)

        # Kinetic Energy
        keng = state.getKineticEnergy()

        # Calculate system degrees of freedom:
        dof = 0
        for i in range(system.getNumParticles()):
            if system.getParticleMass(i) > 0 * unit.dalton:
                dof += 3

        dof -= system.getNumConstraints()

        if any(type(system.getForce(i)) == openmm.CMMotionRemover for i in range(system.getNumForces())):
            dof -= 3

        # Calculate the temperature from the equipartition theorem
        temperature = ((2*keng)/(dof*unit.MOLAR_GAS_CONSTANT_R))

        return volume, temperature

    def setUp(self):
        self.cube = OpenMMnptCube('NPT')
        self.runner = CubeTestRunner(self.cube)
        self.runner.start()

    def _test_success(self):
        print('Testing cube:', self.cube.name)

        # Complex file name
        complex_fname = utils.get_data_filename('examples', 'data/pP38_lp38a_2x_complex.oeb.gz')
        # Read OEMol molecule
        mol = oechem.OEMol()
        with oechem.oemolistream(complex_fname) as ifs:
            oechem.OEReadMolecule(ifs, mol)

        # Process the molecules
        self.cube.process(mol, self.cube.intake.name)
        # Assert that one molecule was emitted on the success port
        self.assertEqual(self.runner.outputs['success'].qsize(), 1)
        # Assert that zero molecules were emitted on the failure port
        self.assertEqual(self.runner.outputs['failure'].qsize(), 0)

        outmol = self.runner.outputs["success"].get()

        # Calculate final volume and temperature
        vol_f, temp_f = self.calculate_VT(outmol)

        # Check 3*std volume
        # Average volume and its standard deviation (in nm^3) measured along
        # one 10ns run for the selected system
        avg_volume = 683.6 * (unit.nanometers**3)
        std_volume = 1.3

        self.assertAlmostEqual(avg_volume/(unit.nanometers**3),
                               vol_f.in_units_of(unit.nanometers**3)/(unit.nanometers**3),
                               delta=3*std_volume)

        # Check 3*std temperature
        # Average temperature and its standard deviation (in K) measured along
        # one 10ns run for the selected system
        avg_temperature = 300.0 * unit.kelvin
        std_temperature = 1.1

        self.assertAlmostEqual(avg_temperature/unit.kelvin,
                               temp_f.in_units_of(unit.kelvin)/unit.kelvin,
                               delta=3*std_temperature)

    @pytest.mark.slow
    def test_success(self):
        self.cube.args.time = 50.0  # in picoseconds
        self._test_success()

    def test_failure(self):
        pass

    def tearDown(self):
        self.runner.finalize()
示例#7
0
from OpenMMCubes.cubes import OpenMMnptCube

job = WorkFloe("Production Run")

job.description = """
Run an unrestrained NPT simulation at 300K and 1atm
"""

job.classification = [['Simulation']]
job.tags = [tag for lists in job.classification for tag in lists]

ifs = OEMolIStreamCube("SystemReader", title="System Reader")
ifs.promote_parameter("data_in", promoted_name="system", title='System Input File',
                      description="System input file")

prod = OpenMMnptCube('production')

# Set simulation time
prod.promote_parameter('time', promoted_name='picosec', default=2000)

# Set the temperature in K
prod.promote_parameter('temperature', promoted_name='temperature', default=300.0,
                       description='Selected temperature in K')

# Set the pressure in atm
prod.promote_parameter('pressure', promoted_name='pressure', default=1.0,
                       description='Selected pressure in atm')

# Trajectory and logging info frequency intervals
prod.promote_parameter('trajectory_interval', promoted_name='trajectory_interval', default=1000,
                       description='Trajectory saving interval')