# clinical-genomics/balsamic architecture

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

## Overview

##### Main Components Identification
The system should be represented with these key components:

a) Core Components:
- Command Line Interface (CLI) Layer
- Workflow Management Layer (Snakemake)
- Container Management (Singularity)
- Analysis Pipeline Components
- Data Models
- Utilities

b) Pipeline Components:
- Alignment Processing
- Variant Calling
- Quality Control
- Annotation
- Reporting

**┌─ User Interface Layer ─────────────────────────────────┐**
- CLI Commands (config, init, report, run)               │
- Workflow Management Layer ────────────────────────────┤
- Snakemake Rules Engine                                │
- Container Management Layer ──────────────────────────┤
- Singularity Containers                               │
- Pipeline Components Layer ───────────────────────────┤
- ┌─────────────┐ ┌──────────┐ ┌────────────┐         │
- Alignment  │ │ Variant  │ │ Quality    │         │
- Processing │ │ Calling  │ │ Control    │         │
- ┘ └──────────┘ └────────────┘         │
- ┌─────────────┐ ┌──────────┐ ┌────────────┐         │
- Annotation  │ │ Report   │ │ UMI        │         │
- Generation│ │ Processing │         │
- ┘ └──────────┘ └────────────┘         │
- Data Layer ────────────────────────────────────────┤
- Models, Constants, Cache                            │
- ┘

##### Key Relationships

- Dependencies between modules
- Input/Output relationships
- Container boundaries
- External system interactions

##### Additional Details
- Version information (v16.0.0)
- Configuration management
- Report generation flow
- Cache and reference data management

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef cli fill:#3498db,stroke:#2980b9,color:white
    classDef workflow fill:#2ecc71,stroke:#27ae60,color:white
    classDef container fill:#9b59b6,stroke:#8e44ad,color:white
    classDef pipeline fill:#1abc9c,stroke:#16a085,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef utils fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interface Layer
    subgraph CLI
        CLI_Main["CLI Interface"]
        Config["Config Commands"]
        Run["Run Commands"]
        Report["Report Commands"]
    end

    %% Workflow Management Layer
    subgraph Workflow
        SnakemakeEngine["Snakemake Rules Engine"]
        CoreWorkflows["Core Workflows"]
    end

    %% Container Management Layer
    subgraph Containers
        ContainerMgmt["Container Management"]
        AlignQC["Alignment/QC Container"]
        VarCall["Variant Calling Container"]
        Annotate["Annotation Container"]
    end

    %% Pipeline Components Layer
    subgraph Pipeline
        Alignment["Alignment Processing"]
        VariantCalling["Variant Calling"]
        QC["Quality Control"]
        Annotation["Annotation"]
        ReportGen["Report Generation"]
        UMI["UMI Processing"]
    end

    %% Data Layer
    subgraph Data
        Models["Data Models"]
        Constants["Constants"]
        Assets["Assets"]
    end

    %% Utilities Layer
    subgraph Utils
        AnalysisUtils["Analysis Utils"]
        CLIUtils["CLI Utils"]
        ReportUtils["Report Utils"]
    end

    %% Relationships
    CLI_Main --> Config
    CLI_Main --> Run
    CLI_Main --> Report
    
    Config --> SnakemakeEngine
    Run --> SnakemakeEngine
    Report --> ReportGen
    
    SnakemakeEngine --> CoreWorkflows
    CoreWorkflows --> ContainerMgmt
    
    ContainerMgmt --> AlignQC
    ContainerMgmt --> VarCall
    ContainerMgmt --> Annotate
    
    AlignQC --> Alignment
    AlignQC --> QC
    VarCall --> VariantCalling
    Annotate --> Annotation
    
    Alignment --> UMI
    UMI --> VariantCalling
    VariantCalling --> Annotation
    Annotation --> ReportGen
    
    Models --> Pipeline
    Constants --> Pipeline
    Assets --> ReportGen
    
    AnalysisUtils --> Pipeline
    CLIUtils --> CLI
    ReportUtils --> ReportGen

    %% Click Events
    click CLI_Main "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/commands/"
    click Config "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/commands/config/"
    click Run "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/commands/run/"
    click Report "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/commands/report/"
    click CoreWorkflows "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/workflows/"
    click SnakemakeEngine "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/snakemake_rules/"
    click ContainerMgmt "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/containers/"
    click AlignQC "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/containers/align_qc/"
    click VarCall "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/containers/varcall_py3/"
    click Annotate "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/containers/annotate/"
    click Alignment "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/snakemake_rules/align/"
    click VariantCalling "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/snakemake_rules/variant_calling/"
    click QC "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/snakemake_rules/quality_control/"
    click Annotation "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/snakemake_rules/annotation/"
    click ReportGen "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/snakemake_rules/report/"
    click UMI "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/snakemake_rules/umi/"
    click Models "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/models/"
    click Constants "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/constants/"
    click Assets "https://github.com/clinical-genomics/BALSAMIC/tree/master/BALSAMIC/assets/"
    click AnalysisUtils "https://github.com/clinical-genomics/BALSAMIC/blob/master/BALSAMIC/utils/analysis.py"
    click CLIUtils "https://github.com/clinical-genomics/BALSAMIC/blob/master/BALSAMIC/utils/cli.py"
    click ReportUtils "https://github.com/clinical-genomics/BALSAMIC/blob/master/BALSAMIC/utils/pdf_report.py"

    %% Class Assignments
    class CLI_Main,Config,Run,Report cli
    class SnakemakeEngine,CoreWorkflows workflow
    class ContainerMgmt,AlignQC,VarCall,Annotate container
    class Alignment,VariantCalling,QC,Annotation,ReportGen,UMI pipeline
    class Models,Constants,Assets data
    class AnalysisUtils,CLIUtils,ReportUtils utils
```
