# nf-core/taxprofiler architecture

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

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

## Overview

##### Main Components

a. Input Processing Layer
- Input validation for samplesheet.csv and databases.csv
- File format handling (FASTQ, FASTA)
- Platform-specific processing (Illumina vs. long-read)

b. Pre-processing Layer
- Quality Control (FastQC/falco)
- Read Processing Modules
- Adapter Removal (fastp, AdapterRemoval2, Porechop)
- Quality Filtering (bbduk, PRINSEQ++, Filtlong, Nanoq)
- Host Read Removal (Bowtie2, Minimap2)

c. Analysis Layer
- Taxonomic Classification Tools
- Primary classifiers (Kraken2, MetaPhlAn, MALT, etc.)
- Post-processing tools (Bracken)
- Coverage Estimation (Nonpareil)
- Statistics Generation (Samtools)

d. Results Processing Layer
- Output Standardization (Taxpasta)
- Visualization Generation (Krona)
- Quality Reporting (MultiQC)

##### Relationships and Data Flow

- Data flow between components
- Tool dependencies
- Optional vs. required paths
- Parallel execution possibilities

##### Specific Implementation Details

a. Top Level Organization:
**Input → QC → Pre-processing → Classification → Post-processing → Results**

b. Parallel Workflows:
- How multiple tools can run simultaneously
- Where workflows merge for combined results

c. Configuration Integration:
- How nextflow.config influences workflow
- Where tool-specific configs apply

##### Notes for Implementation

- Use a hierarchical layout
- Related tools and processes
- Error handling paths
- Validation checkpoints
- Version control points

Remember to highlight the pipeline's key features:
- Multi-tool support
- Flexible input handling
- Parallel processing capabilities
- Standardized output generation
- Quality control integration
- Resource optimization

This will provide a clear understanding of the pipeline's architecture while maintaining technical accuracy and practical utility for the principal software engineer.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        style Legend fill:#f5f5f5,stroke:#333
        L1[Input/Output]:::io
        L2[Quality Control]:::qc
        L3[Processing Module]:::process
        L4[Analysis Tool]:::analysis
        L5[Results Generation]:::results
        L6[Optional Component]:::optional
        L7[(Database)]:::db
    end

    subgraph "Input Processing Layer"
        Input[("Input Files")]:::io
        InputVal["Input Validation"]:::io
        DBVal["Database Validation"]:::io
        FormatHandle["File Format Handler"]:::process
    end

    subgraph "Pre-processing Layer"
        QC{"Quality Control"}:::qc
        FastQC["FastQC/Falco"]:::qc
        ReadProc{"Read Processing"}:::process
        ShortRead["Short Read Processing"]:::process
        LongRead["Long Read Processing"]:::process
        AdaptRem["Adapter Removal"]:::process
        HostRem["Host Removal"]:::process
    end

    subgraph "Analysis Layer"
        TaxClass{"Taxonomic Classification"}:::analysis
        Kraken["Kraken2"]:::analysis
        MetaPhlAn["MetaPhlAn"]:::analysis
        MALT["MALT"]:::analysis
        Bracken["Bracken"]:::analysis
        Coverage["Nonpareil Coverage"]:::analysis
        Stats["Samtools Stats"]:::analysis
    end

    subgraph "Results Processing Layer"
        TaxPasta["Taxpasta Standardization"]:::results
        Krona["Krona Visualization"]:::results
        MultiQC["MultiQC Report"]:::results
        FinalOut["Final Output"]:::results
    end

    %% Connections
    Input --> InputVal
    Input --> DBVal
    InputVal --> FormatHandle
    DBVal --> FormatHandle
    FormatHandle --> QC
    QC --> FastQC
    FastQC --> ReadProc
    ReadProc --> ShortRead
    ReadProc --> LongRead
    ShortRead --> AdaptRem
    LongRead --> AdaptRem
    AdaptRem --> HostRem
    HostRem --> TaxClass
    TaxClass --> Kraken
    TaxClass --> MetaPhlAn
    TaxClass --> MALT
    Kraken --> Bracken
    Kraken --> Coverage
    MetaPhlAn --> Coverage
    MALT --> Coverage
    Coverage --> Stats
    Stats --> TaxPasta
    TaxPasta --> Krona
    Krona --> MultiQC
    MultiQC --> FinalOut

    %% Click Events
    click InputVal "https://github.com/nf-core/taxprofiler/blob/master/assets/schema_input.json"
    click DBVal "https://github.com/nf-core/taxprofiler/blob/master/assets/schema_database.json"
    click FormatHandle "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/cat/fastq/"
    click FastQC "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/fastqc/"
    click ShortRead "https://github.com/nf-core/taxprofiler/blob/master/subworkflows/local/shortread_preprocessing.nf"
    click LongRead "https://github.com/nf-core/taxprofiler/blob/master/subworkflows/local/longread_preprocessing.nf"
    click AdaptRem "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/fastp/"
    click HostRem "https://github.com/nf-core/taxprofiler/blob/master/subworkflows/local/shortread_hostremoval.nf"
    click Kraken "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/kraken2/"
    click MetaPhlAn "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/metaphlan/"
    click MALT "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/malt/"
    click Coverage "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/nonpareil/"
    click Stats "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/samtools/stats/"
    click TaxPasta "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/taxpasta/"
    click Krona "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/krona/"
    click MultiQC "https://github.com/nf-core/taxprofiler/tree/master/modules/nf-core/multiqc/"

    %% Styles
    classDef io fill:#b3e0ff,stroke:#333
    classDef qc fill:#98FB98,stroke:#333
    classDef process fill:#FFE5CC,stroke:#333
    classDef analysis fill:#FFB366,stroke:#333
    classDef results fill:#DDA0DD,stroke:#333
    classDef optional fill:#E6E6E6,stroke:#333
    classDef db fill:#F0F8FF,stroke:#333
```
