-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsimulateProtein.py
25 lines (20 loc) · 935 Bytes
/
simulateProtein.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from openmmforcefields.generators import SystemGenerator
from openmm import unit
from openmm.app import PDBFile, Simulation
from openmm import *
protein_pdb = PDBFile('protein.pdb')
print('Preparing system')
# Initialize a SystemGenerator
system_generator = SystemGenerator(forcefields=['amber/ff14SB.xml'])
system = system_generator.create_system(protein_pdb.topology)
integrator = LangevinIntegrator(300 * unit.kelvin, 1 / unit.picosecond, 0.002 * unit.picoseconds)
simulation = Simulation(protein_pdb.topology, system, integrator)
simulation.context.setPositions(protein_pdb.positions)
print('Minimising')
simulation.minimizeEnergy()
# write out the minimised PDB
with open('minimised1.pdb', 'w') as outfile:
PDBFile.writeFile(protein_pdb.topology,
simulation.context.getState(getPositions=True, enforcePeriodicBox=True).getPositions(),
file=outfile, keepIds=True)
print('Done')