Skip to main content

Cryo-EM Ensemble Optimization using JAX and OpenMM for Molecular Dynamics simulations.

Project description

Cryo-electron microscopy ensemble optimization using individual particles and physical constraints

Summary

CryoJAX ensemble optimization is a module of the cryoJAX library, a JAX and Equinox-based library for differentiable cryo-EM forward models. The purpose of this library is to provide a framework for optimizing structural ensembles, defined as a weighted discrete set of atomic structures, given a set of cryo-EM images. To do this, we implement an algorithm inspired by projected gradient descent, where the optimization step is performed by comparing the ensemble to the cryo-EM dataset, and the projection step is done through Steered Molecular Dynamics using the popular OpenMM library. Details and results are available in our preprint. Instructions for reproducing the paper results are provided below.

Full documentation is available at flatironinstitute.github.io/cryojax-ensemble-optimization.

Installation

Our library has been tested on the latest Ubuntu version. Availability for other platforms is dependent on the availability of OpenMM and JAX.

CPU Installation

Our library can be installed to be used with a CPU via pip.

pip install cryojax_eo

We recommend using a freshly created virtual environment to install our library. A CPU installation is only recommended for dataset simulation, as OpenMM is built for GPU, and simulations will take a long time if run on CPU.

GPU Installation

We recommend installing our library using conda (or one of its variants), as matching JAX's and OpenMM's CUDA versions can be difficult otherwise. Here we show an example of how to install our library with mamba:

mamba create -n cryojax_eo_env python==3.11
mamba activate cryojax_eo_env
mamba install -c conda-forge openmm cuda-version==12.4 # Insert your cuda version!
pip install --upgrade "jax[cuda12]"
pip install cryojax_eo

To find your CUDA version, you can run nvidia-smi in a terminal. The CUDA version will appear in the top right corner of the output.

Note: OpenMM is not required for all our utilities. Data simulation and Ensemble Reweighting only require JAX!

Apptainer/Singularity Installation (HPC clusters)

For HPC environments where conda is unavailable or installation is restricted, we provide an Apptainer definition file at container/cryojax_eo.def. Pre-built images are hosted on Sylabs Cloud.

Option 1 — Pull a pre-built image:

apptainer pull library://davidsilva27/default/cryojax_eo:latest

Option 2 — Build from the definition file:

apptainer build --fakeroot container/cryojax_eo.sif container/cryojax_eo.def

Running commands with the container:

apptainer exec --nv --bind /path/to/data:/path/to/data path/to/container/cryojax_eo.sif \
    run_ensemble_optimization --config config.yaml

The --nv flag exposes the host GPU to the container. The --bind flag mounts a directory from the host into the container, which is required if your data lives outside your home directory (e.g., on a scratch or Ceph filesystem). Replace /path/to/data with the relevant path on your system.

To avoid typing --bind every time, you can set the following environment variable in your ~/.bashrc:

export APPTAINER_BIND=/path/to/data:/path/to/data

Cryo-EM Ensemble Optimization Input

See the input documentation

Cryo-EM Ensemble Reweighting Input

See the input documentation

Cryo-EM heterogeneous dataset simulation

See the input documentation

Reproducing Paper Results

All the necessary data, atomic models, config files, and instructions to reproduce our results are available in Zenodo.

Contact

Please submit any bug reports, feature requests, or general feedback as a GitHub issue or discussion.

Contributing

If you are contributing to this project, please install the package with the following command:

pip install -e ".[dev]"

This will install the required dependencies for development, the most important being Ruff and pre-commit. After installation, activate your environment and install the pre-commit hooks by running

pre-commit install

Make sure that your code is formatted according to our guidelines by running:

pre-commit run --all-files

This will make sure the code is formatted correctly, fix whatever can be automatically fixed, and tell you if something else needs to be fixed.

Acknowledgements

We thank Michael O'Brien, Miro Astore, Lars Dingeldein, Wai Shing Tang, Aaditya Rangan, and Sonya Hanson for helpful discussions.

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

cryojax_eo-0.2.4rc1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

cryojax_eo-0.2.4rc1-py3-none-any.whl (90.2 kB view details)

Uploaded Python 3

File details

Details for the file cryojax_eo-0.2.4rc1.tar.gz.

File metadata

  • Download URL: cryojax_eo-0.2.4rc1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cryojax_eo-0.2.4rc1.tar.gz
Algorithm Hash digest
SHA256 cce674cc492cef083331e379e3fb9c64bdf3f8b63bc6a157c13c9ad4c0018ee3
MD5 f65a98a98f9605e7f1a9e1f35c2bc3cc
BLAKE2b-256 7ca1438f34f913cb55bfa15e700ea53ca3cb71ab6d25d5255d6b4a7548c6ef1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cryojax_eo-0.2.4rc1.tar.gz:

Publisher: publish.yml on flatironinstitute/cryojax-ensemble-optimization

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

File details

Details for the file cryojax_eo-0.2.4rc1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for cryojax_eo-0.2.4rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bedec23b61ec1c7d10c5f66080c3bed709c645547ab08a083fbbb66cd7345d8
MD5 55310f9101cbf11dfa32977f56f1bf17
BLAKE2b-256 30287b0723cdad3bbc9470873d53a035254a99df75b7057fb83637e1676b65f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cryojax_eo-0.2.4rc1-py3-none-any.whl:

Publisher: publish.yml on flatironinstitute/cryojax-ensemble-optimization

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