TemStaPro

Model Introduction

TemStaPro (Temperatures of Stability for Proteins) is a protein thermostability prediction tool based on protein language model representations. It takes protein FASTA sequences as input, uses ProtTrans/ProtT5 to generate sequence representations, and applies classifiers for multiple temperature thresholds to predict stability across different temperature ranges.

Paper:

TemStaPro: protein thermostability prediction using sequence representations from protein language models
https://doi.org/10.1093/bioinformatics/btae157

Model Description

TemStaPro uses ProtT5-XL-Half-UniRef50 to encode protein sequences and predicts thermostability from the resulting mean or per-residue embeddings. The default mode uses binary classifiers to independently assess stability at thresholds of 40, 45, 50, 55, 60, and 65 °C, then combines the classification results to produce a predicted temperature range.

Use Cases

Use case Description
Protein thermostability prediction Predict the stable temperature range from a protein sequence
Multi-temperature threshold classification Assess protein stability independently at thresholds such as 40–65 °C
Per-residue stability analysis Output local prediction results for each amino acid position
Local segment stability analysis Predict thermostability in different protein regions using a sliding window
Protein engineering and screening Help screen potential thermostable proteins or candidate mutants

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

  • TemStaPro supports execution on CPUs and GPUs.
  • Most of the computational cost comes from generating ProtT5 embeddings, so a GPU/DCU is recommended for acceleration.
  • In the official tests, 1,000 protein sequences with an average length of approximately 1,137 aa took about 10 hours on a standard laptop CPU and about 10 minutes on an RTX 2080 Ti GPU system. An accelerator is therefore recommended for batch prediction.

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_CPU.yml or environment_GPU.yml and install or adjust the relevant dependencies as needed.

Prepare Weights and Models

  • TemStaPro inference requires two model resources:

(1) TemStaPro classifier weights. (2) The ProtT5-XL-Half-UniRef50 pretrained model.

  • TemStaPro inference does not require additional dataset downloads; the standard workflow takes the user's own FASTA file as input.

1) TemStaPro Classifier Weights

The current repository provides trained classifier weights in the weight/ directory, for example:

weight/
├── mean_major_imbal-40_s1.pt
├── mean_major_imbal-40_s2.pt
├── ...
├── mean_major_imbal-45_s1.pt
├── ...
├── mean_major_imbal-50_s1.pt
└── ...

Different files correspond to different temperature thresholds and random seeds. TemStaPro automatically loads the corresponding classifiers from weight/, so after downloading the complete Hugging Face model package, separate classifier weight downloads are normally unnecessary.

2) ProtT5-XL-Half-UniRef50

TemStaPro uses ProtT5-XL-Half-UniRef50 to generate protein sequence representations. This model is not included in the current repository and must be prepared separately.

Rostlab/prot_t5_xl_half_uniref50-enc

It is recommended to save the ProtTrans model under ProtTrans/ in the repository root and specify this directory at runtime with -d/--PT-directory:

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -d ./ProtTrans/ \
  --mean-output ./long_sequence_predictions.tsv

If ./ProtTrans/ already contains the following model files, the program loads them locally:

pytorch_model.bin
config.json
tokenizer_config.json
special_tokens_map.json
spiece.model

If the specified directory does not contain the complete model files, the program attempts to download them automatically from Hugging Face and save them there. For network-restricted or offline environments, download them in advance with the Hugging Face CLI:

huggingface-cli download \
  Rostlab/prot_t5_xl_half_uniref50-enc \
  --local-dir ./ProtTrans

The model page is shown below; you can also download the required files manually:

https://huggingface.co/Rostlab/prot_t5_xl_half_uniref50-enc/tree/main

3. Quick Start

Download the Model Package

hf download OneScience-Group/TemStaPro --local-dir ./TemStaPro
cd TemStaPro
  • Complete TemStaPro inference additionally depends on ProtT5-XL-Half-UniRef50. Follow "Prepare Weights and Models" to make sure the ProtTrans model is ready first.
  • Training, validation, and test datasets from Zenodo are not required for inference-only use.

Quick Verification

First, view the command-line options:

python scripts/temstapro --help

Run the official test files retained in the repository:

make -f scripts/makefile all

The first test run may fail while the ProtTrans model is being downloaded. Clean the outputs and run the tests again:

make -f scripts/makefile clean
make -f scripts/makefile all

In offline environments, prepare the ProtTrans model before running the tests.

Example Data

The official test data is located in scripts/tests/data/, primarily using:

scripts/tests/data/long_sequence.fasta

as the example input.

TemStaPro inputs use the standard FASTA format:

>protein_id
MSEQUENCE...

For your own prediction tasks, prepare a FASTA file containing one or more protein sequences. No protein structure is required.

Inference Examples

Protein-Level Thermostability Prediction

Mean-embedding prediction is recommended by default:

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -d ./ProtTrans/ \
  -e ./scripts/tests/outputs/ \
  --mean-output ./long_sequence_predictions.tsv

Where:

Parameter Description
-f Input FASTA file
-d ProtTrans/ProtT5 model directory
-e Embedding cache directory
--mean-output Protein-level prediction results in TSV format

-e is optional, but enabling embedding caching is recommended when running the same sequences multiple times.

Per-Residue Prediction

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -e ./scripts/tests/outputs/ \
  -d ./ProtTrans/ \
  -p ./ \
  --per-res-output ./long_sequence_predictions_per_res.tsv

-p specifies the output directory for prediction plots.

Local Segment Prediction

TemStaPro uses a window size of 41 for per-segment prediction by default:

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -e ./scripts/tests/outputs/ \
  -d ./ProtTrans/ \
  --curve-smoothening \
  -p ./ \
  --per-segment-output ./long_sequence_predictions_k41.tsv

Additional Temperature Thresholds

To enable additional thresholds such as 70, 75, and 80 °C, together with the thermophilicity label, add:

--more-thresholds

Output Description

The default protein-level output is a TSV table containing the binary and raw predictions from classifiers at each temperature threshold. It also generates a predicted temperature label from the combined threshold results.

The default temperature thresholds are:

40
45
50
55
60
65 °C

The results also contain the:

clash

field, which indicates whether the threshold classifiers disagree:

-    No obvious conflict
*    Inconsistent classification results

When per-residue or local-segment prediction is enabled, additional TSV files can be generated. Specifying -p also generates SVG prediction plots.

With -e, ProtTrans embedding cache files are saved in the specified directory and can be reused in later runs, reducing repeated ProtT5 feature extraction overhead.

Typical runtime/intermediate files include:

*.tsv    Final prediction results
*.pt     ProtTrans embedding cache
*.svg    Per-residue or local-segment prediction plots

Official OneScience Information

Citation and License

  • Original TemStaPro paper: TemStaPro: protein thermostability prediction using sequence representations from protein language models.
  • The official TemStaPro source code is released under the MIT License; see LICENCE.md in the repository root.
  • TemStaPro uses ProtTrans/ProtT5 to generate protein representations. Use or redistribution of the corresponding model weights must also comply with the license requirements of ProtTrans, the relevant Hugging Face model page, and the associated pretraining data.
  • The official training, validation, and test data are published on Zenodo. If you use these data for reproduction, training, or evaluation, cite them as required by the data page.
  • If you use this repository in research, cite the original TemStaPro paper and the relevant OneScience project information.

中文说明

模型简介

TemStaPro(Temperatures of Stability for Proteins)是一种基于蛋白质语言模型(protein language model)表征的蛋白质热稳定性预测工具。它以蛋白质 FASTA 序列为输入,使用 ProtTrans/ProtT5 生成序列表征,并应用对应多个温度阈值的分类器预测不同温度范围内的稳定性。

论文

TemStaPro:使用蛋白质语言模型的序列表征预测蛋白质热稳定性
https://doi.org/10.1093/bioinformatics/btae157

模型描述

TemStaPro 使用 ProtT5-XL-Half-UniRef50 编码蛋白质序列,根据所得平均嵌入或逐残基嵌入预测热稳定性。默认模式使用二分类器分别评估 40、45、50、55、60 和 65 °C 阈值下的稳定性,再结合分类结果得到预测温度范围。

使用场景

使用场景 说明
蛋白质热稳定性预测 根据蛋白质序列预测稳定温度范围
多温度阈值分类 在 40–65 °C 等阈值下分别评估蛋白质稳定性
逐残基稳定性分析 输出每个氨基酸位置的局部预测结果
局部片段稳定性分析 使用滑动窗口预测蛋白质不同区域的热稳定性
蛋白质工程与筛选 帮助筛选潜在的耐热蛋白质或候选突变体

使用方法

1. 使用 OneCode

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

体验智能一键 AI4S 编程

2. 手动安装与使用

硬件要求

  • TemStaPro 支持在 CPU 和 GPU 上运行。
  • 大部分计算开销来自生成 ProtT5 嵌入,建议使用 GPU/DCU 加速。
  • 官方测试中,1,000 条平均长度约为 1,137 aa 的蛋白质序列,在标准笔记本 CPU 上耗时约 10 小时,在配备 RTX 2080 Ti GPU 的系统上约 10 分钟。因此建议使用加速器进行批量预测。

配置运行环境

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_CPU.yml 或 environment_GPU.yml 中指定的依赖版本,按需安装或调整相关依赖。

准备权重和模型

  • TemStaPro 推理(inference)需要两项模型资源。

(1) TemStaPro 分类器权重。 (2) ProtT5-XL-Half-UniRef50 预训练模型。

  • TemStaPro 推理无需额外下载数据集,标准流程以用户自己的 FASTA 文件作为输入。
1) TemStaPro 分类器权重

当前仓库在 weight/ 目录提供已训练的分类器权重,例如以下文件。

weight/
├── mean_major_imbal-40_s1.pt
├── mean_major_imbal-40_s2.pt
├── ...
├── mean_major_imbal-45_s1.pt
├── ...
├── mean_major_imbal-50_s1.pt
└── ...

不同文件对应不同温度阈值和随机种子。TemStaPro 会从 weight/ 自动加载对应分类器,因此下载完整 Hugging Face 模型包后,通常无需单独下载分类器权重。

2) ProtT5-XL-Half-UniRef50

TemStaPro 使用 ProtT5-XL-Half-UniRef50 生成蛋白质序列表征。当前仓库不包含此模型,需要单独准备。

Rostlab/prot_t5_xl_half_uniref50-enc

建议将 ProtTrans 模型保存到仓库根目录的 ProtTrans/ 下,并在运行时使用 -d/--PT-directory 指定此目录。

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -d ./ProtTrans/ \
  --mean-output ./long_sequence_predictions.tsv

如果 ./ProtTrans/ 已包含下列模型文件,程序将从本地加载它们。

pytorch_model.bin
config.json
tokenizer_config.json
special_tokens_map.json
spiece.model

如果指定目录没有完整的模型文件,程序会尝试从 Hugging Face 自动下载并保存到该目录。在网络受限或离线环境中,请使用 Hugging Face CLI 提前下载。

huggingface-cli download \
  Rostlab/prot_t5_xl_half_uniref50-enc \
  --local-dir ./ProtTrans

模型页面如下,也可手动下载所需文件。

https://huggingface.co/Rostlab/prot_t5_xl_half_uniref50-enc/tree/main

3. 快速开始

下载模型包

hf download OneScience-Group/TemStaPro --local-dir ./TemStaPro
cd TemStaPro
  • 完整的 TemStaPro 推理还依赖 ProtT5-XL-Half-UniRef50。请遵照“准备权重和模型”一节,先确保 ProtTrans 模型就绪。
  • 仅执行推理时,无需 Zenodo 上的训练、验证和测试数据集。

快速验证

首先查看命令行选项。

python scripts/temstapro --help

运行仓库中保留的官方测试文件。

make -f scripts/makefile all

首次测试可能会因正在下载 ProtTrans 模型而失败。清理输出后重新运行测试。

make -f scripts/makefile clean
make -f scripts/makefile all

离线环境中,请在运行测试前准备好 ProtTrans 模型。

示例数据

官方测试数据位于 scripts/tests/data/,主要使用以下文件

scripts/tests/data/long_sequence.fasta

作为示例输入。

TemStaPro 输入使用标准 FASTA 格式。

>protein_id
MSEQUENCE...

对于自己的预测任务,请准备包含一条或多条蛋白质序列的 FASTA 文件,无需蛋白质结构。

推理示例

蛋白质层面的热稳定性预测

默认建议使用平均嵌入进行预测。

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -d ./ProtTrans/ \
  -e ./scripts/tests/outputs/ \
  --mean-output ./long_sequence_predictions.tsv

各参数含义见下表。

参数 说明
-f 输入 FASTA 文件
-d ProtTrans/ProtT5 模型目录
-e 嵌入缓存目录
--mean-output TSV 格式的蛋白质层面预测结果

-e 为可选项,重复运行相同序列时,建议启用嵌入缓存。

逐残基预测

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -e ./scripts/tests/outputs/ \
  -d ./ProtTrans/ \
  -p ./ \
  --per-res-output ./long_sequence_predictions_per_res.tsv

-p 指定预测图的输出目录。

局部片段预测

TemStaPro 默认以 41 为窗口大小进行逐片段预测。

python scripts/temstapro \
  -f ./scripts/tests/data/long_sequence.fasta \
  -e ./scripts/tests/outputs/ \
  -d ./ProtTrans/ \
  --curve-smoothening \
  -p ./ \
  --per-segment-output ./long_sequence_predictions_k41.tsv

其他温度阈值

要启用 70、75 和 80 °C 等额外阈值及嗜热性标签,请添加以下参数。

--more-thresholds

输出说明

默认的蛋白质层面输出是 TSV 表格,包含各温度阈值对应分类器的二值预测和原始预测。该输出还根据各阈值的综合结果生成预测温度标签。

默认温度阈值如下。

40
45
50
55
60
65 °C

结果还包含以下

clash

字段,用于指示各阈值的分类器是否出现分歧。

-    No obvious conflict
*    Inconsistent classification results

启用逐残基预测或局部片段预测时,可额外生成 TSV 文件。指定 -p 还会生成 SVG 预测图。

使用 -e 时,ProtTrans 嵌入缓存文件将保存至指定目录,并可在之后的运行中复用,以降低重复提取 ProtT5 特征的开销。

常见运行时和中间文件如下。

*.tsv    Final prediction results
*.pt     ProtTrans embedding cache
*.svg    Per-residue or local-segment prediction plots

OneScience 官方信息

引用与许可证

  • TemStaPro 原始论文TemStaPro:使用蛋白质语言模型的序列表征预测蛋白质热稳定性。
  • TemStaPro 官方源代码按 MIT 许可证发布,详见仓库根目录的 LICENCE.md。
  • TemStaPro 使用 ProtTrans/ProtT5 生成蛋白质表征。使用或再分发相应模型权重时,还须遵守 ProtTrans、相关 Hugging Face 模型页面及对应预训练数据的许可证要求。
  • 官方训练、验证和测试数据发布在 Zenodo。使用这些数据进行复现、训练或评估时,请按数据页面要求引用。
  • 若在研究中使用本仓库,请引用 TemStaPro 原始论文及相关 OneScience 项目信息。
Downloads last month
8
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support