Ejemplo n.º 1
0
def test_packmol_simulation_ternary():
    smiles_list = ["Cc1ccccc1", "c1ccccc1", "CC"]
    pdb_filenames = []
    ligand_trajectories, ffxml = utils.smiles_to_mdtraj_ffxml(smiles_list)

    for k, ligand_traj in enumerate(ligand_trajectories):
        pdb_filename = tempfile.mktemp(suffix=".pdb")
        ligand_traj.save(pdb_filename)
        pdb_filenames.append(pdb_filename)

    trj = packmol.pack_box(pdb_filenames, [6, 11, 23])

    xyz = trj.openmm_positions(0)
    top = trj.top.to_openmm()
    top.setUnitCellDimensions(mm.Vec3(*trj.unitcell_lengths[0]) * u.nanometer)

    forcefield = app.ForceField(ffxml)

    temperature = 300 * u.kelvin
    friction = 0.1 / u.picosecond
    timestep = 0.1 * u.femtosecond

    system = forcefield.createSystem(top, nonbondedMethod=app.PME, nonbondedCutoff=1.0 * u.nanometers, constraints=None)

    integrator = mm.LangevinIntegrator(temperature, friction, timestep)

    simulation = app.Simulation(top, system, integrator)
    simulation.context.setPositions(xyz)

    simulation.step(25)
Ejemplo n.º 2
0
def test_smiles_conversion():
    pdb_filename = utils.get_data_filename("chemicals/proteins/1vii.pdb")
    smiles = "Cc1ccccc1"  # Also known as toluene.

    temperature = 300 * u.kelvin
    friction = 0.3 / u.picosecond
    timestep = 0.01 * u.femtosecond

    protein_traj = md.load(pdb_filename)
    protein_traj.center_coordinates()

    protein_top = protein_traj.top.to_openmm()
    protein_xyz = protein_traj.openmm_positions(0)

    ligand_trajectories, ffxml = utils.smiles_to_mdtraj_ffxml([smiles])
    ligand_traj = ligand_trajectories[0]
    ligand_traj.center_coordinates()

    eq(ligand_traj.n_atoms, 15)
    eq(ligand_traj.n_frames, 1)

    # Move the pre-centered ligand sufficiently far away from the protein to avoid a clash.
    min_atom_pair_distance = (
        ((ligand_traj.xyz[0] ** 2.0).sum(1) ** 0.5).max() + ((protein_traj.xyz[0] ** 2.0).sum(1) ** 0.5).max() + 0.3
    )
    ligand_traj.xyz += np.array([1.0, 0.0, 0.0]) * min_atom_pair_distance

    ligand_xyz = ligand_traj.openmm_positions(0)
    ligand_top = ligand_traj.top.to_openmm()

    forcefield = app.ForceField("amber10.xml", ffxml, "tip3p.xml")

    model = app.modeller.Modeller(protein_top, protein_xyz)
    model.add(ligand_top, ligand_xyz)
    model.addSolvent(forcefield, padding=0.4 * u.nanometer)

    system = forcefield.createSystem(
        model.topology, nonbondedMethod=app.PME, nonbondedCutoff=1.0 * u.nanometers, constraints=app.HAngles
    )

    integrator = mm.LangevinIntegrator(temperature, friction, timestep)

    simulation = app.Simulation(model.topology, system, integrator)
    simulation.context.setPositions(model.positions)
    print("running")
    simulation.step(1)