Skip to main content

Differentiable VAE-based structural ensemble prediction for disordered proteins

Project description

🧬 DiffEnsemble

Tests Docs codecov License: MIT Python versions JAX Ruff Checked with mypy

DiffEnsemble is a high-performance, differentiable framework for predicting structural ensembles of Intrinsically Disordered Proteins (IDPs). By combining generative deep learning with hardware-accelerated biophysics, it bridges the gap between protein sequence and solution-state experimental data.


🚀 For Machine Learning Engineers

Generative Architecture

DiffEnsemble utilizes a Variational Autoencoder (VAE) implemented in Flax to learn the conformational manifold of flexible proteins.

  • Encoder: Maps sequence-derived features to a latent Gaussian distribution $(\mu, \sigma)$.
  • Latent Space: Enables efficient sampling of diverse structural states.
  • Decoder: Predicts a set of $(\phi, \psi)$ backbone torsions that define the protein's fold.

End-to-End Differentiability

Built entirely on JAX, the entire pipeline—from the VAE weights to the final biophysical observable—is auto-differentiable.

  • Biophysical Loss: We compute the gradient of the error between predicted ensemble-averaged spectra and experimental data (SAXS/NMR) to update model weights directly.
  • Vectorized Sampling: Leveraging JAX's vmap, we generate and process ensembles of 100+ structures in parallel on GPUs/TPUs.

🧪 For Structural Biologists

The "Ensemble" Concept

Unlike AlphaFold, which predicts a single static structure, IDPs exist as a "cloud" of interconverting conformations. DiffEnsemble predicts this structural ensemble, which is essential for understanding proteins that do not have a stable fold.

Differentiable Physics Engine

We use the NeRF (Natural Extension Reference Frame) algorithm to convert predicted torsions into 3D Cartesian coordinates. These coordinates are then passed to DiffBiophys kernels to calculate:

  • SAXS: Small-Angle X-ray Scattering profiles via the Debye formula.
  • NMR: Residual Dipolar Couplings (RDCs) and Chemical Shifts.

Scientific Validation

DiffEnsemble is rigorously validated against peer-reviewed standards:

  • Sic1 Benchmark: Recapitulates the dimensions of the Sic1 IDP as determined by the Forman-Kay Group (JACS 2020).
  • CASP16 T1200: Benchmarked against the Montelione Group's SpA domain-linker-domain challenge using RDC Q-factors.
  • Polymer Physics: Obeys Flory's scaling laws ($R_g \propto N^{0.588}$) for random coils in a good solvent.

🛠️ Quick Start

import jax
import jax.numpy as jnp
from diff_ensemble.model import EnsembleVAE

# Initialize model (90 residues, 32 latent dims, 100 models)
model = EnsembleVAE(seq_len=90, latent_dim=32, ensemble_size=100)
rng = jax.random.PRNGKey(0)

# Generate a structural ensemble from sequence features
batch_x = jnp.ones((1, 90, 4)) # Example features
torsions, mean, logvar = model.apply({"params": params}, batch_x, rng)
coords = model.generate_coordinates(torsions) # Shape: (100, 270, 3)

# Save the cloud to a multi-model PDB for visualization
from diff_ensemble.io import save_ensemble_to_pdb
save_ensemble_to_pdb(coords, "ensemble_cloud.pdb")

📚 References

  1. Kingma & Welling (2013): Auto-Encoding Variational Bayes.
  2. Gomes et al. (2020): Conformational Ensembles of an IDP Consistent with NMR, SAXS, and smFRET (Forman-Kay Lab).
  3. McBride et al. (2025): Predicting Pose Distribution of Protein Domains (Montelione Lab).
  4. Parsons et al. (2005): Practical conversion from torsion space to Cartesian space for in silico protein synthesis. J. Comput. Chem. 26(10), 1063–1068.

🛠 Software Architecture

The project is structured for modularity and high-performance execution:

  • diff_ensemble/model.py: The Flax-based VAE architecture (Encoder/Decoder).
  • diff_ensemble/observables.py: Forward biophysical kernels and multi-objective loss functions.
  • diff_ensemble/train.py: The training orchestration and optimization loop using Optax.
  • diff_ensemble/io.py: PDB trajectory export and multi-model stack management.
  • diff_ensemble/ensemble.py: High-level API for population-weighted averaging.

🤝 Contributing & Support

We welcome contributions from both the Machine Learning and Structural Biology communities!

  • Bugs/Features: Please open an issue on the GitHub repository.
  • Questions: Visit our Documentation or reach out via GitHub Discussions.

⚖️ License

This project is licensed under the MIT License - see the LICENSE file for details.


🔗 Related Projects

DiffEnsemble depends on and integrates with:

  • diff-biophys — Differentiable JAX kernels for SAXS/NMR (core dependency)
  • synth-pdb — Synthetic structure generation for training data
  • synth-nmr — NMR observables for experimental targets
  • synth-saxs — SAXS profile simulation
  • torsion-tuner — Single-structure refinement counterpart

📖 Citation

@software{diff_ensemble,
  author  = {Elkins, George},
  title   = {DiffEnsemble: Differentiable structural ensemble prediction for IDPs},
  year    = {2026},
  url     = {https://github.com/elkins-lab/diff-ensemble},
  version = {0.1.3}
}

📖 Tutorials

Get started immediately with our interactive Jupyter notebooks:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diff_ensemble-0.1.3.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diff_ensemble-0.1.3-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file diff_ensemble-0.1.3.tar.gz.

File metadata

  • Download URL: diff_ensemble-0.1.3.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for diff_ensemble-0.1.3.tar.gz
Algorithm Hash digest
SHA256 eb9217f7b1c9c6f43dc89e20d18e194116834691f522d40a6efdd827202180dc
MD5 9970904b114086ecd46ed0b067c567e0
BLAKE2b-256 0da67ac3e70446bbc05fa60cdefe6eadb4fccb705d6bbd4361c61d90deb6b44b

See more details on using hashes here.

Provenance

The following attestation bundles were made for diff_ensemble-0.1.3.tar.gz:

Publisher: publish.yml on elkins-lab/diff-ensemble

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diff_ensemble-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: diff_ensemble-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for diff_ensemble-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a66940c1f80a1bfcf80140a0ff4baeeca13d7ef6818d4863fabd246d9a77a80f
MD5 e4f4641bc76a8df18777df06b38a3010
BLAKE2b-256 833860d4e225408f91870fa3a59a2ed208c4fedb450547753950a1ef407c46be

See more details on using hashes here.

Provenance

The following attestation bundles were made for diff_ensemble-0.1.3-py3-none-any.whl:

Publisher: publish.yml on elkins-lab/diff-ensemble

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page