KmPred is a machine learning framework for predicting the Michaelis–Menten constant (Km) of drug–target interactions.
Accurate prediction of Km values is critical for understanding enzyme kinetics, characterizing drug–target binding, and guiding drug discovery pipelines.
This repository contains Jupyter notebooks for preprocessing, feature engineering, training, and evaluating predictive models, along with saved model files and figures.
The Michaelis–Menten constant (Km) is a fundamental parameter in enzymology that quantifies the substrate concentration at which the reaction rate is half of its maximum (Vmax).
For drug–target interactions, Km values are essential for understanding binding affinity, enzyme efficiency, and the overall pharmacological effect of drug candidates.
However, experimentally determining Km values is time-consuming and resource-intensive. To address this, KmPred leverages computational modeling and machine learning techniques to predict Km values directly from molecular and protein features.
Key objectives of KmPred include:
- Automating preprocessing of drug and protein datasets
- Generating meaningful features (descriptors, embeddings, fingerprints, etc.)
- Training robust machine learning models (tree-based and neural architectures)
- Evaluating prediction accuracy with standard metrics (e.g., RMSE, MAE, R²)
- Providing ready-to-use trained models for further drug discovery applications
By integrating computational approaches, KmPred provides a scalable and efficient framework for in silico prediction of drug–target Km values, reducing reliance on expensive experimental assays.
Important: The data used in this project are not included in this repository.
- All raw/processed data have been uploaded to Figshare. You will need to download the data archive and ensure that the folder layout matches what the notebooks expect.
- Typical data used includes (but may not be limited to):
- Drug–target interaction pairs with experimentally determined Km values
- Molecular features for small molecules (fingerprints, descriptors, embeddings)
- Protein features (sequence-based embeddings, structural features)
- Training/test splits for reproducibility
KmPred/
│
├── codes/ # Jupyter notebooks for preprocessing, feature extraction, model training, evaluation
├── figures/ # Plots, evaluation metrics, visualizations
├── models/ # Saved trained models (e.g., Random Forest, XGBoost)
├── data/ # Placeholder for datasets (download from Figshare)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
Clone the repository and install the dependencies:
git clone https://github.com/misharisaud/KmPred.git
cd KmPred
pip install -r requirements.txt- Download the data from this Figshare link.
- Open and run the Jupyter notebooks in the
codes/folder in order (preprocessing → feature extraction → model training → evaluation). - Trained models will be saved in the
models/folder and can be reused without retraining.
Each notebook in the codes/ folder has a specific purpose:
Data preprocessing – cleaning datasets, formatting drug–target pairs
Feature extraction – generating descriptors for drugs and proteins (fingerprints, embeddings, MPEK features, etc.)
Model building – training and evaluating ML models such as Random Forest, XGBoost, and neural networks
Visualization – plotting results, comparing metrics, generating figures for analysis
- Loads training and testing datasets (
train.csv,test.csv). - Splits
features/labelsfor Km prediction. - Defines evaluation metrics: RMSE, MAE, R².
- Uses XGBoost and RandomForestRegressor as models.
- Trains, evaluates, and saves models using
joblib.
- Loads protein FASTA sequences from
protein_seq.fasta. - Extracts sequence-based features using MPEK (Multi-scale Protein Encoding Kernels).
- Computes descriptors and builds feature matrices.
- Outputs extracted protein features for downstream model training.
- Loads multiple CSV feature files from sequence and ligand directories.
- Performs row-safe concatenation by enforcing identical row counts and ID alignment.
- Adds filename prefixes to feature columns to avoid naming conflicts.
- Outputs consolidated feature files for sequences and ligands.
- Processes protein sequences and ligand SMILES from train/test splits.
- Generates FASTA files and deduplicates sequences/SMILES while preserving mappings.
- Extracts extensive protein features using iFeatureOmegaCLI (72+ descriptor types).
- Computes ESM embeddings for protein sequences using ESM-1b and ESM-2 models.
- Generates ligand descriptors using RDKit and iFeatureOmegaCLI with fallback methods.
- Handles error recovery and zero-filling for invalid molecular structures.
- Saves all features to structured directories for model training.
- Loads multiple protein and ligand feature files (e.g., ProtBERT, UniRep embeddings) from CSV files.
- Concatenates feature matrices column-wise for training and testing sets, ensuring row consistency.
- Reads original train/test CSV files and unique FASTA sequences.
- Builds lookup dictionaries mapping sequence strings to feature vectors.
- Enriches the original dataset CSV files by appending protein sequence features (e.g., from ProtBERT, UniRep) while filtering out rows with missing or unmapped sequences.
- Outputs new CSV files (e.g.,
train_short_sequences_with_more_features.csv) with appended features for downstream use.
- Drops redundant
sequence_idcolumns from feature sets. - Merges kinetic data (pH, Temp, log10_Km) with protein and ligand features using a common identifier or index-based alignment.
- Trains an XGBoost regression model on the combined feature set to predict log10_Km.
- Evaluates model performance using RMSE, MAE, R², and Pearson correlation.
- Processes enzyme kinetics data from
enzyme_kinetics_filtered.csvand generates FASTA and SMILES files for sequences and ligands. - Uses
iFeatureOmegaCLIto compute a wide range of protein sequence descriptors (e.g., AAC, CKSAAP, CTDC, PAAC, etc.) and saves each feature set as a separate CSV file. - Extracts protein embeddings using ESM-1b and ESM-2 models via the
fair-esmlibrary and saves them as CSV files. - Processes ligand SMILES using
RDKitandiFeatureOmegaCLIto compute molecular descriptors and fingerprints (e.g., EState, MACCS, Morgan fingerprints, etc.). - Includes custom functions for PubChem-like fingerprints, MACCS keys, and chemical descriptors using Open Babel and RDKit.
- Handles large datasets with parallel processing and error logging for failed molecules.
- Saves all extracted features into structured directories for downstream machine learning tasks.
- Installs and configures specific versions of transformers, tokenizers, and related libraries (including downgrades for compatibility).
- Uses BioPython to read protein sequences from FASTA files.
- Generates protein sequence embeddings using three different pre-trained models:
- ProtBERT (Rostlab/prot_bert_bfd) for 1024-dimensional embeddings
- UniRep (jax-unirep) for 1900-dimensional embeddings
- ProtT5 (Rostlab/prot_t5_xl_uniref50) for embeddings
- Handles GPU setup and compatibility issues with CUDA, JAX, and numpy versions.
- Processes sequences in batches and saves the resulting embeddings to CSV files for later use in machine learning models.
- Loads and explores BRENDA enzyme kinetics data.
- Performs data preprocessing including grouping by enzyme-substrate combinations and averaging KM values.
- Handles molecular fingerprints (ECFP, RDKit, MACCS) and protein sequence embeddings (UniRep).
- Splits data into training and test sets with stratified sampling.
- Exports cleaned datasets and cross-validation indices for machine learning use.
- Includes visualizations of log10(KM) distributions across splits.
- Loads training and test datasets from CSV files containing KEGG IDs, sequences, and log10(Km) values.
- Standardizes molecular structures from
.molfiles using RDKit, including metal disconnection, normalization, reionization, and tautomer enumeration. - Generates canonical isomeric SMILES strings for each molecule.
- Maps KEGG IDs to their corresponding standardized SMILES representations.
- Saves shortened datasets (KEGG ID, Sequence, log10_KM, SMILES) for downstream use.
- Uses RDKit’s MolStandardize and molecular file parsing utilities for cheminformatics preprocessing.
- Loads two sets of CSV files:
- Original datasets with SMILES (
test_short_smiles.csv,train_short_smiles.csv) - BRENDA enzyme datasets with various fingerprints (
brenda_test_seq.csv,brenda_train_seq.csv)
- Original datasets with SMILES (
- Creates KEGG ID to SMILES mapping using mode aggregation (falling back to first value).
- Merges SMILES data from original datasets into BRENDA datasets using KEGG ID matching.
- Exports the enhanced datasets with SMILES information:
brenda_train_short_smiles.csvbrenda_test_short_smiles.csv
- Maintains consistent column structure: ['KEGG ID', 'Sequence', 'log10_KM', 'smiles'].
- Loads training and testing datasets (
train_short_smiles_with_features.csv,test_short_smiles_with_features.csv). - Extracts ligand features (
lig_f) and sequence features (seq_f) from the datasets. - Concatenates ligand and sequence features into a single feature matrix.
- Applies SelectKBest feature selection to reduce dimensionality to 10,000 features.
- Performs hyperparameter tuning using
RandomizedSearchCVwithXGBoost (GPU-accelerated). - Handles CUDA memory allocation errors during cross-validation.
- Evaluates the best model on test data using MSE, RMSE, R², Pearson, and Spearman correlation.
- Saves the trained model and feature selector to disk using
joblib.
The repository generates the following outputs:
- Figures (
figures/): evaluation plots (scatter, residuals, error distributions) - Metrics: RMSE, MAE, R² for regression models
- Saved models (
models/): trained models serialized with joblib or similar
Pre-trained models are available in the models/ folder after running the training notebooks. These models can be directly loaded for inference without retraining. Example:
import joblib
model = joblib.load("models/dtbaffinity_xgb_tuned.pkl")
prediction = model.predict(X_test)