This software is an advanced AI-driven clinical decision-support system engineered to assist infectious disease specialists and healthcare practitioners in detecting HIV-1 antiretroviral drug resistance and optimizing combination Antiretroviral Therapy (ART) regimens.
The system features a hybrid multi-tier clinical intelligence architecture:
-
Machine Learning Diagnostic Portfolio (
ml/models_xgb/):- 25 Antiretroviral Drugs across all 5 therapeutic classes (NRTI, NNRTI, INSTI, PI, and Capsid inhibitor Lenacapavir).
- 50 fine-tuned XGBoost models (25 classifiers + 25 log-fold-change regressors) trained on 14,820 clinical genotype-phenotype isolate pairs from the Stanford HIV Drug Resistance Database (HIVdb).
-
Sequence-Aware Deep Learning Framework (
ml/deep_learning/):-
Multi-Scale 1D-CNN: Multi-receptive field convolutional kernels (
$k=3, 5, 7$ ) capturing physical binding pockets, catalytic triads, and flap loops. -
ESM-2 Protein Transformer with Pure PyTorch LoRA: 4-layer RoPE Transformer encoder (
$d=256$ , 16 attention heads) with built-in Low-Rank Adaptation for parameter-efficient transfer learning. -
Dirichlet Evidential Deep Learning (Subjective Logic): Quantifies epistemic model uncertainty (
$u \in [0, 1]$ ) with clinical reliability tiers (High Reliability, Moderate, High Epistemic Uncertainty / Out-of-Distribution). - Surveillance Epistatic Mutation-Pair (SEMP) Graph: Multi-head cross-attention layer detecting biological epistasis (synergy, antagonism, compensatory rescue).
- 1D Grad-CAM Sequence Heatmaps: Continuous per-residue gradient activation mapping explaining resistance decisions.
-
Multi-Scale 1D-CNN: Multi-receptive field convolutional kernels (
-
Clinical Decision Rules Engine (
clinical/):- Scores and ranks candidate ART regimens (e.g.
TDF + 3TC + DTG,BIC + FTC + TAF) applying WHO and DHHS 2026 guidelines, dual-NRTI backbone requirements, class diversity bonuses, and incompatible co-administration penalties.
- Scores and ranks candidate ART regimens (e.g.
-
Zero-PII Patient Tracking & Longitudinal History:
- Automated cryptographic identifier:
$\text{PatientTestId} = \text{HIV-} \parallel \text{YYYY} \parallel \text{-} \parallel \text{HEX}_5$ (e.g.HIV-2026-A8F3D). - Physical paper chart reference card ensures zero Personally Identifiable Information (PII) is ever stored in the database.
- Instant returning patient lookup automatically restoring previous resistance results and historical regimen rankings for longitudinal comparison.
- Automated cryptographic identifier:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React 18 / Vite Frontend β
β - Step 1: Automated PatientTestId & Physical Card β
β - Step 2: 60+ Curated Mutation Catalog Multi-Select β
β - Step 3: Dual-Engine Regimen Ranking & Scores β
β - Step 4: Grad-CAM, Evidential Gauge & SEMP Grid β
β - Diagnostics: 25-Drug Stanford HIVdb Analytics β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β REST API (FastAPI)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend Server β
β - SQLite Engine (`hiv_selector.db`) β
β - Zero-PII Case Registry & Longitudinal Search β
β - ReportLab Dynamic PDF Clinical Report Generator β
ββββββββ¬βββββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββ βββββββββββββββββββββ ββββββββββββββββββββββββ
β 50 XGBoost ML Models β β Sequence-Aware DL β β Clinical Rules β
β - 25 Classifiers β β - 1D-CNN (k=3,5,7)β β - 9 Scoring Weights β
β - 25 Regressors β β - ESM-2 + LoRA β β - 27 Formularies β
β - 14,820 Stanford Pairs β β - Dirichlet EDL β β - Redundancy Penalty β
β - Tree-Gain Importance β β - SEMP Epistasis β β - Backbone Bonuses β
βββββββββββββββββββββββββββ βββββββββββββββββββββ ββββββββββββββββββββββββ
The platform models and evaluates resistance across 25 antiretroviral agents in 5 therapeutic classes:
| Class | Count | Supported Drugs (Generic & Abbreviation) |
|---|---|---|
| NRTI (Nucleoside Reverse Transcriptase Inhibitors) | 6 | 3TC (Lamivudine), ABC (Abacavir), AZT (Zidovudine), D4T (Stavudine), DDI (Didanosine), TDF (Tenofovir Disoproxil) |
| NNRTI (Non-Nucleoside Reverse Transcriptase Inhibitors) | 5 | EFV (Efavirenz), ETR (Etravirine), NVP (Nevirapine), RPV (Rilpivirine), DOR (Doravirine) |
| INSTI (Integrase Strand Transfer Inhibitors) | 5 | DTG (Dolutegravir), BIC (Bictegravir), CAB (Cabotegravir), EVG (Elvitegravir), RAL (Raltegravir) |
| PI (Protease Inhibitors) | 8 | ATV (Atazanavir), DRV (Darunavir), FPV (Fosamprenavir), IDV (Indinavir), LPV (Lopinavir), NFV (Nelfinavir), SQV (Saquinavir), TPV (Tipranavir) |
| Capsid Inhibitor | 1 | LEN (Lenacapavir) β Multistage capsid target inhibitor |
| TOTAL | 25 | 50 Fine-Tuned XGBoost Models + Sequence Deep Learning Ensemble |
Unlike standard softmax classification which produces overconfident logits on out-of-distribution mutations, our evidential head computes Dirichlet distribution parameters:
-
High Reliability:
$u < 0.20$ -
Moderate Uncertainty:
$0.20 \le u < 0.45$ -
High Epistemic Uncertainty (OOD):
$u \ge 0.45$
Injected into the multi-head attention projection layers (
Captures non-linear biological couplings:
M184V + TDF/AZT: Hypersensitization to Tenofovir/Zidovudine.M41L + T215Y: TAM-1 synergistic excision cross-resistance.G140S + Q148H: Compensatory catalytic rescue restoring integrase fitness under INSTI pressure.K65R + M184V: Antagonistic interaction.
sih/
βββ backend/
β βββ database.py # SQLite engine & sessionmaker
β βββ main.py # FastAPI REST endpoints & UI static file serving
β βββ models.py # SQLAlchemy ORM schemas
β βββ schemas.py # Pydantic validation schemas
β βββ hiv_selector.db # SQLite clinical database
β βββ static_reports/ # Cached ReportLab PDF reports
βββ clinical/
β βββ knowledge_base.json # 9 scoring weights, 27 formularies, contraindications
β βββ regimen_rules.py # Clinical scoring and ranking algorithm
βββ ml/
β βββ data/ # Processed Stanford HIVdb datasets (PI, NRTI, NNRTI, INSTI)
β βββ models/
β β βββ metrics.json # 25-drug Stanford HIVdb metrics & tree-gain importances
β βββ models_xgb/ # 50 trained XGBoost models (25 clf + 25 reg)
β β βββ features_xgb.json # Feature index to clinical mutation mapping
β βββ deep_models/ # Saved PyTorch .pt model weights
β βββ deep_learning/
β βββ __init__.py # Dual standalone/package import resolution
β βββ sequence_tokenizer.py# Consensus reconstruction (PR, RT, IN, CA)
β βββ models_cnn.py # Multi-scale 1D-CNN (k=3, 5, 7)
β βββ models_esm.py # RoPE Transformer with pure PyTorch LoRA
β βββ models_evidential.py # Dirichlet Evidential Head, Subjective Logic, Loss
β βββ models_epistatic.py # SEMP epistatic coupling cross-attention graph
β βββ explainability.py # 1D Grad-CAM residue activation mapping
β βββ predict_deep.py # Unified multi-drug inference orchestrator
β βββ train_deep.py # Deep learning training pipeline
βββ frontend/
β βββ src/
β β βββ data/
β β β βββ mutationCatalog.js # 60+ categorized resistance mutations
β β βββ components/
β β β βββ MutationSelectDropdown.jsx# Searchable dropdown with class tabs
β β β βββ SequenceGradCAMViewer.jsx # Heatmaps, Epistemic Gauge, SEMP grid
β β βββ App.jsx # Main clinical application dashboard
β β βββ index.css # TailwindCSS styles
β βββ dist/ # Production Vite bundle (cache query ?v=7)
βββ tests/
β βββ test_api.py # 8 API integration tests
β βββ test_deep_learning.py # 25 unit tests for evidential, epistatic & CNN
βββ DOCUMENTATION_UPDATES.md # Chronological log and complete updates reference
βββ PROJECT_DOCUMENTATION.md # Architecture and handoff guide
βββ run_app.py # Automated server launcher
- Python 3.9+
- Packages:
torch,xgboost,fastapi,uvicorn,sqlalchemy,pydantic,reportlab,scikit-learn,pandas,numpy
cd sih
python3 run_app.py --port 8000Open http://localhost:8000 in your browser.
- Default Authorized Clinician:
doctor@hivclinic.org/clinicalpass123.
cd sih
python3 -m unittest discover testsResult: 33/33 tests pass (100% OK) in ~2.5 seconds.
cd sih/ml/deep_learning
python3 __init__.pyOutputs confirmation of all 22 exported modules.
The platform implements a Strict Zero-PII Policy:
- Patient names, government identification numbers, telephone numbers, and email addresses are strictly excluded from data ingestion and database schemas.
- Unique cryptographic tokens (
HIV-2026-XXXXX) are referenced on physical paperwork. - The physical paper chart remains the sole linking mechanism, providing full privacy protection under HIPAA and GDPR.