Skip to main content
Glama
KiruthikaSelvaraj1

BBB Permeability Screening Agent

README.md
BBB Permeability Screening Agent

An agentic AI system that predicts whether a drug molecule can cross the blood-brain barrier (BBB) — a key early-stage filter in CNS (brain-related) drug discovery — combining a benchmarked machine learning classifier with agent orchestration, molecular similarity search, and uncertainty awareness.

What it does

Given a medicine name (e.g. "paracetamol") or a raw SMILES structure, the system:

Resolves the name to its chemical structure via PubChem
Predicts BBB permeability using a machine learning classifier trained on real, lab-verified data
Explains the prediction in plain language, grounded in the molecule's actual physicochemical properties
Finds structurally similar known drugs and their known BBB status
Flags when the molecule is unlike anything the model was trained on (applicability domain check), so predictions aren't silently overconfident
Why this matters

Your brain is protected by a natural barrier that blocks most substances — including roughly 98% of small-molecule drugs — from reaching it. This is why treating brain conditions (epilepsy, depression, Alzheimer's, brain tumors) is far harder than treating most other illnesses: pharmaceutical companies often discover a promising drug candidate can't reach the brain only after years of expensive development. Early computational screening, like this project does at small scale, is a real, established step in actual drug discovery pipelines.

Who this is for
Primary: drug discovery researchers/students doing early-stage screening of candidate compounds for CNS drug development
Secondary: as a demonstration of applying current agentic AI engineering (tool orchestration, MCP, explainability, uncertainty quantification) to a real scientific problem

The simplified conversational UI (common medicine name buttons, plain-English explanations) is a presentation layer built to make the underlying science accessible for demos — the underlying tool is built for the researcher use case above.

Related work

BBB permeability prediction is an active, published research area — this project is not a novel scientific contribution, and doesn't claim to be. Existing tools and research include:

BBBper — a live, public ML-based web tool (random forest, ~97% accuracy on its external test set) — http://bbbper.mdu.ac.in
DeePred-BBB (Kumar et al., 2022, Frontiers in Neuroscience) — a deep learning model for improved BBB prediction accuracy
Ensemble ML approaches combining random forest with molecular fingerprints, reporting ROC-AUC around 0.957 in 5-fold cross-validation
Recent work combining LLMs (transformer-based SMILES encoders) with gradient boosting, validated against real lab experiments

This project's differentiation isn't raw accuracy — it's the engineering approach: an agentic system (LangGraph orchestration, MCP tool exposure, similarity search, applicability domain awareness) wrapped around the prediction task, rather than a standalone prediction webpage.

Architecture
BBBP.csv (2039 real, lab-verified molecules)
        |
        v
RDKit featurization (molecular weight, LogP, TPSA, H-bond counts, etc.)
        |
        v
Model comparison: Logistic Regression, SVM, Random Forest, XGBoost
        |         (5-fold cross-validation)
        v
Random Forest selected (best cross-validated ROC-AUC)
        |
        v
   [MCP tools] lookup_smiles / predict_bbbp / explain_prediction
        |
        v
LangGraph agent (route -> lookup -> predict -> explain)
        |
        v
FastAPI backend (+ molecule structure images, similarity search,
                   applicability domain check)
        |
        v
Streamlit frontend (plain-language UI, similar-drugs, comparison mode)
Results

Evaluated with 5-fold stratified cross-validation, then confirmed on a held-out test set (20% of data, never seen during training or model selection):

Model	CV ROC-AUC (mean ± std)
Random Forest (selected)	0.881 ± 0.014
XGBoost	see results/model_comparison.csv
SVM (RBF kernel)	see results/model_comparison.csv
Logistic Regression	see results/model_comparison.csv

Held-out test set performance (Random Forest): 0.923 ROC-AUC, 88% accuracy. Confusion matrix and ROC curve figures in results/.

How this compares to published work: consistent with a 2026 study using an identical setup (random forest, 2048-bit Morgan fingerprints, 5-fold CV) that also found random forest to be the top classical-ML performer on BBBP. Above typical fingerprint-based baseline ranges (~0.80–0.85) reported in the literature; below state-of-the-art graph neural network approaches (~0.96), which use 3D structural information beyond this project's scope.

Note on evaluation methodology: this project uses a random train/test split. The official MoleculeNet BBBP benchmark uses a scaffold split (test molecules have structurally distinct scaffolds from training), which is a harder, more realistic evaluation setting.

Project structure
src/
  features.py               RDKit featurization
  train.py                  Initial model training
  model_comparison.py       Multi-model comparison + evaluation figures
  build_similarity_index.py Precomputes fingerprints for similarity search
  similarity_search.py      Similarity search + applicability domain check
  pubchem_lookup.py         Molecule name -> SMILES resolution
  mcp_server.py             MCP tool exposure
  agent.py                  LangGraph orchestration
  api.py                    FastAPI backend
  app.py                    Streamlit frontend
data/BBBP.csv                Source dataset
models/                       Trained model, scaler, similarity index
results/                      Evaluation figures and comparison table
Setup
bash
pip install -r requirements.txt
Train the model
bash
cd src
python train.py                # initial baseline model
python build_similarity_index.py
python model_comparison.py     # multi-model comparison, selects best model
Run

Two terminals:

bash
cd src
uvicorn api:app --reload
bash
cd src
streamlit run app.py

Or as a standalone MCP server (for use with Claude Desktop or another MCP client):

bash
cd src
python mcp_server.py
Limitations
Trained on 2039 molecules — small relative to production-scale datasets
Uses 10 hand-picked physicochemical descriptors, not full molecular fingerprints or 3D structure
Predictions are pattern-matches against historical lab data, not simulations of biology — the applicability domain check flags when a molecule is too unlike anything in training data to trust the prediction
Not validated against real lab experiments — a research/demo project, not a clinical or production tool
Disclaimer

This is a student research/demonstration project. It is not medical advice and should not be used to make real medical or pharmaceutical decisions.