--- license: mit language: - en - zh tags: - OneScience - life-science - protein - thermostability - ProtTrans - TemStaPro frameworks: PyTorch ---

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](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home) ## 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 ```bash # 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: ```text 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. ```text 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`: ```bash 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: ```text 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: ```bash 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: ```text https://huggingface.co/Rostlab/prot_t5_xl_half_uniref50-enc/tree/main ``` ## 3. Quick Start ### Download the Model Package ```bash 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: ```bash python scripts/temstapro --help ``` Run the official test files retained in the repository: ```bash 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: ```bash 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: ```text scripts/tests/data/long_sequence.fasta ``` as the example input. TemStaPro inputs use the standard FASTA format: ```text >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: ```bash 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 ```bash 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: ```bash 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: ```bash --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: ```text 40 45 50 55 60 65 °C ``` The results also contain the: ```text clash ``` field, which indicates whether the threshold classifiers disagree: ```text - 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: ```text *.tsv Final prediction results *.pt ProtTrans embedding cache *.svg Per-residue or local-segment prediction plots ``` # Official OneScience Information | Platform | Main OneScience repository | Skills repository | | --- | --- | --- | | Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills | | GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills | # Citation and License - Original TemStaPro paper: [TemStaPro: protein thermostability prediction using sequence representations from protein language models](https://doi.org/10.1093/bioinformatics/btae157). - 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.