Beispiel #1
0
def execute(shifted):
    rswitch_inner = 6.5*unit.angstroms
    rcut_inner = 7.0*unit.angstroms
    rswitch = 9.5*unit.angstroms
    rcut = 10*unit.angstroms
    case = 'tests/data/q-SPC-FW'
    pdb = app.PDBFile(case + '.pdb')
    forcefield = app.ForceField(case + '.xml')

    system = forcefield.createSystem(pdb.topology)
    nbforce = atomsmm.hijackForce(system, atomsmm.findNonbondedForce(system))
    exceptions = atomsmm.NonbondedExceptionsForce()
    exceptions.importFrom(nbforce).addTo(system)
    innerforce = atomsmm.NearNonbondedForce(rcut_inner, rswitch_inner, shifted).setForceGroup(1)
    innerforce.importFrom(nbforce).addTo(system)
    outerforce = atomsmm.FarNonbondedForce(innerforce, rcut, rswitch).setForceGroup(2)
    outerforce.importFrom(nbforce).addTo(system)
    potential = atomsmm.splitPotentialEnergy(system, pdb.topology, pdb.positions)

    refsys = forcefield.createSystem(pdb.topology,
                                     nonbondedMethod=openmm.app.PME,
                                     nonbondedCutoff=rcut,
                                     removeCMMotion=True)
    force = refsys.getForce(refsys.getNumForces()-2)
    force.setUseSwitchingFunction(True)
    force.setSwitchingDistance(rswitch)
    refpot = atomsmm.splitPotentialEnergy(refsys, pdb.topology, pdb.positions)

    E = potential["Total"]
    refE = refpot["Total"]
    assert E/E.unit == pytest.approx(refE/refE.unit)

    E = potential["CustomBondForce"] + potential["NonbondedForce"]
    refE = refpot["NonbondedForce"]
    assert E/E.unit == pytest.approx(refE/refE.unit)
Beispiel #2
0
def executeFarForceTest(OuterForceType, adjustment):
    rswitch_inner = 6.5 * unit.angstroms
    rcut_inner = 7.0 * unit.angstroms
    rswitch = 9.5 * unit.angstroms
    rcut = 10 * unit.angstroms
    case = 'tests/data/q-SPC-FW'
    pdb = app.PDBFile(case + '.pdb')
    forcefield = app.ForceField(case + '.xml')

    system = forcefield.createSystem(pdb.topology,
                                     nonbondedMethod=openmm.app.PME)
    nbforce = atomsmm.hijackForce(system, atomsmm.findNonbondedForce(system))
    innerforce = atomsmm.NearNonbondedForce(rcut_inner, rswitch_inner,
                                            adjustment)
    innerforce.importFrom(nbforce).addTo(system)
    outerforce = OuterForceType(innerforce, rcut, rswitch).setForceGroup(2)
    outerforce.importFrom(nbforce).addTo(system)
    potential = atomsmm.splitPotentialEnergy(system, pdb.topology,
                                             pdb.positions)["Total"]

    refsys = forcefield.createSystem(pdb.topology,
                                     nonbondedMethod=openmm.app.PME,
                                     nonbondedCutoff=rcut,
                                     removeCMMotion=True)
    force = refsys.getForce(refsys.getNumForces() - 2)
    force.setUseSwitchingFunction(True)
    force.setSwitchingDistance(rswitch)
    refpot = atomsmm.splitPotentialEnergy(refsys, pdb.topology,
                                          pdb.positions)["Total"]

    assert potential / potential.unit == pytest.approx(refpot / refpot.unit)
Beispiel #3
0
def test_RESPASystem_with_exception_offsets():
    system, positions, topology, solute = readSystem(
        'hydroxyethylaminoanthraquinone-in-water')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    solvation_system = atomsmm.SolvationSystem(system, solute)
    nbforce = solvation_system.getForce(
        atomsmm.findNonbondedForce(solvation_system))
    for index in range(nbforce.getNumExceptions()):
        i, j, chargeprod, sigma, epsilon = nbforce.getExceptionParameters(
            index)
        nbforce.setExceptionParameters(index, i, j, 0.0, sigma, epsilon)
        nbforce.addExceptionParameterOffset('lambda_coul', index, chargeprod,
                                            0.0, 0.0)
    respa_system = atomsmm.RESPASystem(solvation_system, *respa_info.values())
    state = dict(lambda_vdw=0.5, lambda_coul=0.5)
    components = atomsmm.splitPotentialEnergy(respa_system, topology,
                                              positions, **state)
    potential = dict()
    potential['HarmonicBondForce'] = 1815.1848188179738
    potential['HarmonicAngleForce'] = 1111.5544374007236
    potential['PeriodicTorsionForce'] = 1.5998609986459567
    potential['Real-Space'] = 58201.09912379701
    potential['Reciprocal-Space'] = -76436.3982762784
    potential['CustomNonbondedForce'] = -64.67189605331785
    potential['CustomNonbondedForce(1)'] = -17294.836032921234
    potential['CustomNonbondedForce(2)'] = 17294.836032921194
    potential['CustomBondForce'] = 72.25414937535754
    potential['Total'] = -15299.377781942048
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #4
0
def test_AlchemicalRespaSystem_without_middle_scale():
    system, positions, topology, solute = readSystem('phenol-in-water')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    solvation_system = atomsmm.systems.AlchemicalRespaSystem(
        system,
        *respa_info.values(),
        solute,
        coupling_function='lambda^4*(5-4*lambda)',
        middle_scale=False,
    )
    state = {'lambda': 0.5}
    components = atomsmm.splitPotentialEnergy(solvation_system, topology,
                                              positions, **state)
    for item in components.items():
        print(*item)
    potential = {}
    potential['HarmonicBondForce'] = 2621.3223922886677  # kJ/mol
    potential['HarmonicAngleForce'] = 1525.1006876561419  # kJ/mol
    potential['PeriodicTorsionForce'] = 18.767576693568476  # kJ/mol
    potential['Real-Space'] = 80089.51116719692  # kJ/mol
    potential['Reciprocal-Space'] = -107038.52551657759  # kJ/mol
    potential['CustomBondForce'] = -53.526446723139806  # kJ/mol
    potential['CustomCVForce'] = -7.114065227572182  # kJ/mol
    potential['Total'] = -22844.464204692995  # kJ/mol
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #5
0
def test_AlchemicalRespaSystem():
    system, positions, topology, solute = readSystem('phenol-in-water')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    solvation_system = atomsmm.systems.AlchemicalRespaSystem(
        system,
        *respa_info.values(),
        solute,
        coupling_function='lambda^4*(5-4*lambda)',
    )
    state = {'lambda': 0.5, 'respa_switch': 1}
    components = atomsmm.splitPotentialEnergy(solvation_system, topology,
                                              positions, **state)
    for item in components.items():
        print(*item)
    potential = {}
    potential['HarmonicBondForce'] = 2621.3223922886677  # kJ/mol
    potential['HarmonicAngleForce'] = 1525.1006876561419  # kJ/mol
    potential['PeriodicTorsionForce'] = 18.767576693568476  # kJ/mol
    potential['Real-Space'] = 80089.51116719692  # kJ/mol
    potential['Reciprocal-Space'] = -107038.52551657759  # kJ/mol
    potential['CustomNonbondedForce'] = 5037.152491649265  # kJ/mol
    potential['CustomBondForce'] = -53.526446723139806  # kJ/mol
    potential['CustomBondForce(1)'] = -53.374675325650806  # kJ/mol
    potential['CustomCVForce'] = -7.114065227572182  # kJ/mol
    potential['CustomCVForce(1)'] = -6.301336948673654  # kJ/mol
    potential['Total'] = -17866.987725318053  # kJ/mol
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #6
0
def test_RESPASystem_with_special_bonds():
    system, positions, topology, solute = readSystem('q-SPC-FW')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    respa_system = atomsmm.RESPASystem(system, *respa_info.values())
    respa_system.redefine_bond(topology, 'HOH', 'H[1-2]', 'O',
                               1.05 * unit.angstroms)
    respa_system.redefine_angle(topology, 'HOH', 'H[1-2]', 'O', 'H[1-2]',
                                113 * unit.degrees)
    components = atomsmm.splitPotentialEnergy(respa_system, topology,
                                              positions)
    potential = dict()
    potential['HarmonicBondForce'] = 3665.684696323676
    potential['HarmonicAngleForce'] = 1811.197218501007
    potential['PeriodicTorsionForce'] = 0.0
    potential['Real-Space'] = 84694.39953220935
    potential['Reciprocal-Space'] = -111582.71281220087
    potential['CustomNonbondedForce'] = -25531.129587235544
    potential['CustomNonbondedForce(1)'] = 25531.129587235544
    potential['CustomBondForce'] = 0.0
    potential['CustomBondForce(1)'] = -1175.253817235862
    potential['CustomAngleForce'] = -305.0221912655623
    potential['Total'] = -22891.707373668243
    for term, value in components.items():
        print(term, value)
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #7
0
def test_SolvationSystem():
    system, positions, topology, solute = readSystem(
        'hydroxyethylaminoanthraquinone-in-water')
    solvation_system = atomsmm.SolvationSystem(system, solute)
    state = dict(lambda_vdw=0.5, lambda_coul=0.5)
    components = atomsmm.splitPotentialEnergy(solvation_system, topology,
                                              positions, **state)
    potential = dict()
    potential['HarmonicBondForce'] = 1815.1848188179738
    potential['HarmonicAngleForce'] = 1111.5544374007236
    potential['PeriodicTorsionForce'] = 1.5998609986459567
    potential['Real-Space'] = 58273.35327317236
    potential['Reciprocal-Space'] = -76436.3982762784
    potential['CustomNonbondedForce'] = -64.67189605331785
    potential['Total'] = -15299.377781942014
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #8
0
def test_SolvationSystem_with_lj_parameter_scaling():
    system, positions, topology, solute = readSystem(
        'hydroxyethylaminoanthraquinone-in-water')
    solvation_system = atomsmm.SolvationSystem(system,
                                               solute,
                                               use_softcore=False)
    state = dict(lambda_vdw=0.5, lambda_coul=0.5)
    components = atomsmm.splitPotentialEnergy(solvation_system, topology,
                                              positions, **state)
    potential = dict()
    potential['HarmonicBondForce'] = 1815.1848188179738
    potential['HarmonicAngleForce'] = 1111.5544374007236
    potential['PeriodicTorsionForce'] = 1.5998609986459567
    potential['Real-Space'] = 58235.03496195241
    potential['Reciprocal-Space'] = -76436.3982762784
    potential['Total'] = -15273.024197108643
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #9
0
def test_AlchemicalRespaSystem_with_softcore():
    system, positions, topology, solute = readSystem('phenol-in-water')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    solvation_system = atomsmm.systems.AlchemicalRespaSystem(
        system,
        *respa_info.values(),
        solute,
        use_softcore=True,
    )
    state = {'lambda': 0.5, 'respa_switch': 1}
    components = atomsmm.splitPotentialEnergy(solvation_system, topology,
                                              positions, **state)
    platform = openmm.Platform.getPlatformByName('Reference')
    context = openmm.Context(system, openmm.CustomIntegrator(0), platform)
    context.setPositions(positions)
    force = solvation_system.get_alchemical_vdw_force(
        [i / 5 for i in range(6)])
    values = force.getCollectiveVariableValues(
        context) * unit.kilojoules_per_mole
    for index in range(force.getNumCollectiveVariables()):
        name = force.getCollectiveVariableName(index)
        components[name] = values[index]
    for item in components.items():
        print(*item)
    potential = {}
    potential['HarmonicBondForce'] = 2621.3223922886677  # kJ/mol
    potential['HarmonicAngleForce'] = 1525.1006876561419  # kJ/mol
    potential['PeriodicTorsionForce'] = 18.767576693568476  # kJ/mol
    potential['Real-Space'] = 80089.51116719692  # kJ/mol
    potential['Reciprocal-Space'] = -107038.52551657759  # kJ/mol
    potential['CustomNonbondedForce'] = 5037.152491649265  # kJ/mol
    potential['CustomBondForce'] = -53.526446723139806  # kJ/mol
    potential['CustomBondForce(1)'] = -53.374675325650806  # kJ/mol
    potential['CustomNonbondedForce(1)'] = -24.140118811594814  # kJ/mol
    potential['CustomNonbondedForce(2)'] = -24.140118811594814  # kJ/mol
    potential['Total'] = -17901.852560765  # kJ/mol
    potential['E0'] = 0.0  # kJ/mol
    potential['E1'] = -10.071581499620784  # kJ/mol
    potential['E2'] = -19.66450283710424  # kJ/mol
    potential['E3'] = -28.284595753200428  # kJ/mol
    potential['E4'] = -35.004158250494505  # kJ/mol
    potential['E5'] = -37.9416812137183  # kJ/mol
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #10
0
def test_AlchemicalRespaSystem_with_coulomb_scaling():
    system, positions, topology, solute = readSystem('phenol-in-water')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    solvation_system = atomsmm.systems.AlchemicalRespaSystem(
        system,
        *respa_info.values(),
        solute,
        coupling_function='lambda^4*(5-4*lambda)',
        coulomb_scaling=True,
        lambda_coul=0.5,
        # middle_scale=True,
    )
    state = {'lambda': 0.5, 'respa_switch': 1}
    components = atomsmm.splitPotentialEnergy(solvation_system, topology,
                                              positions, **state)
    integrator = openmm.CustomIntegrator(0)
    platform = openmm.Platform.getPlatformByName('Reference')
    simulation = openmm.app.Simulation(topology, solvation_system, integrator,
                                       platform)
    simulation.context.setPositions(positions)
    force = solvation_system.get_alchemical_coul_force()
    Ecoul = force.getCollectiveVariableValues(simulation.context)
    components['Ecoul'] = Ecoul[0] * unit.kilojoule_per_mole
    for item in components.items():
        print(*item)
    potential = {}
    potential['HarmonicBondForce'] = 2621.3223922886677  # kJ/mol
    potential['HarmonicAngleForce'] = 1525.1006876561419  # kJ/mol
    potential['PeriodicTorsionForce'] = 18.767576693568476  # kJ/mol
    potential['Real-Space'] = 80078.91697014398  # kJ/mol
    potential['Reciprocal-Space'] = -107074.49398119976  # kJ/mol
    potential['CustomNonbondedForce'] = 5037.152491649265  # kJ/mol
    potential['CustomBondForce'] = -53.526446723139806  # kJ/mol
    potential['CustomBondForce(1)'] = -53.374675325650806  # kJ/mol
    potential['CustomNonbondedForce(1)'] = -23.447733015522058  # kJ/mol
    potential['CustomCVForce'] = -7.114065227572182  # kJ/mol
    potential['CustomCVForce(1)'] = -6.301336948673654  # kJ/mol
    potential['Total'] = -17936.998120008684  # kJ/mol
    potential['Ecoul'] = -93.14060537915793  # kJ/mol
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #11
0
def test_RESPASystem():
    system, positions, topology, solute = readSystem(
        'hydroxyethylaminoanthraquinone-in-water')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    solvation_system = atomsmm.SolvationSystem(system, solute)
    respa_system = atomsmm.RESPASystem(solvation_system, *respa_info.values())
    state = dict(lambda_vdw=0.5, lambda_coul=0.5)
    components = atomsmm.splitPotentialEnergy(respa_system, topology,
                                              positions, **state)
    potential = dict()
    potential['HarmonicBondForce'] = 1815.1848188179738
    potential['HarmonicAngleForce'] = 1111.5544374007236
    potential['PeriodicTorsionForce'] = 1.5998609986459567
    potential['Real-Space'] = 58161.10011792888
    potential['Reciprocal-Space'] = -76436.3982762784
    potential['CustomNonbondedForce'] = -64.67189605331785
    potential['CustomNonbondedForce(1)'] = -17294.836032921234
    potential['CustomNonbondedForce(2)'] = 17294.836032921194
    potential['CustomBondForce'] = 112.25315524350334
    potential['Total'] = -15299.377781942032
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #12
0
def test_RESPASystem_with_lj_parameter_scaling():
    system, positions, topology, solute = readSystem(
        'hydroxyethylaminoanthraquinone-in-water')
    respa_info = dict(rcutIn=7 * unit.angstroms, rswitchIn=5 * unit.angstroms)
    solvation_system = atomsmm.SolvationSystem(system,
                                               solute,
                                               use_softcore=False)
    respa_system = atomsmm.RESPASystem(solvation_system, *respa_info.values())
    state = dict(lambda_vdw=0.5, lambda_coul=0.5)
    components = atomsmm.splitPotentialEnergy(respa_system, topology,
                                              positions, **state)
    potential = dict()
    potential['HarmonicBondForce'] = 1815.1848188179738
    potential['HarmonicAngleForce'] = 1111.5544374007236
    potential['PeriodicTorsionForce'] = 1.5998609986459567
    potential['Real-Space'] = 58122.78180670893
    potential['Reciprocal-Space'] = -76436.3982762784
    potential['CustomNonbondedForce'] = -17317.054135213173
    potential['CustomNonbondedForce(1)'] = 17317.054135213126
    potential['CustomBondForce'] = 112.25315524350334
    potential['Total'] = -15273.024197108669
    for term, value in components.items():
        assert value / value.unit == pytest.approx(potential[term])
Beispiel #13
0
    def _minimizeOverlaps(self, platform, membrane):

        hydrogen_mass = 3 * unit.amu
        system = self.structure.createSystem(nonbondedMethod=app.PME,
                                             nonbondedCutoff=1 *
                                             unit.nanometer,
                                             rigidWater=True,
                                             flexibleConstraints=False,
                                             constraints=app.HBonds,
                                             hydrogenMass=hydrogen_mass,
                                             removeCMMotion=False)
        backup_system = deepcopy(system)

        for index in self.atom_to_freeze:
            system.setParticleMass(int(index), 0.0 * unit.dalton)
        integrator = mm.LangevinIntegrator(300 * unit.kelvin,
                                           1.0 / unit.picoseconds,
                                           2 * unit.femtosecond)
        simulation = app.Simulation(self.structure.topology, system,
                                    integrator, platform)
        simulation.context.setPositions(self.structure.positions)
        simulation.minimizeEnergy(tolerance=0.1 * unit.kilojoule / unit.mole,
                                  maxIterations=0)
        positions = simulation.context.getState(
            getPositions=True).getPositions()
        min_potential = atomsmm.splitPotentialEnergy(system,
                                                     self.structure.topology,
                                                     positions)
        for key, value in min_potential.items():
            self.logger.debug(key, value)
        simulation.saveCheckpoint('porinMembraneSystem.chk')
        integrator = mm.LangevinIntegrator(300 * unit.kelvin,
                                           1.0 / unit.picoseconds,
                                           2 * unit.femtosecond)
        simulation = app.Simulation(self.structure.topology, backup_system,
                                    integrator, platform)
        simulation.context.setPositions(positions)
        simulation.context.setVelocitiesToTemperature(300 * unit.kelvin)
        simulation.reporters.append(
            app.StateDataReporter(
                'relax-ligand-system.log',
                100,
                step=True,
                temperature=True,
                potentialEnergy=True,
                totalEnergy=True,
                speed=True,
            ))
        topology = md.Topology.from_openmm(self.structure.topology)
        atom_indices = topology.select('(protein and not resname  ' +
                                       membrane + ')' + ' or resname ' +
                                       self.lig_name)
        simulation.reporters.append(
            NetCDFReporter('relax-ligand-system.nc',
                           100,
                           atomSubset=atom_indices))

        simulation.step(100000)
        positions = simulation.context.getState(
            getPositions=True).getPositions()
        PDBxFile.writeFile(self.structure.topology, positions,
                           open("atomistic-system-combined.pdbx", 'w'))
Beispiel #14
0
simulation = app.Simulation(modeller.topology, system, integrator, platform)
simulation.context.setPositions(modeller.positions)
simulation.context.setVelocitiesToTemperature(300 * unit.kelvin)
# Minimize the system after adding hydrogens to the membrane
tolerance = 0.1 * unit.kilojoules_per_mole / unit.angstroms
simulation.minimizeEnergy(tolerance=tolerance, maxIterations=0)
simulation.reporters.append(
    app.StateDataReporter('relax-hydrogens.log',
                          1000,
                          step=True,
                          temperature=True,
                          potentialEnergy=True,
                          totalEnergy=True,
                          speed=True))
simulation.step(10000)
positions = simulation.context.getState(getPositions=True).getPositions()
min_potential = atomsmm.splitPotentialEnergy(system, modeller.topology,
                                             positions)
for key, value in min_potential.items():
    logger.debug(key, value)
logger.debug(modeller.topology)
simulation.saveCheckpoint('state.chk')
#del simulation.context, integrator
# rigidWater = False is necessary because water parameters are required by Parmed
# when loading the ligand
#system = forcefield.createSystem(modeller.topology,
#                                 nonbondedMethod=app.PME,
#                                 rigidWater=False,
#                                 nonbondedCutoff=1*unit.nanometer)
#ligand_atomistic_system = PorinMembraneSystem('comp7', system, modeller.topology, positions, platform, membrane = 'DPPC')