How eylernur/genowall works
Purpose and Entry Points
GenoWall is a research prototype for predicting antimicrobial resistance from an uploaded bacterial genome FASTA, with calibrated per-drug predictions, abstention (“no-call”), and evidence labels. Default scope is *Klebsiella pneumoniae* and four antibiotics.
Runtime entry points:
• FastAPI inference service: src/api.py
• Prediction orchestration: src/predict.py
• Svelte/Vite browser UI: ui/src/main.ts, ui/src/App.svelte
• Optional Streamlit frontend: app/streamlit_app.py
• Reproducible training pipeline: Makefile
Genome Annotation and Feature Boundary
Raw genomes and laboratory AST labels are acquired, then each genome is annotated by AMRFinderPlus. Annotation results become binary gene/mutation features subject to configured identity and coverage thresholds.
Core paths:
• src/ingest_bvbrc.py
• src/annotate.py
• src/features.py
Persisted training boundary:
• data/processed/features.parquet
• data/processed/labels.parquet
• data/processed/feature_dictionary.csv
The feature dictionary distinguishes recognized AMR mechanisms from features used only as statistical associations.
Leakage-Resistant Model Development
Genomes are grouped by Mash homology before splitting, so closely related genomes cannot cross train, calibration, and held-out test partitions. This is the central generalization-control boundary.
Core paths:
• src/cluster_split.py
• data/processed/splits.json
• tests/test_leakage.py
Per antibiotic, the system trains balanced L2 logistic-regression models and calibrates probabilities using the calibration partition. Shipped artifacts permit inference without recreating training data:
• src/train.py
• models/ciprofloxacin.joblib
• models/meropenem.joblib
Decision Layer: Gates, Abstention, Explanation
Inference combines calibrated model probabilities with biological and uncertainty controls. A target-gene gate checks whether expected molecular targets appear intact; no-call rules abstain for uncertain probabilities, gate/model disagreement, or out-of-distribution genomes. Explanation classifies the supporting evidence rather than presenting all features as established mechanisms.
Core paths:
• src/target_gate.py
• src/nocall.py
• src/explain.py
Drug-to-target knowledge is maintained in drugs.csv. Evaluation emits held-out discrimination and calibration results in src/evaluate.py and reports/metrics.md.
Online Prediction Flow
POST /predict accepts multipart FASTA. The API delegates to prediction orchestration, which performs AMRFinderPlus annotation, feature construction aligned to trained-model features, per-drug scoring, decision controls, and report assembly. GET /health exposes runtime scope and safety banners; GET /metrics serves reported evaluation output.
Core paths:
• src/api.py
• src/predict.py
• src/annotate.py
This service is intentionally separate from Vercel because annotation requires native bioinformatics tooling and typically takes 1–2 minutes per genome.
User Delivery and Deployment Boundary
The Svelte UI uploads FASTA to a configurable HTTPS API endpoint and renders drug cards, recommendation, evidence, PDF download, and sharing. It has a mock/preview mode when no API URL is configured.
Core paths:
• ui/src/lib/api.ts
• ui/src/lib/components/UploadZone.svelte
• ui/src/lib/components/DrugCard.svelte
The UI is deployable to Vercel through ui/vercel.json; the Python API must run on a laptop or VM with the Conda environment and AMRFinder database.
Material Dependencies and Controls
Python runs with FastAPI, scikit-learn, AMRFinderPlus, and Mash as declared by environment.yml; Node 20+ runs the Vite/Svelte frontend through ui/package.json. External scientific sources are BV-BRC for genomes/lab phenotypes and NCBI AMRFinderPlus for resistance annotations. Scope, drugs, model thresholds, calibration, clustering, and no-call behavior are centrally controlled by config.yaml.
Main entry points: api.py FastAPI service · predict.py Prediction orchestration · features.py Feature construction · train.py Model training and calibration
Components 19
Offline training pipeline
Reproducible data preparation, validation, and model development.
- BV-BRC genomes and AST · Genome sequences and laboratory phenotypes.
- Data ingestion
src/ingest_bvbrc.py - Feature construction · Applies identity and coverage thresholds to binary features.
src/features.py - Processed training data · Feature matrix and AST labels.
data/processed/features.parquet - Feature dictionary · Separates recognized mechanisms from statistical associations.
data/processed/feature_dictionary.csv - Mash homology split · Prevents related genomes crossing development partitions.
src/cluster_split.py - Train/calibration/test splits
data/processed/splits.json - Model training and calibration · Per-drug balanced L2 logistic regression with calibrated probabilities.
src/train.py - Held-out evaluation · Emits discrimination and calibration results.
src/evaluate.py - Evaluation report
reports/metrics.md
Python inference service
Native-tooling runtime for genome prediction.
- AMRFinderPlus annotation · Calls resistance genes and mutations from genomes.
src/annotate.py - Shipped drug models · Inference-ready calibrated models.
models/ciprofloxacin.joblib - FastAPI service · Provides prediction, health, and metrics endpoints.
src/api.py - Prediction orchestration · Coordinates annotation, aligned features, scoring, and report assembly.
src/predict.py - Safety decision layer · Target gate, abstention rules, and evidence classification.
src/target_gate.py
Browser delivery
Separately deployed client applications.
- Svelte upload UI · Uploads FASTA and renders drug cards, evidence, and reports.
ui/src/App.svelte - HTTPS API client · Uses a configurable endpoint or mock preview mode.
ui/src/lib/api.ts - Optional Streamlit frontend
app/streamlit_app.py
Other components
- Central scope controls · Controls drugs, thresholds, calibration, clustering, and no-call behavior.
config.yaml
Connections 26
- BV-BRC genomes and AST → Data ingestion: genomes and AST labels
- Data ingestion → AMRFinderPlus annotation: training genomes
- AMRFinderPlus annotation → Feature construction: gene and mutation calls
- Feature construction → Processed training data: features and labels
- Feature construction → Feature dictionary: feature classification
- Processed training data → Mash homology split: genomes for partitioning
- Mash homology split → Train/calibration/test splits: homology-safe partitions
- Processed training data → Model training and calibration: training data
- Train/calibration/test splits → Model training and calibration: train and calibration sets
- Model training and calibration → Shipped drug models: calibrated per-drug models
- Model training and calibration → Held-out evaluation: models
- Train/calibration/test splits → Held-out evaluation: held-out test set
- Held-out evaluation → Evaluation report: reported results
- Central scope controls → Feature construction: feature thresholds
- Central scope controls → Mash homology split: clustering controls
- Central scope controls → Safety decision layer: drug and no-call policy
- Svelte upload UI → HTTPS API client: submits FASTA
- HTTPS API client → FastAPI service: POST /predict
- Optional Streamlit frontend → FastAPI service: prediction requests
- FastAPI service → Prediction orchestration: delegates prediction
- FastAPI service → Evaluation report: GET /metrics
- Prediction orchestration → AMRFinderPlus annotation: uploaded FASTA
- Prediction orchestration → Shipped drug models: aligned feature scoring
- Prediction orchestration → Safety decision layer: calibrated probabilities
- Safety decision layer → FastAPI service: per-drug calls and evidence
- Feature dictionary → Safety decision layer: evidence labels