v1.0.5 · Enzyme Prediction

sxLaep

Rapid Enzyme / Non-Enzyme Prediction — an efficient machine learning tool combining multi-physicochemical sequence features with an XGBoost classifier for fast and accurate binary classification of protein sequences.

stars PyPI License last commit
View on GitHub Get Started API Reference

Overview

Accurate identification of enzymes from protein sequences is crucial for understanding metabolic pathways, drug target discovery, and functional annotation of novel proteins.

Pipeline

Input FASTA Feature Extraction XGBoost Classifier Enzyme / Non-Enzyme

Installation

sxLaep supports Python 3.9+ on Windows, Linux, and macOS.

Dependencies

PackageMinimum
numpy≥ 1.23
pandas≥ 1.5
scikit-learn≥ 1.2
xgboost≥ 1.7
joblib≥ 1.2

From PyPI

pip install sxlaep

From Source

git clone https://github.com/labxscut/sxLaep
cd sxLaep
pip install -e .

Docker

docker pull labxscut/sxlaep:python3.11
docker run --rm -it -v $(pwd):/workspace labxscut/sxlaep:python3.11 bash

Quick Start

Predict enzyme probability for a single protein sequence or a FASTA file in just a few lines of code using the bundled pre-trained model.

Command Line (shorthand)

sxlaep --input sequences.fasta --output predictions.csv

Python API

from pathlib import Path
import sxlaep
from sxlaep.model import load_model, predict_sequences, predict_fasta

# Load the bundled pre-trained model (native UBJSON format)
model_path = Path(sxlaep.__file__).parent / "enzyme_xgb_model.ubj"
model = load_model(model_path)

# Single sequence prediction
df = predict_sequences(model, ["MKVLW..."])
# df['pred_label']          -> 0 (Non-Enzyme) or 1 (Enzyme)
# df['enzyme_probability']  -> float (0.0 ~ 1.0)

# FASTA file prediction
result = predict_fasta(
    model_path=model_path,
    fasta_path="sequences.fasta",
    output_csv="predictions.csv",
)
print(result.head())

API Reference

Complete API documentation for all sxLaep modules (v1.0.5).

config — Configuration & Constants

Configuration dataclasses and biochemical constants used by sxLaep.

FeatureConfig(lag=10, weight=0.05, n_segments=3, add_length=True, properties=PROPERTIES)
Frozen dataclass. Feature extraction configuration.
ParameterDefaultDescription
lag10Maximum correlation lag used by multi-property pseudo-AAC.
weight0.05Weight applied to sequence-order correlation terms.
n_segments3Number of N-to-C sequence windows used by windowed AAC.
add_lengthTrueWhether to append raw sequence length to the pseudo-AAC vector.
propertiesPROPERTIESAmino-acid physicochemical property tables used by pseudo-AAC.

Constants

NameDescription
AA2020 standard amino acid alphabet (ACDEFGHIKLMNPQRSTVWY).
HYDROHydrophobicity values for each amino acid.
POLARPolarity values for each amino acid.
CHARGECharge values for each amino acid.
PROPERTIESCombined dictionary of hydro, polar, and charge.
CTD_GROUPSPhysicochemical group definitions for CTD features (7 systems: hydrophobicity, normalized VDW, polarizability, secondary structure, solvent access, polarity, charge).
fasta — FASTA Parsing

FASTA reading and writing utilities for protein sequence experiments.

FastaRecord(identifier: str, description: str, sequence: str)
Frozen dataclass. A single FASTA record with identifier, full description (header without >), and concatenated protein sequence.
read_fasta(fasta_path: str | Path) → list[str]
Read a FASTA file and return only sequence strings (discards headers).
read_fasta_records(fasta_path: str | Path) → list[FastaRecord]
Read a FASTA file and return full records with identifiers, descriptions, and sequences.
write_fasta_records(records: Iterable[FastaRecord], output_path: str | Path) → None
Write FASTA records to disk with 80-char line wrapping. Creates parent directories as needed.
features — Feature Extraction

Protein sequence feature extraction for sxLaep. Combines pseudo-AAC, CTD, and windowed AAC into a 258-dimensional feature vector.

extract_features(sequence: str, config: FeatureConfig | None = None) → np.ndarray
Extract the full sxLaep feature vector for one protein sequence (pseudo-AAC + CTD + windowed AAC).
extract_feature_matrix(sequences: Sequence[str], config=None, n_jobs=1) → np.ndarray
Extract a feature matrix from a sequence collection with optional parallel processing via joblib. Returns (n_sequences, n_features) array.
feature_names(config: FeatureConfig | None = None) → list[str]
Return descriptive names for all extracted sxLaep features.
pse_aac_multi(sequence, lam=10, weight=0.05, properties=PROPERTIES, add_length=True) → np.ndarray
Compute multi-property pseudo-amino acid composition features. Returns vector of length 20 + lam × n_properties + int(add_length).
ctd_features(sequence: str) → np.ndarray
Compute composition-transition-distribution features using 7 physicochemical group systems. Returns 147 features (21 per system: 3 composition + 3 transition + 15 distribution).
window_aac(sequence: str, n_segments=3) → np.ndarray
Compute windowed amino acid composition over N-to-C sequence segments. Returns n_segments × 20 features.
sanitize_sequence(sequence: str) → str
Return an uppercase protein sequence containing only the 20 standard amino acids (non-standard characters removed).
model — Model & Prediction

Model loading and prediction utilities. Pre-trained models use native XGBoost UBJSON format (.ubj) for cross-version compatibility.

load_model(model_path: str | Path) → XGBClassifier
Load a model from native XGBoost format (.json / .ubj) or legacy joblib pickle. Prefers the sibling .ubj file when loading .pkl to avoid version-skew warnings.
predict_sequences(model, sequences, config=None, n_jobs=1) → pd.DataFrame
Predict enzyme probabilities for a list of protein sequences. Returns DataFrame with columns pred_label (0/1) and enzyme_probability (float).
predict_fasta(model_path, fasta_path, output_csv, config=None, n_jobs=1) → pd.DataFrame
Load a model, predict all sequences in a FASTA file, and write results to CSV. Returns DataFrame with columns sequence_id, description, pred_label, enzyme_probability.
run_prediction_pipeline(model_path, fasta_path, output_csv='results/predictions.csv', feature_config=None, n_jobs=1) → pd.DataFrame
Run the complete FASTA-to-prediction workflow. Thin wrapper around predict_fasta.
pipeline — End-to-End Workflow

High-level wrapper for the main sxLaep prediction workflow.

run_prediction_pipeline(model_path, fasta_path, output_csv='results/predictions.csv', feature_config=None, n_jobs=1) → pd.DataFrame
Run the complete FASTA-to-prediction workflow. Thin wrapper around predict_fasta.
cli — Command-Line Interface
build_parser() → argparse.ArgumentParser
Build the sxLaep command-line argument parser with predict subcommand and --input shorthand.
main(argv: list[str] | None = None) → None
Run the sxLaep command-line interface.

Shorthand (bundled model)

sxlaep --input query.fasta --output predictions.csv

Uses the packaged enzyme_xgb_model.ubj. Feature parameters are fixed to the bundled model's defaults.

Predict Subcommand

sxlaep predict \
  --model results/sxlaep_training/enzyme_xgb_model.ubj \
  --fasta data/query.fasta \
  --output results/query_predictions.csv \
  --lag 10 --weight 0.05 --segments 3 \
  --properties hydro polar charge \
  --n-jobs 4

Workflow

End-to-end prediction workflow from raw FASTA files to enzyme/non-enzyme classification results.

Prediction Example

# CLI (shorthand, bundled model)
sxlaep --input data/query.fasta --output results/predictions.csv

# CLI (subcommand, custom model)
sxlaep predict \
  --model results/sxlaep_training/enzyme_xgb_model.ubj \
  --fasta data/query.fasta \
  --output results/query_predictions.csv

# Python API
from sxlaep.model import predict_fasta

df = predict_fasta(
    model_path="results/sxlaep_training/enzyme_xgb_model.ubj",
    fasta_path="data/query.fasta",
    output_csv="results/query_predictions.csv",
)
print(df[["sequence_id", "pred_label", "enzyme_probability"]].head())

Reference

Parameters, output formats, notes, and citations.

Feature Extraction Parameters

ParameterTypeDefaultDescription
lagint10Maximum correlation lag for pseudo-AAC.
weightfloat0.05Weight applied to sequence-order correlation terms.
n_segmentsint3Number of N-to-C sequence windows for windowed AAC.
add_lengthboolTrueAppend raw sequence length to the feature vector.
propertiesdictPROPERTIESPhysicochemical property tables (hydrophobicity, polarity, charge).

Output Format (predict_fasta CSV)

ColumnTypeDescription
sequence_idstrFASTA identifier (first whitespace-delimited token of the header).
descriptionstrFull FASTA header without the leading >.
pred_labelintPredicted class: 0 = Non-Enzyme, 1 = Enzyme.
enzyme_probabilityfloatEnzyme probability score (0.0 ~ 1.0).

Notes

Citations

Please cite sxLaep if you use it in your research:

labxscut. sxLaep: Rapid Enzyme/Non-Enzyme Prediction using Sequence Features and XGBoost. (2026).

Additional references:

  1. Chou KC. Pseudo amino acid composition and its applications in bioinformatics, proteomics and genome biology. Curr Protein Pept Sci. 2010;11(6):573-95.
  2. Dubchak I, Muchnik I, Holbrook SR, Kim SH. Prediction of protein folding class using global description of amino acid sequence. Proc Natl Acad Sci USA. 1995;92(19):8700-4.
  3. Chen T, Guestrin C. XGBoost: A scalable tree boosting system. KDD 2016. p.785-94.