# wustl-oncology/analysis-wdls architecture

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

- Interactive diagram: https://gitdiagram.com/wustl-oncology/analysis-wdls
- Repository: https://github.com/wustl-oncology/analysis-wdls

## Overview

##### Project Type & Purpose
– This is a repository of WDL (Workflow Description Language) pipelines for genomic analyses (e.g., somatic/germline variant calling, RNA‐Seq, epigenomics, immunogenomics).
– Each pipeline (e.g., immuno.wdl) orchestrates a set of tool containers via Cromwell (or Terra) to process sequencing data end-to-end.

##### High-Level File Structure
- definitions/
– Top-level WDL workflow files (e.g., alignment_exome.wdl, immuno.wdl, rnaseq.wdl)
– subworkflows/ (reusable logical blocks)
– tools/ (individual task definitions, each invoking a Docker container)
– types.wdl (shared type definitions)
- example_data/ (YAML/JSON inputs for testing each workflow and task)
- . github/workflows/verify.yaml (CI to lint & validate WDLs)
- README.md (project overview, execution guidance)

##### Additional Insights from README
– Designed for Cromwell/Terra on GCP (or other WDL engines)
– Each task uses a dedicated Docker image for portability
– Input “bundles” of reference genomes & annotations are hosted externally

##### Main Components
a. Workflow Engine (Cromwell/Terra)
b. WDL Workflows (e.g., immuno.wdl)
c. Subworkflows & Task Definitions (from definitions/subworkflows and definitions/tools)
d. Docker Containers (one per tool)
e. Input Data Bundles (reference FASTA, annotations)
f. Execution Environment (GCP buckets, local HPC, or Terra workspace)
g. Outputs (VCFs, QC reports, neoantigen tables)

##### Component Relationships & Data Flow
1. User triggers immuno.wdl (via Cromwell CLI or Terra UI)
2. Cromwell parses immuno.wdl → instantiates tasks and subworkflows
3. Each task calls a Docker image, mounts inputs (FASTQs, reference bundles)
4. Tasks run in sequence or scatter/gather as defined
5. Intermediate results passed between tasks (BAMs → VCFs → immunogenicity tables)
6. Final outputs written to cloud storage or local filesystem
7. CI pipeline verifies WDL syntax & example inputs

##### Architectural Patterns & Principles
– Workflow orchestration: Declarative DAG via WDL
– Modularity: Reusable subworkflows & tool definitions
– Containerization: Tool isolation & versioning via Docker
– Cloud‐native: Storage and execution on GCP/Terra, but portable across platforms

##### Technologies & Frameworks
- WDL (Workflows and Tasks)
- Cromwell or Terra (Execution engines)
- Docker (Container runtime)
- GitHub Actions (CI lint/validation)
- Google Cloud Storage or HPC cluster (Data storage & compute)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External User triggers workflow
    User["User<br/>(Cromwell CLI / Terra UI)"]:::external
    click User "https://github.com/wustl-oncology/analysis-wdls/blob/main/README.md"

    %% Execution Engine
    Engine["Workflow Engine<br/>(Cromwell / Terra)"]:::external
    User -->|"launch immuno.wdl"| Engine

    %% Input Bundles
    Input["Input Data Bundles<br/>(FASTQ, reference FASTA + GTF)"]:::external
    click Input "https://github.com/wustl-oncology/analysis-wdls/blob/main/example_data/immuno.yml"
    Engine -->|"provide inputs"| Input

    %% Main Workflow
    subgraph "WDL Workflows" 
        Immuno["immuno.wdl"]:::workflow
    end
    click Immuno "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/immuno.wdl"
    Engine -->|"parse workflow"| Immuno

    %% Subworkflows invoked by immuno.wdl
    subgraph "Subworkflows (Purple)" 
        AlignSW["alignment_exome Subworkflow"]:::workflow
        QCGen["qc_exome Subworkflow"]:::workflow
        MutectSW["mutect Subworkflow"]:::workflow
        PvacseqSW["pvacseq Subworkflow"]:::workflow
    end
    click AlignSW "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/subworkflows/qc_exome.wdl"
    click QCGen "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/subworkflows/qc_exome.wdl"
    click MutectSW "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/subworkflows/mutect.wdl"
    click PvacseqSW "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/subworkflows/pvacseq.wdl"

    Immuno -->|"call Preprocessing"| AlignSW
    Immuno -->|"call QC"| QCGen
    Immuno -->|"call Variant Calling"| MutectSW
    Immuno -->|"call Immunogenomics"| PvacseqSW

    %% Tool Tasks within subworkflows
    subgraph "Tasks (Docker Containers)" 
        Trim["trim_fastq"]:::task
        BWA["bwa_align"]:::task
        Mutect2["mutect"]:::task
        VEP["vep"]:::task
    end
    click Trim "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/tools/trim_fastq.wdl"
    click BWA "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/tools/bwa_align.wdl"
    click Mutect2 "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/tools/mutect.wdl"
    click VEP "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/tools/vep.wdl"

    AlignSW -->|"FASTQ→trimmed.fastq"| Trim -->|"trimmed.fastq→aligned.bam"| BWA
    QCGen -->|"BAM→qc_report"| QCGen
    MutectSW -->|"BAM→variants.vcf"| Mutect2
    PvacseqSW -->|"VCF→annotated.vcf"| VEP

    %% Shared Types
    Types["types.wdl"]:::workflow
    click Types "https://github.com/wustl-oncology/analysis-wdls/blob/main/definitions/types.wdl"
    Immuno --> Types
    AlignSW --> Types
    QCGen --> Types
    MutectSW --> Types
    PvacseqSW --> Types

    %% Outputs
    Outputs["Final Outputs<br/>(VCF, QC reports, neoantigen tables)"]:::external
    BWA --> Outputs
    Mutect2 --> Outputs
    VEP --> Outputs

    Storage["Storage<br/>(GCS bucket / Local FS)"]:::external
    Outputs -->|"write results"| Storage

    %% Continuous Integration
    CI["CI: verify.yaml"]:::external
    click CI "https://github.com/wustl-oncology/analysis-wdls/blob/main/.github/workflows/verify.yaml"
    CI -->|"lint & validate"| Immuno
    CI --> Types
    CI --> Trim
    CI --> BWA

    %% Dockstore and Packaging
    Dockstore["Dockstore Config<br/>(.dockstore.yml)"]:::external
    click Dockstore "https://github.com/wustl-oncology/analysis-wdls/blob/main/.dockstore.yml"
    Zip["Packaging Script<br/>(zip_wdls.sh)"]:::external
    click Zip "https://github.com/wustl-oncology/analysis-wdls/blob/main/zip_wdls.sh"

    %% Legend
    subgraph Legend
        WDL["WDL Workflows & Subworkflows"]:::workflow
        Task["Dockerized Tasks"]:::task
        Ext["External Systems"]:::external
    end

    classDef workflow fill:#D3B9FF,stroke:#333,stroke-width:1px;
    classDef task fill:#B3D1FF,stroke:#333,stroke-width:1px;
    classDef external fill:#B3FFB3,stroke:#333,stroke-width:1px;
```
