Skip to main content

Biotrainer

License Documentation GitHub release (latest by date)

biotrainer logo
Biological prediction models made simple.

Overview

Biotrainer is an open-source framework that simplifies machine learning model development for protein analysis. It provides the following modules:

  • Training: Easy to use training and inference pipelines for protein feature prediction
  • Embedding: Built-in support for protein language models (ProtT5, ESM-2, ESM-C, ...) and baselines (blosum62, one_hot_encoding, ...)
  • BioEngineer: Zero-shot predictions and mutation generation of protein sequences
  • AutoEval: Automated evaluation of protein language models on curated downstream tasks

Quick Start

1. Installation

Install using pip:

pip install biotrainer

Manual installation using uv:

# First, install uv if you haven't already:
pip install uv

# Create and activate a virtual environment
uv venv
source .venv/bin/activate  # On Unix/macOS
# OR
.venv\Scripts\activate  # On Windows

# Basic installation
uv pip install -e .

# Installing with jupyter notebook support:
uv pip install -e ".[jupyter]"

# Installing with onnxruntime support (for onnx embedders and inference):
uv pip install -e ".[onnx-cpu]"    # CPU version
uv pip install -e ".[onnx-gpu]"    # CUDA version
uv pip install -e ".[onnx-mac]"    # CoreML version (for Apple Silicon)

# You can also combine extras:
uv pip install -e ".[jupyter,onnx-cpu]"

# For Windows users with CUDA support:
# Visit https://pytorch.org/get-started/locally/ and follow GPU-specific installation, e.g.:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

2. Basic Usage

# Training
biotrainer train --config examples/sequence_to_class/config.yml

# Inference after Training
python3
>>> from biotrainer.training import BiotrainerModel
>>> model = BiotrainerModel.from_training_result("output/out.yml")
>>> predictions = model.predict("SEQUENCE")

# AutoEval
autoeval_report = (AutoEval(embedder_name="facebook/esm2_t6_8M_UR50D", development_mode=True).
                    pbc_supervised_contact().
                    pbc_zeroshot_contact().
                    pbc_supervised().
                    pgym(zero_shot_method=ZeroShotMethod.MASKED_MARGINALS).
                    run())
autoeval_report.summary(development_mode=False)

3. Quick Start Datasets

Features

Supported Training Protocols

  • Residue-level classification (residue_to_class)
  • Residue-level regression (residue_to_value) [BETA]
  • Sequence-level classification (sequence_to_class)
  • Sequence-level regression (sequence_to_value)
  • Residues-level classification (residues_to_class, like sequence_to_class with per-residue embeddings)
  • Residues-level regression (residues_to_value, like sequence_to_value with per-residue embeddings)

Autoeval

The biotrainer autoeval module allows automatical evaluation of a protein language model on downstream tasks. You can find public results (wip!) on the autoeval dashboard and compare them to your own. Learn more in the autoeval examples.

Documentation

Tutorials

Detailed Guides

Example Training Configuration

protocol: residue_to_class
input_file: input.fasta
model_choice: CNN
optimizer_choice: adam
learning_rate: 1e-3
loss_choice: cross_entropy_loss
use_class_weights: True
num_epochs: 200
batch_size: 128
embedder_name: Rostlab/prot_t5_xl_uniref50

Docker Support

# Run using pre-built image
docker run --gpus all --rm \
    -v "$(pwd)/examples/docker":/mnt \
    -u $(id -u ${USER}):$(id -g ${USER}) \
    ghcr.io/sacdallago/biotrainer:latest /mnt/config.yml

More information on running docker with gpus: Nvidia container toolkit

Getting Help

Citation

@inproceedings{
sanchez2022standards,
title={Standards, tooling and benchmarks to probe representation learning on proteins},
author={Joaquin Gomez Sanchez and Sebastian Franz and Michael Heinzinger and Burkhard Rost and Christian Dallago},
booktitle={NeurIPS 2022 Workshop on Learning Meaningful Representations of Life},
year={2022},
url={https://openreview.net/forum?id=adODyN-eeJ8}
}

Download files

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

Source Distribution

biotrainer-2.0.0.tar.gz (175.3 kB view details)

Uploaded Source

Built Distribution

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

biotrainer-2.0.0-py3-none-any.whl (237.9 kB view details)

Uploaded Python 3

File details

Details for the file biotrainer-2.0.0.tar.gz.

File metadata

  • Download URL: biotrainer-2.0.0.tar.gz
  • Upload date:
  • Size: 175.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for biotrainer-2.0.0.tar.gz
Algorithm Hash digest
SHA256 166470d45fbdb9577da0fde8f688ee5d05c30321f111b5e4dee1139daf203d02
MD5 0bb09166f53f289813a831392e9bb61e
BLAKE2b-256 231ab8aa02d6c250b9a9789210788dceeb77a0cfcbf2c8c11598327e67e4d252

See more details on using hashes here.

File details

Details for the file biotrainer-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: biotrainer-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 237.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for biotrainer-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ab6bb57fcd87f31c465653c7928c2ceebfe464b49e5d80675ea68cc0668469b
MD5 af723f4b3b483e238aff79c284118272
BLAKE2b-256 d34fd87974bb68b67c88cb5296fad6b631553ccd6a29ce8e4aba29b4af662567

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.4.0

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Supported by

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