# nf-core/sammyseq architecture

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

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

## Overview

##### Project Type & Purpose
- This is a workflow/pipeline project in the bioinformatics domain meant for processing chromatin state data. It is built on Nextflow, leveraging modular “processes” and “subworkflows” to implement tools such as FastQC, Trim Galore, Bowtie2/BWA, Picard, samtools, deeptools, and multiQC.

##### Analyzing the File Structure
- Top-level files and directories (main.nf, nextflow.config, assets, conf, docs, tests, modules, subworkflows) indicate the pipeline entry point (main.nf) and clearly displayed modular tasks.
- The “modules” directory contains many subdirectories for specific tasks (e.g., nf-core/bowtie2, nf-core/bwa, nf-core/fastqc, etc.). This modularization implies that the workflow is divided into distinct, reusable components.
- The “subworkflows” directory holds additional workflows that support more complex processing steps or integration of multiple modules – a key element in the overall design.

##### README Insights
- The README not only provides usage examples and input/output specifications but also offers an overview of the pipeline structure (processing steps) and an embedded tubemap image indicating a high-level workflow.
- It lists third-party tools used at each stage (e.g., FastQC, Trim Galore, BWA/Bowtie2, Picard, samtools, deeptools, MultiQC). These should be clearly noted in the architecture.

a. Pipeline Entry / Orchestrator:
– Main Nextflow file (main.nf) serves as the orchestrator.
– Nextflow runtime (with configurations from nextflow.config and conf/*) that manages process execution.
b. Input and Data Sources:
– The samplesheet (CSV) provided by the user.
– Reference genome (FASTA).
c. Core Processing Stages:
– Read QC: FastQC (asset).
– Read Trimming: Trim Galore/Trimmomatic.
– Alignment: BWA or Bowtie2 modules.
– Duplicate Removal: Picard MarkDuplicates.
– Alignment Statistics: samtools based modules.
– Track Creation: deeptools for bigwig files.
– Optional Pairwise Comparison using spp (if provided).
– QC Reporting: MultiQC aggregation.
d. Modular Structure:
– Separate "modules" (especially within the nf-core folder) represent individual tasks.
– “subworkflows” show composite operations used to combine or extend functionality.
e. Output and Reporting:
– Final reports including QC outputs and aggregated analysis documentation (using MultiQC) resulting in both data files and HTML reports.

##### Relationships & Interactions
– From Input (samplesheet, reference genome) to initial processes (FastQC, trimming).
– From trimming, data are passed to alignment processes.
– Alignment outputs feed into duplicate removal and statistical analysis.
– Later stages combine data into track generation and final MultiQC reporting.
- Dependency between standalone modules and subworkflows by grouping related tasks together (for instance, aligners and samtools tasks).
- Integration with external resources (e.g., Docker, Singularity, and Conda containers) which encapsulate the runtime environment for each module.

##### Important Architectural Patterns and Design Principles
- Modular architecture: The splitting of the pipeline into modules enables reusability and flexibility.
- Declarative workflow orchestration: Use of Nextflow DSL2 to define tasks and data flow.
- Containerization: Inclusion of Docker, Singularity, and Conda profiles ensures reproducibility and portability.
- CI/CD integration: GitHub workflows clear that the pipeline adheres to best practices in continuous integration and testing.
- Separation of concerns: Input, processing, and output phases are clearly separated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Pipeline Orchestration"
        Orchestrator["Pipeline Orchestrator (main.nf)"]:::orchestrator
        Config["Configuration (nextflow.config & conf/)"]:::orchestrator
    end

    subgraph "Input Data"
        Samplesheet["Input: samplesheet.csv"]:::input
        Reference["Reference Genome (External)"]:::input
    end

    subgraph "Processing Modules"
        subgraph "Pre-processing"
            QC["Read QC (FastQC)"]:::module
            Trimming["Read Trimming (Trim Galore/Trimmomatic)"]:::module
        end
        
        subgraph "Alignment"
            Bowtie2["Alignment: Bowtie2"]:::module
            BWA["Alignment: BWA"]:::module
        end

        Dup["Duplicate Removal (Picard MarkDuplicates)"]:::module
        Stats["Alignment Statistics (samtools)"]:::module
        Tracks["Track Generation (deeptools)"]:::module
        Reporting["QC Reporting (MultiQC)"]:::module
    end

    subgraph "Subworkflows / Composite Operations"
        SubWF["Subworkflows (Composite Tasks)"]:::subworkflow
    end
    
    subgraph "CI/CD & Containerization"
        CICD["CI/CD (GitHub Workflows)"]:::external
        Containers["Containerization (tower.yml, .devcontainer)"]:::external
    end

    %% Data Flow
    Samplesheet --> Orchestrator
    Reference --> Orchestrator
    Config --> Orchestrator
    Orchestrator --> QC
    QC --> Trimming
    Trimming --> Bowtie2
    Trimming --> BWA
    Bowtie2 --> Dup
    BWA --> Dup
    Dup --> Stats
    Stats --> Tracks
    Tracks --> Reporting
    Orchestrator --> SubWF
    SubWF --> QC
    SubWF --> Trimming
    CICD --- Orchestrator
    Containers --- Orchestrator
    Containers --- SubWF

    %% Click Events
    click Orchestrator "https://github.com/nf-core/sammyseq/blob/dev/main.nf"
    click Config "https://github.com/nf-core/sammyseq/blob/dev/nextflow.config"
    click Config "https://github.com/nf-core/sammyseq/tree/dev/conf/"
    click Samplesheet "https://github.com/nf-core/sammyseq/blob/dev/assets/samplesheet.csv"
    click QC "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/fastqc/main.nf"
    click Trimming "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/trimgalore/main.nf"
    click Trimming "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/trimmomatic/main.nf"
    click Bowtie2 "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/bowtie2/align/main.nf"
    click BWA "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/bwa/aln/main.nf"
    click BWA "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/bwa/index/main.nf"
    click BWA "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/bwa/mem/main.nf"
    click Dup "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/picard/markduplicates/main.nf"
    click Stats "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/samtools/faidx/main.nf"
    click Stats "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/samtools/flagstat/main.nf"
    click Stats "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/samtools/idxstats/main.nf"
    click Stats "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/samtools/sort/main.nf"
    click Stats "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/samtools/stats/main.nf"
    click Stats "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/samtools/view/main.nf"
    click Tracks "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/deeptools/bamcoverage/main.nf"
    click Tracks "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/deeptools/computematrix/main.nf"
    click Reporting "https://github.com/nf-core/sammyseq/blob/dev/modules/nf-core/multiqc/main.nf"
    click SubWF "https://github.com/nf-core/sammyseq/tree/dev/subworkflows/local/"
    click SubWF "https://github.com/nf-core/sammyseq/tree/dev/subworkflows/nf-core/"
    click CICD "https://github.com/nf-core/sammyseq/tree/dev/.github/workflows/"
    click Containers "https://github.com/nf-core/sammyseq/blob/dev/tower.yml"
    click Containers "https://github.com/nf-core/sammyseq/tree/dev/.devcontainer/"

    %% Styles
    classDef orchestrator fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef input fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef module fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef subworkflow fill:#ffb6c1,stroke:#333,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
