Maximum A Posteriori Learning of Energies - Bayesian inference tools for Free Energy Perturbation (FEP) calculations in computational drug discovery
Project description
MAPLE-fep
Maximum A Posteriori Learning of Energies
A Python package for Bayesian analysis of Free Energy Perturbation (FEP) calculations in computational drug discovery. MAPLE provides probabilistic and deterministic inference methods to correct thermodynamic inconsistencies and detect outliers in FEP perturbation graphs.
Installation
# From PyPI
pip install maple-fep
# From source (development)
git clone https://github.com/aakankschit/MAPLE-fep.git
cd MAPLE-fep
pip install -e ".[dev]"
Quick Start
from maple_fep.models import GaussianMixtureVI, GaussianMixtureVIConfig
from maple_fep.dataset import FEPDataset
# Load your FEP data
dataset = FEPDataset("fep_edges.csv")
# Configure the GMVI model (Gaussian Mixture Variational Inference)
config = GaussianMixtureVIConfig(
prior_std=5.0, # Prior uncertainty on node values
normal_std=1.0, # Expected error for normal edges
outlier_std=3.0, # Expected error for outlier edges
outlier_prob=0.2, # Prior probability of an edge being an outlier
learning_rate=0.01,
n_epochs=1000
)
# Train and get results
model = GaussianMixtureVI(config=config, dataset=dataset)
model.fit()
# Get node estimates (absolute free energies)
results = model.get_results()
node_estimates = results["node_estimates"]
# Identify problematic edges
outlier_probs = model.compute_edge_outlier_probabilities()
Key Features
-
Probabilistic Inference Methods
- MAP: Maximum A Posteriori estimation for regularized point estimates
- MLE: Maximum Likelihood Estimation (unregularized)
- VI: Variational Inference with full uncertainty quantification
- GMVI: Gaussian Mixture VI for automatic outlier detection
-
Deterministic Graph Methods
- WCC: Weighted Cycle Closure for thermodynamic consistency enforcement
- WSFC/SFC: Weighted Spectral Free-energy Correction via graph Laplacian pseudoinverse
-
Outlier Detection
- Probabilistic identification of problematic FEP edges
- Mixture models for robust estimation
-
Uncertainty Quantification
- Full posterior distributions with confidence intervals
- Bootstrap statistics for performance metrics
- Laplacian-based uncertainties for spectral methods
Methods at a Glance
| Method | Class | Type | Key Idea | Outputs |
|---|---|---|---|---|
| MAP | VariationalEstimator |
Probabilistic | Regularized least squares via Bayesian prior | Point estimates |
| MLE | VariationalEstimator |
Probabilistic | Ordinary least squares (uniform prior) | Point estimates |
| VI | VariationalEstimator |
Probabilistic | Variational posterior approximation | Estimates + uncertainties |
| GMVI | GaussianMixtureVI |
Probabilistic | Mixture likelihood for outlier robustness | Estimates + uncertainties + outlier scores |
| WCC | CycleClosureCorrection |
Deterministic | Iterative cycle closure error correction | Corrected estimates + uncertainties |
| WSFC | SpectralCorrection |
Deterministic | Graph Laplacian pseudoinverse: $z^* = L_W^+ B^T W x$ | Estimates + uncertainties |
| SFC | SpectralCorrection |
Deterministic | Unweighted spectral correction (equivalent to MLE) | Estimates + uncertainties |
Core Modules
| Module | Description |
|---|---|
maple_fep.models.probabilistic |
Bayesian estimators: VariationalEstimator (MAP/VI/MLE), GaussianMixtureVI |
maple_fep.models.deterministic |
Graph-based methods: CycleClosureCorrection (WCC), SpectralCorrection (WSFC/SFC) |
maple_fep.models.config |
Pydantic configuration classes for all models |
maple_fep.dataset |
Dataset loading (FEPDataset), benchmarks (FEPBenchmarkDataset), synthetic data |
maple_fep.graph_analysis |
Performance statistics, visualization, graph construction, cycle analysis |
maple_fep.utils |
Parameter optimization (ParameterSweep), performance tracking |
Documentation
- User Guide: Installation, tutorials, examples
- API Reference: Detailed module documentation
- Examples: Jupyter notebooks and scripts
Build documentation locally:
pip install -e ".[docs]"
cd docs && make html
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Run tests with coverage
pytest tests/ --cov=src/maple_fep --cov-report=html
# Format code
black src/ tests/
ruff check src/ tests/
References
MAPLE implements methods from the following publications:
-
WCC: Li, Y.; Liu, R.; Liu, J.; Luo, H.; Wu, C.; Li, Z. An Open Source Graph-Based Weighted Cycle Closure Method for Relative Binding Free Energy Calculations. J. Chem. Inf. Model. 2023, 63, 561--570. DOI: 10.1021/acs.jcim.2c01076
-
SFC/WSFC: Liu, R.; Lai, Y.; Yao, Y.; Huang, W.; Zhong, Y.; Luo, H.-B.; Li, Z. State Function-Based Correction: A Simple and Efficient Free-Energy Correction Algorithm for Large-Scale Relative Binding Free-Energy Calculations. J. Phys. Chem. Lett. 2025, 16, 5763--5768. DOI: 10.1021/acs.jpclett.5c01119
Citation
If you use MAPLE in your research, please cite:
@software{maple_fep_2025,
title={MAPLE: Maximum A Posteriori Learning of Energies},
author={Nandkeolyar, Aakankschit},
year={2025},
url={https://github.com/aakankschit/MAPLE-fep},
}
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maple_fep-0.1.1.tar.gz.
File metadata
- Download URL: maple_fep-0.1.1.tar.gz
- Upload date:
- Size: 144.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f213e2a69b3ba6bd1f8425803cb392b5551bd4c15a425ecd6f618022fa5aa53d
|
|
| MD5 |
31f6aca06e4809a6f5aa705a78ce1170
|
|
| BLAKE2b-256 |
18f4457f75eb9e15d31fb3b6faca27d18ecf7844f8181d98740d713f74104168
|
File details
Details for the file maple_fep-0.1.1-py3-none-any.whl.
File metadata
- Download URL: maple_fep-0.1.1-py3-none-any.whl
- Upload date:
- Size: 93.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c0453df64f3932376504b972a9ad22119632a0c26bdca9c3d2b3eb6a96c2a21
|
|
| MD5 |
f497d908fa6490b82240fb669aee8439
|
|
| BLAKE2b-256 |
d853a6570b96570dd29f524fab50b2387ad41fddf7c41b03e4ad10928362459f
|