# lanadelrea/katmon architecture

> Architecture diagram of the GitHub repository lanadelrea/katmon, 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/lanadelrea/katmon
- Repository: https://github.com/lanadelrea/katmon

## Overview

##### High-Level Components

a) Infrastructure Layer
- Nextflow Runtime Environment
- Container Management (Docker/Conda)
- File System Interface

b) Pipeline Components (organize in workflow order)
- Input Processing
- Variant Analysis Modules
- Output Generation
- Resource Management

##### Detailed Component Breakdown

a) Input Processing
- Input Directory Handler (fastq, fasta, bam files)
- File Validation System

b) Core Analysis Modules (arrange in sequential order):
##### Report Generation Module

c) Resource Management
- Asset Management (primer schemes, reference genomes)
- Environment Management (conda/docker containers)

##### Specific Elements

- Blue: Input/Output processes
- Green: Analysis modules
- Yellow: Resource management
- Gray: Infrastructure components

Specific technical details:
- Docker/Conda environment specifications
- File format transformations
- Module dependencies

##### Key Architectural Patterns to Highlight

- Pipeline Architecture Pattern
- Modular Design (separate modules directory)
- Container-based Isolation
- Configuration Management (nextflow.config)

##### Technical Details to Note

Annotations for:
- Required software versions
- Resource requirements
- Supported input formats
- Output specifications

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Infrastructure
        NF[Nextflow Runtime]:::infra
        DC[Docker/Conda Environments]:::infra
    end

    subgraph "Input Data"
        FASTQ[FASTQ Files]:::input
        FASTA[FASTA Files]:::input
        BAM[BAM Files]:::input
        BAI[BAM Index Files]:::input
    end

    subgraph "Reference Data"
        PS["Primer Schemes"]:::ref
        CD["Custom Databases"]:::ref
        SR["SARS-CoV-2 Reference"]:::ref
        MD["Mutation Database"]:::ref
    end

    subgraph "Pipeline Modules"
        LA["Lineage Assignment"]:::module
        BA["Bammix Analysis"]:::module
        VS["VirStrain Analysis"]:::module
        FA["Freyja Analysis"]:::module
        PL["Plotting"]:::module
        AS["Amplicon Sorting"]:::module
        RG["Report Generation"]:::module
    end

    subgraph "Environment Management"
        BE["Bammix Environment"]:::env
        FE["Freyja Environment"]:::env
        PE["Pangolin Environment"]:::env
        VE["VirStrain Environment"]:::env
    end

    subgraph "Output Results"
        AR["Analysis Results"]:::output
        VP["Visualization Plots"]:::output
        HR["HTML Reports"]:::output
    end

    %% Data Flow
    FASTQ & FASTA & BAM & BAI --> NF
    NF --> LA
    LA --> BA
    BA --> VS
    VS --> FA
    FA --> PL
    PL --> AS
    AS --> RG

    %% Reference Data Usage
    PS -.-> LA & BA & VS & FA
    CD -.-> VS & FA
    SR -.-> LA & BA & VS & FA
    MD -.-> FA & PL

    %% Environment Connections
    BE -.-> BA
    FE -.-> FA
    PE -.-> LA
    VE -.-> VS

    %% Output Generation
    RG --> AR & VP & HR

    %% Click Events
    click NF "https://github.com/lanadelrea/Katmon/blob/main/main.nf"
    click LA "https://github.com/lanadelrea/Katmon/blob/main/modules/01-lineageAssignment.nf"
    click BA "https://github.com/lanadelrea/Katmon/blob/main/modules/02-bammix.nf"
    click VS "https://github.com/lanadelrea/Katmon/blob/main/modules/03-virstrain.nf"
    click FA "https://github.com/lanadelrea/Katmon/blob/main/modules/04-freyja.nf"
    click PL "https://github.com/lanadelrea/Katmon/blob/main/modules/05-plots.nf"
    click AS "https://github.com/lanadelrea/Katmon/blob/main/modules/06-ampliconSorting.nf"
    click RG "https://github.com/lanadelrea/Katmon/blob/main/modules/07-report.nf"
    click BE "https://github.com/lanadelrea/Katmon/blob/main/envs/bammix.yml"
    click FE "https://github.com/lanadelrea/Katmon/blob/main/envs/freyja.yml"
    click PE "https://github.com/lanadelrea/Katmon/blob/main/envs/pangolin.yml"
    click VE "https://github.com/lanadelrea/Katmon/blob/main/envs/virstrain.yml"
    click PS "https://github.com/lanadelrea/Katmon/tree/main/assets/primer-schemes"
    click CD "https://github.com/lanadelrea/Katmon/tree/main/assets/Custom_DB"
    click SR "https://github.com/lanadelrea/Katmon/tree/main/assets/sars-cov-2"
    click MD "https://github.com/lanadelrea/Katmon/blob/main/assets/mutations.tsv"

    %% Styling
    classDef input fill:#AEC6CF,stroke:#333,stroke-width:2px
    classDef output fill:#77DD77,stroke:#333,stroke-width:2px
    classDef module fill:#FFB347,stroke:#333,stroke-width:2px
    classDef ref fill:#FFD700,stroke:#333,stroke-width:2px
    classDef infra fill:#C0C0C0,stroke:#333,stroke-width:2px
    classDef env fill:#DDA0DD,stroke:#333,stroke-width:2px
```
