-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add writer_kwargs to MDAReporter and speed up testing (#9)
* Add code for serializing simulation. (cherry picked from commit 5e1584c) * Add serialized XML files for integrator, system, and state. (cherry picked from commit 17b11e1) * Move villin.pdb to sit alongside other serialized simulation files. (cherry picked from commit 44f4304) * Add a writer_kwargs argument to MDAReporter. (cherry picked from commit b3032d6) * Update Changelog. (cherry picked from commit 9c7e1a8) * Update tests to use a serialized simulation, this makes it so we don't have to reinstantiate the simulation with each test and SIGNIFICANTLY speeds up the test suite. * Update changelog * Better document test data creation. * Correct outputs for describeNextReport and add testing.
- Loading branch information
1 parent
d665b3d
commit d2d1b1d
Showing
10 changed files
with
59,014 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This directory contains a serialized simulation for use in testing. | ||
|
||
The `integrator.xml`, `state.xml`, and `system.xml` here were generated by serialize_simulation.py. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" ?> | ||
<Integrator constraintTolerance="1e-05" friction="1" randomSeed="0" stepSize=".004" temperature="300" type="LangevinMiddleIntegrator" version="1"/> |
39 changes: 39 additions & 0 deletions
39
mdareporter/data/villin_simulation/serialize_simulation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from openmm.app import ForceField, Simulation, PME, HBonds | ||
from openmm import LangevinMiddleIntegrator | ||
from openmm.unit import nanometer, picosecond, kelvin | ||
|
||
from openmm.app import PDBFile, Topology | ||
from openmm.openmm import XmlSerializer | ||
from mdareporter.data.files import VILLIN_PDB | ||
|
||
|
||
pdb = PDBFile(VILLIN_PDB) | ||
|
||
forcefield = ForceField("amber14-all.xml", "amber14/tip3pfb.xml") | ||
system = forcefield.createSystem( | ||
pdb.topology, nonbondedMethod=PME, nonbondedCutoff=1 * nanometer, constraints=HBonds | ||
) | ||
integrator = LangevinMiddleIntegrator(300 * kelvin, 1 / picosecond, 0.004 * picosecond) | ||
simulation = Simulation(pdb.topology, system, integrator) | ||
simulation.context.setPositions(pdb.positions) | ||
simulation.minimizeEnergy() | ||
|
||
|
||
pdb.writeFile( | ||
simulation.topology, | ||
simulation.context.getState(getPositions=True).getPositions(), | ||
open("output.pdb", "w"), | ||
) | ||
system_xml = XmlSerializer.serialize(system) | ||
integrator_xml = XmlSerializer.serialize(integrator) | ||
state_xml = XmlSerializer.serialize( | ||
simulation.context.getState(getPositions=True, getVelocities=True) | ||
) | ||
|
||
# write to files | ||
with open("system.xml", "w") as f: | ||
f.write(system_xml) | ||
with open("integrator.xml", "w") as f: | ||
f.write(integrator_xml) | ||
with open("state.xml", "w") as f: | ||
f.write(state_xml) |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.