Skip to content

Output files and analysis

Window output files

Each window writes <output_prefix>_window_<k>.h5 while it runs. The file holds:

Name Content
reduced_potentials Array of shape (states, samples). Column n is the reduced potential (energy / kT) of sample n of the window, evaluated in every state. fes-ml adds a column at each iteration.
provenance The provenance records of the window, as JSON text.
attribute temperature_K The temperature of the window.
attribute state_labels One label for each state, as JSON text.
attribute lambda_schedule The lambda schedule of the run, as JSON text.
attribute window, format The index of the window, and the version of the file format.

A restart continues the file from the checkpoint. The samples after the checkpoint are removed, because the run makes them again. Pass FES(write_window_files=False) to write no files.

Read a file with fes_ml.output.read_window, or with any HDF5 tool:

from fes_ml.output import read_window

data = read_window("run_window_3.h5")
data.u_kn.shape, data.temperature_K

Free energies with MBAR

The fes-ml-analyse command reads the window files, checks that they belong to one run, and computes the free energies with pymbar (the analysis extra):

fes-ml-analyse run_window_*.h5 --decorrelate --json result.json

It prints the free energy of the last state minus that of the first, in kJ/mol and kcal/mol, with its statistical uncertainty, and the smallest overlap between neighbouring states. For a decoupling schedule (coupled first, decoupled last), the solvation free energy is minus this value.

The checks stop the analysis when:

  • a window has no file, or more than one;
  • the windows have different states, lambda schedules or temperatures;
  • the provenance shows other package versions, another fes-ml commit, or another platform or integrator. Add --allow-mixed to use these windows together. The command then prints a warning.

Options choose the samples of each window: --discard n removes the first n samples, and --stride n keeps every n-th sample. --decorrelate then finds the equilibrated part of each window and keeps uncorrelated samples, with pymbar.timeseries.

The same from Python:

from fes_ml import analysis

windows = analysis.load_windows(glob.glob("run_window_*.h5"))
result = analysis.mbar(windows, decorrelate=True)
result.free_energy(unit="kcal/mol"), result.uncertainty(unit="kcal/mol")
result.delta_f      # f_j - f_i in kT, for all pairs of states
result.overlap      # overlap matrix

Results of fes-ml 0.3 and earlier

fes-ml-analyse also reads the .npy files of earlier versions. These files have no temperature, so give it:

fes-ml-analyse U_kln.npy --temperature 298.15            # shape (windows, states, samples)
fes-ml-analyse window_0.npy window_1.npy ... --temperature 298.15   # shape (states, samples), in window order