narupa.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>
</OpenMMSimulation>
The System
and Integrator
tags are the roots of the serialized system
and integrator, 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 simtk.openmm.app.Simulation
, and
a function deserialize_simulation()
that creates an instance of simulation
from an XML file.
-
narupa.openmm.serializer.
deserialize_simulation
(xml_content: str, imd_force: Optional[pretends.CustomExternalForce] = None) → pretends.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
narupa.openmm.potentials.create_imd_force()
.
Returns: An instance of the simulation.
-
narupa.openmm.serializer.
serialize_simulation
(simulation: pretends.Simulation) → str¶ Generate an XML string from a simulation.
Parameters: simulation – The simulation to serialize. Returns: A string with the content of an XML file describing the simulation.