# nithish-chandra-devarashetty/deeprsma-dp architecture

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

- Interactive diagram: https://gitdiagram.com/nithish-chandra-devarashetty/deeprsma-dp
- Repository: https://github.com/nithish-chandra-devarashetty/deeprsma-dp

## Overview

##### Project Type & Purpose
- DeepRSMA is a specialized deep‑learning pipeline (full-stack research tool) for predicting RNA–small‑molecule binding affinities.
- It ingests raw molecular and RNA data, processes and represents these inputs, trains graph‑based neural networks with cross‑attention fusion, and evaluates performance under three experimental settings: cross‑validation, blind test, and independent test.

##### Key Components
A. Data Storage & Preprocessing
- Raw Data Repository (“data/”):
- RSM_data (cross‑validation CSVs)
- blind_test CSVs
- independent_data.csv
- RNA contact maps (SPOT‑RNA‑2D outputs)
- Preprocessing Modules (“data/process_*.py” + “data/feature.py” + “data/vocab.py” + tokenizer):
- process_data_molecule.py / process_independent_mole.py
- process_data_rna.py / process_independent_rna.py
- compute small‑molecule graphs, tokenize SMILES, build RNA feature matrices

B. Representation & Embedding
- Pretrained RNA embeddings (“data/representations_cv/” and “representations_independent/”) generated via RNA‑FM
- Contact‑map files under “data/RNA_contact/*” generated via SPOT‑RNA‑2D

C. Model Definition
- Python package “model/”:
- gnn_model_mole.py: GNN encoder for small‑molecule graphs
- gnn_model_rna.py: GNN encoder for RNA contact graphs
- transformer_encoder.py: transformer blocks to process node features
- cross_attention.py: cross‑modal attention fusion between molecule & RNA embeddings

D. Training & Evaluation Orchestrator
- Entry‑point scripts:
- main_cv.py (cross‑validation loop)
- main_blind.py (blind test evaluation)
- main_independent.py (independent test evaluation)
- They import data preprocessing, model building, training loops, logging, metrics calculation

E. Environment & External Dependencies
- environment.yml: Conda specification for Python, PyTorch, NumPy, SciPy, etc.
- External services/libraries: SPOT‑RNA‑2D, RNA‑FM for generating contact maps and RNA embeddings

##### Interactions & Data Flow
1. Raw Input Data → Preprocessing Modules → Processed graphs + feature tensors
2. RNA contact maps & pretrained embeddings → Representation Modules → Embedding tensors
3. Processed inputs + embeddings → Model Definition → Forward passes under training scripts
4. Training scripts handle batching, loss computation, backpropagation, checkpointing, reporting metrics
5. Generated performance outputs (metrics, plots) for each experimental setting

##### Architectural Patterns & Principles
- Modular separation of concerns: data ingestion, representation, modelling, orchestration
- Pipeline/ETL pattern for data preprocessing and feature engineering
- Layered model architecture: GNN encoders → transformer blocks → cross‑attention fusion → prediction head
- Reproducibility via environment.yml and script‑based orchestration

##### Essential Elements to Capture
- Raw data sources (CSV, .prob_single files, .npy embeddings)
- Preprocessing scripts and outputs (graph objects, feature matrices)
- Pretrained representation store (embedding loader)
- Model modules (GNN encoders, transformer, cross‑attention fusion)
- Experiment orchestrator (main_cv.py, main_blind.py, main_independent.py)
- External libraries/services and environment management

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Data Layer"
        DataModule["Data Storage (data/)"]:::data
        RawDataCSV["RSM_data CSVs"]:::data
        BlindTestCSV["blind_test CSVs"]:::data
        IndependentCSV["independent_data.csv"]:::data
        ContactMaps["RNA Contact Maps"]:::data
    end

    subgraph "Preprocessing Layer"
        ProcMol["process_data_molecule.py"]:::process
        ProcMolInd["process_independent_mole.py"]:::process
        ProcRNA["process_data_rna.py"]:::process
        ProcRNAInd["process_independent_rna.py"]:::process
        Feature["feature.py"]:::process
        Vocab["vocab.py"]:::process
        Tokenizer["tokenizer.py"]:::process
    end

    subgraph "Representation Layer"
        EmbCV["RNA Embeddings (CV)"]:::representation
        EmbInd["RNA Embeddings (Ind)"]:::representation
    end

    subgraph "Model Layer"
        MoleGNN["GNN Encoder Mole"]:::model
        RNAGNN["GNN Encoder RNA"]:::model
        Transformer["Transformer Blocks"]:::model
        CrossAtt["Cross-Attention Fusion"]:::model
    end

    subgraph "Orchestration Layer"
        MainCV["main_cv.py"]:::orchestration
        MainBlind["main_blind.py"]:::orchestration
        MainInd["main_independent.py"]:::orchestration
    end

    subgraph "External Services"
        SPOT["SPOT-RNA-2D"]:::external
        RNAFM["RNA-FM"]:::external
    end

    subgraph "Infrastructure"
        Env["environment.yml"]:::infra
    end

    DataModule --> ProcMol
    DataModule --> ProcMolInd
    DataModule --> ProcRNA
    DataModule --> ProcRNAInd
    DataModule --> Feature
    DataModule --> Vocab
    DataModule --> Tokenizer

    RawDataCSV --> ProcMol
    BlindTestCSV --> ProcMolInd
    RawDataCSV --> ProcRNA
    IndependentCSV --> ProcRNAInd
    ContactMaps --> ProcRNA

    ProcMol --> MoleGNN
    ProcRNA --> RNAGNN
    Feature --> MoleGNN
    Feature --> RNAGNN
    Tokenizer --> MoleGNN
    Vocab --> MoleGNN

    EmbCV --> RNAGNN
    EmbInd --> RNAGNN

    MoleGNN --> Transformer
    RNAGNN --> Transformer
    Transformer --> CrossAtt

    CrossAtt --> MainCV
    CrossAtt --> MainBlind
    CrossAtt --> MainInd

    SPOT --> ContactMaps
    RNAFM --> EmbCV
    RNAFM --> EmbInd

    MainCV --> Env
    MainBlind --> Env
    MainInd --> Env

    click DataModule "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/tree/master/data/"
    click RawDataCSV "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/tree/master/data/RSM_data/"
    click BlindTestCSV "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/tree/master/data/blind_test/"
    click IndependentCSV "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/independent_data.csv"
    click ContactMaps "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/tree/master/data/RNA_contact/"
    click ProcMol "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/process_data_molecule.py"
    click ProcMolInd "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/process_independent_mole.py"
    click ProcRNA "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/process_data_rna.py"
    click ProcRNAInd "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/process_independent_rna.py"
    click Feature "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/feature.py"
    click Vocab "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/vocab.py"
    click Tokenizer "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/data/tokenizer/tokenizer.py"
    click EmbCV "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/tree/master/data/representations_cv/"
    click EmbInd "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/tree/master/data/representations_independent/"
    click MoleGNN "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/model/gnn_model_mole.py"
    click RNAGNN "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/model/gnn_model_rna.py"
    click Transformer "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/model/transformer_encoder.py"
    click CrossAtt "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/model/cross_attention.py"
    click MainCV "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/main_cv.py"
    click MainBlind "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/main_blind.py"
    click MainInd "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/main_independent.py"
    click Env "https://github.com/nithish-chandra-devarashetty/deeprsma-dp/blob/master/environment.yml"

    classDef data fill:#AED6F1,stroke:#3498DB
    classDef process fill:#A9DFBF,stroke:#27AE60
    classDef representation fill:#F9E79F,stroke:#F1C40F
    classDef model fill:#F5B7B1,stroke:#E74C3C
    classDef orchestration fill:#D7BDE2,stroke:#8E44AD
    classDef external fill:#D5DBDB,stroke:#7F8C8D
    classDef infra fill:#FADBD8,stroke:#E67E22
```
