# soufanom/sgcl-dpi architecture

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

- Interactive diagram: https://gitdiagram.com/soufanom/sgcl-dpi
- Repository: https://github.com/soufanom/sgcl-dpi

## Overview

##### Project Type and Purpose
- SGCL-DPI is a research-grade machine-learning pipeline for predicting drug–protein interactions. It implements a multi-stage workflow: data ingestion → feature and graph generation → model training (GNN + curriculum learning) → evaluation.

##### File-Structure Analysis
- Top-Level Directories:
- Data/ – raw and intermediate datasets (BindingDB, similarity graphs)
- simgraphmaker/ – graph and feature generation scripts
- proteins/ – protein‐feature extraction
- chemprotlinker/ – molecule–protein linking utilities
- gcns/ – main training script (sgcl_dpi.py)
- helpers/ – auxiliary parsers (stitch_data_parser.py)
- Configuration: requirements.txt governs dependencies; no deployment manifests (research prototype).

##### Components
a. Data Sources
- BindingDB-processed data (Data/BindingDB-processed)
- Any external reference data loaded in helpers/ or proteins/
b. Preprocessing Modules
- helpers/stitch_data_parser.py: parses and joins raw BindingDB entries
- proteins/protfeaturegen.py: computes protein descriptors
- chemprotlinker/chemprotlinker.py: links chemical and protein IDs if needed
c. Graph & Feature Generation (simgraphmaker/)
- simgraphmaker.py → features.pkl
- feature_similarity_computer.py → all‐pair similarity scores
- similarity_threshold_processor.py → thresholded similarity CSVs (drug & protein graphs)
Outputs: drug_similarity_sample.csv & protein_similarity_sample.csv in Data/SimilarityGraphs
d. Model Training (gcns/)
- sgcl_dpi.py orchestrates:
– Load features.pkl & similarity graphs
– Construct GNNs for drug & protein graphs
– Apply curriculum strategy (structure-guided sampling)
– Train, cross-validate, compute F1, AUC, AUPR
– Serialize metrics and (optionally) model checkpoints

##### Architectural Patterns & Design Principles
- Pipeline (linear DAG) with clear stage separation
- Modular scripts grouped by concern (data prep / graph prep / training)
- Data‐centric: each stage reads/writes artifacts (pkl, CSV)
- Reproducibility: versioned scripts, environment pinned by requirements.txt

##### Relationships & Data Flow
1. Data Sources → Preprocessing
2. Preprocessing OUTPUT → Graph & Feature Generation
3. Graph & Feature Generation OUTPUT → Model Training
4. Model Training OUTPUT → Evaluation reports & saved artifacts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        DS1[/"BindingDB-processed"/]:::artifact
    end

    %% Preprocessing Modules
    subgraph "Preprocessing" 
        P1["stitch_data_parser.py"]:::preprocessing
        P2["protfeaturegen.py"]:::preprocessing
        P3["chemprotlinker.py"]:::preprocessing
    end

    %% Graph & Feature Generation
    subgraph "Graph & Feature Generation"
        G1["simgraphmaker.py"]:::generation
        G2["feature_similarity_computer.py"]:::generation
        G3["similarity_threshold_processor.py"]:::generation
        FPKL[("features.pkl")]:::artifact
        DSC[/"drug_similarity_sample.csv"/]:::artifact
        PSC[/"protein_similarity_sample.csv"/]:::artifact
    end

    %% Model Training & Evaluation
    subgraph "Model Training & Evaluation"
        subgraph "GNN Pipeline"
            M1["sgcl_dpi.py"]:::training
            subgraph "Curriculum Scheduler"
                CS["Scheduler"]:::training
            end
        end
        REPORTS[("Evaluation Reports")]:::artifact
    end

    %% Documentation & Metadata
    subgraph "Project Metadata"
        REQ["requirements.txt"]:::doc
        RMD["README.md"]:::doc
        LIC["LICENSE"]:::doc
    end

    %% Data Flow
    DS1 -->|raw data| P1
    P1 -->|parsed entries| P2
    P1 -->|parsed entries| P3
    P2 -->|protein features| G1
    P3 -->|linked IDs| G1

    G1 -->|features.pkl| FPKL
    G2 -->|similarity scores| DSC
    G2 -->|similarity scores| PSC
    G3 -->|thresholded graphs| DSC
    G3 -->|thresholded graphs| PSC
    FPKL -->|features.pkl| M1
    DSC -->|drug graph| M1
    PSC -->|protein graph| M1
    M1 -->|metrics & checkpoints| REPORTS

    %% Click Events
    click DS1 "https://github.com/soufanom/sgcl-dpi/tree/main/Data/BindingDB-processed"
    click P1 "https://github.com/soufanom/sgcl-dpi/blob/main/helpers/stitch_data_parser.py"
    click P2 "https://github.com/soufanom/sgcl-dpi/blob/main/proteins/protfeaturegen.py"
    click P3 "https://github.com/soufanom/sgcl-dpi/blob/main/chemprotlinker/chemprotlinker.py"
    click G1 "https://github.com/soufanom/sgcl-dpi/blob/main/simgraphmaker/simgraphmaker.py"
    click G2 "https://github.com/soufanom/sgcl-dpi/blob/main/simgraphmaker/feature_similarity_computer.py"
    click G3 "https://github.com/soufanom/sgcl-dpi/blob/main/simgraphmaker/similarity_threshold_processor.py"
    click M1 "https://github.com/soufanom/sgcl-dpi/blob/main/gcns/sgcl_dpi.py"
    click REQ "https://github.com/soufanom/sgcl-dpi/blob/main/requirements.txt"
    click RMD "https://github.com/soufanom/sgcl-dpi/blob/main/README.md"
    click LIC "https://github.com/soufanom/sgcl-dpi/tree/main/LICENSE"

    %% Styles
    classDef dataSource fill:#E0F7FA,stroke:#333,stroke-width:1px
    classDef preprocessing fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef generation fill:#C8E6C9,stroke:#333,stroke-width:1px
    classDef training fill:#E1BEE7,stroke:#333,stroke-width:1px
    classDef artifact fill:#FFF9C4,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef doc fill:#ECEFF1,stroke:#333,stroke-width:1px
```
