# songlab-cal/gpn architecture

> Architecture diagram of the GitHub repository songlab-cal/gpn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/songlab-cal/gpn
- Repository: https://github.com/songlab-cal/gpn

## Overview

##### Main Components

a) Core Components:
- Model Architecture Layer
- GPN-SS (Single Sequence) Module
- GPN-MSA (Multiple Sequence Alignment) Module
- Encoder Options (ConvNet, RoFormer, ByteNet)
- Data Processing Pipeline
- Training Infrastructure
- Inference Pipeline
- Variant Effect Prediction System

b) Supporting Components:
- Dataset Generation Workflow
- Embedding Extraction System
- Analysis Tools
- Integration Points

**┌─────────────────────────────────────────────────┐**
- Input Layer                     │
- (DNA Sequences, Variants, Multiple Alignments)   │
- ┘
- ↓
**┌─────────────────────────────────────────────────┐**
- Processing Layer                   │
- ┌─────────────┐        ┌─────────────┐        │
- GPN-SS    │        │   GPN-MSA   │        │
- ┘        └─────────────┘        │
- ┘
- ↓
**┌─────────────────────────────────────────────────┐**
- Output Layer                       │
- (Embeddings, Variant Effects, Predictions)      │
- ┘

##### Component Details

- Blue: Core model components
- Green: Data processing components
- Orange: Analysis tools
- Purple: Integration points
- Gray: Supporting infrastructure

##### Key Relationships to Highlight

a) Data Flow:
- How data moves from raw input through the processing pipeline
- Where transformations occur
- Points where different components interact

b) Processing Paths:
- Distinguish between GPN-SS and GPN-MSA workflows
- Parallel processing capabilities
- Batch processing routes

##### Technical Details

- PyTorch integration points
- GPU utilization paths
- Batch processing specifications
- Model architecture options
- Data format transformations

##### Implementation Notes

- The modular nature of the system (shown by the file structure in gpn/)
- The workflow automation (evidenced by Snakemake usage)
- The analysis capabilities (shown in the analysis/ directory)
- The example implementations (as seen in examples/)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        DNA[DNA Sequences]
        VAR[Variants]
        MSA[Multiple Alignments]
    end

    subgraph Processing
        DP["Data Processing"]:::data
        DG["Dataset Generation"]:::data
        
        subgraph Models
            direction TB
            MA["Model Architecture"]:::core
            
            subgraph SS["GPN-SS Pipeline"]
                GPNSS["GPN-SS Module"]:::model
                TI_SS["Training (SS)"]:::train
                VEP_SS["Variant Effect Prediction (SS)"]:::pred
                EMB_SS["Embedding System (SS)"]:::emb
                INF_SS["Inference (SS)"]:::inf
            end
            
            subgraph MS["GPN-MSA Pipeline"]
                GPNMSA["GPN-MSA Module"]:::model
                TI_MSA["Training (MSA)"]:::train
                VEP_MSA["Variant Effect Prediction (MSA)"]:::pred
                EMB_MSA["Embedding System (MSA)"]:::emb
                INF_MSA["Inference (MSA)"]:::inf
            end
        end
    end

    subgraph Analysis
        AT["Analysis Tools"]:::analysis
        HUM["Human Analysis"]:::analysis
        ARA["Arabidopsis Analysis"]:::analysis
    end

    subgraph Examples
        EX_SS["Single Sequence Examples"]:::example
        EX_MSA["MSA Examples"]:::example
    end

    %% Connections
    DNA --> DP
    VAR --> DP
    MSA --> DP
    DP --> DG
    DG --> GPNSS
    DG --> GPNMSA
    
    GPNSS --> TI_SS
    GPNSS --> VEP_SS
    GPNSS --> EMB_SS
    GPNSS --> INF_SS
    
    GPNMSA --> TI_MSA
    GPNMSA --> VEP_MSA
    GPNMSA --> EMB_MSA
    GPNMSA --> INF_MSA
    
    EMB_SS --> AT
    EMB_MSA --> AT
    AT --> HUM
    AT --> ARA
    
    GPNSS --> EX_SS
    GPNMSA --> EX_MSA

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef model fill:#1976D2,stroke:#0D47A1,color:white
    classDef data fill:#4CAF50,stroke:#2E7D32,color:white
    classDef train fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef pred fill:#FF9800,stroke:#EF6C00,color:white
    classDef emb fill:#795548,stroke:#4E342E,color:white
    classDef inf fill:#607D8B,stroke:#37474F,color:white
    classDef analysis fill:#E91E63,stroke:#AD1457,color:white
    classDef example fill:#00BCD4,stroke:#00838F,color:white

    %% Click Events
    click GPNSS "https://github.com/songlab-cal/gpn/tree/main/gpn/ss/"
    click GPNMSA "https://github.com/songlab-cal/gpn/tree/main/gpn/msa/"
    click MA "https://github.com/songlab-cal/gpn/blob/main/gpn/model.py"
    click DG "https://github.com/songlab-cal/gpn/tree/main/workflow/make_dataset/"
    click TI_SS "https://github.com/songlab-cal/gpn/blob/main/gpn/ss/run_mlm.py"
    click TI_MSA "https://github.com/songlab-cal/gpn/blob/main/gpn/msa/train.py"
    click VEP_SS "https://github.com/songlab-cal/gpn/blob/main/gpn/ss/run_vep.py"
    click VEP_MSA "https://github.com/songlab-cal/gpn/blob/main/gpn/msa/vep.py"
    click EMB_SS "https://github.com/songlab-cal/gpn/blob/main/gpn/ss/get_embeddings.py"
    click EMB_MSA "https://github.com/songlab-cal/gpn/blob/main/gpn/msa/embedding.py"
    click AT "https://github.com/songlab-cal/gpn/tree/main/analysis/"
    click HUM "https://github.com/songlab-cal/gpn/tree/main/analysis/human/"
    click ARA "https://github.com/songlab-cal/gpn/tree/main/analysis/arabidopsis/"
    click EX_SS "https://github.com/songlab-cal/gpn/tree/main/examples/ss/"
    click EX_MSA "https://github.com/songlab-cal/gpn/tree/main/examples/msa/"
    click DP "https://github.com/songlab-cal/gpn/blob/main/gpn/data.py"
    click INF_SS "https://github.com/songlab-cal/gpn/blob/main/gpn/ss/get_logits.py"
    click INF_MSA "https://github.com/songlab-cal/gpn/blob/main/gpn/msa/logits.py"
```
