Calculates ligand strain of small molecules from their docked poses.
Project description
StrainRelief 💊
StrainRelief calculates the ligand strain of docked poses and has a suite of different force fields with which to do this. This includes our own MACE neural network potential trained on SPICE2 and also Meta's FAIRChem models, such as e-SEN and UMA. Optimisations are run in parallel using the neural-optimiser package.
- 📄 The publication can be found here.
- 📊 All relevant datasets here.
- 💬 RAG chatbot for questions about the paper and references.
- 💻 Chatbot source code.
- 📉 neural-optimiser package.
Update 1.0.0
This update focuses on accelerating the StrainRelief backend and increasig usability through simpler configurations and workflows:
- Molecular optimisation are now paralellised using the
neural-optimiserpackage providing a 3x speed-up. - New simplified hyra configuration. An example of the full configuration is given here.
Note: this introduces changes that are not backwards-compatible with previous versions.
Installation
Pre-requisities: Python 3.11, PyTorch and PyTorch Geometric compatible with your envirnment
# For example
uv pip install torch==2.8.0 -f https://data.pyg.org/whl/torch-2.8.0+cu128.html
uv pip install torch-geometric==2.7.0 torch-cluster -f https://data.pyg.org/whl/torch-2.8.0+cu128.html
Installation from PyPi
pip install strain-relief
Installation from source (uv)
uv sync --extra dev --editable
or create a virtual environment and install the package and its dependencies in editable mode:
uv venv
source .venv/bin/activate
# [install torch and torch-geometric as above]
uv pip install -e ".[dev]"
uv pip install --force-reinstall e3nn==0.5 fairchem-core
uv run pre-commit install
Note: mace-torch==0.3.x requires e3nn==0.4.4 (only for training, not inference). fairchem-core requires e3nn>=0.5. So until mace-torch==0.4 is released we will have to do this finicky way of installing (GitHub issue).
The Protocol
The protocol used in StrainRelief is designed to be simple, fast and model agnostic - all that is needed to apply a new force field is to write a neural-optimiser Calculator class (such as an ASE calculator wrapper). Additionally, the package is already compatible with all MACE and Meta FAIRChem models.
The protocol consists of 5 steps:
- Minimise the docked pose with a loose convergence criteria to give a local minimum.
- Generate 20 conformers from the docked ligand pose.
- Minimise the generated conformers (and the original docked pose) with a stricter convergence criteria.
- Evaluate the energy of all conformers and choose the lowest energy as an approximation of the global minimum.
- Calculate
E(ligand strain) = E(local minimum) - E(global minimum)and apply threshold.
N.B. energies returned are in kcal/mol.
Usage
StrainRelief runs are configured using hydra configs.
Python Package
from strain_relief import compute_strain
computed = compute_strain(poses: list[RDKit.Mol], config: DictConfig)
for i, r in computed.iterrows():
print(f"Pose {r['id']} has a strain of {r['ligand_strain']:.2f} kcal/mol")
For a complete set of examples see the tutorial notebook.
Command Line
strain-relief \
experiment=mmff94 \
io.input.parquet_path=data/example_ligboundconf_input.parquet \
io.output.parquet_path=data/example_ligboundconf_output.parquet \
conformers.numConfs=1 \
More examples are given here, including the command used for the calculations in the StrainRelief paper.
Adding Your Own Calculator
Add a new Calculator class from neural-optimiser to the strain_relief/calculators/ directory. This can be as simple as implementing a wrapper around an existing ASE calculator:
from neural_optimiser.calculators.base import Calculator
class YourCalculator(Calculator):
def __init__(self, **kwargs):
self.calculator = YourASECalculator(**kwargs)
def _calculate(self, batch: Data | Batch) -> tuple[torch.Tensor, torch.Tensor]:
"""Return (energies, forces) from the calculator."""
ase_atoms = batch.to_ase()
ase_atoms.calc = self.calculator
return ase_atoms.get_potential_energy(), ase_atoms.get_gradients()
Note: MACECalculator and FAIRChemCalculator from neural-optimiser use a from_atomic_data helper method. This converts ConformerBatch objects to AtomicData model inputs in a batched process; a workflow bottleneck not handled by either the MACE or FAIRChem internal ASE calculators. I would recommend implementing something similar for high throughput workflows.
Add a new config to hydra_config/calculator/your_calculator.yaml:
_target_: strain_relief.calculators.your_calculator.YourCalculator
model_paths: null
device: ${device}
any_other_kwargs: null
Configurations
Common kwargs
threshold(set by default to 16.1 kcal/mol - calibrated using LigBoundConf 2.0)conformers.numConfsglobal_optimiser.steps/local_optimiser.stepsglobal_optimiser.fmax/local_optimiser.fmaxio.input.include_chargedhydra.verboseseed
Logging
Logging is set to the INFO level by default which logs only aggregate information. hydra.verbose=true can be used to activate DEBUG level logging which includes information for every molecule and conformer.
Unit Tests
uv run pytest tests/- runs all tests (unit and integration)uv run pytest tests/ -m "not integration"- runs all unit tests
Note: Unit tests will run on a GPU if available.
Citations
If you use StrainRelief or adapt the StrainRelief code for any purpose, please cite:
@article{wallace2025strain,
title={Strain Problems Got You in a Twist? Try StrainRelief: A Quantum-Accurate Tool for Ligand Strain Calculations},
author={Wallace, Ewan RS and Frey, Nathan C and Rackers, Joshua A},
journal={Journal of Chemical Information and Modeling},
year={2025},
publisher={ACS Publications},
url={https://pubs.acs.org/doi/10.1021/acs.jcim.5c00586}
}
More information
For any questions, please reach out to Ewan Wallace: ewan.wallace@roche.com
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 strain_relief-1.0.dev0.tar.gz.
File metadata
- Download URL: strain_relief-1.0.dev0.tar.gz
- Upload date:
- Size: 17.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdffcaad250707fc76fd3c9e24470e5f7f0b9941abd7e53da1954bdbad3d46ec
|
|
| MD5 |
11491a7a5fdd7c350df125ea638d5688
|
|
| BLAKE2b-256 |
275bb43eae59b5a22b422282d1ac48e0ead615568adc03d7e73ef80072ca85d6
|
Provenance
The following attestation bundles were made for strain_relief-1.0.dev0.tar.gz:
Publisher:
pypi.yml on prescient-design/StrainRelief
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strain_relief-1.0.dev0.tar.gz -
Subject digest:
fdffcaad250707fc76fd3c9e24470e5f7f0b9941abd7e53da1954bdbad3d46ec - Sigstore transparency entry: 1849241676
- Sigstore integration time:
-
Permalink:
prescient-design/StrainRelief@01c1e1ad26eefe6704169e76aea886ca912b7ad1 -
Branch / Tag:
refs/tags/1.0.dev0 - Owner: https://github.com/prescient-design
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@01c1e1ad26eefe6704169e76aea886ca912b7ad1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file strain_relief-1.0.dev0-py3-none-any.whl.
File metadata
- Download URL: strain_relief-1.0.dev0-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0b336a8d96a8b42257025b41e3e8c9a692c07a390d99fc2e908e6a69c1dc460
|
|
| MD5 |
2113f79967c0b04cf600792469230604
|
|
| BLAKE2b-256 |
58478177a7b8ef84991ba79cb76d4261eea3b0c1750d28644099417a357cae44
|
Provenance
The following attestation bundles were made for strain_relief-1.0.dev0-py3-none-any.whl:
Publisher:
pypi.yml on prescient-design/StrainRelief
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strain_relief-1.0.dev0-py3-none-any.whl -
Subject digest:
d0b336a8d96a8b42257025b41e3e8c9a692c07a390d99fc2e908e6a69c1dc460 - Sigstore transparency entry: 1849241736
- Sigstore integration time:
-
Permalink:
prescient-design/StrainRelief@01c1e1ad26eefe6704169e76aea886ca912b7ad1 -
Branch / Tag:
refs/tags/1.0.dev0 - Owner: https://github.com/prescient-design
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@01c1e1ad26eefe6704169e76aea886ca912b7ad1 -
Trigger Event:
release
-
Statement type: