# nrminor/oneroof architecture

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

- Interactive diagram: https://gitdiagram.com/nrminor/oneroof
- Repository: https://github.com/nrminor/oneroof

## Overview

##### Main Components

a. Input Sources Layer:
- POD5 Files (Nanopore)
- FASTQ Files (Illumina)
- BAM Files
- Reference Files (FASTA/Genbank)
- Primer BED Files

b. Data Processing Layers:
##### Data Acquisition Layer
- File Watcher Module (for remote monitoring)
- Local Input Processing

##### Primary Processing Layer
- Basecalling Pipeline (Dorado for Nanopore)
- Demultiplexing
- Quality Control (FastQC)

##### Read Processing Layer
- Primer Handling
- Read Filtering
- Amplicon Selection

##### Analysis Layer
- Alignment
- Variant Calling
- Consensus Generation

##### Post-processing Layer
- Quality Assessment (MultiQC)
- Phylogenetic Analysis (Nextclade)
- Reporting

##### Component Relationships

- Feedback loops where applicable (especially for quality control)

##### Technical Details

a. Key Technologies:
- Nextflow DSL2
- Docker/Singularity containers
- GPU acceleration points
- File monitoring system

b. Subworkflows:
- Modular structure reflected in the subworkflows directory
- Relationships between modules

##### Important Notes

- GPU-accelerated components
- Error handling paths
- Points where the pipeline can be resumed
- Resource allocation boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    %% Input Layer
    subgraph Input
        POD5[POD5 Files]
        FASTQ[FASTQ Files]
        BAM[BAM Files]
        REF[Reference Files]
        PBED[Primer BED Files]
    end

    %% Data Acquisition Layer
    subgraph DataAcquisition
        FW["File Watcher"]:::watcher
        LP["Local Processing"]
    end
    click FW "https://github.com/nrminor/oneroof/blob/main/bin/file_watcher.py"

    %% Primary Processing Layer
    subgraph PrimaryProcessing
        BC["Basecalling (Dorado)"]:::gpu
        DM["Demultiplexing"]
        QC["FastQC"]:::qc
    end
    click BC "https://github.com/nrminor/oneroof/blob/main/modules/dorado.nf"
    click QC "https://github.com/nrminor/oneroof/blob/main/modules/fastqc.nf"

    %% Read Processing Layer
    subgraph ReadProcessing
        PH["Primer Handling"]:::processing
        RF["Read Filtering"]:::processing
        AS["Amplicon Selection"]:::processing
        PT["Primer Tools"]:::processing
        PV["Primer Validation"]:::processing
    end
    click PH "https://github.com/nrminor/oneroof/blob/main/subworkflows/primer_handling.nf"
    click PT "https://github.com/nrminor/oneroof/blob/main/bin/make_primer_patterns.py"
    click PV "https://github.com/nrminor/oneroof/blob/main/modules/validate.nf"

    %% Analysis Layer
    subgraph Analysis
        AL["Alignment"]:::analysis
        VC["Variant Calling"]:::analysis
        CG["Consensus Generation"]:::analysis
        MM["Minimap2"]:::analysis
        BCF["BCFTools"]:::analysis
        MD["MosDepth"]:::analysis
    end
    click AL "https://github.com/nrminor/oneroof/blob/main/subworkflows/alignment.nf"
    click VC "https://github.com/nrminor/oneroof/blob/main/subworkflows/variant_calling.nf"
    click CG "https://github.com/nrminor/oneroof/blob/main/subworkflows/consensus_calling.nf"
    click MM "https://github.com/nrminor/oneroof/blob/main/modules/minimap2.nf"
    click BCF "https://github.com/nrminor/oneroof/blob/main/modules/bcftools.nf"
    click MD "https://github.com/nrminor/oneroof/blob/main/modules/mosdepth.nf"

    %% Post-processing Layer
    subgraph PostProcessing
        MQC["MultiQC"]:::qc
        NC["Nextclade"]:::analysis
        PA["Phylogenetic Analysis"]:::analysis
        RP["Reporting"]:::output
        CA["Coverage Analysis"]:::analysis
    end
    click MQC "https://github.com/nrminor/oneroof/blob/main/modules/multiqc.nf"
    click NC "https://github.com/nrminor/oneroof/blob/main/modules/nextclade.nf"
    click PA "https://github.com/nrminor/oneroof/blob/main/subworkflows/phylo.nf"
    click RP "https://github.com/nrminor/oneroof/blob/main/modules/reporting.nf"
    click CA "https://github.com/nrminor/oneroof/blob/main/bin/plot_coverage.py"

    %% Platform-specific Workflows
    subgraph Workflows
        IP["Illumina Pipeline"]:::workflow
        NP["Nanopore Pipeline"]:::workflow
    end
    click IP "https://github.com/nrminor/oneroof/blob/main/workflows/illumina.nf"
    click NP "https://github.com/nrminor/oneroof/blob/main/workflows/nanopore.nf"

    %% Configuration
    subgraph Config
        MC["Main Config"]:::config
        IC["Illumina Config"]:::config
        NC2["Nanopore Config"]:::config
        SE["SNP Effect Config"]:::config
    end
    click MC "https://github.com/nrminor/oneroof/blob/main/nextflow.config"
    click IC "https://github.com/nrminor/oneroof/blob/main/conf/illumina.config"
    click NC2 "https://github.com/nrminor/oneroof/blob/main/conf/nanopore.config"
    click SE "https://github.com/nrminor/oneroof/blob/main/conf/snpeff.config"

    %% Relationships
    POD5 & FASTQ & BAM & REF & PBED --> FW
    FW --> LP
    LP --> BC
    BC --> DM
    DM --> QC
    QC --> PH
    PH --> RF
    RF --> AS
    PT --> PH
    PH --> PV
    AS --> AL
    AL --> VC
    VC --> CG
    AL --> MM
    VC --> BCF
    AL --> MD
    CG & BCF & MD --> MQC
    MQC --> NC
    NC --> PA
    PA --> RP
    MD --> CA
    CA --> RP

    %% Styles
    classDef watcher fill:#A8D0DB
    classDef gpu fill:#FF9999
    classDef processing fill:#90EE90
    classDef analysis fill:#DDA0DD
    classDef qc fill:#FFE5CC
    classDef output fill:#B19CD9
    classDef workflow fill:#87CEEB
    classDef config fill:#D3D3D3

    %% Legend
    subgraph Legend
        L1["File Watcher"]:::watcher
        L2["GPU Accelerated"]:::gpu
        L3["Processing"]:::processing
        L4["Analysis"]:::analysis
        L5["Quality Control"]:::qc
        L6["Output"]:::output
        L7["Workflow"]:::workflow
        L8["Configuration"]:::config
    end
```
