nanover.openmm.serializer module
Serialize and deserialize OpenMM simulations to and from XML files.
A simulation is described as the concatenation of a starting structure as a PDB file, an OpenMM serialized system, an OpenMM serialized integrator, and, optionally, an OpenMM serialized state. The resulting XML file looks like:
<OpenMMSimulation>
<pdbx>
// pasted content of the PDBx file
</pdbx>
<System ...>
// XML content of the OpenMM serialized system
</System>
<Integrator ...>
// XML content of the OpenMM serialized integrator
</Integrator>
<State>
// XML content of the OpenMM serialized state
</State>
</OpenMMSimulation>
The System
, Integrator
and State
tags are the roots of the serialized
system, integrator and state, respectively. The pdbx
tag can be replaced by a
pdb
one for backward compatibility.
This module provides a function serialize_simulation()
that generates an
XML file from an existing instance of openmm.app.Simulation
, and
a function deserialize_simulation()
that creates an instance of simulation
from an XML file.
- nanover.openmm.serializer.deserialize_simulation(xml_content: str | TextIO, imd_force: CustomExternalForce | None = None, platform_name: str | None = None, ignore_state=False) Simulation
Create an OpenMM simulation from XML.
- Parameters:
xml_content – The content of an XML file as a string.
imd_force – Optionally, an imd force to populate and add to the system. The force must be created by
nanover.openmm.potentials.create_imd_force()
.ignore_state – Ignore serialized state when present
- Returns:
An instance of the simulation.
- nanover.openmm.serializer.serialize_simulation(simulation: Simulation, save_state=False) str
Generate an XML string from a simulation.
- Parameters:
simulation – The simulation to serialize.
save_state – Save the present state of the simulation too.
- Returns:
A string with the content of an XML file describing the simulation.