EpHod / README.md
wuxing0105's picture
Upload folder using huggingface_hub
bae5726 verified
|
Raw
History Blame Contribute Delete
7.3 kB
metadata
frameworks:
  - PyTorch
language:
  - en
license: mit
tags:
  - OneScience
  - bioscience
  - enzyme-optimum-pH-prediction
  - protein-language-model
  - EpHod
tasks:
  - regression

EpHod

Model Introduction

EpHod is an ensemble model for predicting the catalytic optimum pH (pHopt) of enzymes.

The model first uses ESM-1v to encode amino acid sequences into protein representations and then combines predictions from a Residual Lightweight Attention network (RLATtr) and a Support Vector Regression model (SVR).

Paper: Machine learning prediction of enzyme optimum pH

Model Description

The EpHod inference pipeline contains three main prediction components:

  • ESM-1v: Encodes enzyme sequences into 1280-dimensional residue-level protein representations;
  • RLATtr: Uses a residual lightweight attention network to predict pHopt and can optionally output residue-level attention weights and a 2560-dimensional EpHod protein representation;
  • SVR: Performs support vector regression using pooled and standardized ESM-1v representations;
  • Ensemble: Uses the average of the RLATtr and SVR predictions as the final pHopt prediction.

The official RLATtr model was first pretrained on approximately 1.9 million proteins labeled with optimum environmental pH (pHenv) and was then fine-tuned on 9,855 enzymes labeled with catalytic optimum pH (pHopt).

Input sequences longer than 1022 residues are truncated.

To avoid pooling-related bias, the current inference entry point uses a fixed batch size of 1.

Use Cases

Use Case Description
Enzyme optimum pH prediction Predict catalytic optimum pH from an enzyme amino acid sequence.
Enzyme candidate screening Compare multiple candidate enzyme sequences based on predicted optimum pH.
Attention analysis Optionally save residue-level RLATtr attention weights.
Protein representation extraction Optionally save the final 2560-dimensional RLATtr protein representation.

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 CPU and accelerator devices supported by PyTorch;
  • GPU or SCNet DCU is recommended for ESM-1v inference;
  • CPU execution is supported but is significantly slower;
  • ESM-1v contains approximately 650 million parameters;
  • Device memory usage depends on sequence length. If device memory is insufficient, reduce the input sequence length or process sequences individually.

Download the Model Package

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


python -m pip install -U huggingface_hub

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

Install the Runtime Environment

DCU Environment

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

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

GPU Environment

# Activate Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311

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

Install the additional dependencies required by EpHod:

python -m pip install --no-deps -r requirements.txt

Weight Preparation

Inference requires all three of the following assets:

Asset Relative Path Purpose
ESM-1v 650M weights weight/esm1v_t33_650M_UR90S_1.pt Generate residue-level protein representations
RLATtr weights weight/ESM1v-RLATtr.pt Neural-network prediction branch
SVR model and normalization statistics weight/ESM1v-SVR.pkl Support Vector Regression prediction branch

Official sources:

Quick Inference

The following command uses a validated smoke-test sequence:

python scripts/inference.py \
  --fasta_path conf/data/smoke.fasta \
  --output_path output/smoke/prediction.csv \
  --verbose 1 \
  --save_attention_weights 0 \
  --save_embeddings 0

A complete example using the provided test sequences:

python scripts/inference.py \
  --fasta_path conf/data/test_sequences.fasta \
  --output_path output/inference/prediction.csv \
  --verbose 1 \
  --save_attention_weights 0 \
  --save_embeddings 0

The output CSV contains three prediction columns:

RLATtr,SVR,Ensemble

Their meanings are:

  • RLATtr: optimum-pH prediction from the neural-network branch;
  • SVR: optimum-pH prediction from the support vector regression branch;
  • Ensemble: arithmetic mean of the RLATtr and SVR predictions and the recommended final EpHod prediction.

The --output_path argument directly specifies the complete output CSV path and automatically creates its parent directory when required.

The original --save_dir and --csv_name options remain available.

If --output_path is not specified, the output path is generated from --save_dir and --csv_name.

Save Attention Weights and Protein Representations

Set the corresponding options to 1:

python scripts/inference.py \
  --fasta_path conf/data/smoke.fasta \
  --output_path output/features/prediction.csv \
  --save_attention_weights 1 \
  --save_embeddings 1

The output includes:

output/features/
β”œβ”€β”€ attention_weights/
β”œβ”€β”€ embeddings.csv
└── prediction.csv

attention_weights/ stores residue-level RLATtr attention information.

embeddings.csv stores the extracted EpHod protein representations.

prediction.csv stores the RLATtr, SVR, and ensemble optimum-pH predictions.

OneScience Official Resources

Citation and License