# juancgvazquez/modapy architecture

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

- Interactive diagram: https://gitdiagram.com/juancgvazquez/modapy
- Repository: https://github.com/juancgvazquez/modapy

## Overview

##### Project Type and Purpose
- MODA (Multi-Omics Data Analysis) is a precision medicine analytical platform that combines Python-based pipelines (MODApy) and an R/Shiny web interface (MODApy-Shiny.R) to process Whole Exome Sequencing (WES) data.
- The platform supports SNP detection, SNP database generation, comparative analysis (single cases, duos, trios), and is extendable toward RNAseq gene fusion detection and other genomic analyses.
- It is designed to run locally or remotely (via Docker) and integrates both command-line and web-based interactions.

##### File Structure
- Key directories and files indicate a clear separation of concerns:
- The MODApy directory holds the main Python modules (e.g., vcfanalysis.py, vcfmgr.py, pipeline.py, downloader.py, variantsdb.py) that implement the core business logic.
- The MODApy-Shiny.R file suggests that an R/Shiny-based frontend is used to provide a web interface.
- Configuration files (config.ini, cfg.py) and initialization scripts hint at how the system is set up and customized.
- The docker directory contains a Dockerfile, configuration, requirements, and a startup script, indicating containerized deployment support.
- The tests and docs directories provide structure for quality assurance and documentation, respectively.

##### Technical Stack and Architectural Patterns
- Backend (Business Logic): Built in Python (MODApy) with modular components handling:
- Data ingestion (downloader.py)
- Data analysis/pipeline processing (pipeline.py, vcfanalysis.py)
- Variant database management (variantsdb.py, parquetvardb.py)
- Utility functions (utils.py, coverage.py, etc.)
- Frontend (Presentation Layer): The Shiny web interface embedded in MODApy-Shiny.R allows users to interact with the system through RStudio Server.
- Deployment & Infrastructure: Docker support enables running the platform in a containerized environment for both local and remote setups.
- External Services: The platform fetches raw sequencing data (e.g., via URLs from sequencing providers) and links to external resources (GeneCards, Varsome, Clinvar, etc.) for detailed annotations.

- Main Components to Include:
- Frontend (Web Interface): Represent with a “Shiny Web Interface” component.
- Configuration & Initialization: Highlight config.ini, cfg.py, and command-line interface (cmd_line.py) as entry points for configuration and execution.
- Data Storage: Although the file structure doesn’t include a dedicated “database” folder, mention the local patient data management and SNP database-generation functionalities as part of the backend.
- Docker & Deployment Environment: Include a “Containerization (Docker)” component that encloses the entire system, showing how the project is deployed.

- Relationship and Data Flow:
- Data output from the analysis modules flowing into the “Variant Database” (or SNP population database) and subsequently out to the frontend for user review.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Docker Container (Deployment)"
        subgraph "Backend"
            subgraph "Configuration & Initialization"
                config_ini["config.ini"]:::config
                cfg_py["cfg.py"]:::config
                cmd_line["cmd_line.py"]:::config
            end
            subgraph "Python Analysis Modules"
                downloader["Data Ingestion (Downloader)"]:::backend
                subgraph "Analysis Pipeline"
                    pipeline["Pipeline Module"]:::backend
                    vcf_analysis["VCF Analysis Module"]:::backend
                    vcf_manager["VCF Manager Module"]:::backend
                end
                subgraph "Data Management"
                    variant_db["Variant Database Manager"]:::backend
                    parquet_db["Parquet Variant DB"]:::backend
                end
            end
        end
        frontend["Shiny Web Interface (R)"]:::frontend
        subgraph "Docker Deployment Files"
            dockerfile["Dockerfile"]:::docker
            start_sh["start.sh"]:::docker
            docker_config["config.ini"]:::docker
        end
    end

    external["External Data Sources"]:::external
    docs["Documentation"]:::test
    tests["Testing"]:::test

    external -->|"data"| downloader
    config_ini -->|"sets"| pipeline
    cfg_py -->|"sets"| pipeline
    cmd_line -->|"triggers"| pipeline
    downloader -->|"feeds"| pipeline
    pipeline -->|"analyzes"| vcf_analysis
    pipeline -->|"analyzes"| vcf_manager
    vcf_analysis -->|"sends"| variant_db
    vcf_manager -->|"sends"| variant_db
    variant_db -->|"updates"| parquet_db
    variant_db -->|"serves"| frontend
    parquet_db -->|"serves"| frontend
    frontend -->|"requests"| pipeline
    docs -.->|"refers"| dockerfile
    tests -.->|"validates"| dockerfile

    click frontend "https://github.com/juancgvazquez/modapy/blob/master/MODApy/MODApy-Shiny.R"
    click pipeline "https://github.com/juancgvazquez/modapy/blob/master/MODApy/pipeline.py"
    click vcf_analysis "https://github.com/juancgvazquez/modapy/blob/master/MODApy/vcfanalysis.py"
    click vcf_manager "https://github.com/juancgvazquez/modapy/blob/master/MODApy/vcfmgr.py"
    click downloader "https://github.com/juancgvazquez/modapy/blob/master/MODApy/downloader.py"
    click variant_db "https://github.com/juancgvazquez/modapy/blob/master/MODApy/variantsdb.py"
    click parquet_db "https://github.com/juancgvazquez/modapy/blob/master/MODApy/parquetvardb.py"
    click config_ini "https://github.com/juancgvazquez/modapy/blob/master/MODApy/config.ini"
    click cfg_py "https://github.com/juancgvazquez/modapy/blob/master/MODApy/cfg.py"
    click cmd_line "https://github.com/juancgvazquez/modapy/blob/master/MODApy/cmd_line.py"
    click dockerfile "https://github.com/juancgvazquez/modapy/tree/master/docker/Dockerfile"
    click start_sh "https://github.com/juancgvazquez/modapy/blob/master/docker/start.sh"
    click docker_config "https://github.com/juancgvazquez/modapy/blob/master/docker/config.ini"
    click docs "https://github.com/juancgvazquez/modapy/tree/master/docs/"
    click tests "https://github.com/juancgvazquez/modapy/tree/master/tests/"

    classDef frontend fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef backend fill:#a3d2ff,stroke:#333,stroke-width:2px;
    classDef config fill:#ffd1a4,stroke:#333,stroke-width:2px;
    classDef docker fill:#c2f0c2,stroke:#333,stroke-width:2px;
    classDef external fill:#f2a2e8,stroke:#333,stroke-width:2px;
    classDef test fill:#f9d6a5,stroke:#333,stroke-width:2px;
```
