# nf-core/rnafusion architecture

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

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

## Overview

##### Main Components

a. Input Layer:
- FastQ files (RNA-seq data)
- Configuration files
- Reference data sources

b. Reference Building Pipeline:
- Ensembl data processing
- STAR index generation
- Tool-specific reference preparation (Arriba, FusionCatcher, STAR-Fusion)
- Fusion-report database setup

c. Main Analysis Pipeline:
- Quality Control Module
- Fusion Detection Module
- Post-processing Module
- Reporting Module

##### Architectural Patterns

- Parallel workflow execution
- Modular design (evident from the modules/ directory structure)
- Data flow between components
- Tool integration points

##### Detailed Component Breakdown

**[Input Layer]**

- [Reference Building Pipeline]──────────────────────┐
- Ensembl Data Processing                     │
- STAR Index Generation                       │
- Tool-specific References                    │
- Database Setup                              │

- [Main Analysis Pipeline]                          │

- [Quality Control]                             │
- FastQC                                  │
- Fastp (optional)                        │

- [Fusion Detection]                            │
- Arriba Workflow                         │
- STAR-Fusion Workflow                    │
- FusionCatcher Workflow                  │

- [Expression Analysis]                         │
- StringTie Workflow                      │

- [Post-processing]                             │
- FusionInspector                        │
- Arriba Visualization                    │
- Metrics Collection                      │

- [Reporting]                                   │
- Fusion-report Integration               │
- MultiQC                                 │
- Final Output Generation                 │

##### Important Relationships to Highlight

- Dependencies between modules
- Data flow between components
- Parallel execution paths
- Input/Output relationships
- Tool integration points

##### Technical Details

- Nextflow DSL2 implementation
- Container support (Docker/Singularity)
- Resource requirements
- External tool dependencies
- File format transformations

## Diagram (Mermaid)

```mermaid
graph TB
    classDef input fill:#ADD8E6,stroke:#333
    classDef reference fill:#90EE90,stroke:#333
    classDef qc fill:#FFFF99,stroke:#333
    classDef analysis fill:#FFA500,stroke:#333
    classDef postproc fill:#DDA0DD,stroke:#333
    classDef report fill:#FFB6C1,stroke:#333
    classDef config fill:#D3D3D3,stroke:#333

    subgraph Input
        I1[FastQ Files]:::input
        I2[Configuration]:::input
        I3[Reference Sources]:::input
    end

    subgraph Reference_Building
        RB["Reference Building Pipeline"]:::reference
        click RB "https://github.com/nf-core/rnafusion/blob/master/workflows/build_references.nf"
        
        E1["Ensembl Processing"]:::reference
        click E1 "https://github.com/nf-core/rnafusion/tree/master/modules/local/ensembl"
        
        H1["HGNC Processing"]:::reference
        click H1 "https://github.com/nf-core/rnafusion/tree/master/modules/local/hgnc"
        
        S1["STAR Index Generation"]:::reference
        click S1 "https://github.com/nf-core/rnafusion/tree/master/modules/nf-core/star/genomegenerate"
        
        DB["Database Setup"]:::reference
    end

    subgraph Main_Analysis
        MA["Main Analysis Pipeline"]:::analysis
        click MA "https://github.com/nf-core/rnafusion/blob/master/workflows/rnafusion.nf"

        subgraph QC
            QC1["Quality Control"]:::qc
            click QC1 "https://github.com/nf-core/rnafusion/blob/master/subworkflows/local/qc_workflow.nf"
            
            FQC["FastQC"]:::qc
            click FQC "https://github.com/nf-core/rnafusion/tree/master/modules/nf-core/fastqc"
            
            FP["Fastp"]:::qc
            click FP "https://github.com/nf-core/rnafusion/tree/master/modules/nf-core/fastp"
        end

        subgraph Fusion_Detection
            FD1["Arriba"]:::analysis
            click FD1 "https://github.com/nf-core/rnafusion/blob/master/subworkflows/local/arriba_workflow.nf"
            
            FD2["STAR-Fusion"]:::analysis
            click FD2 "https://github.com/nf-core/rnafusion/blob/master/subworkflows/local/starfusion_workflow.nf"
            
            FD3["FusionCatcher"]:::analysis
            click FD3 "https://github.com/nf-core/rnafusion/blob/master/subworkflows/local/fusioncatcher_workflow.nf"
        end

        subgraph Expression
            EX["StringTie"]:::analysis
            click EX "https://github.com/nf-core/rnafusion/blob/master/subworkflows/local/stringtie_workflow.nf"
        end

        subgraph Post_Processing
            PP1["FusionInspector"]:::postproc
            click PP1 "https://github.com/nf-core/rnafusion/blob/master/subworkflows/local/fusioninspector_workflow.nf"
            
            PP2["Arriba Visualization"]:::postproc
            click PP2 "https://github.com/nf-core/rnafusion/tree/master/modules/local/arriba/visualisation"
            
            PP3["Metrics Collection"]:::postproc
        end

        subgraph Reporting
            R1["Fusion-report"]:::report
            click R1 "https://github.com/nf-core/rnafusion/blob/master/subworkflows/local/fusionreport_workflow.nf"
            
            R2["MultiQC"]:::report
            click R2 "https://github.com/nf-core/rnafusion/tree/master/modules/nf-core/multiqc"
            
            R3["Final Output"]:::report
            click R3 "https://github.com/nf-core/rnafusion/blob/master/assets/email_template.html"
        end
    end

    subgraph Configuration
        C1["Base Config"]:::config
        click C1 "https://github.com/nf-core/rnafusion/blob/master/conf/base.config"
        
        C2["Modules Config"]:::config
        click C2 "https://github.com/nf-core/rnafusion/blob/master/conf/modules.config"
        
        C3["Pipeline Schema"]:::config
        click C3 "https://github.com/nf-core/rnafusion/blob/master/nextflow_schema.json"
    end

    %% Relationships
    I1 --> MA
    I2 --> MA
    I3 --> RB
    
    RB --> E1
    RB --> H1
    RB --> S1
    RB --> DB
    
    MA --> QC
    QC1 --> FQC
    QC1 --> FP
    
    MA --> Fusion_Detection
    MA --> Expression
    
    Fusion_Detection --> Post_Processing
    Expression --> Post_Processing
    
    Post_Processing --> Reporting
    
    %% Legend
    subgraph Legend
        L1[Input/Output]:::input
        L2[Reference Processing]:::reference
        L3[Quality Control]:::qc
        L4[Analysis]:::analysis
        L5[Post-processing]:::postproc
        L6[Reporting]:::report
        L7[Configuration]:::config
    end
```
