# nf-core/funcscan architecture

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

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

## Overview

Based on our analysis of the file tree and README, this project is a Nextflow-based bioinformatics pipeline (nf-core/funcscan) designed to process nucleotide sequence data (assembled contigs) and screen them for functional genes – including antimicrobial peptides, antibiotic resistance genes, and biosynthetic gene clusters. The project leverages a modular design (with numerous nf-core modules) to encapsulate various stages such as quality control, taxonomic classification, annotation, screening, and report aggregation. It also follows best practices in reproducibility through containerization (Docker/Singularity) and is managed using Nextflow DSL2.

##### Main Components
- Pipeline Controller (Nextflow engine): Represent the main.nf and nextflow.config as the entry point that orchestrates the workflow.
- Input Handling and Configuration: Include components such as sample input (samplesheet.csv) and configuration files from the “conf” directory that set runtime parameters.
- Modular Processing Units (Modules):
- Quality Control Module (using SeqKit)
- Taxonomic Classification Module (using MMseqs2)
- Functional Screening Modules:
– AMP screening (using ampir, Macrel, HMMER, AMPlify)
– ARG screening (using ABRicate, AMRFinderPlus, fARGene, RGI, DeepARG, argNorm)
– BGC screening (using antiSMASH, DeepBGC, GECCO, HMMER)
- Report Aggregation and Summarization: Represent the generation of aggregated summaries and final reports with external tools like AMPcombi, hAMRonization, comBGC, and MultiQC.
- External Dependencies and Containers: Show the support for containerized processes (Docker/Singularity) and note that each module typically runs in its own container.
- Subworkflows: Illustrate that there are additional subworkflows (found under subworkflows) to encapsulate certain tasks (e.g., local execution pipelines, utility workflows, and nf-core shared tooling).

##### Relationships and Flow
- The controller then directs data through sequential Quality Control → Taxonomic Classification.
- Next, further downstream screens for AMPs, ARGs, and BGCs should be depicted as parallel processes that take the annotated data as input.
- After these screening modules, present a consolidation phase where aggregated reports are created, eventually ending at MultiQC for final output.

##### Highlighted Architectural Patterns & Design Principles
- Modularity: The project is organized as Nextflow modules (both local and nf-core) allowing individual pieces to be maintained and updated independently.
- Containerization: Each process runs within its own container ensuring reproducibility and ease of deployment across diverse compute environments.
- Pipeline Orchestration: The orchestrator (Nextflow) is central—it logs, manages dependencies, and sequences tasks based on configuration files.
- CI/CD Integration: Automated testing and continuous integration workflows ensure that the pipeline’s functionality is constantly verified.

##### Technologies, Frameworks and Libraries
- Nextflow (DSL2): As the workflow engine.
- Docker, Singularity: For containerization.
- GitHub Actions (CI/CD), AWS for full-size tests.

- Clearly separate the orchestration/control layer (Nextflow orchestration and configuration) from the core processing modules (quality control, taxonomic classification, annotation, screening, and reporting).

##### Elements
- Each component should have a clear label (e.g., “Quality Control (SeqKit)”, “Taxonomic Classification (MMseqs2)”, “Gene Annotation (Prodigal/Pyrodigal/Prokka/Bakta)”, “AMP Screening”, “ARG Screening”, “BGC Screening”, “Aggregated Reporting (MultiQC)”).
- A section or note indicating that containers are used per module for reproducibility.

- Then, drill down to illustrate key modules and their interconnections clearly.
- Don’t overcomplicate: focus on clear separation of components with a detailed flow from ingest to output, while also noting CI/CD and containerization aspects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input & Configuration
    subgraph "Input & Configuration"
        A["Sample Input (samplesheet.csv)"]:::input
        B["Configuration (conf)"]:::input
    end

    %% Pipeline Controller
    C["Pipeline Controller (main.nf & nextflow.config)"]:::controller

    A --> C
    B --> C

    %% Quality Control
    D["Quality Control (SeqKit)"]:::module
    C --> D

    %% Taxonomic Classification
    E["Taxonomic Classification (MMseqs2)"]:::module
    D --> E

    %% Gene Annotation Modules
    subgraph "Gene Annotation"
        F["Prodigal"]:::annotation
        G["Pyrodigal"]:::annotation
        H["Prokka"]:::annotation
        I["Bakta"]:::annotation
    end
    E --> F
    E --> G
    E --> H
    E --> I

    %% Aggregated Annotation Output
    AA1["Annotated Data"]:::annotation
    F --> AA1
    G --> AA1
    H --> AA1
    I --> AA1

    %% AMP Screening Modules
    subgraph "AMP Screening"
        J["ampir"]:::screening
        K["AMPlify"]:::screening
        L["Macrel"]:::screening
    end

    %% ARG Screening Modules
    subgraph "ARG Screening"
        M["ABRicate"]:::screening
        N["AMRFinderPlus_Run"]:::screening
        O["AMRFinderPlus_Update"]:::screening
        P["argNorm"]:::screening
        Q["RGI"]:::screening
        R["Card Annotation"]:::screening
    end

    %% BGC Screening Modules
    subgraph "BGC Screening"
        S["antiSMASH Lite/Download"]:::screening
        T["DeepBGC Pipeline/Download"]:::screening
        U["GECCO"]:::screening
        V["HMMER"]:::screening
    end

    %% Data flow from Annotation to Screening
    AA1 --- J
    AA1 --- M
    AA1 --- S

    %% Internal flow within Screening modules (to emphasize parallel processes)
    J --> K
    K --> L
    M --> N
    N --> O
    O --> P
    P --> Q
    Q --> R
    S --> T
    T --> U
    U --> V

    %% Aggregated Reporting
    W["Aggregated Reporting (MultiQC)"]:::reporting
    %% Connect all screening outputs to Aggregated Reporting
    J --> W
    K --> W
    L --> W
    M --> W
    N --> W
    O --> W
    P --> W
    Q --> W
    R --> W
    S --> W
    T --> W
    U --> W
    V --> W

    X["Additional Reports (ampcombi, comBGC)"]:::reporting
    W --> X

    %% External Dependencies & Supportive Components
    Y["Containerization (.devcontainer)"]:::external
    Z["CI/CD & Testing (.github/workflows, tests)"]:::external
    AA["Subworkflows"]:::external

    %% Link external support to the Pipeline Controller
    C --- Y
    C --- Z
    C --- AA

    %% Styles
    classDef input fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef controller fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef module fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef annotation fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef screening fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef reporting fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
    classDef external fill:#fefefe,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click A "https://github.com/nf-core/funcscan/blob/master/assets/samplesheet.csv"
    click B "https://github.com/nf-core/funcscan/tree/master/conf/"
    click C "https://github.com/nf-core/funcscan/blob/master/main.nf"
    click D "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/seqkit/seq/main.nf"
    click E "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/mmseqs/taxonomy/main.nf"
    click F "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/prodigal/main.nf"
    click G "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/pyrodigal/main.nf"
    click H "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/prokka/main.nf"
    click I "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/bakta/bakta/main.nf"
    click J "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/ampir/main.nf"
    click K "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/amplify/predict/main.nf"
    click L "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/macrel/contigs/main.nf"
    click M "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/abricate/run/main.nf"
    click N "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/amrfinderplus/run/main.nf"
    click O "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/amrfinderplus/update/main.nf"
    click P "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/argnorm/main.nf"
    click Q "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/rgi/main/main.nf"
    click R "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/rgi/cardannotation/main.nf"
    click S "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/antismash/antismashlite/main.nf"
    click T "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/deepbgc/pipeline/main.nf"
    click U "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/gecco/run/main.nf"
    click V "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/hmmer/hmmsearch/main.nf"
    click W "https://github.com/nf-core/funcscan/blob/master/modules/nf-core/multiqc/main.nf"
    click X "https://github.com/nf-core/funcscan/blob/master/bin/ampcombi_download.py"
    click Y "https://github.com/nf-core/funcscan/tree/master/.devcontainer/"
    click Z "https://github.com/nf-core/funcscan/tree/master/.github/workflows/"
    click AA "https://github.com/nf-core/funcscan/tree/master/subworkflows/"
```
