How sanjanb/bio-pipeline works
Purpose and entry points
Protein Intelligence Platform is a FastAPI web service for retrieving AlphaFold structures and enriching them with confidence, sequence, domain, and homology analysis. The ASGI entry point is app.py (uvicorn app:app). Browser routes submit jobs, expose status/results/downloads, and serve Jinja2 pages from templates/.
Web/API and job lifecycle
app.py owns request handling: POST /predict creates a job and launches background processing; status pages/API poll persisted state; result, raw-PDB, report, and download routes read generated artifacts. This is an in-process FastAPI background-task model, not a durable worker queue, so execution is coupled to the application process.
• app.py
• templates/status.html
• templates/result.html
Persistent job boundary
Job identity, lifecycle state/current pipeline step, and job-history access are modeled separately from protein-analysis data. SQLite is the system of record for progress; generated PDB/report/PyMOL assets remain local filesystem files under the configured output directory. This boundary enables browser polling but does not provide distributed storage or queue recovery.
• models/job.py
• models/protein.py
• data_sources/cache.py
Enrichment orchestration
The async data-source pipeline normalizes user input and composes a canonical protein profile from remote services. It resolves UniProt metadata/sequence, potentially gene and homolog information from Ensembl, NCBI-derived annotations, and BLAST homology; source failures such as BLAST timeouts are best-effort rather than necessarily blocking final output.
• data_sources/pipeline.py
• data_sources/uniprot_client.py
• data_sources/blast_client.py
Structure acquisition and analysis
Structure prediction here means AlphaFold DB lookup/download rather than local model inference. The AlphaFold client obtains a PDB for an accession/eligible sequence; the analyzer parses PDB content with Biopython and derives per-residue pLDDT/confidence summaries used downstream. Sequence input is limited by the AlphaFold DB constraint described in the README.
• alphafold_client.py
• pdb_analyzer.py
• models/protein.py
External-service integration layer
Remote API concerns are split by provider: AlphaFold DB for predicted structures; UniProt for protein metadata/features; Ensembl REST for gene/homology; NCBI E-utilities/CDD for annotations; and NCBI BLAST for similarity searches. File caching reduces repeated source requests; organism normalization supports cross-provider query consistency.
• data_sources/ensembl_client.py
• data_sources/ncbi_client.py
• data_sources/organism.py
Presentation and artifact generation
Analysis results produce three delivery forms: interactive server-rendered pages, a standalone HTML report, and a PyMOL script. Browser pages use 3Dmol.js to fetch raw PDB via the API and Chart.js for confidence visualization; templates render domains and BLAST findings from the assembled profile.
• report_generator.py
• pymol_generator.py
• templates/report.html
Runtime and deployment
The runtime is Python 3.11+ with FastAPI, Jinja2, and Biopython; dependencies are managed by uv. Container packaging is provided by Dockerfile, with Render deployment configuration in render.yaml. Required state is local SQLite plus writable local output storage, making horizontal scaling or ephemeral-container restarts material operational constraints.
• Dockerfile
• render.yaml
• pyproject.toml
Main entry points: pipeline.py Enrichment pipeline · app.py In-process job runner · protein.py Protein profile · report_generator.py HTML report generator
Components 19
Web application
- FastAPI app · Creates jobs, serves polling, results, artifacts, and pages.
app.py - Browser pages · Status and result pages poll jobs and visualize PDB confidence.
templates/status.html - In-process job runner · Execution is coupled to the application process rather than a durable queue.
app.py
Analysis pipeline
- Protein profile · Canonical enriched protein data used by analysis and presentation.
models/protein.py - Enrichment pipeline · Normalizes input and assembles the protein profile with best-effort sources.
data_sources/pipeline.py - AlphaFold client · Looks up and downloads AlphaFold DB PDB structures.
alphafold_client.py - PDB confidence analysis · Parses PDB residues and derives pLDDT confidence summaries.
pdb_analyzer.py
State and artifacts
- Job lifecycle · Tracks job identity, current step, state, and history.
models/job.py - Source cache · Reduces repeated remote-source requests.
data_sources/cache.py - SQLite job state · System of record for progress and polling state.
models/job.py - Local output storage · Stores generated PDB, reports, and PyMOL files.
- HTML report generator
report_generator.py - PyMOL generator
pymol_generator.py - Standalone report template · Renders domains and BLAST findings.
templates/report.html
External providers
- UniProt · Supplies protein metadata, sequence, and features.
data_sources/uniprot_client.py - Ensembl REST
data_sources/ensembl_client.py - NCBI E-utilities/CDD
data_sources/ncbi_client.py - NCBI BLAST · Timeouts and source failures can be non-blocking.
data_sources/blast_client.py
Other components
- Container deployment · Requires writable local SQLite and output storage.
Dockerfile
Connections 23
- Browser pages → FastAPI app: submits and polls
- FastAPI app → In-process job runner: launches
- FastAPI app → SQLite job state: reads status and history
- In-process job runner → Job lifecycle: updates lifecycle
- Job lifecycle → SQLite job state: persists
- In-process job runner → Enrichment pipeline: runs
- Enrichment pipeline → Protein profile: assembles
- Enrichment pipeline → UniProt: queries
- Enrichment pipeline → Ensembl REST: queries
- Enrichment pipeline → NCBI E-utilities/CDD: queries
- Enrichment pipeline → NCBI BLAST: queries
- Enrichment pipeline → Source cache: uses
- In-process job runner → AlphaFold client: acquires structure
- AlphaFold client → PDB confidence analysis: provides PDB
- PDB confidence analysis → Protein profile: adds confidence
- In-process job runner → Local output storage: writes generated assets
- Protein profile → HTML report generator: supplies results
- HTML report generator → Standalone report template: renders
- HTML report generator → Local output storage: writes HTML
- Protein profile → PyMOL generator: supplies analysis
- PyMOL generator → Local output storage: writes script
- FastAPI app → Local output storage: serves downloads and raw PDB
- Container deployment → FastAPI app: packages runtime