DiffBiophys 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
To bridge the gap between static structural models and experimental solution-state data by providing a "differentiable bridge." This allows researchers to:
- Optimize protein structures directly against experimental spectra via gradient descent.
- Train machine learning models using physics-informed loss functions.
- Accelerate large-scale biophysical simulations on GPUs and TPUs.
-
NeRF (Natural Extension Reference Frame): Differentiable conversion from internal coordinates (
$\phi, \psi, \omega$ , bond lengths/angles) to Cartesian XYZ. - Kabsch Alignment: Differentiable optimal superposition using SVD.
- Torsion Analysis: Vectorized calculation of all backbone and side-chain dihedrals.
-
Debye Formula:
$O(N^2)$ inter-atomic interference summation. - Hydration Shell Correction: Excluded-volume solvent subtraction (Fraser et al. 1978).
-
Hardware Acceleration: GPU-optimized pairwise distance kernels via JAX
vmap. - Use Case: Fitting structure compactness and radius of gyration to solution-state X-ray scattering curves.
- Residual Dipolar Couplings (RDCs): Differentiable Saupe tensor alignment and coupling calculation. Includes SVD-based tensor fitting.
- Chemical Shifts: Differentiable ring-current (Johnson-Bovey) shielding and softmax-weighted secondary structure CΞ± shift predictor.
- Karplus J-coupling: Parameterizable 3J coupling equation (Vuister & Bax 1993 defaults).
- Use Case: Refining side-chain packing and domain orientations against high-resolution NMR data.
- Matrix-Method Simulation (planned): Differentiable simulation of peptide bond transition dipole coupling via DeVoe theory.
- Status:
β οΈ Not yet implemented β raisesNotImplementedError.
- Backend: JAX (XLA-compiled) β supports CPU, GPU, and TPU.
- Parallelism: Native support for
vmap(vectorization across ensembles/trajectories) andpmap(multi-device execution). - Differentiability: Forward and reverse-mode autodiff through all kernels.
- Interoperability: JAX arrays are compatible with NumPy and can be exchanged with PyTorch via
dlpack(user-managed conversion).
- Differentiable NeRF and Kabsch alignment.
- GPU-accelerated Debye formula for SAXS with hydration shell correction.
- Unit tests verifying parity with
synth-pdbNumPy implementations.
- Differentiable RDC and Karplus kernels.
- Differentiable Johnson-Bovey ring current model.
- Integration with
synth-nmrparameter libraries (optional dependency).
- Example notebooks for structure refinement via gradient descent.
- Plugin for
torch-based AI models to use biophysical loss functions. - Full CD matrix-method implementation (DeVoe theory).
- Full support for BinaryCIF streaming.
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 (planned)
β βββ ensemble.py # Ensemble averaging API
βββ tests/ # Parity, gradient, and scientific validation checks
βββ examples/ # 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:
- synth-pdb β Synthetic structure generation (uses NumPy implementations)
- synth-nmr β NMR observables (optional dependency)
- synth-saxs β SAXS profile simulator
- diff-ensemble β IDP ensemble VAE (depends on diff-biophys)
- TorsionTuner β GNN refinement (depends on diff-biophys)
- resonance-flow β NMR-guided folding (depends on diff-biophys)
MIT License β see LICENSE for details.
@software{diff_biophys,
author = {Elkins, George},
title = {diff-biophys: Differentiable biophysics kernels for JAX},
year = {2024},
url = {https://github.com/elkins/diff-biophys},
version = {0.1.2}
}