# rivm-bioinformatics/viroconstrictor architecture

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

## Overview

##### Main Components

a. Input Processing Layer:
- FastQ Data Input Handler (supports Nanopore, Illumina, IONTorrent)
- Sample Sheet Parser (samplesheet.py)
- Configuration Manager (runconfigs.py)

b. Core Processing Pipeline:
- Quality Control Module
- Data Cleanup Module
- Primer Sequence Removal Module
- Reference Matching System (match_ref.py)
- Alignment Engine
- TrueConsense Consensus Caller

c. Workflow Management:
- Snakemake Workflow Engine (indicated by .smk files)
- Environment Management (workflow/envs/*.yaml)
- Directory Handler (workflow/directories.py)

d. Analysis Modules:
- Amplicon Coverage Analysis
- ORF Analysis
- Variant Calling (vcf_to_tsv.py)

##### Component Relationships

**Input Data → Sample Processing → Analysis → Output**

- ► Quality Control
- ► FastQC

- ► Reference Matching
- ► Read Mapping
- ► Reference Selection

- ► Processing Pipeline
- ► Primer Removal
- ► Alignment
- ► Consensus Generation

- ► Analysis Modules
- ► Amplicon Coverage
- ► ORF Analysis
- ► Variant Calling

##### Technical Details

a. File Format Handlers:
- FastQ input
- BED format for amplicon definitions
- GFF format for annotations
- VCF format for variants

b. Key Processing Steps:
- Data flow through quality control
- Primer removal process
- Consensus generation workflow

##### Implementation Notes

- Version control and configuration management indicators

##### Specific Elements

a. Input Section:
**[Raw FastQ Data] → [Sample Sheet Parser] → [Config Manager]**
- ↓
**[Platform Detection]**
- ↓
**[Quality Control]**

b. Core Processing:
**[Reference Matching] → [Alignment] → [Primer Removal]**
- ↓
**[Consensus Generation] → [Variant Calling]**

c. Output Section:
**[Consensus Sequences]**
**[Quality Reports]**
**[Coverage Analysis]**
**[Variant Reports]**

##### Additional Recommendations

- Version information and dependency requirements
- Integration points with external tools
- Error handling and logging paths
- Parallel processing capabilities

Remember to indicate that this is a Snakemake-based workflow, which affects how the components interact and how the pipeline handles parallel processing and dependency resolution.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        FastQ[FastQ Data Input]
        SampleSheet[Sample Sheet Parser]:::file
        Config[Configuration Manager]:::file
    end

    subgraph "Quality Control"
        QC[Quality Control Module]:::file
        FastQC[FastQC Analysis]:::file
        DataClean[Data Cleanup]:::file
    end

    subgraph "Reference Processing"
        RefMatch[Reference Matching System]:::file
        ReadMap[Read Mapping]
        RefSelect[Reference Selection]
    end

    subgraph "Core Pipeline"
        PrimerRem[Primer Sequence Removal]:::file
        Align[Alignment Engine]:::file
        ConsCall[TrueConsense Caller]:::file
    end

    subgraph "Analysis"
        AmpCov[Amplicon Coverage Analysis]:::file
        ORF[ORF Analysis]:::file
        VarCall[Variant Calling]:::file
    end

    subgraph "Workflow Management"
        Snake[Snakemake Workflow]:::file
        EnvMgmt[Environment Management]:::dir
        DirHandler[Directory Handler]:::file
    end

    %% Connections
    FastQ --> SampleSheet
    SampleSheet --> Config
    Config --> QC
    
    QC --> FastQC
    QC --> DataClean
    
    DataClean --> RefMatch
    RefMatch --> ReadMap
    RefMatch --> RefSelect
    
    ReadMap --> PrimerRem
    RefSelect --> PrimerRem
    
    PrimerRem --> Align
    Align --> ConsCall
    
    ConsCall --> AmpCov
    ConsCall --> ORF
    ConsCall --> VarCall
    
    Snake --> QC
    Snake --> RefMatch
    Snake --> PrimerRem
    Snake --> ConsCall
    
    EnvMgmt --> Snake
    DirHandler --> Snake

    %% Click Events
    click SampleSheet "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/samplesheet.py"
    click Config "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/runconfigs.py"
    click RefMatch "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/match_ref.py"
    click DirHandler "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/directories.py"
    click Snake "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/workflow.smk"
    click Align "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/envs/Alignment.yaml"
    click DataClean "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/envs/Clean.yaml"
    click ConsCall "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/envs/Consensus.yaml"
    click ORF "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/envs/ORF_analysis.yaml"
    click AmpCov "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/scripts/amplicon_covs.py"
    click VarCall "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/scripts/vcf_to_tsv.py"
    click QC "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/scripts/fastqc_wrapper.sh"
    click PrimerRem "https://github.com/RIVM-bioinformatics/ViroConstrictor/blob/main/ViroConstrictor/workflow/scripts/clipper.py"
    click EnvMgmt "https://github.com/RIVM-bioinformatics/ViroConstrictor/tree/main/ViroConstrictor/workflow/envs/"

    %% Styling
    classDef file fill:#f9f,stroke:#333,stroke-width:2px
    classDef dir fill:#ff9,stroke:#333,stroke-width:2px
    
    %% Legend
    subgraph Legend
        L1[File Component]:::file
        L2[Directory Component]:::dir
        L3[Regular Component]
    end
```
