# amitfenn/dicast architecture

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

- Interactive diagram: https://gitdiagram.com/amitfenn/dicast
- Repository: https://github.com/amitfenn/dicast

## Overview

##### Project Type and Purpose
- DICAST is an open‐source, modular alternative‐splicing analysis framework.
- It integrates 11 splice‐aware mapping tools and 8 event‐detection tools in a unified pipeline, driven by Snakemake and Docker.
- It provides a CLI (Snakemake+Python), a minimal GUI wrapper (Python), an R simulation package (ASimulatoR), and unified‐output scripts in Python and R.

##### File Structure
- Top‐level directories:
- src/            ← source code for each mapping/event tool (Docker containers), R package, conda build
- scripts/        ← wrapper scripts: Snakemake workflows, shell helpers, unified‐output modules
- gui/            ← Python GUI scripts for configuration and launch
- docs/           ← Sphinx docs source & built HTML
- sample_input/   ← example data (FASTQ, BAM, GTF, reference FASTA)
- Key orchestration files:
- scripts/snakemake/Snakefile(.cli)
- scripts/snakemake/*_config.yaml/json
- Dockerfiles & ENTRYPOINT.sh under each src/<tool>
- Unified‐output module:
- scripts/unified_output/… (Python parsers & transformers)
- R package:
- src/ASimulatoR/… (R scripts, data, Dockerfile, renv)

##### Key README Insights
- Emphasis on modular integration of tools via containers.
- Snakemake config drives which tools run and how.
- A “uniform reporting standard” implemented by scripts/unified_output.
- Documentation built with Sphinx and deployed to ReadTheDocs.

##### Main Components
a. Frontend
- CLI layer: Snakemake engine + config files
- GUI layer: gui/dicast.py & dicast_config_setter.py
b. Containerized Tools (Microservices)
- Mapping tools (bbmap, hisat2, STAR, …)
- Event detection tools (MAJIQ, SplAdder, Whippet, …)
c. R Simulation Module
- ASimulatoR R package & its Docker container
d. Unified‐Output
- Python parsers & transformers consolidating per‐tool outputs
- Final consensus report generator
e. Data Stores
- Input: sample_input/ FASTQ, BAM, GTF, FASTA
- Intermediate: Snakemake workdir
- Output: per‐tool directories + unified report
f. Documentation
- Sphinx build process (docs/source → docs/build → ReadTheDocs)

##### Relationships and Data Flow
- User invokes:
[CLI or GUI] → loads YAML/JSON config → Snakemake
- Snakemake rule graph:
→ spins up Docker container for each selected mapping tool
→ mapping outputs (BAM/alignments) → feeds event‐detection containers
→ event outputs (tool‐specific event files)
- Unified‐output scripts read all event files → normalize to common format → consensus report
- ASimulatoR can be run independently (via its Docker) to generate simulated input data.
- Documentation pipeline is orthogonal: Sphinx builds docs from docs/source.

##### Architectural Patterns & Design Principles
- Microservices (each tool in its own Docker container).
- Workflow orchestration (Snakemake as directed acyclic graph).
- Separation of concerns:
- Configuration (YAML/JSON)
- Execution (Snakemake + Docker)
- Aggregation (Python unified‐output)
- Simulation (R package)
- Documentation (Sphinx).
- Extensibility: add a new tool folder under src/, supply Dockerfile + ENTRYPOINT + Snakemake rule.

##### Essential Elements
- Clear component labels (CLI, Snakemake, Mapping Containers, Event Containers, Unified Parser, Reports).
- Config files and sample_input as external inputs.
- Documentation Sphinx build side‐flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    subgraph "External Inputs"
        SI["Sample Input Data<br/>(FASTQ, BAM, GTF, FASTA)"]:::external
        CI["Config Files<br/>(YAML/JSON)"]:::frontend
    end

    subgraph "Frontend" 
        CLI["CLI Layer<br/>Snakemake Engine"]:::frontend
        GUI["GUI Layer<br/>dicast.py"]:::frontend
    end

    subgraph "Orchestration" 
        SN["Snakemake Workflow"]:::orchestration
    end

    subgraph "Mapping Containers" 
        BBMAP["bbmap"]:::mapping
        HISAT["hisat2"]:::mapping
        STAR["STAR"]:::mapping
        CONTX["contextmap"]:::mapping
        CRAC["crac"]:::mapping
        DART["dart"]:::mapping
        GSNAP["gsnap"]:::mapping
        MAPSP["mapsplice"]:::mapping
        MINIM["minimap"]:::mapping
        SEGM["segemehl"]:::mapping
        SUBJC["subjunc"]:::mapping
        BWT["bowtie"]:::mapping
    end

    subgraph "Event Detection Containers"
        MAJIQ["MAJIQ"]:::event
        SPLAD["SplAdder"]:::event
        WHIP["Whippet"]:::event
        EPTR["EventPointer"]:::event
        ASGAL["ASGAL"]:::event
        ASPLI["ASpli"]:::event
        IRF["IRFinder"]:::event
        SGSEQ["SGSeq"]:::event
    end

    subgraph "Simulation Module"
        SIMC["ASimulatoR Container"]:::simulation
    end

    subgraph "Unified Output"
        UINIT["__init__.py"]:::output
        UTRANS["output_transformer.py"]:::output
        GTFUTIL["GTF Utils"]:::output
        PARSER["Tool Parsers"]:::output
        UNIFY["Event Consolidator"]:::output
    end

    subgraph "Final Reports"
        REPORT["Consensus Report"]:::output
    end

    subgraph "Documentation Pipeline"
        DOCSRC["docs/source"]:::docs
        DOCBUILD["docs/build"]:::docs
    end

    %% Connections
    SI -->|"input data"| SN
    CI -->|"workflow config"| SN
    CLI -->|runs| SN
    GUI -->|launches| SN

    SN -->|spins up| BBMAP
    SN -->|spins up| HISAT
    SN -->|spins up| STAR
    SN -->|spins up| CONTX
    SN -->|spins up| CRAC
    SN -->|spins up| DART
    SN -->|spins up| GSNAP
    SN -->|spins up| MAPSP
    SN -->|spins up| MINIM
    SN -->|spins up| SEGM
    SN -->|spins up| SUBJC
    SN -->|spins up| BWT

    BBMAP -->|BAM alignments| MAJIQ
    HISAT -->|BAM alignments| SPLAD
    STAR -->|BAM alignments| WHIP
    CONTX -->|BAM alignments| EPTR
    CRAC -->|BAM alignments| ASGAL
    DART -->|BAM alignments| ASPLI
    GSNAP -->|BAM alignments| IRF
    MAPSP -->|BAM alignments| SGSEQ

    SN -->|optional| SIMC
    SIMC -->|simulated FASTQ| SN

    MAJIQ -->|events.json| UTRANS
    SPLAD -->|events.json| UTRANS
    WHIP -->|events.json| UTRANS
    EPTR -->|events.json| UTRANS
    ASGAL -->|events.json| UTRANS
    ASPLI -->|events.json| UTRANS
    IRF -->|events.json| UTRANS
    SGSEQ -->|events.json| UTRANS

    UTRANS -->|normalized events| UNIFY
    UINIT -->|module init| UNIFY
    GTFUTIL -->|gtf parse| UNIFY
    PARSER -->|tool-specific parse| UNIFY

    UNIFY -->|consensus data| REPORT

    DOCSRC -->|build docs| DOCBUILD

    %% Click Events
    click CLI "https://github.com/amitfenn/dicast/tree/master/scripts/snakemake/Snakefile"
    click CLI "https://github.com/amitfenn/dicast/tree/master/scripts/snakemake/Snakefile-cli"
    click CI "https://github.com/amitfenn/dicast/blob/master/scripts/snakemake/snakemake_config.yaml"
    click CI "https://github.com/amitfenn/dicast/blob/master/scripts/snakemake/snakemake-cli_config.yaml"
    click CI "https://github.com/amitfenn/dicast/blob/master/scripts/snakemake/snakemake_config.json"
    click GUI "https://github.com/amitfenn/dicast/blob/master/gui/dicast.py"
    click GUI "https://github.com/amitfenn/dicast/blob/master/gui/dicast_config_setter.py"
    click BBMAP "https://github.com/amitfenn/dicast/tree/master/src/bbmap/Dockerfile"
    click HISAT "https://github.com/amitfenn/dicast/tree/master/src/hisat/Dockerfile"
    click STAR "https://github.com/amitfenn/dicast/tree/master/src/star/Dockerfile"
    click CONTX "https://github.com/amitfenn/dicast/tree/master/src/contextmap/Dockerfile"
    click CRAC "https://github.com/amitfenn/dicast/tree/master/src/crac/Dockerfile"
    click DART "https://github.com/amitfenn/dicast/tree/master/src/dart/Dockerfile"
    click GSNAP "https://github.com/amitfenn/dicast/tree/master/src/gsnap/Dockerfile"
    click MAPSP "https://github.com/amitfenn/dicast/tree/master/src/mapsplice/Dockerfile"
    click MINIM "https://github.com/amitfenn/dicast/tree/master/src/minimap/Dockerfile"
    click SEGM "https://github.com/amitfenn/dicast/tree/master/src/segemehl/Dockerfile"
    click SUBJC "https://github.com/amitfenn/dicast/tree/master/src/subjunc/Dockerfile"
    click BWT "https://github.com/amitfenn/dicast/tree/master/src/bowtie/Dockerfile"
    click MAJIQ "https://github.com/amitfenn/dicast/tree/master/src/majiq/Dockerfile"
    click SPLAD "https://github.com/amitfenn/dicast/tree/master/src/spladder/Dockerfile"
    click WHIP "https://github.com/amitfenn/dicast/tree/master/src/whippet/Dockerfile"
    click EPTR "https://github.com/amitfenn/dicast/tree/master/src/eventpointer/Dockerfile"
    click ASGAL "https://github.com/amitfenn/dicast/tree/master/src/asgal/Dockerfile"
    click ASPLI "https://github.com/amitfenn/dicast/tree/master/src/aspli/Dockerfile"
    click IRF "https://github.com/amitfenn/dicast/tree/master/src/irfinder/Dockerfile"
    click SGSEQ "https://github.com/amitfenn/dicast/tree/master/src/sgseq/Dockerfile"
    click SIMC "https://github.com/amitfenn/dicast/tree/master/src/ASimulatoR/Dockerfile"
    click UTRANS "https://github.com/amitfenn/dicast/blob/master/scripts/unified_output/output_transformer.py"
    click GTFUTIL "https://github.com/amitfenn/dicast/tree/master/scripts/unified_output/gtf_utils"
    click PARSER "https://github.com/amitfenn/dicast/tree/master/scripts/unified_output/tool_parser"
    click UNIFY "https://github.com/amitfenn/dicast/tree/master/scripts/unified_output/unified"
    click REPORT "https://github.com/amitfenn/dicast/blob/master/scripts/unified_output/output_transformer.py"
    click DOCSRC "https://github.com/amitfenn/dicast/tree/master/docs/source"
    click DOCBUILD "https://github.com/amitfenn/dicast/tree/master/docs/build"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef orchestration fill:#bbeaff,stroke:#333,stroke-width:1px
    classDef mapping fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef event fill:#99ff99,stroke:#333,stroke-width:1px
    classDef simulation fill:#ffebcc,stroke:#333,stroke-width:1px
    classDef output fill:#ffd699,stroke:#333,stroke-width:1px
    classDef docs fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef external fill:#f2f2f2,stroke:#333,stroke-width:1px
```
