Exemple #1
0
    def setup_viologen_implicit():
        """
        Set up viologen in implicit solvent
        """
        viologen = SystemSetup()
        viologen.temperature = 300.0 * unit.kelvin
        viologen.pressure = 1.0 * unit.atmospheres
        viologen.timestep = 1.0 * unit.femtoseconds
        viologen.collision_rate = 1.0 / unit.picoseconds
        viologen.pH = 7.0
        testsystems = get_test_data("viologen", "testsystems")
        viologen.ffxml_files = os.path.join(testsystems,
                                            "viologen-protons.ffxml")
        viologen.gaff = os.path.join(testsystems, "gaff.xml")
        viologen.forcefield = ForceField(viologen.gaff, "gaff-obc2.xml",
                                         viologen.ffxml_files)

        viologen.pdbfile = app.PDBFile(
            os.path.join(testsystems, "viologen-vacuum.pdb"))
        viologen.topology = viologen.pdbfile.topology
        viologen.positions = viologen.pdbfile.getPositions(asNumpy=True)
        viologen.constraint_tolerance = 1.0e-7

        viologen.integrator = openmm.LangevinIntegrator(
            viologen.temperature, viologen.collision_rate, viologen.timestep)

        viologen.integrator.setConstraintTolerance(
            viologen.constraint_tolerance)
        viologen.system = viologen.forcefield.createSystem(
            viologen.topology,
            nonbondedMethod=app.NoCutoff,
            constraints=app.HBonds)
        viologen.cooh1 = {  # indices in topology of the first cooh group
            "HO": 56,
            "OH": 0,
            "CO": 1,
            "OC": 2,
            "R": 3,
        }
        viologen.cooh2 = {  # indices in topology of the second cooh group
            "HO": 57,
            "OH": 27,
            "CO": 25,
            "OC": 26,
            "R": 24,
        }

        viologen.simulation = app.Simulation(
            viologen.topology,
            viologen.system,
            viologen.integrator,
            TestCarboxylicAcid.platform,
        )
        viologen.simulation.context.setPositions(viologen.positions)
        viologen.context = viologen.simulation.context
        viologen.perturbations_per_trial = 10
        viologen.propagations_per_step = 1

        return viologen
Exemple #2
0
    def setup_amino_acid_water(three_letter_code):
        """
        Set up glutamic acid in water
        """
        if three_letter_code not in ["glh", "ash"]:
            raise ValueError("Amino acid not available.")

        aa = SystemSetup()
        aa.temperature = 300.0 * unit.kelvin
        aa.pressure = 1.0 * unit.atmospheres
        aa.timestep = 1.0 * unit.femtoseconds
        aa.collision_rate = 1.0 / unit.picoseconds
        aa.pH = 7.0
        testsystems = get_test_data("amino_acid", "testsystems")
        aa.ffxml_files = "amber10-constph.xml"
        aa.forcefield = ForceField(aa.ffxml_files, "tip3p.xml")

        aa.pdbfile = app.PDBFile(
            os.path.join(testsystems, "{}.pdb".format(three_letter_code)))
        aa.topology = aa.pdbfile.topology
        aa.positions = aa.pdbfile.getPositions(asNumpy=True)
        aa.constraint_tolerance = 1.0e-7

        aa.integrator = create_compound_gbaoab_integrator(aa)

        aa.integrator.setConstraintTolerance(aa.constraint_tolerance)
        aa.system = aa.forcefield.createSystem(
            aa.topology,
            nonbondedMethod=app.PME,
            nonbondedCutoff=1.0 * unit.nanometers,
            constraints=app.HBonds,
            rigidWater=True,
            ewaldErrorTolerance=0.0005,
        )
        aa.system.addForce(
            openmm.MonteCarloBarostat(aa.pressure, aa.temperature, 25))

        aa.simulation = app.Simulation(aa.topology, aa.system, aa.integrator,
                                       TestCarboxylicAcid.platform)
        aa.simulation.context.setPositions(aa.positions)
        aa.context = aa.simulation.context
        aa.perturbations_per_trial = 1000
        aa.propagations_per_step = 1

        return aa
Exemple #3
0
pdb = app.PDBFile('2HYY-noH.pdb')

modeller = app.Modeller(pdb.topology, pdb.positions)

# The pdb contains solvent but not the right ions.
# This would mean we need to equilibrate again even if we just add new ions.
# In this case its easiest to just delete and re-add the solvent with the right amount of ions

modeller.deleteWater()
ions = [ atom for atom in modeller.topology.atoms() if atom.element.symbol in ['Cl', 'Na'] ]
modeller.delete(ions)


modeller.addHydrogens(forcefield=forcefield)
modeller.addSolvent(forcefield, model='tip3p', padding=1.0*nanometers, positiveIon='Na+', negativeIon='Cl-', ionicStrength=120*millimolar, neutralize=True)

system = forcefield.createSystem(modeller.topology, nonbondedMethod=app.PME, nonbondedCutoff=1.0 * nanometers,
                                 constraints=app.HBonds, rigidWater=True,
                                 ewaldErrorTolerance=0.0005)
system.addForce(openmm.MonteCarloBarostat(1.0 * atmosphere, 300.0 * kelvin))
simulation = app.Simulation(modeller.topology, system, GBAOABIntegrator() )
simulation.context.setPositions(modeller.positions)
rename_res = {"HIS": "HIP", "ASP":"AS4", "GLU":"GL4"}
for resi in modeller.topology.residues():
    if resi.name in rename_res:
        resi.name = rename_res[resi.name]

app.PDBFile.writeFile(modeller.topology, simulation.context.getState(getPositions=True).getPositions(),
                       open('2HYY-H.pdb', 'w'))

Exemple #4
0
    def setup_viologen_water():
        """
        Set up viologen in water
        """
        viologen = SystemSetup()
        viologen.temperature = 300.0 * unit.kelvin
        viologen.pressure = 1.0 * unit.atmospheres
        viologen.timestep = 1.0 * unit.femtoseconds
        viologen.collision_rate = 1.0 / unit.picoseconds
        viologen.pH = 7.0
        testsystems = get_test_data("viologen", "testsystems")
        viologen.ffxml_files = os.path.join(testsystems,
                                            "viologen-protons-cooh.ffxml")
        viologen.gaff = os.path.join(testsystems, "gaff.xml")
        viologen.forcefield = ForceField(viologen.gaff, viologen.ffxml_files,
                                         "tip3p.xml")

        viologen.pdbfile = app.PDBFile(
            os.path.join(testsystems, "viologen-solvated.pdb"))
        viologen.topology = viologen.pdbfile.topology
        viologen.positions = viologen.pdbfile.getPositions(asNumpy=True)
        viologen.constraint_tolerance = 1.0e-7

        viologen.integrator = create_compound_gbaoab_integrator(viologen)

        viologen.integrator.setConstraintTolerance(
            viologen.constraint_tolerance)
        viologen.system = viologen.forcefield.createSystem(
            viologen.topology,
            nonbondedMethod=app.PME,
            nonbondedCutoff=1.0 * unit.nanometers,
            constraints=app.HBonds,
            rigidWater=True,
            ewaldErrorTolerance=0.0005,
        )
        viologen.system.addForce(
            openmm.MonteCarloBarostat(viologen.pressure, viologen.temperature,
                                      25))
        viologen.cooh1 = {  # indices in topology of the first cooh group
            "HO": 56,
            "OH": 1,
            "CO": 0,
            "OC": 2,
            "R": 3,
        }
        viologen.cooh2 = {  # indices in topology of the second cooh group
            "HO": 57,
            "OH": 27,
            "CO": 25,
            "OC": 26,
            "R": 24,
        }

        viologen.simulation = app.Simulation(
            viologen.topology,
            viologen.system,
            viologen.integrator,
            TestCarboxylicAcid.platform,
        )
        viologen.simulation.context.setPositions(viologen.positions)
        viologen.context = viologen.simulation.context
        viologen.perturbations_per_trial = 1000
        viologen.propagations_per_step = 1

        return viologen