Skip to content

Installation¤

DiffBio requires Python 3.11+ and works on Linux, macOS, and Windows (via WSL).

Quick Install¤

Install DiffBio from PyPI:

pip install diffbio

Install from Source¤

For the latest development version:

git clone https://github.com/avitai/DiffBio.git
cd DiffBio
pip install -e ".[dev]"

If you use uv for faster package management:

uv pip install diffbio

Or for development:

git clone https://github.com/avitai/DiffBio.git
cd DiffBio
uv sync --all-extras

Dependencies¤

DiffBio depends on the following core packages:

Package Purpose
JAX Automatic differentiation and XLA compilation
Flax Neural network library for JAX
Datarax Composable data pipeline framework
jaxtyping Type annotations for JAX arrays

GPU Support¤

For GPU acceleration, install JAX with CUDA support:

pip install -U "jax[cuda12]"
pip install -U "jax[cuda11_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

Verify GPU is available:

import jax
print(jax.devices())  # Should show GPU devices

Verify Installation¤

import diffbio
from diffbio.operators.alignment import SmoothSmithWaterman, SmithWatermanConfig
from diffbio.operators.alignment import create_dna_scoring_matrix

print(f"DiffBio version: {diffbio.__version__}")

# Test operator creation
config = SmithWatermanConfig(temperature=1.0)
scoring = create_dna_scoring_matrix(match=2.0, mismatch=-1.0)
aligner = SmoothSmithWaterman(config, scoring_matrix=scoring)
print("Installation successful!")

Development Installation¤

For contributing to DiffBio:

git clone https://github.com/avitai/DiffBio.git
cd DiffBio

# Install with all development dependencies
pip install -e ".[dev,docs]"

# Install pre-commit hooks
pre-commit install

Running Tests¤

# Run all tests
pytest -v

# Run with coverage
pytest --cov=src/diffbio --cov-report=term-missing

Building Documentation¤

# Serve docs locally
mkdocs serve

# Build static site
mkdocs build

Troubleshooting¤

Common Issues¤

JAX not using GPU:

Check that CUDA is properly installed and JAX can see it:

import jax
print(jax.default_backend())  # Should print 'gpu' or 'cuda'

Import errors:

Ensure all dependencies are installed:

pip install --upgrade diffbio[all]

Memory issues with large sequences:

DiffBio operators use JAX's XLA compilation which can be memory-intensive for very long sequences. Consider:

  • Using smaller batch sizes
  • Chunking long sequences
  • Enabling memory-efficient attention patterns

For additional help, please open an issue on GitHub.