wepy.util.mdtraj module¶
Utilities for converting formats used in wepy to mdtraj objects.
Requires mdtraj be installed.
-
wepy.util.mdtraj.
mdtraj_to_json_topology
(mdj_top)[source]¶ Generate a JSON string topology from an mdtraj.Topology object.
This is the primary way in which JSON toplogies can be generated.
This format was created for use in the HDF5 format generated by the mdtraj library.
- Parameters
mdj_top (mdtraj.Topology object) – The topology you want to serialize to a JSON string.
- Returns
json_top – JSON string of the topology.
- Return type
Warning
The topology format for wepy is subject to change in the future!
Notes
Copied in part from MDTraj.formats.hdf5.topology setter.
-
wepy.util.mdtraj.
json_to_mdtraj_topology
(json_string)[source]¶ Convert a JSON string topology to an mdtraj.Toplogy object.
This can be used to write out different topology formats from mdtraj.
- Parameters
json_string (str) – JSON string of the topology.
- Returns
topology
- Return type
mdtraj.Topology object
Warning
The topology format for wepy is subject to change in the future!
Notes
Copied in part from MDTraj.formats.hdf5 topology property.
-
wepy.util.mdtraj.
_new_json_to_mdtraj_topology
(json_string)[source]¶ Another implementation of converting JSON to mdtraj.
TODO what is the difference between this and the other one?
- Parameters
json_string (str) – JSON string of the topology.
- Returns
topology
- Return type
mdtraj.Topology object
-
wepy.util.mdtraj.
traj_fields_to_mdtraj
(traj_fields, json_topology, rep_key='positions')[source]¶ Create an mdtraj.Trajectory object directly from a dictionary of fields values.
The time value in the trajectory will just be the frame indices for the positions.
- Parameters
traj_fields (dict of str: values) – The values for the trajectory, must have a positions field specified by the rep_key kwarg, and a ‘box_vectors’ field.
json_topology (str) – JSON format topology of the positions.
rep_key (str) – The key that will be used to access the field that will be used as the positions in the trajectory, and must match the topology.