# suhasreddysingam/deeprsma architecture

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

- Interactive diagram: https://gitdiagram.com/suhasreddysingam/deeprsma
- Repository: https://github.com/suhasreddysingam/deeprsma

## Overview

##### Project Type and Purpose
- This is a research-focused deep learning application for predicting the binding affinity between RNA and small molecules using a cross-fusion approach.
- It integrates several experimental setups: cross validation, blind test, and independent test.
- The project leverages pre-computed RNA embeddings and contact maps along with molecule data.

##### Main Architectural Components
a. Data Layer:
– Raw Data: Includes various datasets stored under “data” (e.g., RSM_data, blind_test, independent_data, and RNA_contact which has detailed RNA contact maps for different RNA classes).
– Pre-trained Representations: RNA embeddings, contact maps, and additional molecular representations (data/representations_cv and data/representations_independent).
– Additional data processing scripts (e.g., process_data_molecule.py, process_data_rna.py, process_independent_mole.py, process_independent_rna.py).
– Supporting utilities: vocabulary files, tokenizers, and feature extraction scripts.

b. Preprocessing and Feature Extraction:
– Data processing modules that convert raw data into suitable inputs.
– This includes generation of contact maps and pre-trained RNA embeddings (with dependency on external libraries SPOT-RNA-2D and RNA-FM).
– Scripts under “data” which help prepare cross validation, blind test, and independent test datasets.

c. Model and Training Module:
– Deep learning models are built in the “model” folder.
- Components include cross_attention, GNN models for molecules and RNA, and a transformer encoder.
- These components likely perform the fusion of features from RNA and small molecules.
– Main training/testing runners:
- main_cv.py for cross validation,
- main_blind.py for blind testing,
- main_independent.py for independent testing.
– The model leverages a cross fusion mechanism to integrate heterogeneous features from different data streams.

d. Environment and Deployment:
– The environment is defined in environment.yml (using conda).
– There is a clear separation between data processing, model training, and evaluation scripts.

##### Relationships and Data Flow
– Raw data and pre-computed representations serve as input to the data processing modules.
– The processed data is then fed into different training/testing pipelines based on experimental setup (controlled by the main_*.py scripts).
– Within the model pipeline, processed features flow into the deep learning architecture, which fuses information using modules like cross_attention, GNNs, and transformer encoders.
– The outputs are binding affinity predictions, which can then be evaluated or used for further analysis.
– External libraries (e.g., SPOT-RNA-2D, RNA-FM) are utilized during the pre-training or feature extraction phase.

##### Architectural Patterns and Design Principles
– Modular design: Each component (data processing, model architecture, and experiment runners) is isolated in its own folder/file.
– Pipeline-based data flow: The system processes raw data to generate features that are subsequently passed through a network of deep learning modules.
– Separation of concerns: Data preparation is handled separately from model training and evaluation.
– Reusability and extensibility: The design leaves room to adjust or add new experimental setups or models.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Ingestion
    subgraph "Data Ingestion"
        D1["Raw Data (RSM_data)"]:::data
        D2["RNA Contact (RNA_contact)"]:::data
        D3["Blind Test Data (blind_test)"]:::data
        D4["Independent Data (independent_data.csv)"]:::data
        D5["Representations (representations_cv)"]:::data
        D6["Representations (representations_independent)"]:::data
    end

    %% Data Processing & Feature Extraction
    subgraph "Data Processing & Feature Extraction"
        P1["Molecule Processing (process_data_molecule.py)"]:::processing
        P2["RNA Processing (process_data_rna.py)"]:::processing
        P3["Independent Molecule Processing (process_independent_mole.py)"]:::processing
        P4["Independent RNA Processing (process_independent_rna.py)"]:::processing
        P5["Feature Extraction (feature.py)"]:::processing
        P6["Tokenizer (tokenizer.py)"]:::processing
        P7["SMILES Vocabulary (smiles_vocab.pkl)"]:::processing
        P8["Vocabulary (vocab.py)"]:::processing
    end

    %% Model & Fusion Modules
    subgraph "Model & Fusion Modules"
        M1["Cross Attention Module (cross_attention.py)"]:::model
        M2["Molecule GNN Module (gnn_model_mole.py)"]:::model
        M3["RNA GNN Module (gnn_model_rna.py)"]:::model
        M4["Transformer Encoder (transformer_encoder.py)"]:::model
    end

    %% Experiment Runners
    subgraph "Experiment Runners"
        E1["Cross Validation Runner (main_cv.py)"]:::experiment
        E2["Blind Test Runner (main_blind.py)"]:::experiment
        E3["Independent Test Runner (main_independent.py)"]:::experiment
    end

    %% Environment Setup
    ENV["Environment Setup (environment.yml)"]:::env

    %% Data flow connections from Data Ingestion to Data Processing
    D1 -->|"feeds"| P1
    D1 -->|"feeds"| P2
    D2 -->|"feeds"| P2
    D3 -->|"feeds"| P1
    D4 -->|"feeds"| P3
    D4 -->|"feeds"| P4
    D5 -->|"feeds"| P5
    D6 -->|"feeds"| P5

    %% Data Processing interconnections (utilities support)
    P1 --> P5
    P2 --> P5
    P3 --> P5
    P4 --> P5
    P5 --> P6
    P5 --> P7
    P5 --> P8

    %% Flow from Data Processing to Model Components
    P1 -->|"processed_data"| M2
    P2 -->|"processed_data"| M3
    P5 -->|"embedded_features"| M1
    P6 -->|"tokenized_data"| M4
    M2 --> M1
    M3 --> M1
    M1 --> M4

    %% Model outputs to Experiment Runners
    M4 -->|"predictions"| E1
    M4 -->|"predictions"| E2
    M4 -->|"predictions"| E3

    %% Environment dependency links (pre-requisite for setup)
    ENV --- D1
    ENV --- D2
    ENV --- D3
    ENV --- D4
    ENV --- P1
    ENV --- P2
    ENV --- M1

    %% External dependencies note for feature extraction
    note1["External Libraries: SPOT-RNA-2D, RNA-FM"]:::processing
    P5 --- note1

    %% Click Events for Data Layer - Raw Data
    click D1 "https://github.com/suhasreddysingam/deeprsma/tree/master/data/RSM_data"
    click D2 "https://github.com/suhasreddysingam/deeprsma/tree/master/data/RNA_contact"
    click D3 "https://github.com/suhasreddysingam/deeprsma/tree/master/data/blind_test"
    click D4 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/independent_data.csv"
    click D5 "https://github.com/suhasreddysingam/deeprsma/tree/master/data/representations_cv"
    click D6 "https://github.com/suhasreddysingam/deeprsma/tree/master/data/representations_independent"

    %% Click Events for Data Processing Scripts and Utilities
    click P1 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/process_data_molecule.py"
    click P2 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/process_data_rna.py"
    click P3 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/process_independent_mole.py"
    click P4 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/process_independent_rna.py"
    click P5 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/feature.py"
    click P6 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/tokenizer/tokenizer.py"
    click P7 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/smiles_vocab.pkl"
    click P8 "https://github.com/suhasreddysingam/deeprsma/blob/master/data/vocab.py"

    %% Click Events for Model Components
    click M1 "https://github.com/suhasreddysingam/deeprsma/blob/master/model/cross_attention.py"
    click M2 "https://github.com/suhasreddysingam/deeprsma/blob/master/model/gnn_model_mole.py"
    click M3 "https://github.com/suhasreddysingam/deeprsma/blob/master/model/gnn_model_rna.py"
    click M4 "https://github.com/suhasreddysingam/deeprsma/blob/master/model/transformer_encoder.py"

    %% Click Events for Experiment Runners
    click E1 "https://github.com/suhasreddysingam/deeprsma/blob/master/main_cv.py"
    click E2 "https://github.com/suhasreddysingam/deeprsma/blob/master/main_blind.py"
    click E3 "https://github.com/suhasreddysingam/deeprsma/blob/master/main_independent.py"

    %% Click Event for Environment setup
    click ENV "https://github.com/suhasreddysingam/deeprsma/blob/master/environment.yml"

    %% Styles for color coding
    classDef data fill:#f4cccc,stroke:#d00000,stroke-width:2px;
    classDef processing fill:#ffe599,stroke:#b45f06,stroke-width:2px;
    classDef model fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef experiment fill:#c9daf8,stroke:#3d85c6,stroke-width:2px;
    classDef env fill:#ead1dc,stroke:#741b47,stroke-width:2px;
```
