# miglesur/pactyper architecture

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

- Interactive diagram: https://gitdiagram.com/miglesur/pactyper
- Repository: https://github.com/miglesur/pactyper

## Overview

##### Main Components

a) Input Layer:
- Fastq Files Directory
- Core Genome FASTA File
- Configuration (config.yaml)

b) Processing Pipeline Components:
- Read Alignment Module (BWA mem)
- Variant Calling Module (Freebayes)
- SNP Processing Module (vcftools, snp-sites)
- Clone Type Prediction Module
- Matrix Management Module

c) Output Layer:
- Alignment Statistics
- Aligned FASTA
- VCF Files
- Clone Type Predictions
- SNP Distance Matrix

##### Key Flows

- Data flow from input fastq through alignment
- Decision points for clone type assignment
- Matrix update process
- Output generation paths

##### Technical Details

A technical stack sidebar showing:
- Required software dependencies
- Version requirements
- Programming languages (Snakemake/Python)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        style Legend fill:#f5f5f5,stroke:#333
        L1[Input Files]:::input
        L2[Processing Module]:::process
        L3[Decision Point]:::decision
        L4[Output Files]:::output
        L5[Documentation]:::docs
    end

    subgraph Input
        FastqDir[Fastq Files Directory]:::input
        CoreGenome[Core Genome FASTA]:::input
        Config[config.yaml]:::input
        Doc[README]:::docs
        click Doc "https://github.com/MigleSur/Pactyper/blob/master/README.md"
    end

    subgraph Pipeline
        BWA[BWA mem Alignment]:::process
        VarCall[Freebayes Variant Calling]:::process
        SNPProc[SNP Processing]:::process
        ClonePred[Clone Type Prediction]:::process
        MatrixMgmt[Matrix Management]:::process
        
        MainFlow[Main Workflow]:::process
        AltFlow[Alternative Workflow]:::process
        
        click MainFlow "https://github.com/MigleSur/Pactyper/tree/master/Snakefile"
        click AltFlow "https://github.com/MigleSur/Pactyper/tree/master/Snakefile_non_computerome"
    end

    subgraph Decision
        IsFirst{First Sample?}:::decision
        SNPThreshold{SNP Distance Check}:::decision
    end

    subgraph Output
        AlignStats[Alignment Statistics]:::output
        AlignedFasta[Aligned FASTA]:::output
        VCFFiles[VCF Files]:::output
        CloneTypes[Clone Type Predictions]:::output
        SNPMatrix[SNP Distance Matrix]:::output
    end

    %% Connections
    FastqDir --> BWA
    CoreGenome --> BWA
    Config --> BWA
    
    BWA --> VarCall
    VarCall --> SNPProc
    SNPProc --> IsFirst
    
    IsFirst -->|Yes| ClonePred
    IsFirst -->|No| SNPThreshold
    
    SNPThreshold -->|Within Threshold| ClonePred
    SNPThreshold -->|Outside Threshold| MatrixMgmt
    
    ClonePred --> MatrixMgmt
    
    BWA --> AlignStats
    BWA --> AlignedFasta
    VarCall --> VCFFiles
    ClonePred --> CloneTypes
    MatrixMgmt --> SNPMatrix

    classDef input fill:#a8d1ff,stroke:#333
    classDef process fill:#90EE90,stroke:#333
    classDef decision fill:#FFE5B4,stroke:#333
    classDef output fill:#FFA07A,stroke:#333
    classDef docs fill:#E6E6FA,stroke:#333
```
