# nf-core/bacass architecture

> Architecture diagram of the GitHub repository nf-core/bacass, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nf-core/bacass
- Repository: https://github.com/nf-core/bacass

## Overview

This repository is an nf-core Nextflow DSL2 pipeline for bacterial genome assembly and annotation, centered on a single orchestrated workflow with many reusable process modules underneath.

High-level architecture

The repo is organized into five main layers:

1. Pipeline entry and orchestration
2. Reusable process modules
3. Subworkflows that connect modules into higher-level stages
4. Configuration, schemas, and auxiliary scripts/templates
5. Testing and CI/CD support

The core runtime model is: a samplesheet is parsed, samples are branched by sequencing strategy, reads are QC’d/trimmed, assembled, optionally contamination-checked and reference-grouped, then annotated and summarized into final reports.

Core orchestration boundary

The main workflow logic lives in:
- `main.nf`
- `workflows/bacass.nf`

These are the top-level Nextflow orchestration points. They are responsible for:
- reading pipeline parameters and the input samplesheet
- selecting one of the supported assembly modes:
  - short-read
  - long-read
  - hybrid
- wiring together the module and subworkflow graph
- collecting outputs for final reporting and publication artifacts

The workflow is not a monolith: most actual work is delegated to modules and subworkflows, which keeps the topology composable and testable.

Input model and data flow

The pipeline expects a tabular samplesheet with columns like:
- `ID`
- `R1`
- `R2`
- `LongFastQ`
- `Fast5`
- `GenomeSize`

This input model drives branching through the pipeline:
- paired short reads are routed through trimming/QC and short-read assembly paths
- long-read samples are routed through long-read QC and assembler/polisher paths
- samples with both short and long reads are routed through hybrid assembly paths

The `GenomeSize` field is relevant for long-read assembly tools that benefit from an expected genome size.

Primary processing stages

1. Read preprocessing and QC

Short-read path:
- `fastp` for trimming/filtering
- `fastqc` for read-level QC

Long-read path:
- `porechop` or `filtlong` for read cleanup/filtering
- `nanoplot` and `pycoqc` for long-read QC summaries
- `gunzip` / `untar` where needed to unpack compressed inputs or databases

There is also a combined QC subworkflow:
- `subworkflows/local/qc_nanoplot_toulliqc`
- `modules/nf-core/toulligqc`

This indicates a long-read QC aggregation branch that combines outputs from multiple tools into a coherent sample-level report.

2. Assembly

Short-read assembly:
- `unicycler`

Long-read assembly options:
- `dragonflye`
- `miniasm`
- `canu`

Long-read polishing:
- `racon`
- `medaka`
- `nanopolish`

Hybrid assembly:
- `unicycler` can be used with both read types
- `dragonflye` can also be used in a hybrid context according to the README, though operationally it still sits in the long-read assembly ecosystem and is fed additional short-read information for polishing

This assembly layer is one of the key architectural boundaries: the pipeline branches heavily here based on `assembly_type` and `assembler`.

3. Post-assembly QC and contamination checks

After assembly, the pipeline performs assembly validation and contamination screening:
- `quast` for assembly quality statistics
- `busco` for completeness assessment
- `kraken2` for taxonomic contamination screening
- `kmerfinder` for reference-genome identification / purity checking

These tools feed into the downstream grouping and reporting logic.

4. Annotation

Assembled contigs can be annotated using one of:
- `prokka`
- `bakta`
- `dfast`

This is another explicit branch point in the workflow. Annotation happens after assembly QC and is part of the final deliverables for the bacterial genome.

5. Reporting and aggregation

Final reporting is built from several layers:
- `multiqc` for consolidated QC reporting
- custom multiqc configuration under `assets/`
- `bin/multiqc_to_custom_csv.py` for translating MultiQC outputs into a custom tabular summary
- `modules/nf-core/custom/dumpsoftwareversions` for provenance capture
- `bin/kmerfinder_summary.py` and `bin/find_common_reference.py` for Kmerfinder-oriented aggregation
- `bin/csv_to_yaml.py` and `bin/download_reference.py` for metadata/reference handling

There is also a reference-grouping flow when Kmerfinder is used:
- samples are grouped by estimated reference genome
- one QUAST pass runs on samples without reference genomes
- a second QUAST pass runs “by reference genome” for grouped samples

This creates a distinct post-processing branch that only exists when Kmerfinder-driven grouping is enabled.

Module organization

Most computational steps are provided as nf-core modules under `modules/nf-core/`.
These are standard reusable DSL2 modules, typically one tool per module, with their own:
- `main.nf`
- `meta.yml`
- `environment.yml`
- module-specific tests

This is the “tool execution” layer.

Examples of major nf-core modules used here:
- `fastp`
- `fastqc`
- `unicycler`
- `dragonflye`
- `miniasm`
- `canu`
- `racon`
- `medaka`
- `nanopolish`
- `kraken2`
- `quast`
- `busco`
- `prokka`
- `bakta`
- `liftoff`
- `multiqc`
- `samtools`
- `porechop`
- `filtlong`
- `nanoplot`
- `toulligqc`
- `untar`
- `gunzip`

Local/custom modules

The repository also includes several custom modules under `modules/local/` for behavior that is pipeline-specific:
- `kmerfinder` submodules:
  - `download_reference`
  - `kmerfinder`
  - `summary`
- `kraken2/db_preparation`
- `dfast`
- `medaka`
- `nanopolish`
- `pycoqc`
- `custom/multiqc`

These local modules are important architectural markers because they represent logic not directly covered by upstream nf-core modules, especially around:
- database download/preparation
- custom report formatting
- pipeline-specific wrappers around tools
- specialized QC and summary generation

Subworkflows as composition units

The `subworkflows/` directory shows the pipeline’s intermediate composition layer. These are not low-level tool wrappers; they stitch modules into reusable stages.

Key subworkflows include:

- `subworkflows/nf-core/fastq_trim_fastp_fastqc`
  - a short-read preprocessing unit that chains trimming and QC

- `subworkflows/local/qc_nanoplot_toulliqc`
  - a long-read QC aggregation subworkflow

- `subworkflows/local/kmerfinder_summary_download`
  - combines Kmerfinder summarization with reference download logic

- `subworkflows/local/bakta_dbdownload_run`
  - encapsulates Bakta database acquisition and annotation execution

- `subworkflows/local/utils_nfcore_bacass_pipeline`
  - likely a pipeline-specific utility composition layer for common data handling

- `subworkflows/nf-core/utils_nfcore_pipeline`
- `subworkflows/nf-core/utils_nextflow_pipeline`
- `subworkflows/nf-core/utils_nfschema_plugin`
  - nf-core utility subworkflows used for standard pipeline plumbing, schema integration, and shared helper behavior

This layering makes the architecture diagram clearer:
- top-level workflow decides what branch to run
- subworkflows define the stage boundaries
- modules perform the actual tool invocations

Configuration and environment boundary

The runtime is controlled by:
- `nextflow.config`
- `conf/base.config`
- multiple profile configs for test variants and platform behavior:
  - `conf/test.config`
  - `conf/test_full.config`
  - `conf/test_hybrid.config`
  - `conf/test_long.config`
  - `conf/test_dfast.config`
  - `conf/test_liftoff.config`
  - and others

The pipeline is designed to run across execution backends via Nextflow with container support:
- Docker
- Singularity
- Conda

This is a significant architectural feature: compute is abstracted away from the workflow logic, and the same pipeline can run on local workstations, HPC, or cloud.

The schema and asset files are also part of the configuration boundary:
- `nextflow_schema.json` defines parameter validation
- `assets/schema_input.json` and `assets/samplesheet.tsv` support input structure and documentation
- `assets/multiqc_config*.yml`, `assets/adaptivecard.json`, `assets/slackreport.json`, and email templates support output/report formatting
- `assets/methods_description_template.yml` suggests structured methods text generation

External dependencies and database flow

Several tools require external reference data or databases:
- `kraken2db`
- Kmerfinder references
- Bakta databases

The pipeline contains explicit download/preparation logic for these, so database handling is not left to the user alone. This creates a second data plane alongside sample data:
- sample reads flow through assembly/analysis
- reference/database artifacts flow through download and preparation steps into selected modules

A notable example is the Kmerfinder branch, where reference genome identification can influence downstream grouping and reporting.

Output architecture

The outputs are a mixture of:
- assembled contigs/scaffolds
- annotation files
- QC reports
- contamination summaries
- MultiQC aggregate reports
- software version manifests
- custom tabular summaries

The `docs/output.md` and `docs/usage.md` files suggest that output contracts are documented and are a meaningful part of the repo design, not just incidental artifacts.

Testing and CI/CD layer

The repository has a substantial validation system, which is architecturally important because it reflects the workflow’s modular decomposition:
- `tests/` contains end-to-end workflow tests for multiple pipeline modes:
  - default
  - short/long/hybrid
  - `dfast`
  - `dragonflye`
  - `liftoff`
  - `miniasm`
  - `prokka`
- module tests exist alongside many module definitions
- `nf-test.config` and GitHub Actions workflows run those tests
- `.github/workflows/awsfulltest.yml` indicates full-sized AWS validation
- linting and release workflows enforce repo consistency

This indicates that the pipeline is treated as a compositional workflow system with strong regression coverage across many mode combinations.

What to emphasize in an architecture diagram

If you draw this repository, the most important boundaries are:

- Input boundary: samplesheet plus runtime parameters and optional database URLs
- Orchestration boundary: `main.nf` / `workflows/bacass.nf`
- Branching boundary: short vs long vs hybrid assembly
- Tool-execution boundary: nf-core modules vs local custom modules
- Aggregation boundary: QC summaries, Kmerfinder reference grouping, MultiQC, software versions
- External-data boundary: Kraken2/Kmerfinder/Bakta database downloads
- Validation boundary: nf-test, GitHub Actions, and AWS full-test workflows

In short, this is a Nextflow-based bacterial assembly pipeline whose architecture is centered on mode-based branching and modular tool composition, with custom subworkflows for database handling, long-read QC aggregation, Kmerfinder-driven grouping, and final reporting.

Main entry points: [`workflows/bacass.nf`](https://github.com/nf-core/bacass/blob/HEAD/workflows/bacass.nf) (bacass flow), [`modules/nf-core/multiqc/main.nf`](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/multiqc/main.nf) (Final reports), [`subworkflows/nf-core/fastq_trim_fastp_fastqc/main.nf`](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/nf-core/fastq_trim_fastp_fastqc/main.nf) (Trim & QC), [`subworkflows/local/qc_nanoplot_toulliqc/main.nf`](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/local/qc_nanoplot_toulliqc/main.nf) (Long-read QC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph "Orchestration"
  main_nf["Main entry<br/>Nextflow entrypoint<br/>[main.nf]"]
  bacass_wf["bacass flow<br/>DSL2 workflow<br/>[bacass.nf]"]
  samplesheet_input["Samplesheet<br/>input model<br/>[samplesheet.tsv]"]
  utils_pipeline["Pipeline utils<br/>nf-core subworkflow<br/>[main.nf]"]
  utils_nextflow["Nextflow utils<br/>nf-core subworkflow<br/>[main.nf]"]
  schema_plugin["Schema utils<br/>nf-core subworkflow<br/>[main.nf]"]
end

subgraph "Processing"
  trim_qc["Trim & QC<br/>subworkflow<br/>[main.nf]"]
  fastp_mod["fastp<br/>read trim module<br/>[main.nf]"]
  fastqc_mod["fastqc<br/>read QC module<br/>[main.nf]"]
  long_qc["Long-read QC<br/>subworkflow<br/>[main.nf]"]
  nanoplot_mod["nanoplot<br/>long-read QC module<br/>[main.nf]"]
  toulligqc_mod["toulligqc<br/>QC aggregation module<br/>[main.nf]"]
  assembly_branch{{"Assembly modes<br/>workflow branch<br/>[bacass.nf]"}}
  assembler_short["unicycler<br/>assembly module<br/>[main.nf]"]
  assembler_long["long assemblers<br/>assembly modules<br/>[main.nf]"]
  polish_mod["Polishing<br/>polish modules<br/>[main.nf]"]
end

subgraph "Reporting"
  assembly_qc["Assembly QC<br/>analysis stage<br/>[main.nf]"]
  busco_mod["busco<br/>completeness module<br/>[main.nf]"]
  contam_screen["Contamination<br/>screening stage<br/>[main.nf]"]
  kmerfinder_flow["Kmerfinder flow<br/>local subworkflow<br/>[main.nf]"]
  kmerfinder_mod["kmerfinder<br/>local module<br/>[main.nf]"]
  ref_download["Reference download<br/>local module<br/>[main.nf]"]
  annotate_branch{{"Annotation<br/>[bacass.nf]"}}
  bakta_flow["Bakta run<br/>subworkflow<br/>[main.nf]"]
  bakta_mod["bakta<br/>annotation module<br/>[main.nf]"]
  prokka_mod["prokka<br/>annotation module<br/>[main.nf]"]
  dfast_mod["dfast<br/>local annotation module<br/>[main.nf]"]
  reporting["Final reports<br/>aggregation stage<br/>[main.nf]"]
  custom_multiqc["Custom MultiQC<br/>local module<br/>[main.nf]"]
  versions["Versions<br/>provenance module"]
end

subgraph "Config & Validation"
  config_schema["Schema"]
  nextflow_cfg["Nextflow config<br/>runtime config<br/>[nextflow.config]"]
  base_cfg["Base config<br/>runtime config<br/>[base.config]"]
  nf_tests["Workflow tests<br/>nf-test suite<br/>[default.nf.test]"]
end

main_nf -->|"reads"| samplesheet_input
main_nf -->|"starts"| bacass_wf
bacass_wf -->|"plumbing"| utils_pipeline
bacass_wf -->|"channels"| utils_nextflow
bacass_wf -->|"validate"| schema_plugin
bacass_wf -->|"short reads"| trim_qc
trim_qc -->|"trim"| fastp_mod
trim_qc -->|"qc"| fastqc_mod
bacass_wf -->|"long reads"| long_qc
long_qc -->|"summarize"| nanoplot_mod
long_qc -->|"aggregate"| toulligqc_mod
bacass_wf -->|"select"| assembly_branch
assembly_branch -->|"short/hybrid"| assembler_short
assembly_branch -->|"long"| assembler_long
assembly_branch -->|"polish"| polish_mod
assembly_branch -->|"post-assembly"| assembly_qc
assembly_qc -->|"completeness"| busco_mod
assembly_qc -->|"screen"| contam_screen
contam_screen -->|"group"| kmerfinder_flow
kmerfinder_flow -->|"identify"| kmerfinder_mod
kmerfinder_flow -->|"db"| ref_download
bacass_wf -->|"select"| annotate_branch
annotate_branch -->|"bakta"| bakta_flow
bakta_flow -->|"run"| bakta_mod
annotate_branch -->|"prokka"| prokka_mod
annotate_branch -->|"dfast"| dfast_mod
bacass_wf -->|"collect"| reporting
reporting -->|"format"| custom_multiqc
reporting -->|"provenance"| versions
reporting -.->|"validated by"| config_schema
nextflow_cfg -->|"includes"| base_cfg
nf_tests -.->|"regresses"| bacass_wf

click main_nf "https://github.com/nf-core/bacass/blob/master/main.nf"
click bacass_wf "https://github.com/nf-core/bacass/blob/master/workflows/bacass.nf"
click samplesheet_input "https://github.com/nf-core/bacass/blob/master/assets/samplesheet.tsv"
click utils_pipeline "https://github.com/nf-core/bacass/blob/master/subworkflows/nf-core/utils_nfcore_pipeline/main.nf"
click utils_nextflow "https://github.com/nf-core/bacass/blob/master/subworkflows/nf-core/utils_nextflow_pipeline/main.nf"
click schema_plugin "https://github.com/nf-core/bacass/blob/master/subworkflows/nf-core/utils_nfschema_plugin/main.nf"
click trim_qc "https://github.com/nf-core/bacass/blob/master/subworkflows/nf-core/fastq_trim_fastp_fastqc/main.nf"
click fastp_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/fastp/main.nf"
click fastqc_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/fastqc/main.nf"
click long_qc "https://github.com/nf-core/bacass/blob/master/subworkflows/local/qc_nanoplot_toulliqc/main.nf"
click nanoplot_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/nanoplot/main.nf"
click toulligqc_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/toulligqc/main.nf"
click assembly_branch "https://github.com/nf-core/bacass/blob/master/workflows/bacass.nf"
click assembler_short "https://github.com/nf-core/bacass/blob/master/modules/nf-core/unicycler/main.nf"
click assembler_long "https://github.com/nf-core/bacass/blob/master/modules/nf-core/dragonflye/main.nf"
click polish_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/racon/main.nf"
click assembly_qc "https://github.com/nf-core/bacass/blob/master/modules/nf-core/quast/main.nf"
click busco_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/busco/busco/main.nf"
click contam_screen "https://github.com/nf-core/bacass/blob/master/modules/nf-core/kraken2/kraken2/main.nf"
click kmerfinder_flow "https://github.com/nf-core/bacass/blob/master/subworkflows/local/kmerfinder_summary_download/main.nf"
click kmerfinder_mod "https://github.com/nf-core/bacass/blob/master/modules/local/kmerfinder/kmerfinder/main.nf"
click ref_download "https://github.com/nf-core/bacass/blob/master/modules/local/kmerfinder/download_reference/main.nf"
click annotate_branch "https://github.com/nf-core/bacass/blob/master/workflows/bacass.nf"
click bakta_flow "https://github.com/nf-core/bacass/blob/master/subworkflows/local/bakta_dbdownload_run/main.nf"
click bakta_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/bakta/bakta/main.nf"
click prokka_mod "https://github.com/nf-core/bacass/blob/master/modules/nf-core/prokka/main.nf"
click dfast_mod "https://github.com/nf-core/bacass/blob/master/modules/local/dfast/main.nf"
click reporting "https://github.com/nf-core/bacass/blob/master/modules/nf-core/multiqc/main.nf"
click custom_multiqc "https://github.com/nf-core/bacass/blob/master/modules/local/custom/multiqc/main.nf"
click versions "https://github.com/nf-core/bacass/blob/master/modules/nf-core/custom/dumpsoftwareversions/templates/dumpsoftwareversions.py"
click config_schema "https://github.com/nf-core/bacass/blob/master/nextflow_schema.json"
click nextflow_cfg "https://github.com/nf-core/bacass/blob/master/nextflow.config"
click base_cfg "https://github.com/nf-core/bacass/blob/master/conf/base.config"
click nf_tests "https://github.com/nf-core/bacass/blob/master/tests/default.nf.test"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class main_nf,bacass_wf,samplesheet_input,utils_pipeline,utils_nextflow,schema_plugin toneBlue
class trim_qc,fastp_mod,fastqc_mod,long_qc,nanoplot_mod,toulligqc_mod,assembly_branch,assembler_short,assembler_long,polish_mod toneAmber
class assembly_qc,busco_mod,contam_screen,kmerfinder_flow,kmerfinder_mod,ref_download,annotate_branch,bakta_flow,bakta_mod,prokka_mod,dfast_mod,reporting,custom_multiqc,versions toneMint
class config_schema,nextflow_cfg,base_cfg,nf_tests toneRose
```

## Components

### Orchestration

Pipeline entrypoint and top-level workflow wiring

- [Main entry](https://github.com/nf-core/bacass/blob/HEAD/main.nf): Nextflow entrypoint · Loads pipeline parameters and starts the workflow. · `main.nf`
- [bacass flow](https://github.com/nf-core/bacass/blob/HEAD/workflows/bacass.nf): DSL2 workflow · Top-level orchestration for mode selection and stage wiring. · `workflows/bacass.nf`
- [Samplesheet](https://github.com/nf-core/bacass/blob/HEAD/assets/samplesheet.tsv): input model · Tabular sample metadata driving read-type branching. · `assets/samplesheet.tsv`
- [Pipeline utils](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/nf-core/utils_nfcore_pipeline/main.nf): nf-core subworkflow · Shared pipeline plumbing and data-handling helpers. · `subworkflows/nf-core/utils_nfcore_pipeline/main.nf`
- [Nextflow utils](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/nf-core/utils_nextflow_pipeline/main.nf): nf-core subworkflow · Common Nextflow helper logic and channel utilities. · `subworkflows/nf-core/utils_nextflow_pipeline/main.nf`
- [Schema utils](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/nf-core/utils_nfschema_plugin/main.nf): nf-core subworkflow · Schema/plugin integration helpers for parameter validation. · `subworkflows/nf-core/utils_nfschema_plugin/main.nf`

### Processing

Read QC, assembly, polishing, and QC stages

- [Trim & QC](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/nf-core/fastq_trim_fastp_fastqc/main.nf): subworkflow · Short-read preprocessing stage combining trimming and QC. · `subworkflows/nf-core/fastq_trim_fastp_fastqc/main.nf`
- [fastp](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/fastp/main.nf): read trim module · Read trimming and filtering for short reads. · `modules/nf-core/fastp/main.nf`
- [fastqc](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/fastqc/main.nf): read QC module · Per-sample short-read quality control. · `modules/nf-core/fastqc/main.nf`
- [Long-read QC](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/local/qc_nanoplot_toulliqc/main.nf): subworkflow · Aggregates long-read QC outputs into sample-level reports. · `subworkflows/local/qc_nanoplot_toulliqc/main.nf`
- [nanoplot](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/nanoplot/main.nf): long-read QC module · Read-length and quality summary generation. · `modules/nf-core/nanoplot/main.nf`
- [toulligqc](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/toulligqc/main.nf): QC aggregation module · Long-read sequencing QC aggregation and reporting. · `modules/nf-core/toulligqc/main.nf`
- [Assembly modes](https://github.com/nf-core/bacass/blob/HEAD/workflows/bacass.nf): workflow branch · Selects short-read, long-read, or hybrid assembly paths. · `workflows/bacass.nf`
- [unicycler](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/unicycler/main.nf): assembly module · Short-read and hybrid assembly path. · `modules/nf-core/unicycler/main.nf`
- [long assemblers](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/dragonflye/main.nf): assembly modules · Long-read assembly options including dragonflye, miniasm, and canu. · `modules/nf-core/dragonflye/main.nf`
- [Polishing](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/racon/main.nf): polish modules · Long-read polishing with racon, medaka, and nanopolish. · `modules/nf-core/racon/main.nf`

### Reporting

Aggregation, annotation, and final summaries

- [Assembly QC](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/quast/main.nf): analysis stage · Post-assembly quality and completeness assessment. · `modules/nf-core/quast/main.nf`
- [busco](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/busco/busco/main.nf): completeness module · Assembly completeness evaluation. · `modules/nf-core/busco/busco/main.nf`
- [Contamination](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/kraken2/kraken2/main.nf): screening stage · Taxonomic contamination and reference identification branch. · `modules/nf-core/kraken2/kraken2/main.nf`
- [Kmerfinder flow](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/local/kmerfinder_summary_download/main.nf): local subworkflow · Reference identification, grouping, and summary generation. · `subworkflows/local/kmerfinder_summary_download/main.nf`
- [kmerfinder](https://github.com/nf-core/bacass/blob/HEAD/modules/local/kmerfinder/kmerfinder/main.nf): local module · Reference matching and genome identification. · `modules/local/kmerfinder/kmerfinder/main.nf`
- [Reference download](https://github.com/nf-core/bacass/blob/HEAD/modules/local/kmerfinder/download_reference/main.nf): local module · Fetches Kmerfinder reference data. · `modules/local/kmerfinder/download_reference/main.nf`
- [Annotation](https://github.com/nf-core/bacass/blob/HEAD/workflows/bacass.nf): annotation branch · Selects Prokka, Bakta, or DFAST annotation paths. · `workflows/bacass.nf`
- [Bakta run](https://github.com/nf-core/bacass/blob/HEAD/subworkflows/local/bakta_dbdownload_run/main.nf): subworkflow · Downloads Bakta databases and runs annotation. · `subworkflows/local/bakta_dbdownload_run/main.nf`
- [bakta](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/bakta/bakta/main.nf): annotation module · Bacterial genome annotation with Bakta. · `modules/nf-core/bakta/bakta/main.nf`
- [prokka](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/prokka/main.nf): annotation module · Bacterial genome annotation with Prokka. · `modules/nf-core/prokka/main.nf`
- [dfast](https://github.com/nf-core/bacass/blob/HEAD/modules/local/dfast/main.nf): local annotation module · Pipeline-specific annotation wrapper for DFAST. · `modules/local/dfast/main.nf`
- [Final reports](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/multiqc/main.nf): aggregation stage · MultiQC, custom CSV summaries, provenance, and publication artifacts. · `modules/nf-core/multiqc/main.nf`
- [Custom MultiQC](https://github.com/nf-core/bacass/blob/HEAD/modules/local/custom/multiqc/main.nf): local module · Pipeline-specific MultiQC formatting and report export. · `modules/local/custom/multiqc/main.nf`
- [Versions](https://github.com/nf-core/bacass/blob/HEAD/modules/nf-core/custom/dumpsoftwareversions/templates/dumpsoftwareversions.py): provenance module · Captures software versions for final output. · `modules/nf-core/custom/dumpsoftwareversions/templates/dumpsoftwareversions.py`

### Config & Validation

Schemas, profiles, tests, and CI support

- [Schema](https://github.com/nf-core/bacass/blob/HEAD/nextflow_schema.json): validation schema · Parameter and input validation contract. · `nextflow_schema.json`
- [Nextflow config](https://github.com/nf-core/bacass/blob/HEAD/nextflow.config): runtime config · Global execution and profile configuration. · `nextflow.config`
- [Base config](https://github.com/nf-core/bacass/blob/HEAD/conf/base.config): runtime config · Shared executor and module settings. · `conf/base.config`
- [Workflow tests](https://github.com/nf-core/bacass/blob/HEAD/tests/default.nf.test): nf-test suite · End-to-end mode coverage across short, long, hybrid, and annotation variants. · `tests/default.nf.test`

## Connections

- Main entry → Samplesheet: reads · Consumes sample metadata and input paths.
- Main entry → bacass flow: starts · Delegates execution to the main workflow.
- bacass flow → Pipeline utils: plumbing · Uses shared pipeline helpers.
- bacass flow → Nextflow utils: channels · Uses standard Nextflow utility helpers.
- bacass flow → Schema utils: validate · Connects schema and parameter handling.
- bacass flow → Trim & QC: short reads · Routes paired short reads into preprocessing.
- Trim & QC → fastp: trim · Trims and filters short reads.
- Trim & QC → fastqc: qc · Runs per-sample read QC.
- bacass flow → Long-read QC: long reads · Routes long-read samples to QC aggregation.
- Long-read QC → nanoplot: summarize · Generates long-read QC summaries.
- Long-read QC → toulligqc: aggregate · Combines long-read QC metrics.
- bacass flow → Assembly modes: select · Branches by assembly strategy.
- Assembly modes → unicycler: short/hybrid · Uses Unicycler for short-read or hybrid assembly.
- Assembly modes → long assemblers: long · Uses long-read assemblers such as Dragonflye, Miniasm, or Canu.
- Assembly modes → Polishing: polish · Applies long-read polishing steps where needed.
- Assembly modes → Assembly QC: post-assembly · Evaluates assembly quality.
- Assembly QC → busco: completeness · Adds completeness assessment.
- Assembly QC → Contamination: screen · Checks for contamination and taxonomic purity.
- Contamination → Kmerfinder flow: group · Feeds reference grouping and summary generation.
- Kmerfinder flow → kmerfinder: identify · Runs Kmerfinder reference matching.
- Kmerfinder flow → Reference download: db · Downloads required reference data.
- bacass flow → Annotation: select · Chooses annotation toolchain.
- Annotation → Bakta run: bakta · Downloads Bakta database and annotates.
- Bakta run → bakta: run · Executes Bakta annotation.
- Annotation → prokka: prokka · Annotates assemblies with Prokka.
- Annotation → dfast: dfast · Annotates assemblies with DFAST.
- bacass flow → Final reports: collect · Aggregates final artifacts and reports.
- Final reports → Custom MultiQC: format · Creates custom summary outputs from MultiQC data.
- Final reports → Versions: provenance · Captures software version manifests.
- Final reports → Schema: validated by · Output and parameter conventions are governed by schema.
- Nextflow config → Base config: includes · Base runtime settings feed the main Nextflow config.
- Workflow tests → bacass flow: regresses · Tests exercise major workflow modes and branches.
