ProteinMPNN

Model Introduction

ProteinMPNN is a protein sequence design model based on a Message Passing Neural Network. Given a protein backbone structure, it can efficiently generate highly expressible and foldable amino acid sequences.

Model Description

ProteinMPNN uses an encoder-decoder architecture. The encoder extracts geometric and topological features of the backbone structure through a graph neural network, while the decoder generates the amino acid sequence position by position in an autoregressive manner.

Usage

1. Using OneCode

You can try intelligent one-click AI4S programming through the OneCode online environment:

Try intelligent one-click AI4S programming

2. Manual Installation and Usage

Hardware Requirements

  • Running on a GPU or DCU is recommended.
  • A CPU can be used for import checks and small-configuration connectivity validation, but full training and inference will be slow.
  • DCU users need to install DTK in advance. DTK 25.04.2 or later is recommended, or the OneScience-recommended version that matches the current cluster.

3. Quick Start

Download the Model Package

hf download OneScience-Group/ProteinMPNN --local-dir ./ProteinMPNN 
cd ProteinMPNN 

Install the Runtime Environment

DCU Environment

# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[bio] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

If the runtime environment explicitly needs to point to the OneScience root directory, set:

export ONESCIENCE_ROOT=/path/to/onescience

Quick Verification

export PYTHONPATH=$(pwd)/model:${ONESCIENCE_ROOT}/src:${PYTHONPATH:-}
python -c "from proteinmpnn.protein_mpnn_utils import ProteinMPNN; print('proteinmpnn wrapper ok')"
python scripts/inference.py --help
python scripts/training.py --help

Inference

The current weights have been placed in subdirectories under weight/. The standard ProteinMPNN uses weight/vanilla_model_weights/; if --path_to_model_weights is not explicitly passed, scripts/inference.py uses this directory by default.

Run Minimal Inference with the Script

cd /path/to/proteinmpnn
bash scripts/test_inference.sh

This script uses the following by default:

Input PDB: data/inputs/PDB_monomers/pdbs/5L33.pdb
Designed chain: A
Model weights: weight/vanilla_model_weights
Output directory: outputs/test_inference/

View the generated sequences:

ls outputs/test_inference/seqs

Equivalent command:

python scripts/inference.py \
  --pdb_path ./data/inputs/PDB_monomers/pdbs/5L33.pdb \
  --pdb_path_chains "A" \
  --out_folder ./outputs/test_inference \
  --path_to_model_weights ./weight/vanilla_model_weights \
  --model_name v_48_020 \
  --num_seq_per_target 2 \
  --sampling_temp "0.1" \
  --seed 37 \
  --batch_size 1

Available weights:

  • Standard model: --path_to_model_weights ./weight/vanilla_model_weights
  • Soluble protein model: --path_to_model_weights ./weight/soluble_model_weights or add --use_soluble_model
  • CA-only model: --path_to_model_weights ./weight/ca_model_weights or add --ca_only

Inference Example Scripts

The scripts/infer_examples/ directory contains examples for 12 inference scenarios, all adapted to the current directory structure:

Script Scenario
submit_example_1.sh Inference on multiple single-chain PDBs.
submit_example_2.sh Multi-chain complex; design only the specified chains.
submit_example_3.sh Inference on a single PDB complex.
submit_example_3_score_only.sh Score existing structures/sequences without generating new sequences.
submit_example_3_score_only_from_fasta.sh Score a structure using FASTA sequences.
submit_example_4.sh Fix certain residue positions and exclude them from design.
submit_example_4_non_fixed.sh Design only the specified positions.
submit_example_5.sh Tied positions, with multi-position tied design.
submit_example_6.sh Homooligomer-constrained design.
submit_example_7.sh Output unconditional probabilities.
submit_example_8.sh Add a global amino acid bias.
submit_example_pssm.sh Add PSSM constraints to assist design.

Run a single example:

bash scripts/infer_examples/submit_example_3.sh

Note: submit_example_3_score_only_from_fasta.sh depends on submit_example_3.sh first generating outputs/example_3_outputs/seqs/3HTN.fa.

Training

The current example training data is placed in data/pdb_2021aug02_sample/. This directory should contain:

list.csv
valid_clusters.txt
test_clusters.txt
pdb/<2nd-3rd characters of pdbid>/<pdbid>.pt
pdb/<2nd-3rd characters of pdbid>/<pdbid>_<chain>.pt

Run the training example script directly:

cd /path/to/proteinmpnn
bash scripts/test_train.sh

This script uses the following by default:

Training data: data/pdb_2021aug02_sample
Output directory: outputs/train/exp_020/
Number of samples per epoch: 1000
Save a checkpoint every 50 epochs

View the training log and weights:

cat outputs/train/exp_020/log.txt
ls outputs/train/exp_020/model_weights

Equivalent command:

python scripts/training.py \
  --path_for_training_data ./data/pdb_2021aug02_sample \
  --path_for_outputs ./outputs/train/exp_020 \
  --num_examples_per_epoch 1000 \
  --save_model_every_n_epochs 50

To resume training, pass:

python scripts/training.py \
  --path_for_training_data ./data/pdb_2021aug02_sample \
  --path_for_outputs ./outputs/train/exp_020 \
  --previous_checkpoint ./outputs/train/exp_020/model_weights/epoch_last.pt

Common Parameters

Inference Parameters

Parameter Description Default/Example
--pdb_path Input path for a single PDB ./data/inputs/PDB_monomers/pdbs/5L33.pdb
--jsonl_path Parsed PDB JSONL input path Generated by parse_multiple_chains.py
--pdb_path_chains Chains to design in single-PDB mode "A" or "A B"
--out_folder Inference output directory ./outputs/test_inference
--path_to_model_weights Weight directory ./weight/vanilla_model_weights
--model_name Weight file name without .pt v_48_020
--num_seq_per_target Number of sequences to generate for each target 2
--sampling_temp Sampling temperature "0.1"
--score_only Score only, without generating new sequences 0 or 1
--save_score Save score files 0 or 1
--save_probs Save probability files 0 or 1
--ca_only Use the CA-only model Disabled by default
--use_soluble_model Use the soluble protein model Disabled by default

Training Parameters

Parameter Description Default/Example
--path_for_training_data Preprocessed training data directory ./data/pdb_2021aug02_sample
--path_for_outputs Training output directory ./outputs/train/exp_020
--previous_checkpoint Checkpoint for resuming training epoch_last.pt
--num_epochs Number of training epochs Default 200
--num_examples_per_epoch Number of samples loaded per epoch Example 1000
--batch_size Token batch size Default 10000
--save_model_every_n_epochs Save a checkpoint every N epochs 50 in the example script
--mixed_precision Whether to use mixed precision Default True

Official OneScience Information

Citations and License

  • Original ProteinMPNN paper: Robust deep learning-based protein sequence design using ProteinMPNN.

  • ProteinMPNN-related source code uses the MIT License. See LICENSE in the repository root for details. The specific terms of use for model weights and data should follow the instructions provided by the corresponding publishers.

  • If you use ProteinMPNN in research, it is recommended to cite the corresponding original ProteinMPNN paper and relevant OneScience project information, and to add citations for downstream analysis tools or datasets according to the actual task.


中文说明

模型简介

ProteinMPNN 是一个基于消息传递神经网络(Message Passing Neural Network)的蛋白质序列设计模型。给定一个蛋白质骨架结构,它可以高效地生成高表达性、可折叠的氨基酸序列。

模型描述

ProteinMPNN 采用编码器-解码器架构。编码器通过图神经网络提取骨架结构的几何与拓扑特征,解码器则以自回归方式逐位置生成氨基酸序列。

使用方法

1. 使用 OneCode

你可以通过 OneCode 在线环境体验一键式 AI4S 智能编程:

体验一键式 AI4S 智能编程

2. 手动安装与使用

硬件要求

  • 建议在 GPU 或 DCU 上运行。
  • CPU 可用于导入检查和小配置的连通性验证,但完整的训练和推理(inference)会很慢。
  • DCU 用户需提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或与当前集群匹配的 OneScience 推荐版本。

3. 快速开始

下载模型包

hf download OneScience-Group/ProteinMPNN --local-dir ./ProteinMPNN 
cd ProteinMPNN 

安装运行环境

DCU 环境
# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[bio] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

如果运行环境需要显式指向 OneScience 根目录,请设置:

export ONESCIENCE_ROOT=/path/to/onescience

快速验证

export PYTHONPATH=$(pwd)/model:${ONESCIENCE_ROOT}/src:${PYTHONPATH:-}
python -c "from proteinmpnn.protein_mpnn_utils import ProteinMPNN; print('proteinmpnn wrapper ok')"
python scripts/inference.py --help
python scripts/training.py --help

推理

当前权重已放置在 weight/ 下的子目录中。标准 ProteinMPNN 使用 weight/vanilla_model_weights/;如果未显式传入 --path_to_model_weights,scripts/inference.py 默认使用该目录。

使用脚本运行最小推理

cd /path/to/proteinmpnn
bash scripts/test_inference.sh

该脚本默认使用以下内容:

Input PDB: data/inputs/PDB_monomers/pdbs/5L33.pdb
Designed chain: A
Model weights: weight/vanilla_model_weights
Output directory: outputs/test_inference/

查看生成的序列:

ls outputs/test_inference/seqs

等价命令:

python scripts/inference.py \
  --pdb_path ./data/inputs/PDB_monomers/pdbs/5L33.pdb \
  --pdb_path_chains "A" \
  --out_folder ./outputs/test_inference \
  --path_to_model_weights ./weight/vanilla_model_weights \
  --model_name v_48_020 \
  --num_seq_per_target 2 \
  --sampling_temp "0.1" \
  --seed 37 \
  --batch_size 1

可用权重:

  • 标准模型:--path_to_model_weights ./weight/vanilla_model_weights
  • 可溶性蛋白模型:--path_to_model_weights ./weight/soluble_model_weights,或添加 --use_soluble_model
  • 仅 CA 模型:--path_to_model_weights ./weight/ca_model_weights,或添加 --ca_only

推理示例脚本

scripts/infer_examples/ 目录包含 12 种推理场景的示例,均已适配当前目录结构:

脚本 场景
submit_example_1.sh 对多个单链 PDB 进行推理。
submit_example_2.sh 多链复合物;仅设计指定的链。
submit_example_3.sh 对单个 PDB 复合物进行推理。
submit_example_3_score_only.sh 仅对已有结构/序列打分,不生成新序列。
submit_example_3_score_only_from_fasta.sh 使用 FASTA 序列对结构打分。
submit_example_4.sh 固定某些残基位点,将其排除在设计之外。
submit_example_4_non_fixed.sh 仅设计指定的位点。
submit_example_5.sh 绑定位点(tied positions),进行多位点绑定设计。
submit_example_6.sh 同源寡聚体约束设计。
submit_example_7.sh 输出无条件概率。
submit_example_8.sh 添加全局氨基酸偏置。
submit_example_pssm.sh 添加 PSSM 约束以辅助设计。

运行单个示例:

bash scripts/infer_examples/submit_example_3.sh

注意:submit_example_3_score_only_from_fasta.sh 依赖于 submit_example_3.sh 先生成 outputs/example_3_outputs/seqs/3HTN.fa。

训练

当前的示例训练数据放置在 data/pdb_2021aug02_sample/ 中。该目录应包含:

list.csv
valid_clusters.txt
test_clusters.txt
pdb/<2nd-3rd characters of pdbid>/<pdbid>.pt
pdb/<2nd-3rd characters of pdbid>/<pdbid>_<chain>.pt

直接运行训练示例脚本:

cd /path/to/proteinmpnn
bash scripts/test_train.sh

该脚本默认使用以下内容:

Training data: data/pdb_2021aug02_sample
Output directory: outputs/train/exp_020/
Number of samples per epoch: 1000
Save a checkpoint every 50 epochs

查看训练日志和权重:

cat outputs/train/exp_020/log.txt
ls outputs/train/exp_020/model_weights

等价命令:

python scripts/training.py \
  --path_for_training_data ./data/pdb_2021aug02_sample \
  --path_for_outputs ./outputs/train/exp_020 \
  --num_examples_per_epoch 1000 \
  --save_model_every_n_epochs 50

若要恢复训练,请传入:

python scripts/training.py \
  --path_for_training_data ./data/pdb_2021aug02_sample \
  --path_for_outputs ./outputs/train/exp_020 \
  --previous_checkpoint ./outputs/train/exp_020/model_weights/epoch_last.pt

常用参数

推理参数

参数 描述 默认值/示例
--pdb_path 单个 PDB 的输入路径 ./data/inputs/PDB_monomers/pdbs/5L33.pdb
--jsonl_path 解析后的 PDB JSONL 输入路径 由 parse_multiple_chains.py 生成
--pdb_path_chains 单 PDB 模式下要设计的链 "A" 或 "A B"
--out_folder 推理输出目录 ./outputs/test_inference
--path_to_model_weights 权重目录 ./weight/vanilla_model_weights
--model_name 不带 .pt 的权重文件名 v_48_020
--num_seq_per_target 为每个目标生成的序列数量 2
--sampling_temp 采样温度 "0.1"
--score_only 仅打分,不生成新序列 0 或 1
--save_score 保存打分文件 0 或 1
--save_probs 保存概率文件 0 或 1
--ca_only 使用仅 CA 模型 默认关闭
--use_soluble_model 使用可溶性蛋白模型 默认关闭

训练参数

参数 描述 默认值/示例
--path_for_training_data 预处理后的训练数据目录 ./data/pdb_2021aug02_sample
--path_for_outputs 训练输出目录 ./outputs/train/exp_020
--previous_checkpoint 用于恢复训练的模型权重(检查点) epoch_last.pt
--num_epochs 训练轮数 默认 200
--num_examples_per_epoch 每轮加载的样本数量 示例为 1000
--batch_size token 批大小 默认 10000
--save_model_every_n_epochs 每 N 轮保存一次检查点 示例脚本中为 50
--mixed_precision 是否使用混合精度 默认 True

OneScience 官方信息

引用与许可

  • ProteinMPNN 原始论文:Robust deep learning-based protein sequence design using ProteinMPNN。

  • ProteinMPNN 相关源代码使用 MIT License。详见仓库根目录下的 LICENSE。模型权重和数据的具体使用条款应遵循相应发布方提供的说明。

  • 如果你在研究中使用 ProteinMPNN,建议引用 ProteinMPNN 相应的原始论文和相关的 OneScience 项目信息,并根据实际任务补充下游分析工具或数据集的引用。

Downloads last month
25
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support