alchemlyb: the simple alchemistry library

2.5.0 · active · verified Wed Apr 15

alchemlyb is a Python library for the analysis of alchemical free energy calculations, a crucial method in computational chemistry and biology. It provides flexible building blocks for parsing data from molecular dynamics engines, subsampling time series data, and estimating free energies using best-practice approaches like Multistate Bennett Acceptance Ratio (MBAR), Bennett Acceptance Ratio (BAR), and Thermodynamic Integration (TI). The library also offers high-level, end-to-end workflows for streamlined analysis. It is currently at version 2.5.0 and under active development, adhering to semantic versioning to ensure API stability within major releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use the high-level `ABFE` workflow to automatically analyze absolute binding free energy calculations, requiring only a few lines of code. It uses example GROMACS data provided by the `alchemtest` library to parse files, perform data preprocessing, estimate free energies using MBAR, BAR, and TI estimators, and generate diagnostic plots.

import os
from alchemtest.gmx import load_ABFE
from alchemlyb.workflows import ABFE

# This example uses test data from the alchemtest library. 
# Ensure alchemtest is installed: `pip install alchemtest`

# Obtain the path of the data
dir_path = os.path.dirname(load_ABFE()['data']['complex'][0])

# Initialize and run the Absolute Binding Free Energy (ABFE) workflow
workflow = ABFE(
    units='kcal/mol', 
    software='GROMACS', 
    dir=dir_path, 
    prefix='dhdl', 
    suffix='xvg', 
    T=298, 
    outdirectory='./alchemlyb_output'
)

# Execute the complete workflow with specified parameters
result = workflow.run(
    skiptime=10, 
    uncorr='dhdl', 
    threshold=50, 
    estimators=('MBAR', 'BAR', 'TI'), 
    overlap='O_MBAR.pdf', 
    breakdown=True, 
    forwrev=10
)

print("Free energy estimates:")
print(result)

view raw JSON →