Spaces:
Build error
Build error
Update app.py
Browse files12345678910111213141516171819202122232425262728302 unmodified lines3313323333343353363373383393403413423433443453463473483494 unmodified lines35435535635735835936036136236336436536654 unmodified lines42142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152270 unmodified lines59359459559659759859960060160260392 unmodified lines69669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873916 unmodified lines75675775875976076176276376476576676776876977077115 unmodified lines78778878979079179279379479579679779879980080180282 unmodified lines88588688788888989089115 unmodified lines9079089099109119129139149159169179189199203 unmodified lines9249259269279289299303 unmodified lines9349359369379389399405 unmodified lines9469479489499509519529539549559569579589599609619622 unmodified lines9659669679689699709719727 unmodified lines980981982983984985986987988989990991992993994995996997998999100010011002100366 unmodified lines10701071107210731074107510761077107810791080108177 unmodified lines11591160116111621163116411651166116711681169117011711172"""WOLOJI Comprehensive Bacterial Genomics SuiteSingle-file build (merged from the woloji/ package + app.py) for deploymentsthat require one script. Generated from WOLOJI v2.0.1."""from __future__ import annotationsimport gzipimport hashlibimport jsonimport mathimport osimport reimport shutilimport subprocessimport tempfileimport zipfilefrom collections import Counter, defaultdictfrom collections.abc import Callable, Sequencefrom dataclasses import asdict, dataclassfrom datetime import UTC, datetimefrom pathlib import Pathimport matplotlibimport numpy as npimport pandas as pdimport streamlit as stfrom Bio import SeqIO302 unmodified lines"GTDB-Tk": ["gtdbtk", "--version"],"Mash": ["mash", "--version"],"skani": ["skani", "--version"],"Bakta": ["bakta", "--version"],"Prokka": ["prokka", "--version"],"eggNOG-mapper": ["emapper.py", "--version"],"AMRFinderPlus": ["amrfinder", "--version"],"ABRicate": ["abricate", "--version"],"antiSMASH": ["antismash", "--version"],"MOB-suite": ["mob_recon", "--version"],"geNomad": ["genomad", "--version"],"IntegronFinder": ["integron_finder", "--version"],"MinCED": ["minced", "--version"],"mlst": ["mlst", "--version"],"chewBBACA": ["chewBBACA.py", "--version"],"Panaroo": ["panaroo", "--version"],"Snippy": ["snippy", "--version"],"Gubbins": ["run_gubbins.py", "--version"],"MAFFT": ["mafft", "--version"],4 unmodified lines}DATABASES = {"Bakta": "BAKTA_DB","GTDB-Tk": "GTDBTK_DATA_PATH","CheckM2": "CHECKM2DB","eggNOG-mapper": "EGGNOG_DATA_DIR","geNomad": "GENOMAD_DB","MOB-suite": "MOB_SUITE_DB","VFDB/ABRicate": "ABRICATE_DB_DIR",}54 unmodified linesplt.close(fig)# =============================================================================# woloji/codon.py -- codon usage / RSCU / ENc analysis# =============================================================================matplotlib.use("Agg")import matplotlib.pyplot as pltfrom Bio import SeqIOGENETIC_CODE = {"TTT":"F","TTC":"F","TTA":"L","TTG":"L","TCT":"S","TCC":"S","TCA":"S","TCG":"S","TAT":"Y","TAC":"Y","TAA":"*","TAG":"*","TGT":"C","TGC":"C","TGA":"*","TGG":"W","CTT":"L","CTC":"L","CTA":"L","CTG":"L","CCT":"P","CCC":"P","CCA":"P","CCG":"P","CAT":"H","CAC":"H","CAA":"Q","CAG":"Q","CGT":"R","CGC":"R","CGA":"R","CGG":"R","ATT":"I","ATC":"I","ATA":"I","ATG":"M","ACT":"T","ACC":"T","ACA":"T","ACG":"T","AAT":"N","AAC":"N","AAA":"K","AAG":"K","AGT":"S","AGC":"S","AGA":"R","AGG":"R","GTT":"V","GTC":"V","GTA":"V","GTG":"V","GCT":"A","GCC":"A","GCA":"A","GCG":"A","GAT":"D","GAC":"D","GAA":"E","GAG":"E","GGT":"G","GGC":"G","GGA":"G","GGG":"G",}AA_TO_CODONS = defaultdict(list)for c,a in GENETIC_CODE.items():if a != "*": AA_TO_CODONS[a].append(c)def _enc(counts: Counter) -> float:family_f = defaultdict(list)for codons in AA_TO_CODONS.values():if len(codons) <= 1: continuetotal = sum(counts.get(c,0) for c in codons)if total <= 1: continuep2 = sum((counts.get(c,0)/total)**2 for c in codons)F = (total*p2 - 1)/(total-1)if F > 0: family_f[len(codons)].append(F)def mf(k):vals = family_f.get(k, [])return float(np.mean(vals)) if vals else np.nanvals = [mf(2),mf(3),mf(4),mf(6)]available = [x for x in vals if not np.isnan(x) and x > 0]if not available: return np.nanfallback = float(np.mean(available))F2,F3,F4,F6 = [x if not np.isnan(x) and x>0 else fallback for x in vals]return float(min(max(2 + 9/F2 + 1/F3 + 5/F4 + 3/F6,20),61))def analyse_ffn(ffn: Path, outdir: Path, min_codons: int = 30):outdir.mkdir(parents=True, exist_ok=True)global_counts = Counter(); gene_rows=[]for rec in SeqIO.parse(str(ffn), "fasta"):s = str(rec.seq).upper().replace("U","T")usable = len(s) - len(s)%3s = s[:usable]if usable < min_codons*3: continuecounts=Counter(); pos_gc=[0,0,0]; pos_n=[0,0,0]; ncod=0for i in range(0, usable, 3):codon=s[i:i+3]if len(codon)!=3 or any(b not in "ACGT" for b in codon): continueaa=GENETIC_CODE.get(codon)if aa is None: continuefor j,b in enumerate(codon):pos_n[j]+=1if b in "GC": pos_gc[j]+=1if aa != "*": counts[codon]+=1; global_counts[codon]+=1ncod+=1if ncod == 0: continuegc1=100*pos_gc[0]/pos_n[0] if pos_n[0] else np.nangc2=100*pos_gc[1]/pos_n[1] if pos_n[1] else np.nangc3=100*pos_gc[2]/pos_n[2] if pos_n[2] else np.nangene_rows.append({"gene_id":rec.id,"codons":ncod,"GC1_percent":gc1,"GC2_percent":gc2,"GC3_percent":gc3,"GC12_percent":np.nanmean([gc1,gc2]),"ENc":_enc(counts)})per_gene=pd.DataFrame(gene_rows)rscu=[]for aa,codons in sorted(AA_TO_CODONS.items()):total=sum(global_counts.get(c,0) for c in codons)expected=total/len(codons) if codons else 0for c in codons:rscu.append({"amino_acid":aa,"codon":c,"count":global_counts.get(c,0),"RSCU":global_counts.get(c,0)/expected if expected else 0})rscu_df=pd.DataFrame(rscu)per_gene.to_csv(outdir/"per_gene_codon_metrics.csv",index=False)rscu_df.to_csv(outdir/"rscu.csv",index=False)pd.DataFrame([{"CDS_analysed":len(per_gene),"genome_ENc":_enc(global_counts)}]).to_csv(outdir/"codon_summary.csv",index=False)if not per_gene.empty:fig,ax=plt.subplots(figsize=(6.5,5))ax.scatter(per_gene["GC3_percent"]/100,per_gene["ENc"],s=12,alpha=.55)x=np.linspace(0.001,.999,300); expected=2+x+29/(x*x+(1-x)*(1-x))ax.plot(x,expected,linestyle="--",linewidth=1.2)ax.set_xlabel("GC3 fraction");ax.set_ylabel("Effective number of codons (ENc)");ax.set_title("ENc plot")fig.tight_layout();fig.savefig(outdir/"enc_plot.png",dpi=600,bbox_inches="tight");plt.close(fig)valid=per_gene.dropna(subset=["GC3_percent","GC12_percent"])if len(valid)>=3:x=valid["GC3_percent"].to_numpy()/100;y=valid["GC12_percent"].to_numpy()/100slope,intercept=np.polyfit(x,y,1);pred=slope*x+interceptssr=np.sum((y-pred)**2);sst=np.sum((y-y.mean())**2);r2=1-ssr/sst if sst else np.nanfig,ax=plt.subplots(figsize=(6.5,5));ax.scatter(x,y,s=12,alpha=.55);order=np.argsort(x);ax.plot(x[order],pred[order],linestyle="--")ax.set_xlabel("GC3 fraction");ax.set_ylabel("GC12 fraction");ax.set_title(f"Neutrality plot: slope={slope:.3f}, R²={r2:.3f}")fig.tight_layout();fig.savefig(outdir/"neutrality_plot.png",dpi=600,bbox_inches="tight");plt.close(fig)return {"per_gene":per_gene,"rscu":rscu_df}# =============================================================================# woloji/utilities.py -- primer design, local BLAST, PhyloForge# =============================================================================70 unmodified lines"fastp_length": 50,"fastp_n_limit": 5,"assembly_mode": "Auto","annotation_engine": "Auto","ani_min_fraction": 15,"vfdb_min_identity": 90,"vfdb_min_coverage": 80,"panaroo_clean_mode": "strict","iqtree_model": "MFP","iqtree_bootstrap": 1000,"dry_run": False,92 unmodified linesrunner.run(f"{sample_id}_checkm2", cmd)def _annotate(sample: Sample, assembly: Path, out: Path, runner: Runner, p: dict):root = out / "06_annotation" / sample.sample_idroot.mkdir(parents=True, exist_ok=True)engine = p["annotation_engine"]bakta_db = os.getenv("BAKTA_DB", "")if engine in {"Auto", "Bakta"} and command_exists("bakta") and bakta_db and Path(bakta_db).exists():cmd = ["bakta", "--db", bakta_db, "--output", root / "bakta", "--prefix", sample.sample_id,"--threads", p["threads"], assembly]runner.run(f"{sample.sample_id}_bakta", cmd)return {"engine": "Bakta", "gff": root/"bakta"/f"{sample.sample_id}.gff3", "faa": root/"bakta"/f"{sample.sample_id}.faa", "ffn": root/"bakta"/f"{sample.sample_id}.ffn"}cmd = ["prokka", "--outdir", root / "prokka", "--prefix", sample.sample_id, "--cpus", p["threads"],"--kingdom", "Bacteria"]if sample.genus: cmd += ["--genus", sample.genus]if sample.species: cmd += ["--species", sample.species]cmd += [assembly]runner.run(f"{sample.sample_id}_prokka", cmd)return {"engine": "Prokka", "gff": root/"prokka"/f"{sample.sample_id}.gff", "faa": root/"prokka"/f"{sample.sample_id}.faa", "ffn": root/"prokka"/f"{sample.sample_id}.ffn"}def _amr(sample_id, assembly, out, runner, threads):aout = out / "09_amr" / sample_id; aout.mkdir(parents=True, exist_ok=True)runner.run(f"{sample_id}_amrfinder", ["amrfinder", "-n", assembly, "--plus", "--threads", threads, "-o", aout/"amrfinder.tsv"])def _virulence(sample_id, assembly, out, runner, p):vout = out / "10_virulence" / sample_id; vout.mkdir(parents=True, exist_ok=True)cmd = ["abricate", "--db", "vfdb", "--minid", p["vfdb_min_identity"], "--mincov", p["vfdb_min_coverage"]]datadir = os.getenv("ABRICATE_DB_DIR", "")if datadir: cmd += ["--datadir", datadir]cmd += [assembly]runner.run(f"{sample_id}_vfdb", cmd, stdout_file=vout/"vfdb.tsv")def _antismash(sample_id, assembly, out, runner, threads):aout = out / "11_secondary_metabolites" / sample_idrunner.run(f"{sample_id}_antismash", ["antismash", assembly, "--output-dir", aout, "--cpus", threads, "--taxon", "bacteria"])def _mobileome(sample_id, assembly, out, runner, threads):root = out / "12_mobileome" / sample_id; root.mkdir(parents=True, exist_ok=True)mob_db = os.getenv("MOB_SUITE_DB", "")16 unmodified linesrunner.run(f"{sample_id}_mlst", ["mlst", "--full", assembly], stdout_file=root/f"{sample_id}.tsv")def _eggnog(sample_id, faa, out, runner, threads):if not faa: returnroot = out / "08_functional" / sample_id; root.mkdir(parents=True, exist_ok=True)data_dir = os.getenv("EGGNOG_DATA_DIR", "")cmd = ["emapper.py", "-i", faa, "--itype", "proteins", "-o", sample_id, "--output_dir", root,"--cpu", threads, "--override"]if data_dir: cmd += ["--data_dir", data_dir]runner.run(f"{sample_id}_eggnog", cmd)def _gtdbtk(assemblies: dict[str, Path], out: Path, runner: Runner, threads: int):if not assemblies: returnroot = out / "05_taxonomy" / "gtdbtk"; inp = root / "input"; inp.mkdir(parents=True, exist_ok=True)15 unmodified linesrunner.run("skani_triangle", ["skani", "triangle", "-s", "90", "-t", threads, "-E", *paths], stdout_file=root/"skani_triangle.tsv")def _panaroo(annotations: dict[str, dict], out: Path, runner: Runner, threads: int, clean_mode: str):gffs = [str(v["gff"]) for v in annotations.values() if v and Path(v["gff"]).exists()]if len(gffs) < 2:runner.skip("panaroo", ["panaroo"], "Panaroo requires at least two valid GFF annotations")returnroot = out / "14_pangenome" / "panaroo"runner.run("panaroo", ["panaroo", "-i", *gffs, "-o", root, "--clean-mode", clean_mode,"--remove-invalid-genes", "-a", "core", "--aligner", "mafft", "-t", threads])def _chewbbaca(assemblies: dict[str, Path], schema_dir: Path | None, out: Path, runner: Runner, threads: int):if len(assemblies) < 2 or not schema_dir:runner.skip("chewbbaca", ["chewBBACA.py", "AlleleCall"], "cgMLST/wgMLST requires at least two genomes and a schema directory")82 unmodified linesp = DEFAULTS.copy(); p.update(params or {})run_dir.mkdir(parents=True, exist_ok=True)runner = Runner(run_dir/"logs", dry_run=bool(p.get("dry_run")), timeout=int(p.get("timeout", 14400)))assemblies: dict[str, Path] = {}; annotations: dict[str, dict] = {}input_manifest = []for s in samples:for label, path in [("Read_1", s.read1), ("Read_2", s.read2), ("Long_Reads", s.long_reads), ("Assembly", s.assembly)]:15 unmodified linesassemblies[sample.sample_id] = asmif modules.get("quast", True): _quast(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("checkm2", False): _checkm2(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("annotation", True): annotations[sample.sample_id] = _annotate(sample, asm, run_dir, runner, p)if modules.get("composition", True) and annotations.get(sample.sample_id,{}).get("ffn"):ffn = Path(annotations[sample.sample_id]["ffn"])if ffn.exists() and not runner.dry_run: analyse_ffn(ffn, run_dir/"07_composition_codon"/sample.sample_id)if modules.get("functional", False): _eggnog(sample.sample_id, annotations.get(sample.sample_id,{}).get("faa"), run_dir, runner, p["threads"])if modules.get("amr", True): _amr(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("virulence", True): _virulence(sample.sample_id, asm, run_dir, runner, p)if modules.get("secondary", False): _antismash(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("mobileome", True): _mobileome(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("mlst", True): _mlst(sample.sample_id, asm, run_dir, runner)3 unmodified lines_gtdbtk(assemblies, run_dir, runner, p["threads"])_mash_skani(assemblies, run_dir, runner, p["threads"])if modules.get("cgmlst", False): _chewbbaca(assemblies, schema_dir, run_dir, runner, p["threads"])if modules.get("pangenome", True): _panaroo(annotations, run_dir, runner, p["threads"], p["panaroo_clean_mode"])if modules.get("phylogenomics", False): _phylogenomics(samples, assemblies, reference, run_dir, runner, p)if modules.get("population", False): _poppunk(assemblies, run_dir, runner, p["threads"])3 unmodified lines"suite": "WOLOJI Comprehensive Bacterial Genomics Suite","version": "2.0.1", "created_at": utc_now(), "parameters": p,"modules": modules,"database_paths": {k: os.getenv(k, "") for k in ["BAKTA_DB","GTDBTK_DATA_PATH","CHECKM2DB","EGGNOG_DATA_DIR","GENOMAD_DB","MOB_SUITE_DB","ABRICATE_DB_DIR"]},"samples": [s.sample_id for s in samples],"software_versions": status_rows(),}5 unmodified lines# =============================================================================# app.py -- Streamlit interface# =============================================================================import osimport shutilimport tempfileimport zipfilefrom datetime import UTC, datetimefrom pathlib import Pathimport pandas as pdimport streamlit as stst.set_page_config(page_title="WOLOJI Comprehensive Bacterial Genomics Suite", page_icon="🧬", layout="wide")st.title("🧬 WOLOJI Comprehensive Bacterial Genomics Suite")2 unmodified lineswith 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.")7 unmodified linesquast = 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,66 unmodified linesprogress.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,77 unmodified linesUnpaired 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.123456789101112131415161718192021222324252627282930313233343536373839302 unmodified lines3423433443453463473483493503513523534 unmodified lines35835936036136236336436536636754 unmodified lines42242342442542642770 unmodified lines49849950050150250392 unmodified lines59659759859960060116 unmodified lines61861962062162262315 unmodified lines63964064164264364482 unmodified lines72772872973073173273315 unmodified lines7497507517527537543 unmodified lines7587597607617627633 unmodified lines7677687697707717727735 unmodified lines7797807817827837842 unmodified lines7877887897907917927937947957 unmodified lines80380480580680780880981081181281381481581681781866 unmodified lines88588688788888989089189289389477 unmodified lines972973974975976977978979980981982983984985986987988989"""WOLOJI Bacterial Genomics Suite (trimmed build)Single-file build merged from the woloji/ package + app.py.Removed from this build (covered by separate dedicated tools):- Genome annotation (Bakta / Prokka)- Genome composition & codon usage (RSCU / ENc)- AMR detection (AMRFinderPlus)- Virulence screening (ABRicate / VFDB)- Secondary metabolites (antiSMASH)Also removed because they depend entirely on the annotation step above:- Functional annotation (eggNOG-mapper) -- needs the .faa file from annotation- Pan-genome analysis (Panaroo) -- needs the GFF files from annotationRemaining pipeline: read QC, assembly/polishing, QUAST, CheckM2, taxonomy(GTDB-Tk, Mash, skani), mobileome (MOB-suite, geNomad, IntegronFinder, MinCED),MLST, cgMLST/wgMLST, core SNP phylogenomics, population genomics (PopPUNK),plus the standalone utilities tab (primer design, local BLAST, PhyloForge)."""from __future__ import annotationsimport gzipimport hashlibimport jsonimport osimport reimport shutilimport subprocessimport tempfileimport zipfilefrom collections.abc import Callable, Sequencefrom dataclasses import asdict, dataclassfrom datetime import UTC, datetimefrom pathlib import Pathimport matplotlibimport pandas as pdimport streamlit as stfrom Bio import SeqIO302 unmodified lines"GTDB-Tk": ["gtdbtk", "--version"],"Mash": ["mash", "--version"],"skani": ["skani", "--version"],"MOB-suite": ["mob_recon", "--version"],"geNomad": ["genomad", "--version"],"IntegronFinder": ["integron_finder", "--version"],"MinCED": ["minced", "--version"],"mlst": ["mlst", "--version"],"chewBBACA": ["chewBBACA.py", "--version"],"Snippy": ["snippy", "--version"],"Gubbins": ["run_gubbins.py", "--version"],"MAFFT": ["mafft", "--version"],4 unmodified lines}DATABASES = {"GTDB-Tk": "GTDBTK_DATA_PATH","CheckM2": "CHECKM2DB","geNomad": "GENOMAD_DB","MOB-suite": "MOB_SUITE_DB",}54 unmodified linesplt.close(fig)# =============================================================================# woloji/utilities.py -- primer design, local BLAST, PhyloForge# =============================================================================70 unmodified lines"fastp_length": 50,"fastp_n_limit": 5,"assembly_mode": "Auto","iqtree_model": "MFP","iqtree_bootstrap": 1000,"dry_run": False,92 unmodified linesrunner.run(f"{sample_id}_checkm2", cmd)def _mobileome(sample_id, assembly, out, runner, threads):root = out / "12_mobileome" / sample_id; root.mkdir(parents=True, exist_ok=True)mob_db = os.getenv("MOB_SUITE_DB", "")16 unmodified linesrunner.run(f"{sample_id}_mlst", ["mlst", "--full", assembly], stdout_file=root/f"{sample_id}.tsv")def _gtdbtk(assemblies: dict[str, Path], out: Path, runner: Runner, threads: int):if not assemblies: returnroot = out / "05_taxonomy" / "gtdbtk"; inp = root / "input"; inp.mkdir(parents=True, exist_ok=True)15 unmodified linesrunner.run("skani_triangle", ["skani", "triangle", "-s", "90", "-t", threads, "-E", *paths], stdout_file=root/"skani_triangle.tsv")def _chewbbaca(assemblies: dict[str, Path], schema_dir: Path | None, out: Path, runner: Runner, threads: int):if len(assemblies) < 2 or not schema_dir:runner.skip("chewbbaca", ["chewBBACA.py", "AlleleCall"], "cgMLST/wgMLST requires at least two genomes and a schema directory")82 unmodified linesp = DEFAULTS.copy(); p.update(params or {})run_dir.mkdir(parents=True, exist_ok=True)runner = Runner(run_dir/"logs", dry_run=bool(p.get("dry_run")), timeout=int(p.get("timeout", 14400)))assemblies: dict[str, Path] = {}input_manifest = []for s in samples:for label, path in [("Read_1", s.read1), ("Read_2", s.read2), ("Long_Reads", s.long_reads), ("Assembly", s.assembly)]:15 unmodified linesassemblies[sample.sample_id] = asmif modules.get("quast", True): _quast(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("checkm2", False): _checkm2(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("mobileome", True): _mobileome(sample.sample_id, asm, run_dir, runner, p["threads"])if modules.get("mlst", True): _mlst(sample.sample_id, asm, run_dir, runner)3 unmodified lines_gtdbtk(assemblies, run_dir, runner, p["threads"])_mash_skani(assemblies, run_dir, runner, p["threads"])if modules.get("cgmlst", False): _chewbbaca(assemblies, schema_dir, run_dir, runner, p["threads"])if modules.get("phylogenomics", False): _phylogenomics(samples, assemblies, reference, run_dir, runner, p)if modules.get("population", False): _poppunk(assemblies, run_dir, runner, p["threads"])3 unmodified lines"suite": "WOLOJI Comprehensive Bacterial Genomics Suite","version": "2.0.1", "created_at": utc_now(), "parameters": p,"modules": modules,"database_paths": {k: os.getenv(k, "") for k in ["GTDBTK_DATA_PATH","CHECKM2DB","GENOMAD_DB","MOB_SUITE_DB"]},"samples": [s.sample_id for s in samples],"software_versions": status_rows(),}5 unmodified lines# =============================================================================# app.py -- Streamlit interface# =============================================================================st.set_page_config(page_title="WOLOJI Comprehensive Bacterial Genomics Suite", page_icon="🧬", layout="wide")st.title("🧬 WOLOJI Comprehensive Bacterial Genomics Suite")2 unmodified lineswith 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, mobile genetic elements, sequence typing, SNP phylogenomics, population genomics, ""and reproducibility reporting. Genome annotation, codon usage analysis, AMR detection, virulence screening, ""and secondary metabolite prediction are handled by separate dedicated tools and are out of scope here. ""Database-dependent modules run only when the corresponding database path is configured. Prediction-based outputs do not ""replace phenotypic or experimental validation.")7 unmodified linesquast = st.checkbox("3. QUAST assembly QC", True)checkm2 = st.checkbox("4. CheckM2 completeness", False)taxonomy = st.checkbox("5. Taxonomy + ANI", True)mobileome = st.checkbox("6. Mobileome / plasmids / prophages / CRISPR", True)mlst = st.checkbox("7. Classical MLST", True)cgmlst = st.checkbox("8. cgMLST / wgMLST", False)phylogenomics = st.checkbox("9. Core SNP phylogenomics", False)population = st.checkbox("10. 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"])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,66 unmodified linesprogress.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, "mobileome": mobileome, "mlst": mlst, "cgmlst": cgmlst,"phylogenomics": phylogenomics, "population": population}params = {"threads": threads, "memory_gb": memory_gb, "assembly_mode": assembly_mode,"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,77 unmodified linesUnpaired 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, mobileome, MLST and report.**Comparative genomics:** analyse multiple assemblies and enable 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.### Out of scopeGenome annotation, codon usage / composition analysis, AMR detection, virulence screening, and secondary metaboliteprediction are performed with separate dedicated tools and are not part of this build.### Important database variables`GTDBTK_DATA_PATH`, `CHECKM2DB`, `GENOMAD_DB`, `MOB_SUITE_DB`.### 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.
app.py+36-219