Structural Evolution

Model Introduction

Structural Evolution is an unsupervised protein and antibody mutation recommendation workflow based on a structure-informed protein language model. It takes a PDB/CIF structure of a protein or protein complex as input, scores candidate mutation sequences under structural conditions with ESM-IF1, and selects high-probability substitutions from deep mutational scanning candidates to assist protein and antibody sequence optimization.

Paper:

Unsupervised evolution of protein and antibody complexes with a structure-informed language model
https://doi.org/10.1126/science.adk8946

Model Description

Structural Evolution uses the structure-conditioned language model ESM-IF1 to recommend mutations for a target chain in a given protein structure. The program first extracts the target chain's wild-type sequence from the input PDB/CIF and generates single-point deep mutational scanning candidates. It then calculates the log-likelihood of each candidate under a single-chain or multichain backbone condition and selects recommended mutations in descending score order.

Use Cases

Use case Description
Single-point protein mutation recommendation Select high-probability amino acid substitutions from structure information
Antibody sequence optimization Recommend structure-conditioned mutations for antibody heavy and light chains separately
Protein complex optimization Evaluate target-chain mutations in a multichain backbone context
Deep mutational scanning candidate screening Score all single-point mutations and output high-scoring candidates

Usage

1. Using OneCode

Experience intelligent one-click AI4S programming in the OneCode online environment:

Try intelligent one-click AI4S programming

2. Manual Installation and Usage

Hardware Requirements

  • Structural Evolution supports inference on CPUs and GPUs.
  • A GPU/DCU is recommended for ESM-IF1 inference to accelerate candidate sequence scoring.
  • Larger protein complexes or larger mutation candidate libraries require more GPU/DCU memory and host memory.
  • If no GPU/DCU is available, you can explicitly use the CPU with --nogpu, but execution will be significantly slower.

Set Up the Runtime Environment

DCU Environment

# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311

# Install with uv support
pip install onescience[bio] \
  -i http://mirrors.onescience.ai:3141/pypi/simple/ \
  --trusted-host mirrors.onescience.ai

Environment Notes

  • If you encounter missing dependencies or version incompatibilities during execution, refer to the dependency versions specified in environment.yml and install or adjust the relevant dependencies as needed.

Prepare the Weights

Complete Structural Evolution inference only requires the additional ESM-IF1 model weights. Standard mutation recommendation does not require downloading any additional training dataset from the paper.

1) ESM-IF1 Model Weights

Download the ESM-IF1 weights:

https://zenodo.org/records/12631662

Command:

wget -P ~/.cache/torch/hub/checkpoints \
  https://zenodo.org/records/12631662/files/esm_if1_20220410.zip

unzip ~/.cache/torch/hub/checkpoints/esm_if1_20220410.zip \
  -d ~/.cache/torch/hub/checkpoints/

After extraction, make sure that the following file exists:

~/.cache/torch/hub/checkpoints/
└── esm_if1_20220410.pt

The file must exist.

scripts/recommend.py always loads the model from:

~/.cache/torch/hub/checkpoints/esm_if1_20220410.pt

loads the model from this path. If you save the weights elsewhere, update the checkpoint path in the code.

3. Quick Start

Download the Model Package

hf download OneScience-Group/structural-evolution \
  --local-dir ./structural-evolution

cd structural-evolution
  • Structural Evolution additionally depends on the ESM-IF1 model weights. Prepare esm_if1_20220410.pt as described in "Prepare the Weights" and make sure that the checkpoint path in the code matches its actual location.

Quick Verification

View the inference options:

python scripts/recommend.py --help

Run a quick verification with the official example structure:

python scripts/recommend.py \
  scripts/examples/7mmo_abc_fvar.pdb \
  --chain A \
  --n 10

Example Data

The official repository provides an example structure in:

scripts/examples/

The directory contains:

scripts/examples/
└── 7mmo_abc_fvar.pdb

This structure contains the LYCoV-1404 antibody variable region and SARS-CoV-2 RBD, and demonstrates mutation recommendation for an antibody heavy chain.

For your own tasks, prepare:

PDB or CIF structure of a protein or protein complex
+
Target chain ID

For example:

structure.pdb
chain A

Inference Examples

Basic Mutation Recommendation

The simplest way to run it is:

python scripts/recommend.py \
  /path/to/structure.pdb \
  --chain A

Default output:

Top 10 mutations
maxrep = 1
multichain backbone = True

This recommends 10 mutations by default and allows each original residue position to appear at most once.

Antibody Example

Official example:

python scripts/recommend.py \
  scripts/examples/7mmo_abc_fvar.pdb \
  --chain A \
  --seqpath scripts/examples/7mmo_chainA_lib.fasta \
  --outpath scripts/examples/7mmo_chainA_scores.csv \
  --upperbound 109 \
  --offset 1

Where:

Parameter Description
--chain Target chain ID
--seqpath Output path for the generated deep mutational scanning FASTA
--outpath Output path for the CSV containing scores for all mutation candidates
--n Number of mutations to recommend; default: 10
--maxrep Maximum number of times the same position may appear in the recommendations; default: 1
--upperbound During final recommendation, consider only positions below this residue number
--offset Offset correction for PDB residue numbering
--order Specify chain order in a multichain structure
--multichain-backbone Use all chains as the structural context
--singlechain-backbone Use only the target chain backbone
--nogpu Force CPU execution

In the antibody example above, --chain A specifies the heavy chain. --upperbound 109 excludes mutations in the final framework region. Because the input structure lacks the first residue, --offset 1 corrects the mutation numbering.

Customize the Number of Recommendations

For example, output the top 20 candidates and allow the same position to appear at most twice:

python scripts/recommend.py \
  /path/to/your_structure.pdb \
  --chain A \
  --n 20 \
  --maxrep 2

Single-Chain Backbone Condition

To use only the backbone information of the target chain:

python scripts/recommend.py \
  /path/to/your_structure.pdb \
  --chain A \
  --singlechain-backbone

CPU Inference

python scripts/recommend.py \
  /path/to/your_structure.pdb \
  --chain A \
  --nogpu

Output Description

Structural Evolution first generates a complete single-point deep mutational scanning sequence library for the target chain in the input structure, then uses ESM-IF1 to calculate the structure-conditioned log-likelihood of each candidate sequence.

If the following options are not specified manually:

--seqpath
--outpath

the program automatically saves the results under output/.

The main outputs include:

*.fasta
*.csv

The files are:

Output Description
DMS FASTA Contains the wild-type sequence and all single-point mutation candidates
scores CSV Stores candidate sequences and their corresponding log_likelihood scores
Terminal output Top-N recommended mutations sorted by log_likelihood

Candidate sequences in the CSV are sorted by:

log_likelihood

in descending order, and recommended mutations are finally selected using parameters such as n, maxrep, and upperbound.

Official OneScience Information

Citation and License

  • Original Structural Evolution paper: Unsupervised evolution of protein and antibody complexes with a structure-informed language model.
  • Structural Evolution is released under the MIT License, which permits use, copying, modification, publication, distribution, sublicensing, and commercial use provided that the copyright notice and license text are retained. See LICENSE in the repository root.
  • Structural Evolution inference depends on ESM-IF1 and related ESM code. The MIT License of the Structural Evolution repository does not automatically cover third-party model weights or dependency resources. For commercial use, redistribution, or other purposes, also review the applicable ESM/ESM-IF1 licenses and model-weight terms of use.
  • If you use this repository in research, cite the original Structural Evolution paper and, as appropriate, the related work on ESM-IF1 and other components actually used.

中文说明

模型简介

Structural Evolution 是一个基于结构感知蛋白质语言模型(protein language model)的无监督蛋白质与抗体突变推荐流程。它以蛋白质或蛋白质复合物的 PDB/CIF 结构作为输入,使用 ESM-IF1 在结构条件下对候选突变序列打分,并从深度突变扫描候选中挑选高概率的替换,以辅助蛋白质和抗体序列优化。

论文:

Unsupervised evolution of protein and antibody complexes with a structure-informed language model
https://doi.org/10.1126/science.adk8946

模型描述

Structural Evolution 使用结构条件语言模型 ESM-IF1,为给定蛋白质结构中的目标链推荐突变。程序首先从输入的 PDB/CIF 中提取目标链的野生型序列,并生成单点深度突变扫描候选。随后在单链或多链主链条件下计算每个候选的对数似然,并按分数降序选出推荐的突变。

应用场景

应用场景 说明
蛋白质单点突变推荐 从结构信息中挑选高概率的氨基酸替换
抗体序列优化 分别为抗体重链和轻链推荐结构条件下的突变
蛋白质复合物优化 在多链主链上下文中评估目标链的突变
深度突变扫描候选筛选 对所有单点突变打分并输出高分候选

使用方式

1. 使用 OneCode

在 OneCode 在线环境中体验一键智能 AI4S 编程:

体验一键智能 AI4S 编程

2. 手动安装与使用

硬件要求

  • Structural Evolution 支持在 CPU 和 GPU 上进行推理。
  • ESM-IF1 推理推荐使用 GPU/DCU,以加速候选序列打分。
  • 更大的蛋白质复合物或更大的突变候选库需要更多的 GPU/DCU 显存和主机内存。
  • 如果没有可用的 GPU/DCU,可以使用 --nogpu 显式指定 CPU,但执行速度会显著变慢。

配置运行环境

DCU 环境
# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311

# Install with uv support
pip install onescience[bio] \
  -i http://mirrors.onescience.ai:3141/pypi/simple/ \
  --trusted-host mirrors.onescience.ai
环境说明
  • 如果执行过程中遇到依赖缺失或版本不兼容的问题,请参考 environment.yml 中指定的依赖版本,并按需安装或调整相关依赖。

准备权重

完整的 Structural Evolution 推理只需要额外的 ESM-IF1 模型权重。标准的突变推荐不需要下载论文中的任何额外训练数据集。

1)ESM-IF1 模型权重

下载 ESM-IF1 权重:

https://zenodo.org/records/12631662

命令:

wget -P ~/.cache/torch/hub/checkpoints \
  https://zenodo.org/records/12631662/files/esm_if1_20220410.zip

unzip ~/.cache/torch/hub/checkpoints/esm_if1_20220410.zip \
  -d ~/.cache/torch/hub/checkpoints/

解压后,请确认以下文件存在:

~/.cache/torch/hub/checkpoints/
└── esm_if1_20220410.pt

该文件必须存在。

scripts/recommend.py 始终从以下路径加载模型:

~/.cache/torch/hub/checkpoints/esm_if1_20220410.pt

即从该路径加载模型。如果您将权重保存在其他位置,请更新代码中的检查点路径。

3. 快速开始

下载模型包

hf download OneScience-Group/structural-evolution \
  --local-dir ./structural-evolution

cd structural-evolution
  • Structural Evolution 还额外依赖 ESM-IF1 模型权重。请按照“准备权重”中的说明准备 esm_if1_20220410.pt,并确保代码中的检查点路径与其实际位置一致。

快速验证

查看推理选项:

python scripts/recommend.py --help

使用官方示例结构运行快速验证:

python scripts/recommend.py \
  scripts/examples/7mmo_abc_fvar.pdb \
  --chain A \
  --n 10

示例数据

官方仓库在以下位置提供了一个示例结构:

scripts/examples/

该目录包含:

scripts/examples/
└── 7mmo_abc_fvar.pdb

此结构包含 LYCoV-1404 抗体可变区和 SARS-CoV-2 RBD,演示了抗体重链的突变推荐。

对于您自己的任务,请准备:

PDB or CIF structure of a protein or protein complex
+
Target chain ID

例如:

structure.pdb
chain A

推理示例

基础突变推荐

最简单的运行方式是:

python scripts/recommend.py \
  /path/to/structure.pdb \
  --chain A

默认输出:

Top 10 mutations
maxrep = 1
multichain backbone = True

这会默认推荐 10 个突变,并允许每个原始残基位置最多出现一次。

抗体示例

官方示例:

python scripts/recommend.py \
  scripts/examples/7mmo_abc_fvar.pdb \
  --chain A \
  --seqpath scripts/examples/7mmo_chainA_lib.fasta \
  --outpath scripts/examples/7mmo_chainA_scores.csv \
  --upperbound 109 \
  --offset 1

其中:

参数 说明
--chain 目标链 ID
--seqpath 生成的深度突变扫描 FASTA 的输出路径
--outpath 包含所有突变候选分数的 CSV 的输出路径
--n 推荐的突变数量;默认值:10
--maxrep 同一位置在推荐结果中可出现的最大次数;默认值:1
--upperbound 在最终推荐时,只考虑残基编号低于该值的位置
--offset PDB 残基编号的偏移校正
--order 指定多链结构中的链顺序
--multichain-backbone 使用所有链作为结构上下文
--singlechain-backbone 仅使用目标链主链
--nogpu 强制使用 CPU 执行

在上面的抗体示例中,--chain A 指定重链。--upperbound 109 排除了最后一个框架区中的突变。由于输入结构缺少第一个残基,--offset 1 用于校正突变编号。

自定义推荐数量

例如,输出前 20 个候选,并允许同一位置最多出现两次:

python scripts/recommend.py \
  /path/to/your_structure.pdb \
  --chain A \
  --n 20 \
  --maxrep 2

单链主链条件

仅使用目标链的主链信息:

python scripts/recommend.py \
  /path/to/your_structure.pdb \
  --chain A \
  --singlechain-backbone

CPU 推理

python scripts/recommend.py \
  /path/to/your_structure.pdb \
  --chain A \
  --nogpu

输出说明

Structural Evolution 首先为输入结构中的目标链生成完整的单点深度突变扫描序列库,然后使用 ESM-IF1 计算每条候选序列在结构条件下的对数似然。

如果未手动指定以下选项:

--seqpath
--outpath

程序会自动将结果保存在 output/ 下。

主要输出包括:

*.fasta
*.csv

这些文件为:

输出 说明
DMS FASTA 包含野生型序列和所有单点突变候选
scores CSV 保存候选序列及其对应的 log_likelihood 分数
终端输出 按 log_likelihood 排序的前 N 个推荐突变

CSV 中的候选序列按以下字段:

log_likelihood

降序排列,最终使用 n、maxrep 和 upperbound 等参数选出推荐的突变。

OneScience 官方信息

引用与许可

  • Structural Evolution 原始论文:Unsupervised evolution of protein and antibody complexes with a structure-informed language model。
  • Structural Evolution 基于 MIT License 发布,在保留版权声明和许可文本的前提下,允许使用、复制、修改、发布、分发、再授权和商业使用。详见仓库根目录中的 LICENSE。
  • Structural Evolution 的推理依赖 ESM-IF1 及相关的 ESM 代码。Structural Evolution 仓库的 MIT License 并不自动涵盖第三方模型权重或依赖资源。如用于商业用途、再分发或其他目的,还请查阅适用的 ESM/ESM-IF1 许可和模型权重使用条款。
  • 如果您在研究中使用本仓库,请引用 Structural Evolution 原始论文,并酌情引用 ESM-IF1 及实际使用的其他组件的相关工作。
Downloads last month
11
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support