# bede/hostile architecture

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

- Interactive diagram: https://gitdiagram.com/bede/hostile
- Repository: https://github.com/bede/hostile

## Overview

##### Project Type and Core Components
The system is a command-line bioinformatics tool with these main components:

a. Core Processing Pipeline
- Input Handler (FASTQ files/streams)
- Alignment System (Bowtie2/Minimap2)
- Filtering Engine
- Output Handler

b. Index Management System
- Index Downloader
- Cache Manager
- Custom Index Builder (masking functionality)

c. CLI Interface
- Command Parser
- Configuration Manager

##### Key Architectural Elements

a. Data Flow Components:
**Input Sources -> Processing Pipeline -> Output Destinations**
- FASTQ files (single/paired)      - Clean FASTQ files
- stdin streams                    - stdout streams

b. Processing Pipeline:
**Read Input -> Alignment -> Filtering -> Output Generation**

c. Index Management:
**Standard Indexes -----> Index Cache <----- Custom Indexes**
**Remote Repository --/        |**

- Processing Pipeline

##### Implementation Details to Highlight

a. Processing Modes:
- Long read pipeline (Minimap2)
- Short read pipeline (Bowtie2)
- Single/Paired read handling

b. Index Management:
- Standard index downloading
- Custom index creation
- Masking functionality

c. External Dependencies:
- Bowtie2
- Minimap2
- Samtools
- Bedtools

##### The flexibility in input/output handling

This will create a comprehensive yet clear representation of Hostile's architecture that highlights its key features and processing workflow.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Processing Module]
        L2[(Storage)]
        L3[/Input Output/]
        L4{{External Tool}}
        style L1 fill:#b3d9ff
        style L2 fill:#e6e6e6
        style L3 fill:#98FB98
        style L4 fill:#ffd9b3
    end

    subgraph "Input Layer"
        IN1[/FASTQ Files/]:::io
        IN2[/stdin Stream/]:::io
    end

    subgraph "Core Processing Pipeline"
        IH[Input Handler]:::core
        AL[Alignment System]:::core
        FE[Filtering Engine]:::core
        OH[Output Handler]:::core
        
        IH --> AL
        AL --> FE
        FE --> OH
    end

    subgraph "External Tools"
        BT{{Bowtie2}}:::external
        MM{{Minimap2}}:::external
        ST{{Samtools}}:::external
        BD{{Bedtools}}:::external
    end

    subgraph "Index Management"
        ID[Index Downloader]:::index
        CM[Cache Manager]:::index
        CIB[Custom Index Builder]:::index
        IC[(Index Cache)]:::storage
        
        ID --> IC
        CM --> IC
        CIB --> IC
    end

    subgraph "Output Layer"
        OUT1[/Clean FASTQ/]:::io
        OUT2[/stdout Stream/]:::io
    end

    subgraph "Configuration"
        CP[Command Parser]:::config
        CFG[Configuration Manager]:::config
    end

    IN1 --> IH
    IN2 --> IH
    
    AL --> BT
    AL --> MM
    FE --> ST
    FE --> BD
    
    IC -.-> AL
    
    OH --> OUT1
    OH --> OUT2
    
    CP --> IH
    CP --> AL
    CP --> FE
    CFG --> AL
    CFG --> FE

    classDef core fill:#b3d9ff
    classDef storage fill:#e6e6e6
    classDef io fill:#98FB98
    classDef external fill:#ffd9b3
    classDef index fill:#e6b3ff
    classDef config fill:#ffff99

    click AL "https://github.com/bede/hostile/blob/main/src/hostile/aligner.py"
    click FE "https://github.com/bede/hostile/blob/main/src/hostile/lib.py"
    click IH "https://github.com/bede/hostile/blob/main/src/hostile/util.py"
    click CP "https://github.com/bede/hostile/blob/main/src/hostile/cli.py"
    click IC "https://github.com/bede/hostile/tree/main/tests/data/sars-cov-2"
    click CIB "https://github.com/bede/hostile/tree/main/tests/data/mask"
    click IN1 "https://github.com/bede/hostile/tree/main/tests/data"
    click CFG "https://github.com/bede/hostile/blob/main/environment.yml"
```
