# swittouck/scarap architecture

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

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Input Processing Layer
- FAA/FFN file handlers
- File validation components
- Input parsers

b) Core Processing Modules
- Pangenome inference engine
- Core genome processor
- Sampling module
- Alignment processor

c) External Dependencies
- MAFFT integration
- MMseqs2 integration

d) Output Generation Layer
- Results writers
- File formatters

##### Component Organization

**[Input Layer]**

**[Core Processing Layer]**

**[External Tools Layer]**

**[Output Layer]**

##### Specific Module Relationships

a) Primary Workflows:
- Pan workflow: Input → MMseqs2 → Pangenome Processing → Output
- Core workflow: Input → MMseqs2 → Core Genome Processing → Output
- Sample workflow: Input → Core/Pan Processing → AAI/ANI Calculation → Output

b) Secondary Workflows:
- Concatenation workflow: Input → MAFFT → Alignment Processing → Output
- Check workflows: Input → Validation Processing → Output

##### Detailed Component Breakdown

- callers.py: External tool interface
- checkers.py: Validation components
- computers.py: Computation engines
- modules.py: Main module definitions
- pan.py: Pangenome specific logic
- readerswriters.py: I/O operations

##### Key Design Elements

- Modular architecture (reflected in the file structure)
- Pipeline processing flow
- External tool integration
- Data transformation stages

##### Implementation Details

Technical aspects:
- Python 3.6+ runtime environment
- Dependency on scientific computing libraries (numpy, pandas, etc.)
- File format specifications (FASTA, TSV)
- Parallel processing capabilities (-t parameter)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef input fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px
    classDef external fill:#98FB98,stroke:#333,stroke-width:2px
    classDef output fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef utility fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Input Layer
    subgraph InputLayer["Input Processing Layer"]
        FileHandlers["File Handlers & I/O"]
        Validation["File Validation"]
        InputParsers["Input Parsers"]
    end

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing Layer"]
        PanGenome["Pangenome Inference"]
        CoreGenome["Core Genome Processor"]
        Sampling["Sampling Module"]
        Alignment["Alignment Processor"]
        MainModules["Main Module Definitions"]
        ModuleWrappers["Module Wrappers"]
    end

    %% External Tools Layer
    subgraph ExternalLayer["External Tools Layer"]
        MAFFT["MAFFT Integration"]
        MMseqs2["MMseqs2 Integration"]
        ExternalTools["External Tool Interface"]
    end

    %% Output Layer
    subgraph OutputLayer["Output Layer"]
        ResultsWriter["Results Writer"]
        FileFormatter["File Formatter"]
    end

    %% Utility Components
    subgraph UtilityLayer["Utility Layer"]
        Helpers["Helper Functions"]
        Utils["Utility Functions"]
    end

    %% Relationships
    FileHandlers --> PanGenome
    FileHandlers --> CoreGenome
    Validation --> PanGenome
    Validation --> CoreGenome
    InputParsers --> PanGenome
    InputParsers --> CoreGenome

    PanGenome --> MMseqs2
    CoreGenome --> MMseqs2
    Sampling --> CoreGenome
    Sampling --> PanGenome
    Alignment --> MAFFT

    MMseqs2 --> ResultsWriter
    MAFFT --> ResultsWriter
    PanGenome --> ResultsWriter
    CoreGenome --> ResultsWriter

    Helpers --> CoreLayer
    Utils --> CoreLayer
    ExternalTools --> MAFFT
    ExternalTools --> MMseqs2

    %% Click Events
    click FileHandlers "https://github.com/swittouck/SCARAP/blob/master/src/scarap/readerswriters.py"
    click Validation "https://github.com/swittouck/SCARAP/blob/master/src/scarap/checkers.py"
    click PanGenome "https://github.com/swittouck/SCARAP/blob/master/src/scarap/pan.py"
    click CoreGenome "https://github.com/swittouck/SCARAP/blob/master/src/scarap/computers.py"
    click MainModules "https://github.com/swittouck/SCARAP/blob/master/src/scarap/modules.py"
    click ModuleWrappers "https://github.com/swittouck/SCARAP/blob/master/src/scarap/module_wrappers.py"
    click ExternalTools "https://github.com/swittouck/SCARAP/blob/master/src/scarap/callers.py"
    click Helpers "https://github.com/swittouck/SCARAP/blob/master/src/scarap/helpers.py"
    click Utils "https://github.com/swittouck/SCARAP/blob/master/src/scarap/utils.py"

    %% Legend
    subgraph Legend
        InputComp["Input/Output Components"]:::input
        CoreComp["Core Components"]:::core
        ExtComp["External Tools"]:::external
        UtilComp["Utility Components"]:::utility
    end
```
