# antons-bio/amplicontyper architecture

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

## Overview

##### Main Components

a) Input Processing Layer
- FASTQ files handler
- BAM files handler
- Metadata processor
- Input validation system

b) Core Processing Components
- Model Training Pipeline
- Classification Pipeline
- Read Processing Engine
- Mapping Module (minimap2 integration)

c) Model Management
- Model Storage
- Model Loading/Saving
- Reference Sequence Storage
- SNP Database

d) Reporting System
- HTML Report Generator
- TSV Report Generator
- Visualization Components

##### Specific Component Relationships

**[Input Layer]**

- FASTQ Processing ──────┐
- BAM Processing ────────┤
- Metadata Processing ───┘

- ▼
**[Core Processing Layer]**
- Training Pipeline
- Positive BAM Processing
- Negative BAM Processing

- Classification Pipeline
- Read Mapping (minimap2)
- Length Validation
- Model Application

- ▼
**[Model Management]**
- Model Storage (.pkl files)
- Reference Sequences
- SNP Database

- ▼
**[Output Layer]**
- HTML Report Generation
- TSV Report Generation
- Visualization Components

##### Important Elements to Highlight

- Double lines: Primary processing paths

b) Key Integration Points:
- External tool integration (minimap2)
- Model serialization/deserialization
- Report generation pipeline

##### Technical Details

- File format specifications (FASTQ, BAM, VCF)
- Model versioning system
- Supported reference databases
- Performance optimization points

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef input fill:#a8d1f0,stroke:#333
    classDef process fill:#90EE90,stroke:#333
    classDef model fill:#FFE5B4,stroke:#333
    classDef output fill:#FFA07A,stroke:#333
    classDef external fill:#D3D3D3,stroke:#333

    %% Input Layer
    subgraph InputLayer
        InputProcessor["Input Processor"]
        InputValidator["Input Validator"]
        DataHandler["Data Classes Handler"]
        FASTQ["FASTQ Files"]
        BAM["BAM Files"]
        Meta["Metadata"]
    end

    %% Core Processing Layer
    subgraph CoreProcessing
        TrainPipe["Training Pipeline"]
        ClassifyPipe["Classification Pipeline"]
        ReadEngine["Read Processing Engine"]
        MapModule["Mapping Module"]
        Minimap2["minimap2"]:::external
    end

    %% Model Management Layer
    subgraph ModelManagement
        ModelMgr["Model Manager"]
        ModelStore["Model Storage"]
        RefSeq["Reference Sequences"]
        SNPDb["SNP Database"]
    end

    %% Output Layer
    subgraph OutputLayer
        ReportGen["Report Generator"]
        ReportClass["Reporting Classes"]
        HTMLReport["HTML Reports"]
        TSVReport["TSV Reports"]
        Viz["Visualization"]
    end

    %% Relationships
    FASTQ & BAM & Meta --> InputProcessor
    InputProcessor --> InputValidator
    InputValidator --> DataHandler
    
    DataHandler --> TrainPipe
    DataHandler --> ClassifyPipe
    
    TrainPipe & ClassifyPipe --> ReadEngine
    ReadEngine --> MapModule
    MapModule --> Minimap2
    
    TrainPipe & ClassifyPipe --> ModelMgr
    ModelMgr --> ModelStore
    ModelMgr --> RefSeq
    ModelMgr --> SNPDb
    
    ClassifyPipe --> ReportGen
    ReportGen --> ReportClass
    ReportClass --> HTMLReport
    ReportClass --> TSVReport
    ReportClass --> Viz

    %% Click Events
    click InputProcessor "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/input_processing.py"
    click InputValidator "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/inputs_validation.py"
    click DataHandler "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/data_classes.py"
    click TrainPipe "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/train.py"
    click ClassifyPipe "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/classify.py"
    click ReadEngine "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/read_classifier.py"
    click MapModule "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/map.py"
    click ModelMgr "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/model_manager.py"
    click ModelStore "https://github.com/AntonS-bio/AmpliconTyper/tree/main/models/"
    click ReportGen "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/classifier_report.py"
    click ReportClass "https://github.com/AntonS-bio/AmpliconTyper/blob/main/scripts/reporting_classes.py"

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Processing Components"]:::process
        L3["Model Components"]:::model
        L4["Output Components"]:::output
        L5["External Tools"]:::external
    end

    %% Style Applications
    class InputProcessor,InputValidator,DataHandler,FASTQ,BAM,Meta input
    class TrainPipe,ClassifyPipe,ReadEngine,MapModule process
    class ModelMgr,ModelStore,RefSeq,SNPDb model
    class ReportGen,ReportClass,HTMLReport,TSVReport,Viz output
```
