# thinng/graphdta architecture

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

- Interactive diagram: https://gitdiagram.com/thinng/graphdta
- Repository: https://github.com/thinng/graphdta

## Overview

##### Project type and purpose
- This is a machine‐learning research project focused on drug–target affinity prediction. It extends DeepDTA by representing small molecules as graphs and training graph neural network (GNN) models (GIN, GAT, GAT_GCN, GCN) using PyTorch Geometric.
- The README describes data preparation (create_data.py), dataset utilities (utils.py), two training regimes (training.py and training_validation.py), and four model classes under models/.

##### File structure
- Top‐level files:
- create_data.py: transforms raw Davis/KIBA data into PyTorch‐format datasets
- training.py & training_validation.py: orchestrate training & evaluation
- utils.py: dataset classes and performance metrics
- supplement.pdf: research supplement
- data/
- Two raw datasets (davis, kiba) with subfolders for Y (labels), proteins.txt, ligands_can.txt, and fold definitions
- After running create_data.py, data/processed/ will contain .pt train/test splits
- models/: four GNN implementations (ginconv.py, gat.py, gat_gcn.py, gcn.py)
- No dedicated frontend or service layer—this is a command‐line model training pipeline.

##### README for additional insights
- Clearly delineates three stages: (1) data conversion, (2) training on test‐set‐selected best MSE, (3) training with validation split and final test.
- Dependencies: PyTorch Geometric and RDKit for graph construction from SMILES.

##### Elements
- Clear labels for each component (e.g., “create_data.py”, “GINConvNet”)
- Orange for model classes
- Purple for external dependencies

##### Detailed checklist
- Data layer: raw data files, processed .pt files
- Preprocessing module: create_data.py, utils.py (dataset loader)
- Modeling: four GNN modules with a generic “Model Interface” annotation
- Training controllers: training.py vs. training_validation.py (annotate difference in selection criterion)
- Outputs: model and result files
- External: RDKit, PyG libraries

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RawDavis(("Raw Data: Davis")):::data
        RawKIBA(("Raw Data: KIBA")):::data
        ProcessedData(("Processed Datasets (.pt)")):::data
    end

    %% Preprocessing Layer
    subgraph "Preprocessing Layer"
        direction TB
        CreateData["create_data.py"]:::script
        Utils["utils.py"]:::script
    end

    %% Modeling Layer
    subgraph "Modeling Layer"
        direction TB
        GINConv["GINConvNet"]:::model
        GATNet["GATNet"]:::model
        GAT_GCN["GAT_GCN Net"]:::model
        GCNNet["GCNNet"]:::model
    end

    %% Training Orchestration
    subgraph "Training Orchestration"
        direction TB
        TrainingTest["training.py\n(test-set selection)"]:::script
        TrainingVal["training_validation.py\n(validation selection)"]:::script
    end

    %% Outputs
    subgraph "Outputs"
        direction TB
        Models["Trained Models (*.model)"]:::output
        Results["Result CSVs"]:::output
        Supplement["supplement.pdf"]:::docs
    end

    %% Dependencies
    subgraph "External Dependencies"
        direction TB
        RDKit["RDKit"]:::dep
        PyG["PyTorch Geometric"]:::dep
    end

    %% Flow Connections
    RawDavis -->|"input"| CreateData
    RawKIBA -->|"input"| CreateData
    CreateData -->|"outputs .pt"| ProcessedData
    Utils --> CreateData
    ProcessedData --> TrainingTest
    ProcessedData --> TrainingVal
    TrainingTest --> GINConv
    TrainingTest --> GATNet
    TrainingTest --> GAT_GCN
    TrainingTest --> GCNNet
    TrainingVal --> GINConv
    TrainingVal --> GATNet
    TrainingVal --> GAT_GCN
    TrainingVal --> GCNNet
    GINConv --> Models
    GATNet --> Models
    GAT_GCN --> Models
    GCNNet --> Models
    Models --> Results
    Supplement --> Results

    RDKit --> CreateData
    RDKit --> GINConv
    RDKit --> GATNet
    RDKit --> GAT_GCN
    RDKit --> GCNNet
    PyG --> GINConv
    PyG --> GATNet
    PyG --> GAT_GCN
    PyG --> GCNNet

    %% Click Events
    click RawDavis "https://github.com/thinng/graphdta/tree/master/data/davis/"
    click RawKIBA "https://github.com/thinng/graphdta/tree/master/data/kiba/"
    click CreateData "https://github.com/thinng/graphdta/blob/master/create_data.py"
    click Utils "https://github.com/thinng/graphdta/blob/master/utils.py"
    click GINConv "https://github.com/thinng/graphdta/blob/master/models/ginconv.py"
    click GATNet "https://github.com/thinng/graphdta/blob/master/models/gat.py"
    click GAT_GCN "https://github.com/thinng/graphdta/blob/master/models/gat_gcn.py"
    click GCNNet "https://github.com/thinng/graphdta/blob/master/models/gcn.py"
    click TrainingTest "https://github.com/thinng/graphdta/blob/master/training.py"
    click TrainingVal "https://github.com/thinng/graphdta/blob/master/training_validation.py"
    click Supplement "https://github.com/thinng/graphdta/blob/master/supplement.pdf"

    %% Styles
    classDef data fill:#AED6F1,stroke:#1F618D,color:#1B2631
    classDef script fill:#ABEBC6,stroke:#1D8348,color:#145A32
    classDef model fill:#F9E79F,stroke:#B7950B,color:#784212
    classDef dep fill:#D2B4DE,stroke:#7D3C98,color:#4A235A
    classDef output fill:#F5B7B1,stroke:#C0392B,color:#641E16
    classDef docs fill:#E5E8E8,stroke:#566573,color:#1C2833
```
