Integrative Refinement Engine using differentiable forward models
Project description
⚙️ Diff-Integrator: The Integrative Refinement Engine
Diff-Integrator is a JAX-accelerated optimization engine designed for integrative structural biology. It acts as the "orchestrator" that combines differentiable observables from diff-biophys into multi-objective loss functions.
By cleanly separating the optimization loop from the underlying biophysical kernels, diff-integrator enables robust, joint refinement of protein structures against diverse experimental data (e.g., SAXS, NMR Chemical Shifts, NMR RDCs) simultaneously.
🎯 Vision
The goal of diff-integrator is to provide a seamless optax-based refinement pipeline that handles:
- Multi-Objective Optimization: Easily weight and combine multiple experimental constraints via
JointLoss. - Abstract Parameterization: Optimize arbitrary parameter spaces—from Cartesian coordinates to internal backbone angles (phi/psi)—via user-defined
kinematics_fnmappers. - Dynamic Fitting: Analytically refit nuisance parameters (like Saupe alignment tensors or SAXS scaling factors) dynamically during gradient descent.
📚 Interactive Tutorials
Experience Diff-Integrator directly in your browser with our Colab tutorials:
| Tutorial | Audience | Description | Action |
|---|---|---|---|
| 📉 Results Dashboard | Graduate / researcher | Visualizes the loss descent, Q-factors, chemical shift accuracy, NeRF drift, and structural changes across all three benchmarks. | |
| 🧪 Refinement Concepts | Student / researcher | Educational notebook explaining NMR observables, NeRF coordinate parameterization, RDC tensor degeneracy, and the fixed-tensor protocol. | |
| ⚠️ Method Limitations | Reviewer / scientist | Honest quantitative assessment of the current method's failure modes: NeRF geometric drift, RDC overfitting on PEG data, and degrees-of-freedom imbalance. |
⚡ Core Components
IntegrativeRefiner
The core optimization engine. Built on optax (defaulting to the Adam optimizer), it manages the training loop, gradient calculation, and loss tracking.
- Abstract Support: Accepts arbitrary parameter sets (
init_params) and maps them to Cartesian space using an optionalkinematics_fn.
JointLoss
A container for combining multiple LossTerm objects. It computes the total weighted loss by evaluating each term on the current parameters and generated coordinates.
LossTerm (Interface)
An abstract base class for defining differentiable constraints. All terms implement __call__(self, params, coords).
Included Observables
GeometryLoss: Implements basic structural priors, including harmonic restraints to a target Cartesian structure.SAXSLoss: Dynamically scales and fits theoretical SAXS profiles against experimental data using Debye kernels.RDCLoss: Analytically fits the Saupe tensor to current bond vectors at each step to compute Residual Dipolar Coupling (RDC) Mean Squared Errors or Q-factors.CAShiftLoss: Wraps the ring-current and secondary structure shift predictor to compute $C_\alpha$ chemical shift RMSDs.
🚀 Usage Example
import jax.numpy as jnp
from diff_integrator.loss import JointLoss
from diff_integrator.optimizer import IntegrativeRefiner
from diff_integrator.terms.geometry import GeometryLoss
from diff_integrator.terms.nmr import RDCLoss
# 1. Define loss terms
target_coords = jnp.load("target.npy")
geom_term = GeometryLoss(target_coords, loss_type="rmsd")
rdc_term = RDCLoss(
atom_pairs=bond_indices,
exp_rdcs=experimental_rdc_values,
d_max=21700.0,
loss_type="q_factor"
)
# 2. Combine into a joint loss
joint_loss = JointLoss([
(geom_term, 10.0), # Weight = 10.0
(rdc_term, 1.0) # Weight = 1.0
])
# 3. Refine
refiner = IntegrativeRefiner(loss_fn=joint_loss)
final_coords, history = refiner.run(
init_params=starting_coords,
epochs=1000,
learning_rate=0.01
)
🔬 Scientific Validation
diff-integrator is being validated against several experimental NMR datasets:
- 2KZV (CvR118A): Joint refinement using $C_\alpha$ Chemical Shifts and dual-medium (PAG/PEG) RDCs, lowering the $C_\alpha$ RMSD and bringing RDC Q-factors near zero.
- GmR58A & HR2876B: Successful gradient-based minimization of $C_\alpha$ shift RMSD using internal coordinates (dihedrals).
📂 Repository Structure
diff-integrator/
├── diff_integrator/ # Core package
│ ├── loss.py # JointLoss and LossTerm interface
│ ├── optimizer.py # IntegrativeRefiner engine
│ └── terms/ # Concrete loss implementations
│ ├── geometry.py # Harmonic restraints, RMSD
│ ├── saxs.py # Debye scattering loss
│ ├── nmr.py # RDC and Q-factor loss
│ └── chemical_shifts.py # C-alpha shift loss
├── benchmarks/ # Real-world optimization tests
├── tests/ # Unit tests (100% coverage)
├── docs/ # MkDocs documentation
└── pyproject.toml # Build configuration
🚀 Installation
Ensure you have JAX installed, then install diff-integrator locally:
pip install -e .
🤝 Contributing
Contributions are welcome! Please run the test suite and ensure mypy typing passes before submitting PRs:
pytest --cov=diff_integrator
mypy .
⚖️ 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 diff_integrator-0.1.1.tar.gz.
File metadata
- Download URL: diff_integrator-0.1.1.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd5c22e863e7906a08a14effc80550ef273683373869a7c1ebaec1076658ce39
|
|
| MD5 |
a9233b3081466249c619cadd5e4de518
|
|
| BLAKE2b-256 |
1ce20776f6b7271bcc2371691bc2f670b89b16ff7c3df324f5b1d2361b1bce92
|
Provenance
The following attestation bundles were made for diff_integrator-0.1.1.tar.gz:
Publisher:
publish.yml on elkins-lab/diff-integrator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
diff_integrator-0.1.1.tar.gz -
Subject digest:
cd5c22e863e7906a08a14effc80550ef273683373869a7c1ebaec1076658ce39 - Sigstore transparency entry: 1982498123
- Sigstore integration time:
-
Permalink:
elkins-lab/diff-integrator@a35161a4246c6e6dab424dbfa38bdb7ed3fd062f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/elkins-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a35161a4246c6e6dab424dbfa38bdb7ed3fd062f -
Trigger Event:
release
-
Statement type:
File details
Details for the file diff_integrator-0.1.1-py3-none-any.whl.
File metadata
- Download URL: diff_integrator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.0 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 |
b2d818d4a1a75183565a66fa1d9a42a119c5a295c5b9e5ede5588515bbf64f6c
|
|
| MD5 |
adee0b0255dd1bc5f1c8e989f6ab31f0
|
|
| BLAKE2b-256 |
1976f0795ff48c502b01cdfd8d7cccd7d982c9fccea8a7fca46a4319ecf6172f
|
Provenance
The following attestation bundles were made for diff_integrator-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on elkins-lab/diff-integrator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
diff_integrator-0.1.1-py3-none-any.whl -
Subject digest:
b2d818d4a1a75183565a66fa1d9a42a119c5a295c5b9e5ede5588515bbf64f6c - Sigstore transparency entry: 1982498342
- Sigstore integration time:
-
Permalink:
elkins-lab/diff-integrator@a35161a4246c6e6dab424dbfa38bdb7ed3fd062f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/elkins-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a35161a4246c6e6dab424dbfa38bdb7ed3fd062f -
Trigger Event:
release
-
Statement type: