# arthurvm/afanc architecture

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

## Overview

##### Main Components and Architecture

a) Core Components (Top Level):
- get_dataset → autodatabase → screen

b) External Dependencies Layer:
- NCBI Tools (Entrez, BLAST+, Datasets)
- Analysis Tools (Mash, Kraken2, Bowtie2)
- Visualization Tools (Krona)

##### Detailed Module Breakdown

For each main module, create a sub-section showing internal components:

a) get_dataset Module:
- Input: Species list/accession IDs
- Process: download_assemblies.py
- Output: Hierarchical directory structure

b) autodatabase Module:
- Components:
- Assembly QC (assemblyQC.py)
- FASTA Processing (prepareNewFasta.py)
- Taxonomy Management (taxadd.py)
- Variant Indexing (makeVariantIndex.py)
- Database Construction Flow

c) screen Module:
- Components:
- Genome Processing (getGenomes.py)
- Mapping (mapHits.py)
- Variant Profiling (variant_profiler/)
- Report Generation (report/)

##### Data Flow Representation

- Input Files → Processing → Output Files
- File formats (FASTA, FASTQ, JSON)
- Database interaction points

##### Key Design Elements

Specific features:
- Input/Output formats at each stage
- External dependency connections
- Database interaction points

##### Technical Details

Annotations for:
- Python version requirement (3.7+)
- Key file formats
- Database structures
- Processing stages

##### Bottom: External dependencies

- File format indicators

- Modular design
- Pipeline workflow
- Data transformation stages
- External tool integration
- Database construction and usage

Remember to highlight the unique features of Afanc:
- Variant-level metagenomic analysis
- Automated database construction
- Integration with multiple bioinformatics tools
- Hierarchical taxonomy handling
- High-resolution screening capabilities

This will provide a clear understanding of both the system's architecture and its functional workflow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Pipeline
        GD[get_dataset]:::getdataset
        AD[autodatabase]:::autodatabase
        SC[screen]:::screen
        GD --> AD --> SC
    end

    subgraph "get_dataset Module"
        Input["Input Files\n(Species/Accession)"]:::input
        DA["download_assemblies"]:::component
        Output["Hierarchical Directory\nStructure"]:::output
        Input --> DA --> Output
    end

    subgraph "autodatabase Module"
        AQC["Assembly QC"]:::component
        FP["FASTA Processing"]:::component
        TM["Taxonomy Management"]:::component
        VI["Variant Indexing"]:::component
        
        AQC --> FP --> TM --> VI
    end

    subgraph "screen Module"
        GP["Genome Processing"]:::component
        MP["Mapping"]:::component
        VP["Variant Profiling"]:::component
        RG["Report Generation"]:::component
        MM["Mapping Metrics"]:::component
        
        GP --> MP --> VP --> RG
        MP --> MM
    end

    subgraph "Utility Components"
        GU["General Utils"]:::utility
        VM["Version Management"]:::utility
        WD["Working Directory"]:::utility
        FM["FASTA Modification"]:::utility
        CE["Command Execution"]:::utility
    end

    subgraph "Core Management"
        CLI["CLI Interface"]:::core
        CP["Command Parser"]:::core
        
        CLI --> CP
    end

    subgraph "External Dependencies"
        NCBI["NCBI Tools\n(Entrez, BLAST+, Datasets)"]:::external
        AT["Analysis Tools\n(Mash, Kraken2, Bowtie2)"]:::external
        VT["Visualization Tools\n(Krona)"]:::external
    end

    %% Component Connections
    GD -.-> DA
    AD -.-> AQC
    SC -.-> GP

    %% Click Events
    click GD "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/get_dataset/download_assemblies.py"
    click DA "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/get_dataset/download_assemblies.py"
    click AQC "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/autodatabase/assemblyQC.py"
    click FP "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/autodatabase/prepareNewFasta.py"
    click TM "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/autodatabase/taxadd.py"
    click VI "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/autodatabase/makeVariantIndex.py"
    click GP "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/screen/getGenomes.py"
    click MP "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/screen/mapHits.py"
    click VP "https://github.com/ArthurVM/Afanc/tree/main/src/Afanc/screen/variant_profiler/"
    click RG "https://github.com/ArthurVM/Afanc/tree/main/src/Afanc/screen/report/"
    click MM "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/screen/maths/mappingMetrics.py"
    click GU "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/utilities/generalUtils.py"
    click VM "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/utilities/getVersions.py"
    click WD "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/utilities/makeWD.py"
    click FM "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/utilities/modifyFasta.py"
    click CE "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/utilities/runCommands.py"
    click CLI "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/cli.py"
    click CP "https://github.com/ArthurVM/Afanc/blob/main/src/Afanc/parser.py"

    classDef getdataset fill:#3498db
    classDef autodatabase fill:#2ecc71
    classDef screen fill:#e67e22
    classDef component fill:#95a5a6
    classDef utility fill:#9b59b6
    classDef core fill:#34495e
    classDef external fill:#e74c3c
    classDef input fill:#f1c40f
    classDef output fill:#1abc9c
```
