# cgps-discovery/ghru-assembly architecture

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

- Interactive diagram: https://gitdiagram.com/cgps-discovery/ghru-assembly
- Repository: https://github.com/cgps-discovery/ghru-assembly

## Overview

##### Main System Components

a) Input Layer:
- Samplesheet.csv as the primary input source
- Three possible input types (short reads, long reads, or both)
- Optional inputs (adapter file, medaka model)

b) Pipeline Control Layer:
- Main.nf as the central orchestrator
- Nextflow.config and base.config as configuration components
- Workflow selection logic (sr_assembly.nf, lr_assembly.nf, hybrid_assembly.nf)

c) Processing Modules Layer:
Modules into functional groups:
- Preprocessing modules (short_reads_preprocess.nf, long_reads_preprocess.nf)
- Assembly modules (short_read_assembly.nf, long_read_assembly.nf, hybrid_assemblers.nf)
- Quality Control modules (quast.nf, contamination.nf, assembly_depth.nf)
- Analysis modules (speciation.nf, qualifyr.nf)

d) Container Layer:
- Docker containers (speciator, kmc, bash_container)

##### Flow Representation

Three main workflow paths:
##### Short Reads Path
- Input → short_reads_preprocess → Shovill assembly → QC
##### Long Reads Path
- Input → long_reads_preprocess → Dragonflye assembly → QC
##### Hybrid Path
- Input → both preprocessors → Unicycler assembly → QC

##### Additional Details

Elements in separate panels or callouts:
- Resource requirements (10 cores, 16GB RAM, 50GB storage)
- Supported platforms (Linux/WSL)
- Pipeline version information
- Key configuration parameters

##### Notes for Implementation

- Keep the main flow clear and centered
- Use consistent spacing and alignment
- Version numbers for key components
- Error handling paths
- Parallel processing capabilities
- Optional components clearly

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        SI["samplesheet.csv"]:::input
        AF["adapters.fas"]:::input
        SV["validate_samplesheet.py"]:::script
    end

    subgraph Pipeline
        MN["main.nf"]:::main
        BC["base.config"]:::config
        NC["nextflow.config"]:::config
    end

    subgraph "Workflow Selection"
        SR["sr_assembly.nf"]:::workflow
        LR["lr_assembly.nf"]:::workflow
        HY["hybrid_assembly.nf"]:::workflow
    end

    subgraph "Preprocessing Modules"
        SRP["short_reads_preprocess.nf"]:::module
        LRP["long_reads_preprocess.nf"]:::module
    end

    subgraph "Assembly Modules"
        SRA["short_read_assembly.nf"]:::module
        LRA["long_read_assembly.nf"]:::module
        HA["hybrid_assemblers.nf"]:::module
    end

    subgraph "Quality Control"
        QU["quast.nf"]:::qc
        CO["contamination.nf"]:::qc
        AD["assembly_depth.nf"]:::qc
        QR["qualifyr.nf"]:::qc
        SP["speciation.nf"]:::qc
    end

    subgraph "Containers"
        direction TB
        SC[("speciator")]:::container
        KC[("kmc")]:::container
        BC2[("bash_container")]:::container
    end

    subgraph "Supporting Components"
        GD[("GUNC DB")]:::database
        GS1["get_genome_size.sh"]:::script
        GS2["get_genome_size_long.sh"]:::script
    end

    %% Input Layer Connections
    SI --> SV
    SV --> MN
    AF --> SRP
    AF --> LRP

    %% Pipeline Control
    MN --> SR & LR & HY
    BC --> MN
    NC --> MN

    %% Workflow Paths
    SR --> SRP --> SRA
    LR --> LRP --> LRA
    HY --> SRP & LRP --> HA

    %% Quality Control Flow
    SRA & LRA & HA --> QU
    SRA & LRA & HA --> CO
    SRA & LRA & HA --> AD
    QU & CO & AD --> QR
    CO --> SP

    %% Container Usage
    SC -.-> SP
    KC -.-> SRP
    BC2 -.-> GS1
    BC2 -.-> GS2

    %% Supporting Components
    GD -.-> CO

    %% Click Events
    click SI "https://github.com/cgps-discovery/GHRU-assembly/blob/main/samplesheet.csv"
    click AF "https://github.com/cgps-discovery/GHRU-assembly/blob/main/data/adapters.fas"
    click SV "https://github.com/cgps-discovery/GHRU-assembly/blob/main/bin/validate_samplesheet.py"
    click MN "https://github.com/cgps-discovery/GHRU-assembly/blob/main/main.nf"
    click BC "https://github.com/cgps-discovery/GHRU-assembly/blob/main/config/base.config"
    click NC "https://github.com/cgps-discovery/GHRU-assembly/blob/main/nextflow.config"
    click SR "https://github.com/cgps-discovery/GHRU-assembly/blob/main/workflows/sr_assembly.nf"
    click LR "https://github.com/cgps-discovery/GHRU-assembly/blob/main/workflows/lr_assembly.nf"
    click HY "https://github.com/cgps-discovery/GHRU-assembly/blob/main/workflows/hybrid_assembly.nf"
    click SRP "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/short_reads_preprocess.nf"
    click LRP "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/long_reads_preprocess.nf"
    click SRA "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/short_read_assembly.nf"
    click LRA "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/long_read_assembly.nf"
    click HA "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/hybrid_assemblers.nf"
    click QU "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/quast.nf"
    click CO "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/contamination.nf"
    click AD "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/assembly_depth.nf"
    click QR "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/qualifyr.nf"
    click SP "https://github.com/cgps-discovery/GHRU-assembly/blob/main/modules/speciation.nf"
    click SC "https://github.com/cgps-discovery/GHRU-assembly/tree/main/Docker/speciator/Dockerfile"
    click KC "https://github.com/cgps-discovery/GHRU-assembly/tree/main/Docker/kmc/Dockerfile"
    click BC2 "https://github.com/cgps-discovery/GHRU-assembly/tree/main/Docker/bash_container/Dockerfile"
    click GD "https://github.com/cgps-discovery/GHRU-assembly/tree/main/db/guncDB/gunc_db_folder"
    click GS1 "https://github.com/cgps-discovery/GHRU-assembly/blob/main/bin/get_genome_size.sh"
    click GS2 "https://github.com/cgps-discovery/GHRU-assembly/blob/main/bin/get_genome_size_long.sh"

    %% Styling
    classDef input fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef main fill:#ff9999,stroke:#333,stroke-width:2px
    classDef config fill:#ffe599,stroke:#333,stroke-width:2px
    classDef workflow fill:#b399ff,stroke:#333,stroke-width:2px
    classDef module fill:#99ff99,stroke:#333,stroke-width:2px
    classDef qc fill:#ff99e6,stroke:#333,stroke-width:2px
    classDef container fill:#cccccc,stroke:#333,stroke-width:2px
    classDef database fill:#ffb366,stroke:#333,stroke-width:2px
    classDef script fill:#99ffff,stroke:#333,stroke-width:2px
```
