Chainsaw

Model Introduction

Chainsaw is a fully convolutional neural network designed to predict protein domain boundaries from three-dimensional protein structures. The model extracts residue-distance features and STRIDE secondary-structure features from PDB or mmCIF structures, predicts the probability that residue pairs belong to the same structural domain, and then applies post-processing to generate the final domain segmentation.

Paper: Chainsaw: protein domain segmentation with fully convolutional neural networks

Model Description

Chainsaw takes a three-dimensional protein structure as input rather than an amino acid sequence alone. Its main processing pipeline is as follows:

  1. Parse the specified protein chain and generate a residue-distance matrix;
  2. Run STRIDE to calculate secondary-structure features;
  3. Use a fully convolutional neural network to predict residue-pair domain co-membership;
  4. Convert the predicted matrix into continuous or discontinuous domain boundaries and output confidence scores.

The model package includes three versions of the official pretrained weights, with model_v3 used by default. Basic inference does not require downloading additional weights or retraining the model.

Use Cases

Use Case Description
Single-structure prediction Segment a protein chain from a PDB or mmCIF file into structural domains.
Batch structure prediction Process multiple PDB or mmCIF structure files in a directory.
AlphaFold structure analysis Identify domain boundaries in AlphaFold-predicted structures.
Domain boundary screening Output the number of domains, residue ranges, confidence scores, and runtime for downstream analysis.

Usage

1. OneCode

You can use the OneCode online environment for an intelligent one-click AI4S programming experience:

Try OneCode for AI4S Programming

2. Manual Installation

Hardware Requirements

  • Supports inference on both CPU and DCU;
  • STRIDE, structure parsing, and part of the post-processing pipeline are executed on CPU.

Download the Model Package

Install the Hugging Face command-line tool and download the model repository:

pip install -U huggingface_hub

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

Install the Runtime Environment

DCU Environment

conda create -n onescience311 python=3.11 -y
conda activate onescience311

pip install onescience[bio-dcu] \
  -i http://mirrors.onescience.ai:3141/pypi/simple/ \
  --trusted-host mirrors.onescience.ai

Compile STRIDE

Chainsaw relies on STRIDE to generate secondary-structure features. The STRIDE source code is located in scripts/stride/. Before the first run, execute:

cd scripts/stride
make
chmod +x stride
cd ../..

By default, the inference script looks for the STRIDE executable at:

scripts/stride/stride

When running commands from the root directory of the Hugging Face model package, no additional path configuration is required.

If you need to specify the STRIDE executable explicitly, use:

export STRIDE_EXE=scripts/stride/stride

Weights and Data Preparation

The Hugging Face model package already contains the official weights and configuration files required for basic inference. No additional model weights need to be downloaded at runtime.

Model Version Weights Configuration
model_v1 weight/model_v1/weights.pt conf/model_v1/
model_v2 weight/model_v2/weights.pt conf/model_v2/
model_v3 (default) weight/model_v3/weights.pt conf/model_v3/

Input structures must be provided by the user. Both PDB and mmCIF files are supported.

The example files included in:

scripts/example_files/

can be used for basic validation without downloading any training dataset.

Quick Inference

All commands below should be executed from the root directory of the downloaded Hugging Face model package.

If the output directory does not exist, the inference script will create it automatically.

DCU Inference

unset CUDA_VISIBLE_DEVICES
export TORCHDYNAMO_DISABLE=1

python scripts/get_predictions.py \
  --structure_file scripts/example_files/AF-A0A1W2PQ64-F1-model_v4.pdb \
  --output output/inference/predictions_dcu.tsv

CPU Inference

export CUDA_VISIBLE_DEVICES=""
export TORCHDYNAMO_DISABLE=1

python scripts/get_predictions.py \
  --structure_file scripts/example_files/AF-A0A1W2PQ64-F1-model_v4.pdb \
  --output output/inference/predictions_cpu.tsv

Batch Processing of Structure Files

Place the structures to be predicted in:

input/structures/

Then run:

python scripts/get_predictions.py \
  --structure_directory input/structures \
  --output output/inference/batch_predictions.tsv

Using Another Official Model Version

python scripts/get_predictions.py \
  --model_dir weight/model_v1 \
  --config_dir conf/model_v1 \
  --structure_file input/protein.pdb \
  --output output/inference/model_v1_predictions.tsv

Output

The inference result is saved as a TSV file, with one row corresponding to each input structure chain.

Field Description
chain_id Identifier of the input protein chain. If no chain is explicitly specified, the first available chain is used.
sequence_md5 MD5 hash of the input amino acid sequence.
nres Number of valid residues.
ndom Number of predicted structural domains.
chopping Predicted domain residue ranges. Underscores connect fragments belonging to the same discontinuous domain, while commas separate different domains.
confidence Prediction confidence score.
time_sec Inference time for a single structure, in seconds.

Training

The upstream repository does not publicly provide the complete training dataset, an executable end-to-end training entry point, or the full set of training hyperparameters such as learning rate, batch size, and number of epochs.

Therefore, this Hugging Face model package does not provide a training command.

The official pretrained weights included in the package can be used directly for the intended inference tasks.

OneScience Official Resources

Citation and License


中文说明

模型简介

Chainsaw 是一种用于从三维蛋白质结构预测蛋白质结构域边界的全卷积神经网络。模型从 PDB 或 mmCIF 结构中提取残基距离特征和 STRIDE 二级结构特征,预测残基对同属一个结构域的概率,再通过后处理得到最终的结构域分割结果。

论文:Chainsaw:使用全卷积神经网络进行蛋白质结构域分割

模型描述

Chainsaw 以三维蛋白质结构为输入,单独的氨基酸序列无法作为输入。主要处理流程如下。

  1. 解析指定的蛋白质链并生成残基距离矩阵
  2. 运行 STRIDE 计算二级结构特征
  3. 使用全卷积神经网络预测残基对是否同属一个结构域
  4. 将预测矩阵转换为连续或不连续的结构域边界并输出置信度分数。

模型包包含三个版本的官方预训练权重,默认使用 model_v3。基本推理(inference)无需下载其他权重或重新训练模型。

使用场景

使用场景 说明
单结构预测 将 PDB 或 mmCIF 文件中的蛋白质链分割成结构域。
批量结构预测 处理目录中的多个 PDB 或 mmCIF 结构文件。
AlphaFold 结构分析 识别 AlphaFold 预测结构中的结构域边界。
结构域边界筛查 输出结构域数量、残基范围、置信度分数和运行时间,以供下游分析。

使用指南

1. OneCode

可通过 OneCode 在线环境体验智能一键 AI4S 编程。

体验 OneCode 的 AI4S 编程

2. 手动安装

硬件要求

  • 支持在 CPU 和 DCU 上推理
  • STRIDE、结构解析和部分后处理流程在 CPU 上执行。

下载模型包

安装 Hugging Face 命令行工具,然后下载模型仓库。

pip install -U huggingface_hub

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

安装运行环境

DCU 环境

conda create -n onescience311 python=3.11 -y
conda activate onescience311

pip install onescience[bio-dcu] \
  -i http://mirrors.onescience.ai:3141/pypi/simple/ \
  --trusted-host mirrors.onescience.ai

编译 STRIDE

Chainsaw 使用 STRIDE 生成二级结构特征。STRIDE 源代码位于 scripts/stride/。首次运行前,执行以下命令。

cd scripts/stride
make
chmod +x stride
cd ../..

推理脚本默认在以下位置查找 STRIDE 可执行文件。

scripts/stride/stride

在 Hugging Face 模型包根目录运行命令时,无需额外配置路径。

如需显式指定 STRIDE 可执行文件,请使用以下命令。

export STRIDE_EXE=scripts/stride/stride

权重和数据准备

Hugging Face 模型包已包含基本推理所需的官方权重和配置文件,运行时无需下载其他模型权重。

模型版本 权重 配置
model_v1 weight/model_v1/weights.pt conf/model_v1/
model_v2 weight/model_v2/weights.pt conf/model_v2/
model_v3(默认) weight/model_v3/weights.pt conf/model_v3/

输入结构需由用户提供,支持 PDB 和 mmCIF 文件。

以下位置包含的示例文件

scripts/example_files/

可用于基本验证,无需下载任何训练数据集。

快速推理

以下命令均应在下载的 Hugging Face 模型包根目录下执行。

如果输出目录不存在,推理脚本会自动创建。

DCU 推理

unset CUDA_VISIBLE_DEVICES
export TORCHDYNAMO_DISABLE=1

python scripts/get_predictions.py \
  --structure_file scripts/example_files/AF-A0A1W2PQ64-F1-model_v4.pdb \
  --output output/inference/predictions_dcu.tsv

CPU 推理

export CUDA_VISIBLE_DEVICES=""
export TORCHDYNAMO_DISABLE=1

python scripts/get_predictions.py \
  --structure_file scripts/example_files/AF-A0A1W2PQ64-F1-model_v4.pdb \
  --output output/inference/predictions_cpu.tsv

批量处理结构文件

将待预测的结构放到以下位置。

input/structures/

然后执行以下命令。

python scripts/get_predictions.py \
  --structure_directory input/structures \
  --output output/inference/batch_predictions.tsv

使用其他官方模型版本

python scripts/get_predictions.py \
  --model_dir weight/model_v1 \
  --config_dir conf/model_v1 \
  --structure_file input/protein.pdb \
  --output output/inference/model_v1_predictions.tsv

输出

推理结果保存为 TSV 文件,每行对应输入结构中的一条链。

Field 说明
chain_id 输入蛋白质链的标识符。若未显式指定链,将使用第一条可用链。
sequence_md5 输入氨基酸序列的 MD5 哈希值。
nres 有效残基数。
ndom 预测的结构域数量。
chopping 预测的结构域残基范围。下划线连接同属一个不连续结构域的片段,逗号分隔不同结构域。
confidence 预测置信度分数。
time_sec 单个结构的推理时间,单位为 seconds。

训练

上游仓库未公开完整训练数据集、可执行的端到端训练入口,以及学习率、批大小和训练轮次等一整套训练超参数。

因此,此 Hugging Face 模型包未提供训练命令。

包内的官方预训练权重可直接用于预期的推理任务。

OneScience 官方资源

引用与许可证

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