Spaces:
Build error
Build error
Upload 15 files
Browse filesFiles changed (15)
- .gitignoreAdded+15
- CHANGELOG.mdAdded+33
- CITATION.cffAdded+12
- DEPLOYMENT_CHECKLIST.mdAdded+14
- DockerfileAdded+75
- Dockerfile.liteAdded+16
- LICENSEAdded+21
- PUBLICATION_READINESS.mdAdded+47
- README.mdAdded+242
- REVISION_SUMMARY.mdAdded+42
- app.pyAdded+239
- example_metadata.csvAdded+5
- pyproject.tomlAdded+31
- requirements-dev.txtAdded+4
- requirements.txtAdded+6
123456789101112131415__pycache__/*.py[cod]*.so.pytest_cache/.ruff_cache/.coveragecoverage.xmlhtmlcov/.venv/venv/.env.DS_Storeruns/results/*.zip123456789101112131415161718192021222324252627282930313233# Changelog
## 2.0.1 - 2026-08-11
* Corrected the bacterial genetic code table so `GCC` is defined directly as alanine. Removed the previous silent runtime override.* Added an automated NCBI genetic-code table 11 regression test covering all 64 codons.* Added ENc reference-boundary tests and RSCU calculation tests.* Added automatic sample-pairing tests for `_R1/_R2`, `_1/_2`, lane suffixes, long reads and assemblies.* Automatic sample inference now rejects ambiguous duplicate read or assembly assignments instead of silently overwriting them.* Removed unused `scipy` and `pyyaml` Python dependencies.* Modernized type annotations and removed unused imports.* Replaced NaN self-comparison with explicit `math.isnan` checks.* Added explicit `check=False` to non-raising `subprocess.run` calls.* Replaced non-UI broad exception handling with specific OS/subprocess exceptions. Streamlit UI boundaries retain broad exception handling so one failed module cannot terminate the session.* Made generated run names timezone aware.* Added GitHub Actions CI for Ruff, Python compilation, pytest with coverage, citation metadata checks and the dry-run smoke test.* Added verified ORCID and institutional affiliation to `CITATION.cff`.* Removed the unverified repository placeholder from `CITATION.cff` and added a release finalization script that inserts and validates the real repository URL.* Added a biological validation harness and structured benchmark record template for direct-tool concordance studies.
## 2.0.0 - 2026-08-11
* Unified bacterial WGS workflow from raw reads or assembled genomes.* Added fastp, FastQC, MultiQC, SPAdes, Flye, Unicycler and Polypolish orchestration.* Added QUAST, CheckM2, Mash, skani and GTDB-Tk integration.* Added Bakta/Prokka annotation selection and codon-bias outputs.* Added eggNOG, AMRFinderPlus, VFDB/ABRicate, antiSMASH, MOB-suite, geNomad, IntegronFinder and MinCED modules.* Added MLST and chewBBACA support.* Added Panaroo pan-genome analysis.* Added Snippy, Gubbins and IQ-TREE core-SNP phylogenomics.* Added PopPUNK population genomics.* Preserved standalone primer design, local BLAST and PhyloForge utilities.* Added SHA256 input provenance, command manifests, software version capture and publication-report outputs.123456789101112cff-version: 1.2.0message: "If you use WOLOJI Comprehensive Bacterial Genomics Suite, please cite the software release and the underlying tools used in your selected workflow."title: "WOLOJI Comprehensive Bacterial Genomics Suite"version: "2.0.1"date-released: "2026-08-11"type: softwarelicense: MITauthors: - family-names: "Isa" given-names: "Mustafa Alhaji" orcid: "https://orcid.org/0000-0003-0074-5902" affiliation: "Bioinformatics Laboratory, Centre for Instructional Technology, University of Maiduguri, Maiduguri, Nigeria"1234567891011121314# WOLOJI deployment checklist
1. Create a Hugging Face Space with SDK set to Docker.2. Upload the repository contents at the repository root.3. Use CPU hardware with sufficient RAM for bacterial assembly. Small/default Spaces are appropriate mainly for interface testing and small examples.4. Attach persistent storage for database-heavy modules.5. Populate the required databases under `/data` or another mounted location.6. Set the corresponding Space variables.7. Rebuild the Space.8. Open **Tools & databases** and confirm that the expected executables and databases are detected.9. Run the CI workflow in the canonical source repository and confirm Ruff, compilation, pytest, citation metadata validation and dry-run smoke testing pass.10. Run at least one small validated isolate before analysing study data.11. Record the final deployed repository or Space URL with `tools/finalize_release_metadata.py` before creating a tagged publication release.12. Retain the downloaded WOLOJI run ZIP, Docker image identifier, database versions and benchmark records with the manuscript analysis archive.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475FROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractiveARG MICROMAMBA_VERSION=2.8.1-0ARG TARGETARCH
ENV LANG=C.UTF-8 \ LC_ALL=C.UTF-8 \ MAMBA_ROOT_PREFIX=/opt/micromamba \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ STREAMLIT_SERVER_PORT=7860 \ STREAMLIT_SERVER_ADDRESS=0.0.0.0
USER rootRUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl bzip2 xz-utils gzip unzip zip git wget tini \ build-essential procps openjdk-17-jre-headless libgomp1 libcurl4-openssl-dev libssl-dev \ && rm -rf /var/lib/apt/lists/*
# Micromamba is used to isolate groups of bioinformatics tools whose Python# dependencies would otherwise conflict in one monolithic environment.RUN case "${TARGETARCH:-amd64}" in \ amd64) MM_ARCH=64 ;; \ arm64) MM_ARCH=aarch64 ;; \ *) MM_ARCH=64 ;; \ esac && \ curl -fsSL "https://github.com/mamba-org/micromamba-releases/releases/download/${MICROMAMBA_VERSION}/micromamba-linux-${MM_ARCH}" \ -o /usr/local/bin/micromamba && chmod +x /usr/local/bin/micromamba
RUN micromamba config prepend channels conda-forge && \ micromamba config append channels bioconda && \ micromamba config set channel_priority strict
# Web application environment.RUN micromamba create -y -n app python=3.11 pip && micromamba clean --all --yes
# Core WGS environment. These programs cover raw-read processing, assembly,# polishing and general sequence utilities.RUN micromamba create -y -n core \ fastp fastqc multiqc spades quast flye unicycler polypolish bwa samtools minimap2 \ mash skani mafft iqtree blast minced \ && micromamba clean --all --yes
# Annotation and surveillance tools are separated to reduce dependency conflicts.RUN micromamba create -y -n annotation bakta prokka \ && micromamba create -y -n surveillance abricate ncbi-amrfinderplus integron_finder mlst panaroo snippy gubbins \ && micromamba create -y -n secondary antismash \ && micromamba clean --all --yes
# Database-heavy tools are isolated from the core environment. Reference# databases themselves are NOT baked into the image; mount them under /data.RUN micromamba create -y -n taxonomy gtdbtk checkm2 \ && micromamba create -y -n functional eggnog-mapper genomad mob_suite \ && micromamba create -y -n epidemiology chewbbaca poppunk \ && micromamba clean --all --yes
ENV PATH=/opt/micromamba/envs/core/bin:/opt/micromamba/envs/annotation/bin:/opt/micromamba/envs/surveillance/bin:/opt/micromamba/envs/secondary/bin:/opt/micromamba/envs/taxonomy/bin:/opt/micromamba/envs/functional/bin:/opt/micromamba/envs/epidemiology/bin:/opt/micromamba/envs/app/bin:$PATH
# Hugging Face Docker Spaces expect the runtime user to be UID 1000.RUN useradd -m -u 1000 -s /bin/bash appuser && \ mkdir -p /app /data /home/appuser/.streamlit /home/appuser/.cache && \ chown -R 1000:1000 /app /data /home/appuser
WORKDIR /appCOPY --chown=1000:1000 requirements.txt /app/requirements.txtRUN /opt/micromamba/envs/app/bin/python -m pip install --no-cache-dir -r /app/requirements.txt
COPY --chown=1000:1000 . /app
ENV HOME=/home/appuser XDG_CACHE_HOME=/home/appuser/.cacheUSER 1000EXPOSE 7860ENTRYPOINT ["/usr/bin/tini", "--"]CMD ["/opt/micromamba/envs/app/bin/streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]12345678910111213141516FROM python:3.11-slim
ARG DEBIAN_FRONTEND=noninteractiveRUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl tini ncbi-blast+ mafft \ && rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 -s /bin/bash appuserWORKDIR /appCOPY requirements.txt /app/requirements.txtRUN pip install --no-cache-dir -r requirements.txtCOPY --chown=1000:1000 . /appUSER 1000EXPOSE 7860ENTRYPOINT ["/usr/bin/tini", "--"]CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]123456789101112131415161718192021MIT License
Copyright (c) 2026 Mustafa Alhaji Isa
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647# WOLOJI publication readiness checklist
WOLOJI v2.0.1 includes automated software verification, provenance tracking and a biological validation harness. A successful Docker deployment and passing unit tests do not by themselves establish biological validity. Complete the empirical concordance and performance blocks below before manuscript submission.
## Automated software verification included in the repository
- Full NCBI bacterial genetic-code table 11 regression test.- RSCU and ENc reference tests.- FASTA statistics tests.- Automatic FASTQ pairing and ambiguity tests.- Dry-run end-to-end orchestration smoke test.- Python compilation check.- Ruff static checks.- Pytest coverage report.- Static citation metadata check.- GitHub Actions CI on pushes and pull requests.
## Required empirical validation blocks before submission
1. Read QC and assembly. Use public bacterial Illumina, Nanopore and hybrid datasets. Compare retained reads, assembly size, contigs, N50, genome fraction and misassemblies with direct command-line runs.2. Taxonomy. Benchmark species assignments, ANI and aligned fraction against curated reference genomes using the same database releases.3. Annotation. Compare gene/CDS counts and selected annotations between WOLOJI and direct Bakta or Prokka runs.4. AMR. Use isolates with curated genotypes and, where available, phenotypic AST. Report gene-level precision, recall and F1 rather than only agreement percentage.5. Virulence and mobile elements. Benchmark against curated positive and negative genomes and report exact database versions.6. MLST/cgMLST. Report exact concordance with independently generated profiles.7. Pan-genome. Compare core/accessory gene counts and gene presence/absence matrices with direct Panaroo runs.8. SNP phylogenomics. Compare core-SNP counts, pairwise SNP distances, recombination-filtered alignment and tree topology with direct Snippy, Gubbins and IQ-TREE runs.9. Reproducibility. Rerun identical inputs with the same image and databases and compare output checksums where deterministic.10. Performance. Report wall-clock time, peak RAM, disk use and failure rate across increasing numbers of isolates.
The `validation/` directory contains a structured benchmark table and a generic output-comparison script to make these runs auditable.
## External comparator
Use at least one established bacterial WGS workflow as an external comparator. Do not claim better biological accuracy solely from having more modules or a graphical interface. Separate biological concordance, computational performance, usability and breadth of reporting as distinct evaluation domains.
## Release metadata gate
Before tagging or archiving a release, insert the real GitHub repository or Hugging Face Space URL into `CITATION.cff`:
```bashpython tools/finalize_release_metadata.py \ --repository-url "https://huggingface.co/spaces/<REAL_ACCOUNT>/<REAL_SPACE>" \ --check --require-repository```
Do not publish a release containing a placeholder repository address.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242---title: WOLOJI Comprehensive Bacterial Genomics Suiteemoji: 🧬colorFrom: bluecolorTo: greensdk: dockerapp_port: 7860fullWidth: trueshort_description: End-to-end bacterial whole-genome analysis---
# WOLOJI Comprehensive Bacterial Genomics Suite v2.0.1
WOLOJI is a Docker-based Streamlit platform for bacterial isolate whole-genome analysis. It combines the strongest functions of the earlier Woloji, Gulumba and Bulamarwa applications into one reproducible workflow while keeping standalone sequence utilities for primer design, BLAST and phylogenetic analysis.
The package is designed to start from raw Illumina, Oxford Nanopore or assembled bacterial genomes and coordinate the following analysis blocks:
1. Input validation and SHA256 provenance.2. Raw read quality control with fastp, FastQC and MultiQC.3. Short-read assembly with SPAdes.4. Long-read assembly with Flye.5. Hybrid assembly with Unicycler and optional Polypolish short-read polishing.6. Assembly quality assessment with QUAST and optional CheckM2.7. Species and taxonomic analysis with Mash, skani and optional GTDB-Tk.8. Standardized genome annotation with Bakta when its database is mounted, otherwise Prokka.9. Genome composition and codon-bias analysis, including GC1, GC2, GC3, ENc, RSCU and neutrality plots.10. Functional annotation with eggNOG-mapper.11. Antimicrobial resistance analysis with NCBI AMRFinderPlus.12. Virulence screening through ABRicate/VFDB when the database is available.13. Secondary metabolite biosynthetic gene clusters with antiSMASH.14. Plasmid and mobile genetic element analysis with MOB-suite, geNomad, IntegronFinder and MinCED.15. Classical MLST.16. cgMLST/wgMLST allele calling with chewBBACA using a user-supplied schema.17. Pan-genome analysis with Panaroo.18. Core SNP analysis with Snippy, recombination filtering with Gubbins and phylogenetic inference with IQ-TREE.19. Population genomic clustering with PopPUNK.20. Standalone Primer3, local BLAST and MAFFT/IQ-TREE utilities.21. Publication-oriented tables, figures, methods notes, command logs, software provenance and run manifests.
## Repository structure
```text.├── app.py├── Dockerfile├── Dockerfile.lite├── requirements.txt├── requirements-dev.txt├── pyproject.toml├── README.md├── CITATION.cff├── LICENSE├── CHANGELOG.md├── PUBLICATION_READINESS.md├── DEPLOYMENT_CHECKLIST.md├── example_metadata.csv├── .dockerignore├── .streamlit/│ └── config.toml├── .github/workflows/│ ├── ci.yml│ └── release-readiness.yml├── config/│ └── databases.env.example├── tests/│ ├── test_core.py│ ├── test_codon.py│ ├── test_io.py│ └── smoke_dry_run.py├── tools/│ └── finalize_release_metadata.py├── validation/│ ├── README.md│ ├── benchmark_runs.tsv│ └── compare_outputs.py└── woloji/ ├── __init__.py ├── codon.py ├── figures.py ├── io.py ├── models.py ├── pipeline.py ├── tooling.py ├── utilities.py └── utils.py```
## Hugging Face deployment
Create a new Hugging Face Space and choose **Docker** as the SDK. Upload every file in this repository to the root of the Space. The README front matter declares `sdk: docker` and port `7860`.
The Docker build installs the application and command-line software, but it deliberately does not download the very large biological databases. Database-dependent modules remain visible and are reported as skipped until their database paths are configured.
### Recommended persistent database mount
Mount persistent storage at `/data` and configure Space variables such as:
```bashBAKTA_DB=/data/bakta/dbGTDBTK_DATA_PATH=/data/gtdbtkCHECKM2DB=/data/checkm2/uniref100.KO.1.dmndEGGNOG_DATA_DIR=/data/eggnogGENOMAD_DB=/data/genomad_dbMOB_SUITE_DB=/data/mob_suiteABRICATE_DB_DIR=/data/abricate```
Use the **Tools & databases** tab after deployment to confirm executable and database availability before analysing research data.
## Input
### Recommended metadata file
The application accepts a CSV or TSV table. `Sample_ID` is required. Other columns are optional.
```csvSample_ID,Read_1,Read_2,Long_Reads,Assembly,Genus,SpeciesISO01,ISO01_R1.fastq.gz,ISO01_R2.fastq.gz,,,Escherichia,coliISO02,,,ISO02_nanopore.fastq.gz,,Klebsiella,pneumoniaeISO03,,,,ISO03.fasta,Staphylococcus,aureus```
Without metadata, WOLOJI automatically pairs filenames containing `_R1/_R2` or `_1/_2`. An unpaired FASTQ is interpreted as long-read input.
## Important analysis requirements
### GTDB-Tk
Set `GTDBTK_DATA_PATH` to a compatible GTDB-Tk reference-data release. Do not mix software and database releases without checking compatibility.
### CheckM2
Set `CHECKM2DB` to the CheckM2 diamond database file when it is stored outside the default location.
### Bakta
Set `BAKTA_DB` to the unpacked Bakta database directory.
### eggNOG-mapper
Set `EGGNOG_DATA_DIR` to the prepared eggNOG-mapper data directory.
### geNomad
Set `GENOMAD_DB` to the unpacked geNomad database directory.
### MOB-suite
Set `MOB_SUITE_DB` to an initialized MOB-suite database directory. Database initialization should be performed before deployment rather than during an analysis request.
### chewBBACA
Upload the cgMLST or wgMLST schema as a ZIP. The same schema and training settings should be used across isolates being compared.
### Core SNP analysis
Upload a suitable reference genome and enable **Core SNP phylogenomics**. WOLOJI uses reads when available and assemblies otherwise. The analysis calls Snippy, `snippy-core`, Gubbins and IQ-TREE.
## Reproducibility output
Each run generates a ZIP containing, where applicable:
```text00_input/01_read_qc/02_assembly/03_polishing/04_assembly_qc/05_taxonomy/06_annotation/07_composition_codon/08_functional/09_amr/10_virulence/11_secondary_metabolites/12_mobileome/13_typing/14_pangenome/16_phylogenomics/17_population/20_publication_report/logs/input_manifest.tsvcommand_manifest.jsonrun_manifest.json```
The input manifest stores SHA256 checksums. The command manifest records every executed or skipped command, return code, start/finish times and log paths. The run manifest records parameters and database paths.
## Publication use
WOLOJI is an orchestration and reporting platform. Publications must cite both WOLOJI and the underlying programs actually used in the selected workflow. Database release dates and versions should also be reported. Prediction-based AMR, virulence, plasmid, prophage, CRISPR, secondary-metabolite and taxonomy outputs require biological interpretation and, where relevant, experimental validation.
For a software manuscript, benchmark WOLOJI on synthetic/mock data and public bacterial WGS datasets, and report concordance, runtime, RAM, failure rate and reproducibility against established bacterial WGS workflows. Do not claim superiority solely because more modules are exposed through the graphical interface.
## Local development
```bashpython -m venv .venvsource .venv/bin/activatepip install -r requirements.txtstreamlit run app.py```
The web interface can run in **dry-run mode** even when command-line bioinformatics tools are not installed. Dry-run records the intended commands without executing them.
## Verification and continuous integration
The repository includes biological regression tests for the complete NCBI bacterial genetic code table 11, ENc limits, RSCU calculations, FASTA statistics and automatic sample filename pairing. It also includes a dry-run orchestration smoke test.
Run locally with:
```bashpython -m pip install -r requirements-dev.txtruff check .python -m compileall -q app.py woloji tests tools validationpytest -q --cov=woloji --cov-report=term-missingPYTHONPATH=. python tests/smoke_dry_run.pypython tools/finalize_release_metadata.py --check```
GitHub Actions performs the same checks on Python 3.11 and 3.12 for every push and pull request.
## Biological validation before manuscript submission
The `validation/` directory provides a structured benchmark record and a generic table concordance script. Use these to compare WOLOJI outputs with direct runs of the same underlying tools on public or curated datasets. Software verification and biological validation are treated separately. See `PUBLICATION_READINESS.md` and `validation/README.md`.
## Release citation metadata
`CITATION.cff` contains the verified author ORCID and institutional affiliation. The repository URL is deliberately not guessed. After the final GitHub repository or Hugging Face Space exists, finalize the citation metadata with the real URL:
```bashpython tools/finalize_release_metadata.py \ --repository-url "https://huggingface.co/spaces/<REAL_ACCOUNT>/<REAL_SPACE>" \ --check --require-repository```
The release-readiness GitHub workflow performs the same validation using a manually supplied repository URL.
## License
The WOLOJI application code in this repository is released under the MIT License. Each external bioinformatics tool and reference database retains its own license and terms. Review those terms before redistribution or commercial deployment.123456789101112131415161718192021222324252627282930313233343536373839404142# WOLOJI v2.0.1 revision summary
This patch addresses the software-review findings raised after v2.0.0.
## Correctness
- Corrected the `GCC` codon entry directly to alanine and removed the silent runtime override.- Added a complete NCBI bacterial genetic code table 11 regression test.- Added RSCU and ENc reference tests.- Added version consistency between the package, run manifest and generated Methods text.
## Code quality
- Removed unused imports.- Modernized type annotations for Python 3.11+.- Replaced NaN self-comparison with `math.isnan`.- Replaced non-UI broad exception handlers with specific OS/subprocess exceptions.- Added explicit `check=False` to non-raising subprocess calls.- Made generated run timestamps timezone aware.- Removed unused `scipy` and `pyyaml` dependencies.
## Tests and CI
- Added FASTQ pairing and ambiguity tests.- Added biological codon/RSCU/ENc tests.- Added validation-helper tests.- Retained the end-to-end dry-run smoke test.- Added GitHub Actions CI on Python 3.11 and 3.12 for Ruff, compilation, pytest coverage, citation metadata checks and dry-run orchestration.
## Citation and release metadata
- Added the verified author ORCID and institutional affiliation to `CITATION.cff`.- Removed the unverified repository placeholder.- Added `tools/finalize_release_metadata.py` and a manual release-readiness workflow so a release cannot be finalized without a real repository URL.
## Scientific validation
- Added `validation/compare_outputs.py` for direct WOLOJI versus standalone-tool concordance checks.- Added `validation/benchmark_runs.tsv` for structured benchmark recording.- Expanded `PUBLICATION_READINESS.md` to distinguish software verification from empirical biological validation.
Empirical benchmarking against direct standalone-tool runs still requires the selected public or curated datasets and installed external bioinformatics databases. The repository now contains the harness and reporting structure needed to perform and archive those comparisons.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239from __future__ import annotations
import osimport shutilimport tempfileimport zipfilefrom datetime import datetime, timezonefrom pathlib import Path
import pandas as pdimport streamlit as st
from woloji import __version__from woloji.io import auto_samples, samples_from_metadata, save_uploadsfrom woloji.pipeline import run_pipelinefrom woloji.tooling import database_rows, status_rowsfrom woloji.utils import safe_name
st.set_page_config(page_title="WOLOJI Comprehensive Bacterial Genomics Suite", page_icon="🧬", layout="wide")
st.title("🧬 WOLOJI Comprehensive Bacterial Genomics Suite")st.caption(f"Version {__version__} | Raw reads to publication-oriented bacterial whole-genome analysis")
with st.expander("Scope and interpretation", expanded=False): st.write( "WOLOJI is designed for bacterial isolate whole-genome analysis. It coordinates read quality control, assembly, " "assembly quality, taxonomy, annotation, functional analysis, AMR, virulence, secondary metabolites, mobile genetic " "elements, sequence typing, pan-genome analysis, SNP phylogenomics, population genomics, and reproducibility reporting. " "Database-dependent modules run only when the corresponding database path is configured. Prediction-based outputs do not " "replace phenotypic or experimental validation." )
run_tab, utilities_tab, status_tab, help_tab = st.tabs(["Run complete analysis", "Woloji sequence utilities", "Tools & databases", "Deployment guide"])
with st.sidebar: st.header("Workflow modules") read_qc = st.checkbox("1. Raw read QC", True) assembly = st.checkbox("2. Genome assembly / polishing", True) quast = st.checkbox("3. QUAST assembly QC", True) checkm2 = st.checkbox("4. CheckM2 completeness", False) taxonomy = st.checkbox("5. Taxonomy + ANI", True) annotation = st.checkbox("6. Genome annotation", True) composition = st.checkbox("7. Genome composition & codon bias", True) functional = st.checkbox("8. Functional annotation (eggNOG)", False) amr = st.checkbox("9. AMR detection", True) virulence = st.checkbox("10. Virulence screening", True) secondary = st.checkbox("11. Secondary metabolites", False) mobileome = st.checkbox("12. Mobileome / plasmids / prophages / CRISPR", True) mlst = st.checkbox("13. Classical MLST", True) cgmlst = st.checkbox("14. cgMLST / wgMLST", False) pangenome = st.checkbox("15. Pan-genome", True) phylogenomics = st.checkbox("16. Core SNP phylogenomics", False) population = st.checkbox("17. Population genomics", False)
st.header("Core parameters") threads = st.slider("CPU threads", 1, max(1, os.cpu_count() or 2), min(4, max(1, os.cpu_count() or 2))) memory_gb = st.number_input("Assembly memory limit (GB)", 2, 256, 12, 1) assembly_mode = st.selectbox("Assembly strategy", ["Auto", "Hybrid: Unicycler", "Long-read: Flye", "Short-read: SPAdes"]) annotation_engine = st.selectbox("Annotation engine", ["Auto", "Bakta", "Prokka"]) fastp_quality = st.slider("fastp minimum Phred", 10, 35, 20) fastp_length = st.number_input("fastp minimum read length", 20, 300, 50, 5) fastp_n_limit = st.number_input("fastp maximum N bases per read", 0, 50, 5, 1, help="fastp --n_base_limit is an absolute count, not a percentage.") dry_run = st.checkbox("Dry run: generate commands without executing", False)
with run_tab: st.subheader("1. Upload data") files = st.file_uploader( "Upload FASTQ/FASTQ.GZ, FASTA/FASTA.GZ, or a ZIP containing them", accept_multiple_files=True, type=["fastq","fq","gz","fa","fasta","fna","fas","zip"], ) meta = st.file_uploader("Optional metadata CSV/TSV", type=["csv","tsv","txt"], key="meta") st.caption("Recommended metadata columns: Sample_ID, Read_1, Read_2, Long_Reads, Assembly, Genus, Species") reference = st.file_uploader("Optional reference genome for core SNP analysis", type=["fa","fasta","fna","gbk","gbff"], key="ref") schema_zip = st.file_uploader("Optional chewBBACA cgMLST/wgMLST schema ZIP", type=["zip"], key="schema")
run_name = st.text_input("Run name", value=f"woloji_{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S')}") run = st.button("Run WOLOJI analysis", type="primary", use_container_width=True)
if run: if not files: st.error("Upload at least one sequencing or assembly file.") else: work_root = Path(tempfile.gettempdir()) / "woloji_runs" work_root.mkdir(parents=True, exist_ok=True) run_dir = work_root / safe_name(run_name) if run_dir.exists(): shutil.rmtree(run_dir) input_dir = run_dir / "00_input"; input_dir.mkdir(parents=True, exist_ok=True) mapping = save_uploads(files, input_dir) metadata_path = None if meta: metadata_path = input_dir / os.path.basename(meta.name) metadata_path.write_bytes(meta.getvalue()) try: samples = samples_from_metadata(metadata_path, mapping) if metadata_path else auto_samples(mapping) except Exception as exc: st.error(f"Input parsing failed: {exc}") samples = [] if not samples: st.error("No valid samples were detected. Use metadata if automatic filename pairing is ambiguous.") else: ref_path = None if reference: ref_path = input_dir / os.path.basename(reference.name) ref_path.write_bytes(reference.getvalue()) schema_dir = None if schema_zip: schema_file = input_dir / os.path.basename(schema_zip.name) schema_file.write_bytes(schema_zip.getvalue()) schema_dir = run_dir / "00_input" / "cgmlst_schema" schema_dir.mkdir(parents=True, exist_ok=True) with zipfile.ZipFile(schema_file) as zf: zf.extractall(schema_dir) children = [p for p in schema_dir.iterdir() if p.is_dir()] if len(children) == 1: schema_dir = children[0]
st.write("Detected samples") st.dataframe(pd.DataFrame([{ "Sample_ID": s.sample_id, "Read_1": s.read1.name if s.read1 else "", "Read_2": s.read2.name if s.read2 else "", "Long_Reads": s.long_reads.name if s.long_reads else "", "Assembly": s.assembly.name if s.assembly else "", } for s in samples]), use_container_width=True) status = st.empty(); progress = st.progress(0) events = [] def cb(msg): events.append(msg); status.info(msg) progress.progress(min(95, 5 + int(90 * len(events) / max(1, len(samples)*3))))
modules = { "read_qc": read_qc, "assembly": assembly, "quast": quast, "checkm2": checkm2, "taxonomy": taxonomy, "annotation": annotation, "composition": composition, "functional": functional, "amr": amr, "virulence": virulence, "secondary": secondary, "mobileome": mobileome, "mlst": mlst, "cgmlst": cgmlst, "pangenome": pangenome, "phylogenomics": phylogenomics, "population": population, } params = { "threads": threads, "memory_gb": memory_gb, "assembly_mode": assembly_mode, "annotation_engine": annotation_engine, "fastp_quality": fastp_quality, "fastp_length": int(fastp_length), "fastp_n_limit": int(fastp_n_limit), "dry_run": dry_run, } try: zip_path, manifest, records = run_pipeline(samples, run_dir, modules, params, reference=ref_path, schema_dir=schema_dir, progress_cb=cb) progress.progress(100); status.success("Analysis finished") command_df = pd.DataFrame([r.to_dict() for r in records]) st.subheader("Execution summary") if not command_df.empty: st.dataframe(command_df[["name","returncode","skipped","reason"]], use_container_width=True) st.json(manifest) st.download_button("Download complete WOLOJI result package", data=zip_path.read_bytes(), file_name=zip_path.name, mime="application/zip", use_container_width=True) except Exception as exc: progress.empty(); status.error(f"Pipeline failed: {exc}")
with utilities_tab: from woloji.utilities import design_primers, local_blast, phyloforge, fasta_first_sequence u1,u2,u3 = st.tabs(["Primer design", "GeneClean-BLAST", "PhyloForge"]) with u1: st.markdown("#### Primer Design Tool") primer_file=st.file_uploader("Target FASTA",type=["fa","fasta","fna"],key="primer_file") primer_text=st.text_area("Or paste target DNA sequence",height=120,key="primer_text") pc1,pc2=st.columns(2) prod_min=pc1.number_input("Minimum product size",50,5000,100,10) prod_max=pc2.number_input("Maximum product size",60,10000,600,10) if st.button("Design primers",key="design_primers"): seq=primer_text.strip().replace(" ","").replace("\n","") if primer_file: _,seq=fasta_first_sequence(primer_file.getvalue(),primer_file.name) if not seq: st.error("Provide a FASTA file or DNA sequence.") else: try: pdf=design_primers(seq,product_min=int(prod_min),product_max=int(prod_max)) st.dataframe(pdf,use_container_width=True,hide_index=True) st.download_button("Download primer table",pdf.to_csv(index=False).encode(),"woloji_primers.csv","text/csv") except Exception as exc: st.error(f"Primer design failed: {exc}") with u2: st.markdown("#### GeneClean-BLAST") q=st.file_uploader("Query FASTA",type=["fa","fasta","fna"],key="blast_q") subj=st.file_uploader("Subject/reference FASTA",type=["fa","fasta","fna"],key="blast_s") if st.button("Run local BLAST",key="run_blast"): if not q or not subj: st.error("Upload query and subject FASTA files.") else: try: bdf=local_blast(q.getvalue(),subj.getvalue(),threads=threads) st.dataframe(bdf,use_container_width=True,hide_index=True) st.download_button("Download BLAST table",bdf.to_csv(index=False).encode(),"woloji_blast.csv","text/csv") except Exception as exc: st.error(f"BLAST failed: {exc}") with u3: st.markdown("#### PhyloForge") pf=st.file_uploader("Upload homologous FASTA sequences",type=["fa","fasta","fna","fas"],accept_multiple_files=True,key="phylo_files") if st.button("Align and infer tree",key="run_phylo"): if not pf or len(pf)<2: st.error("Upload at least two homologous sequences or sequence sets.") else: try: aln,tree=phyloforge(pf,threads=threads) st.text_area("MAFFT alignment",aln,height=250) st.code(tree,language="text") st.download_button("Download alignment",aln.encode(),"woloji_alignment.fasta","text/plain") st.download_button("Download Newick tree",tree.encode(),"woloji_tree.nwk","text/plain") except Exception as exc: st.error(f"PhyloForge failed: {exc}")
with status_tab: st.subheader("Installed command-line tools") if st.button("Refresh tool status"): st.session_state["tool_status"] = status_rows() st.session_state["db_status"] = database_rows() if "tool_status" not in st.session_state: st.session_state["tool_status"] = status_rows() st.session_state["db_status"] = database_rows() st.dataframe(pd.DataFrame(st.session_state["tool_status"]), use_container_width=True, hide_index=True) st.subheader("Reference database configuration") st.dataframe(pd.DataFrame(st.session_state["db_status"]), use_container_width=True, hide_index=True) st.info("Large reference databases should be mounted on persistent storage and exposed through the environment variables shown above.")
with help_tab: st.markdown("""### Input namingFor paired Illumina files without metadata, use names such as `Sample01_R1.fastq.gz` and `Sample01_R2.fastq.gz`.Unpaired FASTQ files are interpreted as long-read data. For mixed or non-standard names, use the metadata table.
### Recommended analysis modes**Routine isolate WGS:** read QC, assembly, QUAST, taxonomy/ANI, annotation, AMR, virulence, mobileome, MLST and report.
**Comparative genomics:** analyse multiple assemblies and enable Panaroo, cgMLST/wgMLST and population genomics.
**Outbreak/phylogenomic analysis:** provide a reference genome and enable core SNP phylogenomics. WOLOJI calls Snippy, Gubbins and IQ-TREE when available.
### Important database variables`BAKTA_DB`, `GTDBTK_DATA_PATH`, `CHECKM2DB`, `EGGNOG_DATA_DIR`, `GENOMAD_DB`, `MOB_SUITE_DB`, `ABRICATE_DB_DIR`.
### Publication outputsEvery run records input SHA256 hashes, selected parameters, database paths, exact command lines, command logs, software outputs, assembly summary tables, publication figures, and a reproducibility manifest.""")12345Sample_ID,Read_1,Read_2,Long_Reads,Assembly,Genus,SpeciesISO01,ISO01_R1.fastq.gz,ISO01_R2.fastq.gz,,,Escherichia,coliISO02,ISO02_R1.fastq.gz,ISO02_R2.fastq.gz,,,Escherichia,coliISO03,,,ISO03_nanopore.fastq.gz,,Klebsiella,pneumoniaeISO04,,,,ISO04.fasta,Staphylococcus,aureus12345678910111213141516171819202122232425262728293031[project]name = "woloji-genomics-suite"version = "2.0.1"description = "Comprehensive bacterial whole-genome analysis and publication reporting platform"requires-python = ">=3.11"authors = [{name = "Mustafa Alhaji Isa"}]license = {text = "MIT"}dependencies = [ "streamlit>=1.49,<2", "pandas>=2.2,<3", "numpy>=1.26,<3", "matplotlib>=3.8,<4", "biopython>=1.83,<2", "primer3-py>=2.0,<3",]
[tool.pytest.ini_options]pythonpath = ["."]testpaths = ["tests"]addopts = "-ra"
[tool.ruff]target-version = "py311"line-length = 120
[tool.ruff.lint]select = ["E9", "F", "I"]
[tool.ruff.lint.per-file-ignores]"woloji/codon.py" = ["E402", "I001"]"woloji/figures.py" = ["E402", "I001"]1234-r requirements.txtpytest>=8,<9pytest-cov>=5,<8ruff>=0.12,<1123456streamlit>=1.49,<2pandas>=2.2,<3numpy>=1.26,<3matplotlib>=3.8,<4biopython>=1.83,<2primer3-py>=2.0,<3.gitignoreAdded+15
CHANGELOG.mdAdded+33
CITATION.cffAdded+12
DEPLOYMENT_CHECKLIST.mdAdded+14
DockerfileAdded+75
Dockerfile.liteAdded+16
LICENSEAdded+21
PUBLICATION_READINESS.mdAdded+47
README.mdAdded+242
REVISION_SUMMARY.mdAdded+42
app.pyAdded+239
example_metadata.csvAdded+5
pyproject.tomlAdded+31
requirements-dev.txtAdded+4
requirements.txtAdded+6