polychrom.polymerutils module
Loading and saving individual conformations
The module polychrom.polymerutils provides tools for saving and loading individual conformations. Note that
saving and loading trajectories should generally be done using polychrom.hdf5_format module. This module
provides tools for loading/saving invividual conformations, or for working with projects that have both old-style
and new-style trajectories.
For projects using both old-style and new-style trajectories(e.g. in a project that was switched to polychrom,
and new files were added), a function polychrom.polymerutils.fetch_block() can be helpful as it provides the
same interface for fetching a conformation from both old-style and new-style trajectory. Note however that it is not
the fastest way to iterate over conformations in the new-style trajectory, and the
polychrom.hdf5_format.list_URIs() is faster.
A typical workflow with the new-style trajectories should be:
URIs = polychrom.hdf5_format.list_URIs(folder)
for URI in URIs:
data = polychrom.hdf5_format.load_URI(URI)
xyz = data["pos"]
- polychrom.polymerutils.fetch_block(folder, ind, full_output=False)[source]
A function to fetch a single block from a folder with a new-style trajectory. Old-style trajectories are deprecated.
- Parameters:
folder (str, folder with a trajectory)
ind (str or int, number of a block to fetch)
full_output (bool (default=False)) – If set to true, outputs a dict with positions, eP, eK, time etc. if False, outputs just the conformation (relevant only for new-style URIs, so default is False)
- Returns:
data, Nx3 numpy array
if full_output==True, then dict with data and metadata; XYZ is under key “pos”