meld.vault.DataStore

class meld.vault.DataStore(state_template, n_replicas, pdb_writer, block_size=100)[source]

Bases: object

Load / store data for MELD runs.

Data will be stored in the ‘Data’ subdirectory. Backups will be stored in ‘Data/Backup’.

Some information is stored as python pickled files:

  • Data/data_store.dat – the DataStore object

  • Data/communicator.dat – the MPICommunicator object

  • Data/remd_runner.dat – the LeaderReplicaExchangeRunner object

Other data (positions, velocities, etc) is stored in files in the Data/Blocks diretory.

__init__(state_template, n_replicas, pdb_writer, block_size=100)[source]

Initialize the DataStore

Parameters
  • n_atoms – number of atoms

  • n_replicas (int) – number of replicas

  • pdb_writer (PDBWriter) – the object to handle writing pdb files

  • block_size (int) – size of netcdf blocks and frequency to do backups

Methods

__init__(state_template, n_replicas, pdb_writer)

Initialize the DataStore

append_traj(state, stage)

Append structure from state to end of trajectory

backup(stage)

Backup all files to Data/Backup.

close()

Close the DataStore

initialize(mode)

Prepare to use the DataStore object.

iterate_box_vectors([start, end])

Iterate over the box_vectors from disk.

iterate_permutation_vectors([start, end])

Iterate over the permutation vectors from disk.

iterate_positions([start, end])

Iterate the positions over time.

load_acceptance_probabilities(stage)

Load acceptance probability vector from disk.

load_alignments(stage)

load_all_acceptance_probabilities()

Load all acceptance probabilities from disk

load_all_alphas()

Load all alphas from disk.

load_all_box_vectors()

Load all box_vectors from disk.

load_all_energies()

Load all energies from disk.

load_all_energy_matrices()

Load all energy matrix from disk

load_all_permutation_vectors()

Load all permutation vector from disk.

load_all_positions()

Load all positions from disk.

load_all_velocities()

Load all velocities from disk.

load_alphas(stage)

Load alphas from disk.

load_box_vectors(stage)

Load box_vectors from disk.

load_communicator()

Load the communicator from disk

load_continuous_parameters(stage)

load_data_store([load_backup])

Load the DataStore object from disk.

load_discrete_parameters(stage)

load_energies(stage)

Load energies from disk.

load_energy_matrix(stage)

Load energy matrix from disk

load_group_energies(stage)

rtype

ndarray

load_mappings(stage)

load_permutation_vector(stage)

Load permutation vector from disk.

load_positions(stage)

Load positions from disk.

load_positions_random_access(stage)

Load positions from disk.

load_remd_runner()

Load replica runner from disk

load_run_options()

Load RunOptions from disk

load_states(stage)

Load states from disk

load_system()

Load MELD system from disk

load_velocities(stage)

Load velocities from disk.

save_acceptance_probabilities(accept_probs, ...)

Save acceptance probabilities vector to disk.

save_alignments(data, stage)

save_alphas(alphas, stage)

Save alphas to disk.

save_box_vectors(box_vectors, stage)

Save the box_vectors to disk.

save_communicator(comm)

Save the communicator to disk

save_continuous_parameters(data, stage)

save_data_store()

Save this object to disk.

save_discrete_parameters(data, stage)

save_energies(energies, stage)

Save energies to disk.

save_energy_matrix(energy_matrix, stage)

Save energy matrix to disk

save_group_energies(group_energies, stage)

save_mappings(data, stage)

save_permutation_vector(perm_vec, stage)

Save permutation vector to disk.

save_positions(positions, stage)

Save the positions to disk.

save_remd_runner(runner)

Save replica runner to disk

save_run_options(run_options)

Save RunOptions to disk :type run_options: RunOptions :param run_options: options to save to disk

save_states(states, stage)

Save states to disk.

save_system(system)

Save MELD system to disk

save_velocities(velocities, stage)

Save velocities to disk.

Attributes

log_dir

Sub-directory for log files

max_safe_block

Maximum safe block that can be read

max_safe_frame

Maximum safe fram that can be read

n_atoms

The number of atoms

n_replicas

The number of replicas

append_traj(state, stage)[source]

Append structure from state to end of trajectory

Parameters
  • state (IState) – state to append

  • stage (int) – stage number

backup(stage)[source]

Backup all files to Data/Backup.

Backup will occur if stage % backup_freq == 0

Parameters

stage (int) – stage

close()[source]

Close the DataStore

initialize(mode)[source]

Prepare to use the DataStore object.

Parameters

mode (str) – mode to open with

Available modes are:

  • ‘w’ – create a new directory structure and initialize the hd5 file

  • ‘a’ – append to the existing files

  • ‘r’ – open the file in read-only mode

iterate_box_vectors(start=None, end=None)[source]

Iterate over the box_vectors from disk.

Parameters
  • start (Optional[int]) – starting frame

  • end (Optional[int]) – ending frame

Return type

Iterator[ndarray]

Returns

iterator over n_replicas x 3 x 3 array

iterate_permutation_vectors(start=None, end=None)[source]

Iterate over the permutation vectors from disk.

Parameters
  • start (Optional[int]) – starting stage

  • end (Optional[int]) – ending stage

Return type

Iterator[ndarray]

Returns

an iterator over n_replicas array of int

iterate_positions(start=None, end=None)[source]

Iterate the positions over time.

Parameters
  • start (Optional[int]) – starting step

  • end (Optional[int]) – ending step

Return type

Iterator[ndarray]

Returns

An iterator over steps of n_replicas x n_atoms x 3 array

load_acceptance_probabilities(stage)[source]

Load acceptance probability vector from disk.

Parameters

stage (int) – stage to load

Return type

ndarray

Returns

n_replica_pairs array

load_all_acceptance_probabilities()[source]

Load all acceptance probabilities from disk

Return type

ndarray

Returns

n_stages x n_replica_pairs array

Warning

This might take a lot of memory

load_all_alphas()[source]

Load all alphas from disk.

Return type

ndarray

Returns

n_stage x n_replicas array

Warning

This could use a lot of memory.

load_all_box_vectors()[source]

Load all box_vectors from disk.

Return type

ndarray

Returns

n_steps x n_replicas x 3 x 3 array

Warning

This could use a lot of memory.

load_all_energies()[source]

Load all energies from disk.

Return type

ndarray

Returns

n_stage x n_replicas array of energies

Warning

This could use a lot of memory

load_all_energy_matrices()[source]

Load all energy matrix from disk

Return type

ndarray

Returns

n_stages x n_replicas x n_replicas array of energies

load_all_permutation_vectors()[source]

Load all permutation vector from disk.

Return type

ndarray

Returns

n_stages x n_replicas array of int

Warning

This might take a lot of memory

load_all_positions()[source]

Load all positions from disk.

Return type

ndarray

Returns

n_steps x n_replicas x n_atoms x 3 array

Warning

This could use a lot of memory.

load_all_velocities()[source]

Load all velocities from disk.

Return type

ndarray

Returns

n_steps x n_replicas x n_atoms x 3 array

Warning

This could use a lot of memory.

load_alphas(stage)[source]

Load alphas from disk.

Parameters

stage (int) – stage to load from disk

Return type

ndarray

Returns

n_replicas array

load_box_vectors(stage)[source]

Load box_vectors from disk.

Parameters

stage (int) – stage to load

Return type

ndarray

Returns

n_replicas x 3 x 3 array

load_communicator()[source]

Load the communicator from disk

Return type

ICommunicator

classmethod load_data_store(load_backup=False)[source]

Load the DataStore object from disk.

Parameters

load_backup (bool) – whether to load the backup

load_energies(stage)[source]

Load energies from disk.

Parameters

stage – stage to load

Return type

ndarray

Returns

n_replicas array of energies

load_energy_matrix(stage)[source]

Load energy matrix from disk

Parameters

stage (int) – stage to laod

Return type

ndarray

Returns

n_replicas x n_replicas array of energies

load_permutation_vector(stage)[source]

Load permutation vector from disk.

Parameters

stage (int) – stage to load

Return type

ndarray

Returns

n_replicas array of int

load_positions(stage)[source]

Load positions from disk.

Parameters

stage (int) – stage to load

Return type

ndarray

Returns

n_replicas x n_atoms x 3 array

Warning

load_positions() can only access moving forward in time. Attempts to move backwards in time will raise an error.

load_positions_random_access(stage)[source]

Load positions from disk.

Parameters

stage (int) – stage to load

Return type

ndarray

Returns

n_replicas x n_atoms x 3 array

Note

This differs from load_positions() in that you can positions from any stage, while load_positions() can only move forward in time. However, this comes at a performance penalty.

load_remd_runner()[source]

Load replica runner from disk

Returns

LeaderReplicaExchangeRunner

load_run_options()[source]

Load RunOptions from disk

Return type

RunOptions

load_states(stage)[source]

Load states from disk

Parameters

stage (int) – stage to load

Return type

Sequence[IState]

Returns

list of states

load_system()[source]

Load MELD system from disk

Return type

ISystem

load_velocities(stage)[source]

Load velocities from disk.

Parameters

stage (int) – stage to load

Return type

ndarray

Returns

n_replicas x n_atoms x 3 array

log_dir: str = 'Logs'

Sub-directory for log files

property max_safe_block

Maximum safe block that can be read

property max_safe_frame

Maximum safe fram that can be read

property n_atoms: int

The number of atoms

property n_replicas: int

The number of replicas

save_acceptance_probabilities(accept_probs, stage)[source]

Save acceptance probabilities vector to disk.

Parameters
  • accept_probs (ndarray) – n_replica_pairs array

  • stage (int) – stage to store

save_alphas(alphas, stage)[source]

Save alphas to disk.

Parameters
  • alphas (ndarray) – n_replicas array

  • stage (int) – stage to store

save_box_vectors(box_vectors, stage)[source]

Save the box_vectors to disk.

Parameters
  • positions – n_replicas x 3 x 3 array

  • stage (int) – stage to store

save_communicator(comm)[source]

Save the communicator to disk

save_data_store()[source]

Save this object to disk.

save_energies(energies, stage)[source]

Save energies to disk.

Parameters
  • energies (ndarray) – n_replicas array of energy

  • stage (int) – stage to save

save_energy_matrix(energy_matrix, stage)[source]

Save energy matrix to disk

Parameters
  • energy_matrix (ndarray) – n_replicas x n_replicas matrix of energies

  • stage (int) – stage to store

save_permutation_vector(perm_vec, stage)[source]

Save permutation vector to disk.

Parameters
  • perm_vec (ndarray) – n_replicas array of int

  • stage (int) – stage to store

save_positions(positions, stage)[source]

Save the positions to disk.

Parameters
  • positions (ndarray) – n_replicas x n_atoms x 3 array

  • stage (int) – stage to store

save_remd_runner(runner)[source]

Save replica runner to disk

Parameters

runner (LeaderReplicaExchangeRunner) – replica exchange runner to save

save_run_options(run_options)[source]

Save RunOptions to disk :type run_options: RunOptions :param run_options: options to save to disk

save_states(states, stage)[source]

Save states to disk.

Parameters
  • states (Sequence[IState]) – states to store

  • stage (int) – stage to store

save_system(system)[source]

Save MELD system to disk

Parameters

system (ISystem) – system to save

save_velocities(velocities, stage)[source]

Save velocities to disk.

Parameters
  • velocities (ndarray) – n_replicas x n_atoms x 3 array

  • stage (int) – stage to store