| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Diff-Biophys is a high-performance Python library for differentiable biophysical modeling. Built on JAX, it re-implements core structural biology and spectroscopy observables (SAXS, NMR, CD) as hardware-accelerated, auto-differentiable kernels.
Documentation Website | Use Cases | Tutorials
To bridge the gap between static structural models and experimental solution-state data by providing a "differentiable bridge." This allows researchers to:
diff-biophys sits at the intersection of Machine Learning and Structural Biology. If you find the terminology confusing, please read our Concepts & Context Guide! It acts as a "Rosetta Stone" to explain:
Experience Diff-Biophys directly in your browser with our Colab tutorials:
| Tutorial | Audience | Description | Action |
|---|---|---|---|
| 🎓 Hello, Gradient Descent! | Undergrad (any) | No biology needed. Learn what a gradient is, how gradient descent works, and how JAX computes gradients automatically — then fit a real Karplus curve. | |
| 🔬 NMR Fundamentals | Undergrad (bio/chem) | Chemical shifts, the Karplus equation, RDCs, and the magic angle — computed differentiably and connected back to protein backbone torsion angles. | |
| 🧬 Protein Folding | Undergrad (bio/chem) | Use the NeRF algorithm to build 3D structures from angles and "fold" a random coil into an α-helix using RDC and Chemical Shift gradients. | |
| 🌉 Hybrid Refinement | Graduate / researcher | Use an energy-minimized structure from synth-pdb as a starting point and refine it against experimental gradients to rescue a decoy. | |
| 💡 CD Spectroscopy | Undergrad (bio/chem) | Build an α-helix from scratch, simulate its CD spectrum via the DeVoe model, watch it change as the helix unwinds, and compute the gradient of [θ]₂₂₂ w.r.t. atomic positions. | |
| 🧪 Diff-Biophys Showcase | Graduate / researcher | A complete overview of the JAX-accelerated SAXS and NMR kernels. | |
| ⚗️ Structure Refinement Lab | Graduate / researcher | Use gradient descent to optimize protein structures against experimental SAXS profiles. |
Protein conformational space is notoriously rugged, filled with countless local minima ("traps") that can catch a simple gradient descent optimizer. It is important to be realistic about where differentiable physics excels and where it has limitations.
Because gradient descent (the core of this library) follows the mathematically steepest path, it will always slide into the nearest "valley." If your starting structure is very far from the correct fold (e.g., a random string of atoms), the optimizer may get stuck in a physically impossible or non-native local minimum.
diff-biophys is a library of differentiable experimental observables, not a full molecular dynamics forcefield (like Amber or CHARMM). It does not natively calculate Van der Waals repulsions (steric clashes), hydrogen bond networks, or Ramachandran plot probabilities. If you run gradient descent using only experimental losses (like RDCs or SAXS) on an underdetermined system, the optimizer will happily smash atoms through each other to perfectly fit the data—resulting in extreme mathematical overfitting. To maintain physical realism, the library assumes you will pair its experimental losses with some form of structural prior, such as a simple harmonic restraint on the backbone, a differentiable molecular mechanics penalty, or by fine-tuning an AI folding model that already "knows" what a protein looks like.
Differentiable physics is most powerful when combined with experimental data (RDCs, SAXS, FSC). These observables act like a "global gravitational pull." Because a SAXS curve or an RDC depends on the entire shape of the molecule, they create a much wider and smoother "basin of attraction" than pure physical forces (like hydrogen bonds), helping the optimizer cross small physical "bumps" in the landscape.
For complex proteins, we do not recommend "folding from scratch." Instead, use a Hybrid Refinement strategy:
In our tutorials, we use an optimizer called Adam (Adaptive Moment Estimation). Think of it as "gradient descent with memory and friction." Unlike a simple ball rolling down a hill, Adam:
The benchmarks in benchmarks/ were designed to expose the limits of the library, not just demonstrate its successes. Here is an evidence-based summary of which setups genuinely improve a structure and which overfit.
| Use case | Overfits? | Why not |
|---|---|---|
| ML training loss — backprop experimental gradients through AlphaFold/ESMFold | ✅ No | The generative model encodes structural priors; diff-biophys provides the experimental signal |
| Alignment tensor fitting for a fixed structure (fit_saupe_tensor) | ✅ No | 5 free parameters vs 20–70+ RDC observations; problem is overdetermined |
| Cα chemical shift refinement only (Phase 1) | ✅ Rarely | The shift predictor is smooth and broad; gradients are gentle |
| SAXS global shape refinement | ✅ Rarely | Hundreds of q-points constrain global shape, not local torsions |
| Forward evaluation — computing Q-factors, SAXS χ², etc. for fixed structures | ✅ N/A | No optimization; pure observable calculation |
| Small loop refinement with harmonic restraint (--w-restraint) | ⚠️ Controlled | Restraint limits the effective search radius |
| Free backbone + sparse RDCs only | ❌ Always | ~3× more torsional DOFs than RDC constraints per medium |
The bottom line: diff-biophys is a library of differentiable experimental observables, designed to be embedded inside a larger system that supplies physical realism — whether that is a generative AI model, a molecular mechanics forcefield, or even a simple harmonic spring. Running gradient descent on a fully free backbone against a handful of RDCs will always overfit, for the same reason that NMR structure calculation programs (CYANA, X-PLOR) never use RDCs in isolation: the system is underdetermined. The benchmarks demonstrate this failure mode explicitly so users do not mistake a low Q-factor after optimization for genuine structural improvement.
DiffBiophys is validated against foundational biophysical principles and analytical solutions to ensure physical realism:
diff-biophys/
├── diff_biophys/ # Core package
│ ├── geometry/ # NeRF, Kabsch, Torsions
│ ├── saxs/ # Debye kernels, form factors
│ ├── nmr/ # RDCs, Karplus, Ring Currents, Chemical Shifts
│ ├── cd/ # CD simulation (DeVoe Matrix Method)
│ └── ensemble.py # Ensemble averaging API
├── tests/ # Parity, gradient, and scientific validation checks
├── examples/interactive_tutorials/ # Jupyter notebooks (Refinement Lab)
├── docs/ # API and Theory
├── pyproject.toml # Modern build config
└── README.md
pip install diff-biophysFor GPU support (CUDA):
pip install "jax[cuda12]" diff-biophysContributions are welcome from both ML and structural biology communities! Please open an issue or pull request on GitHub. Run pre-commit run --all-files before submitting.
diff-biophys is the differentiable engine powering the higher-level tools in this ecosystem:
Since Diff-Biophys is built entirely on JAX, we highly recommend these resources to get the most out of the library:
MIT License — see LICENSE for details.
@software{diff_biophys,
author = {Elkins, George},
title = {diff-biophys: Differentiable biophysics kernels for JAX},
year = {2026},
publisher = {Zenodo},
version = {v0.2.0},
doi = {10.5281/zenodo.20673558},
url = {https://doi.org/10.5281/zenodo.20673558}
}| Back | FazBrowse Home | New Git URL |