bioemu2 README

项目的 README,来自 github.com/microsoft/bioemu2。合并为一个 markdown 文件:README.md。

BioEmu2 logo

BioEmu2

A foundation model for biomolecular structure and dynamics

Predict folded structures, sample equilibrium ensembles, and propagate structures forward in time.

Installation · Quick start · Tutorials · Documentation


BioEmu2 simulating the PUMA BH3 peptide binding MCL-1

BioEmu2 simulating the PUMA BH3 peptide binding MCL-1.


BioEmu2, short for "biomolecular emulator", is developed by Microsoft Research AI for Science.

Key features include:

System requirements

BioEmu2 requires Linux and an NVIDIA GPU; macOS and Windows are not supported. The cuda extra installs CUDA 13 cuEquivariance, which requires compute capability 7.5 or newer, such as NVIDIA T4, A100, RTX A6000, L40S, H100, and B200 (CUDA 13 release notes). GPUs with compute capability 7.0 (Volta, such as NVIDIA V100) need the CUDA 12 installation instead. We have tested V100 (compute capability 7.0), T4 (7.5, with the CUDA 12 installation), A100 and RTX A6000 (8.0 and 8.6), and B200 (10.0); other eligible GPUs have not been verified end to end. Check your GPU's compute capability with nvidia-smi --query-gpu=name,compute_cap --format=csv.

Context-parallel sampling requires at least four GPUs.

Installation

Use Python 3.12, 3.13, or 3.14 on a supported Linux machine. We recommend installing BioEmu2 in an isolated virtual environment or conda environment. To install in an isolated virtual environment, create and activate it from the repository root:

python3.12 -m venv .venv
source .venv/bin/activate

Replace python3.12 with the name or path of your Python 3.12, 3.13, or 3.14 executable if needed. Use python -m pip so packages are installed into the active Python environment rather than a different interpreter's pip.

Run the installation command for your GPU from the repository root. For GPUs with compute capability 7.5 or newer, such as NVIDIA T4, A100, RTX A6000, L40S, H100, and B200, use the cuda extra:

python -m pip install ".[cuda]"

Compute capability 7.0 (Volta, such as NVIDIA V100) is the oldest supported; on these GPUs, use the cuda12 extra with the PyTorch CUDA 12.6 package index:

python -m pip install ".[cuda12]" \
  --extra-index-url https://download.pytorch.org/whl/cu126

GPUs with compute capability below 7.0 are not supported.

We tested BioEmu2 and evaluated its benchmark metrics with Python 3.12. Python 3.13 and 3.14 pass the test suite, but we have not evaluated benchmark metrics with them.

For development, see DEVELOPER.md.

For Jupyter or VS Code notebooks, follow the notebook quickstart to install visualization dependencies and register a kernel.

Quick start

CLI

Sample eight equilibrium conformations of adenylate kinase (PDB 1AKE):

bioemu2 sample-equilibrium \
  --pdb-id 1AKE \
  --out outputs/adk

To sample a system that is not a PDB entry, pass a system YAML file with --system instead of --pdb-id. Start from one of the example system YAML files.

Or predict a folded structure from a PDB entry:

bioemu2 predict-structure \
  --pdb-id 1UBQ \
  --num-samples 1 \
  --out outputs/ubiquitin

Propagate each sampled adenylate kinase conformation by 1 ns:

bioemu2 propagate \
  --x0-cif outputs/adk/topology.cif \
  --x0-xtc outputs/adk/samples.xtc \
  --lag-time-ns 1 \
  --out outputs/adk-propagated

Run bioemu2 --help to list all commands.

Python API using EmuSession

Construct an EmuSession to sample and propagate structures:

from pathlib import Path

from bioemu2 import EmuSession, System, load_model, save_frames

model = load_model()

# Predict a folded structure for ubiquitin.
ubiquitin = System.from_pdb_id("1UBQ")
prediction = EmuSession(ubiquitin, model=model, mode="structure").sample(num_samples=1)
save_frames(prediction, Path("outputs/ubiquitin"))

# Sample equilibrium conformations of adenylate kinase.
adk = System.from_pdb_id("1AKE")
emu = EmuSession(adk, model=model, mode="equilibrium")
samples = emu.sample(num_samples=8)
save_frames(samples, Path("outputs/adk"))

# Propagate each adenylate kinase conformation by 1 ns.
endpoints = emu.propagate(samples, lag_time_ns=1.0)
save_frames(endpoints, Path("outputs/adk-propagated"))

save_frames() writes samples.xtc and topology.cif to each output directory.

See define molecular systems, predict and sample structures, and propagate structures for more options. The functional Python APIs provide high-level sampling and propagation functions similar to the CLI commands, plus lower-level workflows for explicit control of embeddings and samplers.

More workflows

Steer sampling

Choose a steering sampler to favour structures with desired properties:

bioemu2 sample-equilibrium \
  --system src/bioemu2/assets/examples/systems/myoglobin_101m.yaml \
  --out outputs/myoglobin \
  --sampler edm_gd

See steer sampling and define steering potentials to select an algorithm and configure its objective.

Sample large structures across multiple GPUs

Context parallelism distributes the model's pair representations across a square mesh of GPUs, reducing the memory required on each device:

CUDA_VISIBLE_DEVICES=0,1,2,3 \
torchrun --standalone --nproc-per-node=4 \
  --module bioemu2.cp sample-equilibrium \
  --pdb-id 1AKE \
  --checkpoint bioemu2-preview \
  --num-samples 3 \
  --out outputs/adk-cp

See sample large structures with context parallelism for mesh requirements, the Python API, and current limitations.

Inspect and subsample MSAs

Retrieve an alignment from ColabFold or load your own A3M files, inspect the raw sequences, and select or randomly subsample rows with Python indexing. Pass the resulting MSA directly to EmuSession to control the alignment used for structure prediction, equilibrium sampling, or propagation without manually constructing embeddings.

See use multiple sequence alignments for local-file loading, MSA subsampling, and custom-MSA inference.

Tutorials

Notebook quickstart

The examples directory contains complete workflows as regular Python files split into executable cells with # %% markers. This Python Interactive format provides notebook-style cells while keeping the examples as plain .py files. They require a Linux machine with a supported NVIDIA GPU and network access.

Activate a Python environment as described in installation. From the repository root, install BioEmu2 with the visualization dependencies and register a kernel. The viz extra includes ipykernel and py3Dmol:

python -m pip install ".[cuda,viz]"
python -m ipykernel install --user --name bioemu2 --display-name "BioEmu2"

On compute capability 7.0 GPUs, such as NVIDIA V100, replace the first command with:

python -m pip install ".[cuda12,viz]" \
  --extra-index-url https://download.pytorch.org/whl/cu126

Select the BioEmu2 kernel in Jupyter or VS Code. If registration succeeds but the kernel does not appear in VS Code, restart VS Code and try again. To check that it uses the environment you installed into, run import sys; print(sys.executable) in a cell. The examples load system YAML from the installed bioemu2 package, regardless of the working directory. Relative outputs/ paths are written under the current working directory.

Open a single-GPU example in VS Code and select Run Cell, or run Jupyter: Run Current File in Interactive Window from the Command Palette. Launch the context-parallel example with torchrun as described in the context-parallel sampling guide.

The # %% markers are ordinary Python comments, so you can also run a single-GPU example as a regular script, for example python examples/sample_structures.py. The script computes the same results and writes the same output files as running the cells interactively. 3D structure views are not displayed. Matplotlib plots open in separate windows if a graphical display is available, and the script continues after you close them.

To run the cells interactively without VS Code, convert an example to a Jupyter notebook with Jupytext and open it in JupyterLab:

python -m pip install jupytext jupyterlab
jupytext --to notebook examples/sample_structures.py
jupyter lab examples/sample_structures.ipynb

Select the BioEmu2 kernel, then run individual cells or choose Run All Cells from the Run menu.

In VS Code, you can instead run Jupyter: Export Current Python File as Jupyter Notebook from the Command Palette. Generated .ipynb files are ignored by Git.

License

BioEmu2 is released under the MIT License. It includes code and reference data adapted from other open-source projects; the third-party notices identify those components and their licenses.

bioemu2 (microsoft/bioemu2)

正在搜索数据库…

这是什么?BioEmu2(生物分子模拟器)是 Microsoft Research AI for Science 的基础模型,可以预测折叠后的蛋白质/核酸结构,采样平衡态结构系综,并沿时间向前推演结构的变化。
它是 Python 库、命令行工具,还是两者都是?两者都是:你可以把它作为 Python 包安装,然后通过命令行运行(例如 bioemu2 sample),也可以通过以 EmuSession 对象为核心的 Python API 以编程方式调用。
我该怎么安装和运行?在 Linux 上创建 Python 3.12/3.13/3.14 虚拟环境,然后在仓库根目录下运行带有对应 GPU 选项(cuda 或 cuda12)的 pip install 命令,之后即可使用 bioemu2 命令行工具或 EmuSession 采样结构。
运行它需要什么硬件?一台 Linux 机器,配备计算能力(compute capability)7.0 或更高的 NVIDIA GPU(例如 V100、T4、A100、H100、B200);低于 7.0 的 GPU 不受支持,上下文并行采样至少需要四块 GPU。
它能在 macOS 或 Windows 上运行吗?任何 NVIDIA GPU 都可以吗?不能。完全不支持 macOS 和 Windows,计算能力低于 7.0 的 GPU 也无法运行;像 V100 这类较老的 Volta 显卡需要单独的 CUDA 12 安装路径,而不能使用默认的 CUDA 13 版本。
这是为谁设计的?面向计算生物学家和研究人员,适用于需要预测蛋白质结构、采样构象系综,或在不使用经典物理模拟的情况下进行分子动力学式推演的场景。
它能在笔记本 GPU 上运行,还是只能用数据中心级显卡?它需要独立的 NVIDIA GPU,计算能力达到 7.5 及以上(如 T4、A100、RTX A6000、L40S、H100、B200)才能使用标准的 CUDA 13 安装方式;若走 CUDA 12 路径,则可支持计算能力为 7.0 的 V100。计算能力不足的笔记本消费级 GPU 不受支持。
什么是 EmuSession?它是主要的 Python API 对象,用于构建分子体系,然后只需调用几个方法即可采样、推演或引导其结构,无需使用命令行。
引导采样(steering sampling)能做什么?你可以选择一个引导采样器并配置势函数,使 BioEmu2 生成的结构朝向期望的性质偏移,而不是仅仅采样无条件的平衡态系综。
对于单块 GPU 放不下的大结构,它是怎么处理的?上下文并行会将模型的对表示(pair representations)拆分到由多块 GPU(至少四块)组成的方形网格上,从而让你采样比单块 GPU 显存所能容纳的更大的结构。
我能使用自己的序列比对结果吗?可以。你可以从 ColabFold 获取比对结果,或加载自己的 A3M 文件,查看并子采样序列,然后将得到的 MSA 直接输入 EmuSession,以控制结构预测或采样。
作者
microsoft
大小
6.6 MB
星标
519
时长
2个月
提交 · 90 天