# labweng/metddi architecture

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

- Interactive diagram: https://gitdiagram.com/labweng/metddi
- Repository: https://github.com/labweng/metddi

## Overview

##### Main Components
- Data Preparation & Preprocessing:
– Input data (located under the “data/” folder as specified in the README; not shown in the file tree but referenced multiple times)
– Preprocessing notebooks (preprocessing.ipynb in Classification, Regression, etc.)
– Preprocessed files such as “preprocessed_drug_info.npy.7z”

- Feature Engineering & Molecule Graph Construction:
– Feature extraction modules (features.py files in each module)
– Molecule graph construction (mol_graph.py files)
– Tokenization support via token_id.json

- Model Components:
– Atom-level and motif-level models (model_atom_level.py, model_motif_level.py) used across the pipelines
– Separate scripts for training and evaluation for Classification (both UnseenDDIs and Unseendrugs) and Regression (Train_MeTDDI_regression.py and evaluation_regression.py)

- Evaluation & Case Studies:
– Evaluation scripts (UnseenDDI_evaluate.py, UnseenDrugs_evaluate.py, evaluation_regression.py)
– Case study demonstration (case_study.py for reproducing figures)

- Visualization Module:
– Notebooks and scripts (MeTDDI_visualize.ipynb, visualize_one_DDI_pair.ipynb)
– Additional supporting files (mechanism_evidence_dict.npy)

- External Dependencies & Configuration:
– Dependencies (as detailed in the README requirements and versions for TensorFlow, rdkit, etc.)
– License and versioning (LICENSE file in code)

##### Architectural Patterns & Design Principles
- Modular design: Each module (classification, regression, visualization) functions as an independent pipeline but reuses common components like feature engineering and model construction.
- Emphasis on interpretability: The visualization module and the dual-level modeling (atom level and motif level) highlight the design’s focus on not only predicting DDIs but also explaining them.
- Separation of Concerns: Data preprocessing, model training, evaluation, and visualization are all distinctly separated into different directories and scripts to ease development, testing, and maintenance.

##### Technical Stack & Dependencies
- Python 3.8 and TensorFlow-GPU (v2.4.1 or 2.5.0) for deep learning components.
- Additional libraries: ipython, matplotlib, pandas, rdkit, scikit-learn, network.
- Use of Jupyter notebooks in several modules (for preprocessing and visualization) to facilitate experiment tracking and ease of result demonstration.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Input Data Layer
    A["Raw Drug Data"]:::data

    %% Preprocessing Layer
    subgraph "Data Preparation & Preprocessing"
        B["Classification Preprocessing (UnseenDDIs)"]:::preprocessing
        C["Classification Preprocessing (Unseendrugs)"]:::preprocessing
        D["Regression Preprocessing"]:::preprocessing
    end

    %% Feature Engineering & Molecule Graph Construction Layer
    subgraph "Feature Engineering & Molecule Graph Construction"
        E["Feature Engineering & Molecule Graph (Classification - UnseenDDIs)"]:::feature
        F["Feature Engineering & Molecule Graph (Classification - Unseendrugs)"]:::feature
        G["Feature Engineering & Molecule Graph (Regression)"]:::feature
        H["Feature Engineering & Molecule Graph (Visualization)"]:::feature
    end

    %% Model Components Layer
    subgraph "Model Components"
        I["Atom & Motif Models (Classification - UnseenDDIs)"]:::model
        J["Atom & Motif Models (Classification - Unseendrugs)"]:::model
        K["Atom & Motif Models (Regression)"]:::model
        L["Atom & Motif Models (Visualization)"]:::model
    end

    %% Training & Evaluation Layer
    subgraph "Training & Evaluation"
        subgraph "Classification Pipeline"
            M["Train UnseenDDIs"]:::train
            N["Evaluate UnseenDDI"]:::eval
            O["Train UnseenDrugs"]:::train
            P["Evaluate UnseenDrugs"]:::eval
        end
        subgraph "Regression Pipeline"
            Q["Train Regression"]:::train
            R["Evaluate Regression"]:::eval
            S["Case Study"]:::eval
        end
    end

    %% Visualization Layer
    subgraph "Visualization & Interpretability"
        T["MeTDDI Visualize Notebook"]:::visual
        U["Visualize One DDI Pair Notebook"]:::visual
        V["Visualization Script (DDI_vis)"]:::visual
        W["Dataset Inference"]:::visual
        X["Mechanism Evidence File"]:::visual
    end

    %% External Dependencies Layer
    subgraph "External Dependencies"
        Y["LICENSE"]:::external
        Z["README"]:::external
    end

    %% Data Flow Connections
    A --> B
    A --> C
    A --> D

    B --> E
    C --> F
    D --> G
    D --> H

    E --> I
    F --> J
    G --> K
    H --> L

    I --> M
    J --> O
    K --> Q

    M --> N
    O --> P
    Q --> R
    R --> S

    N --> T
    P --> U
    R --> V
    S --> W
    L --> X

    %% Styles
    classDef data fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef preprocessing fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef feature fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef model fill:#F5B7B1,stroke:#943126,stroke-width:2px;
    classDef train fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef eval fill:#F5CBA7,stroke:#873600,stroke-width:2px;
    classDef visual fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;

    %% Click Events for Data Preparation & Preprocessing
    click B "https://github.com/labweng/metddi/blob/main/code/Classification/UnseenDDIs/preprocessing.ipynb"
    click C "https://github.com/labweng/metddi/blob/main/code/Classification/Unseendrugs/preprocessing.ipynb"
    click D "https://github.com/labweng/metddi/blob/main/code/Regression/preprocessing.ipynb"

    %% Click Events for Feature Engineering & Molecule Graph Construction
    click E "https://github.com/labweng/metddi/blob/main/code/Classification/UnseenDDIs/features.py"
    click F "https://github.com/labweng/metddi/blob/main/code/Classification/Unseendrugs/features.py"
    click G "https://github.com/labweng/metddi/blob/main/code/Regression/features.py"
    click H "https://github.com/labweng/metddi/blob/main/code/Visualization/features.py"

    %% Click Events for Model Components
    click I "https://github.com/labweng/metddi/blob/main/code/Classification/UnseenDDIs/model_atom_level.py"
    click J "https://github.com/labweng/metddi/blob/main/code/Classification/Unseendrugs/model_atom_level.py"
    click K "https://github.com/labweng/metddi/blob/main/code/Regression/model_atom_level.py"
    click L "https://github.com/labweng/metddi/blob/main/code/Visualization/model_atom_level.py"

    %% Click Events for Training & Evaluation Scripts
    click M "https://github.com/labweng/metddi/blob/main/code/Classification/UnseenDDIs/Train_UnseenDDIs.py"
    click N "https://github.com/labweng/metddi/blob/main/code/Classification/UnseenDDIs/UnseenDDI_evaluate.py"
    click O "https://github.com/labweng/metddi/blob/main/code/Classification/Unseendrugs/Train_UnseenDrugs.py"
    click P "https://github.com/labweng/metddi/blob/main/code/Classification/Unseendrugs/UnseenDrugs_evaluate.py"
    click Q "https://github.com/labweng/metddi/blob/main/code/Regression/Train_MeTDDI_regression.py"
    click R "https://github.com/labweng/metddi/blob/main/code/Regression/evaluation_regression.py"
    click S "https://github.com/labweng/metddi/blob/main/code/Regression/case_study.py"

    %% Click Events for Visualization Module
    click T "https://github.com/labweng/metddi/blob/main/code/Visualization/MeTDDI_visualize.ipynb"
    click U "https://github.com/labweng/metddi/blob/main/code/Visualization/visualize_one_DDI_pair.ipynb"
    click V "https://github.com/labweng/metddi/blob/main/code/Visualization/DDI_vis.py"
    click W "https://github.com/labweng/metddi/blob/main/code/Visualization/dataset_inference.py"
    click X "https://github.com/labweng/metddi/blob/main/code/Visualization/mechanism_evidence_dict.npy"

    %% Click Events for External Dependencies
    click Y "https://github.com/labweng/metddi/tree/main/code/LICENSE"
    click Z "https://github.com/labweng/metddi/blob/main/README.md"
```
