Beispiel #1
0
    forcefield_kwargs=forcefield_kwargs)

# Use Modeller to combine the protein and ligand into a complex
print('Reading protein')
protein_pdb = PDBFile(pdb_in)

print('Preparing complex')
modeller = Modeller(protein_pdb.topology, protein_pdb.positions)
print('System has %d atoms' % modeller.topology.getNumAtoms())

# This next bit is black magic.
# Modeller needs topology and positions. Lots of trial and error found that this is what works to get these from
# an openforcefield Molecule object that was created from a RDKit molecule.
# The topology part is described in the openforcefield API but the positions part grabs the first (and only)
# conformer and passes it to Modeller. It works. Don't ask why!
modeller.add(ligand_mol.to_topology().to_openmm(), ligand_mol.conformers[0])

print('System has %d atoms' % modeller.topology.getNumAtoms())

# Solvate
print('Adding solvent...')
# we use the 'padding' option to define the periodic box. The PDB file does not contain any
# unit cell information so we just create a box that has a 10A padding around the complex.
modeller.addSolvent(system_generator.forcefield,
                    model='tip3p',
                    padding=10.0 * unit.angstroms)
print('System has %d atoms' % modeller.topology.getNumAtoms())

with open(output_complex, 'w') as outfile:
    PDBFile.writeFile(modeller.topology, modeller.positions, outfile)
def calculate_protein_energetics():
    """
    * Create an OpenMM system using the first fragment.
    * Add each fragment into the system.
    * Calculate the energy of the system and print.
    """

    os.chdir('group2')
    # Necessary due to size of calculation
    sys.setrecursionlimit(15000)

    frag1 = PDBFile('frag1/no_QUP_frag1.pdb')
    forcefield = ForceField(
        'frag1/QUBE_pro_frag1.xml',
        'frag2/QUBE_pro_frag2_plus.xml',
        'frag3/QUBE_pro_frag3_plus.xml',
        'frag4/QUBE_pro_frag4_plus.xml',
    )

    modeller = Modeller(frag1.topology, frag1.positions)

    frag2 = PDBFile('frag2/no_QUP_frag2.pdb')
    modeller.add(frag2.topology, frag2.positions)

    frag3 = PDBFile('frag3/no_QUP_frag3.pdb')
    modeller.add(frag3.topology, frag3.positions)

    frag4 = PDBFile('frag4/no_QUP_frag4.pdb')
    modeller.add(frag4.topology, frag4.positions)

    system = forcefield.createSystem(
        modeller.topology,
        nonbondedMethod=NoCutoff,
    )

    system = apply_opls_combo(system)

    integrator = LangevinIntegrator(
        298.15 * unit.kelvin,  # Temperature of heat bath
        1.0 / unit.picoseconds,  # Friction coefficient
        2.0 * unit.femtoseconds,  # Time step
    )

    platform = Platform.getPlatformByName('CPU')
    simulation = Simulation(modeller.topology, system, integrator, platform)
    simulation.context.setPositions(modeller.positions)
    print('energy from openmm library')
    print(simulation.context.getState(getEnergy=True).getPotentialEnergy())

    positions = simulation.context.getState(getPositions=True).getPositions()

    with open('output.pdb', 'w') as out_file:
        PDBFile.writeFile(simulation.topology, positions, out_file)

    structure = parmed.load_file('output.pdb')
    energy_comps = parmed.openmm.energy_decomposition_system(structure, system)

    total_energy = 0.0
    for comp in energy_comps:
        total_energy += comp[1]
        print(*comp)

    print(f'Total energy {total_energy: 6.6f}')
print(ligand_mol)
# can't read as PDB as "No toolkits in registry can read file"
#complex_pdb = Molecule(open('complex1.pdb', 'rb'), file_format='pdb')

# Use Modeller to combine the protein and ligand into a complex
print('Reading protein')
protein_pdb = PDBFile('protein.pdb')

# reading the ligand gives lots of warnings about "duplicate atom" but this seems incorrect
print('Reading ligand')
ligand_pdb = PDBFile('ligand1.pdb')

print('Preparing complex')
# Approach 1
modeller = Modeller(protein_pdb.topology, protein_pdb.positions)
modeller.add(ligand_pdb.topology, ligand_pdb.positions)
PDBFile.writeFile(modeller.topology, modeller.positions,
                  open('complex1.pdb', 'w'))

# Approach 2
# protein_pdb = parmed.load_file('protein.pdb')
# ligand_pdb = parmed.load_file('ligand1.pdb')
# complex = protein_pdb + ligand_pdb
# complex.save('complex1.pdb')

complex_pdb = PDBFile('complex1.pdb')

print('Preparing system')
forcefield_kwargs = {
    'constraints': app.HBonds,
    'rigidWater': True,
Beispiel #4
0
# Use Modeller to combine the protein and ligand into a complex
print('Reading protein')
protein_pdb = PDBFile(opt.receptor)

print('Preparing complex')
modeller = Modeller(protein_pdb.topology, protein_pdb.positions)
print('System has %d atoms' % modeller.topology.getNumAtoms())

# This next bit is black magic.
# Modeller needs topology and positions. Lots of trial and error found that this is what works to get these from
# an openforcefield Molecule object that was created from a RDKit molecule.
# The topology part is described in the openforcefield API but the positions part grabs the first (and only)
# conformer and passes it to Modeller. It works. Don't ask why!
if len(other_mols) != 0:
    for other_mol in other_mols:
        modeller.add(other_mol.to_topology().to_openmm(),
                     other_mol.conformers[0])
    #modeller.add(ligand_mol.to_topology().to_openmm(), ligand_mol.conformers[0])

# Generate ligand with solvent for FEP
if opt.ligand:
    modeller_org = Modeller(ligand_mol.to_topology().to_openmm(),
                            ligand_mol.conformers[0])
    modeller_org.addSolvent(system_generator.forcefield,
                            model='tip3p',
                            ionicStrength=0.1 * unit.molar,
                            padding=10.0 * unit.angstroms)
    system_org = system_generator.create_system(modeller_org.topology,
                                                molecules=ligand_mol)
    system_org.addForce(
        openmm.MonteCarloBarostat(1 * unit.atmospheres, opt.temp * unit.kelvin,
                                  25))