openmmtools.multistate.MultiStateReporter¶
- class openmmtools.multistate.MultiStateReporter(storage, open_mode=None, checkpoint_interval=50, checkpoint_storage=None, analysis_particle_indices=())[source]¶
Handle storage write/read operations and different format conventions.
You can use this object to programmatically inspect the data generated by ReplicaExchange.
- Parameters:
- storagestr
The path to the storage file for analysis.
A second checkpoint file will be determined from either
checkpoint_storage
or automatically based on the storage optionIn the future this will be able to take Storage classes as well.
- open_modestr or None
The mode of the file between ‘r’, ‘w’, and ‘a’ (or equivalently ‘r+’).
If None, the storage file won’t be open on construction, and a call to
Reporter.open()
will be needed before attempting read/write operations.- checkpoint_intervalint >= 1, Default: 50
The frequency at which checkpointing information is written relative to analysis information.
This is a multiple of the iteration at which energies is written, hence why it must be greater than or equal to 1. Checkpoint information cannot be written on iterations which where
iteration % checkpoint_interval != 0
.- checkpoint_storagestr or None, optional
Optional name of the checkpoint point file. This file is used to save trajectory information and other less frequently accessed data.
This should NOT be a full path, and instead just a filename
If None: the derived checkpoint name is the same as storage, less any extension, then “_checkpoint.nc” is added.
The reporter internally tracks what data goes into which file, so its transparent to all other classes In the future, this will be able to take Storage classes as well
- analysis_particle_indicestuple of ints, Optional. Default: () (empty tuple)
If specified, it will serialize positions and velocities for the specified particles, at every iteration, in the reporter storage (.nc) file. If empty, no positions or velocities will be stored in this file for any atoms.
- Attributes:
filepath
Returns the string file name of the primary storage file
checkpoint_interval
Returns the checkpoint interval
- is_periodic
- n_states
- n_replicas
analysis_particle_indices
Return the tuple of indices of the particles which additional information is stored on for analysis
Methods
close
()Close the storage files
is_open
()Return True if the Reporter is ready to read/write.
open
([mode, convention, netcdf_format])Open the storage file for reading/writing.
read_checkpoint_iterations
()Utility function to provide all iterations on which a checkpoint was written
read_dict
(path)Restore a dictionary from the storage file.
read_end_thermodynamic_states
()Read thermodynamic states at the ends of the protocol."
read_energies
([iteration])Retrieve the energy matrix at the given iteration on the analysis file
read_last_iteration
([last_checkpoint])Read the last iteration from file which was written in sequential order.
read_logZ
(iteration)Read logZ at a given iteration from file.
read_mcmc_moves
()Return the MCMCMoves of the
yank.multistate.MultiStateSampler
simulation on the checkpointread_mixing_statistics
([iteration])Retrieve the mixing statistics for the given iteration on the analysis file
read_online_analysis_data
(iteration, *keys)- Parameters:
read_replica_thermodynamic_states
([iteration])Retrieve the indices of the ThermodynamicStates for each replica on the analysis file
read_sampler_states
(iteration[, ...])Retrieve the stored sampler states on the checkpoint file
read_thermodynamic_states
()Retrieve the stored thermodynamic states from the checkpoint file.
read_timestamp
([iteration])Return the timestamp for the given iteration.
storage_exists
([skip_size])Check if the storage files exist on disk.
sync
()Force any buffer to be flushed to the file
write_current_statistics
(data)Write real time YAML file with analysis data.
write_dict
(path, data)Store the contents of a dict.
write_energies
(energy_thermodynamic_states, ...)Store the energy matrix at the given iteration on the analysis file
write_last_iteration
(iteration)Tell the reporter what the last iteration which was written in sequential order was to allow resuming and analysis only on valid data.
write_logZ
(iteration, logZ)Write logZ
write_mcmc_moves
(mcmc_moves)Store the MCMCMoves of the
yank.multistate.MultiStateSampler
simulation or subclasses on the checkpointwrite_mixing_statistics
(n_accepted_matrix, ...)Store the mixing statistics for the given iteration on the analysis file
write_online_analysis_data
(iteration, **kwargs)Write semi-arbitrary 1-D numeric online analysis data to storage with optional per-iteration flag.
write_online_data_dynamic_and_static
(...)Helper function to do a
write_online_analysis_data()
call twice, both with and without setting iteration.write_replica_thermodynamic_states
(...)Store the indices of the ThermodynamicStates for each replica on the analysis file
write_sampler_states
(sampler_states, iteration)Store all sampler states for a given iteration on the checkpoint file
write_thermodynamic_states
(...)Store all the ThermodynamicStates to the checkpoint file.
write_timestamp
(iteration)Store a timestamp for the given iteration on both analysis and checkpoint file.
- __init__(storage, open_mode=None, checkpoint_interval=50, checkpoint_storage=None, analysis_particle_indices=())[source]¶
Methods
__init__
(storage[, open_mode, ...])close
()Close the storage files
is_open
()Return True if the Reporter is ready to read/write.
open
([mode, convention, netcdf_format])Open the storage file for reading/writing.
read_checkpoint_iterations
()Utility function to provide all iterations on which a checkpoint was written
read_dict
(path)Restore a dictionary from the storage file.
read_end_thermodynamic_states
()Read thermodynamic states at the ends of the protocol."
read_energies
([iteration])Retrieve the energy matrix at the given iteration on the analysis file
read_last_iteration
([last_checkpoint])Read the last iteration from file which was written in sequential order.
read_logZ
(iteration)Read logZ at a given iteration from file.
read_mcmc_moves
()Return the MCMCMoves of the
yank.multistate.MultiStateSampler
simulation on the checkpointread_mixing_statistics
([iteration])Retrieve the mixing statistics for the given iteration on the analysis file
read_online_analysis_data
(iteration, *keys)- Parameters:
read_replica_thermodynamic_states
([iteration])Retrieve the indices of the ThermodynamicStates for each replica on the analysis file
read_sampler_states
(iteration[, ...])Retrieve the stored sampler states on the checkpoint file
read_thermodynamic_states
()Retrieve the stored thermodynamic states from the checkpoint file.
read_timestamp
([iteration])Return the timestamp for the given iteration.
storage_exists
([skip_size])Check if the storage files exist on disk.
sync
()Force any buffer to be flushed to the file
write_current_statistics
(data)Write real time YAML file with analysis data.
write_dict
(path, data)Store the contents of a dict.
write_energies
(energy_thermodynamic_states, ...)Store the energy matrix at the given iteration on the analysis file
write_last_iteration
(iteration)Tell the reporter what the last iteration which was written in sequential order was to allow resuming and analysis only on valid data.
write_logZ
(iteration, logZ)Write logZ
write_mcmc_moves
(mcmc_moves)Store the MCMCMoves of the
yank.multistate.MultiStateSampler
simulation or subclasses on the checkpointwrite_mixing_statistics
(n_accepted_matrix, ...)Store the mixing statistics for the given iteration on the analysis file
write_online_analysis_data
(iteration, **kwargs)Write semi-arbitrary 1-D numeric online analysis data to storage with optional per-iteration flag.
write_online_data_dynamic_and_static
(...)Helper function to do a
write_online_analysis_data()
call twice, both with and without setting iteration.write_replica_thermodynamic_states
(...)Store the indices of the ThermodynamicStates for each replica on the analysis file
write_sampler_states
(sampler_states, iteration)Store all sampler states for a given iteration on the checkpoint file
write_thermodynamic_states
(...)Store all the ThermodynamicStates to the checkpoint file.
write_timestamp
(iteration)Store a timestamp for the given iteration on both analysis and checkpoint file.
Attributes
analysis_particle_indices
Return the tuple of indices of the particles which additional information is stored on for analysis
checkpoint_interval
Returns the checkpoint interval
filepath
Returns the string file name of the primary storage file
is_periodic
n_replicas
n_states