# hxyfighter/molrl-mgpt architecture

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

- Interactive diagram: https://gitdiagram.com/hxyfighter/molrl-mgpt
- Repository: https://github.com/hxyfighter/molrl-mgpt

## Overview

##### Project type and purpose
- This is an open-source research framework (“MolRL-MGPT”) for de novo drug design using reinforcement learning (RL) with multiple GPT-style agents.
- It provides two main workflows: (a) pre-training a molecular language model on big SMILES datasets, and (b) running multi-agent RL for goal-directed molecule generation (e.g., GuacaMol tasks or SARS-CoV-2 docking).

##### File structure
- Top level:
- README.md (project overview and instructions)
- codes/ (all Python modules and entry scripts)
- data/ (raw datasets, vocabulary, protein target files)
- codes/ directory:
- pretrain.py + model.py + vocabulary.py + dataset.py – the pre-training pipeline
- MARL.py + MARL_guacamol.py + assess_goal_directed_generation.py – multi-agent RL orchestration and evaluation
- scoring_function.py + utils.py – environment helpers and external docking/score wrappers
- data/ directory:
- ChEMBL_Smiles.csv, vocab.txt – SMILES corpus and token vocabulary
- targets/*.pdbqt – protein structures for docking oracles
- Key config and dependency files are implicit (no Dockerfile, but uses PyTorch, RDKit, OpenBabel, QuickVina).

##### README for additional insights
- Workflows:
a. Pre-training: `python codes/pretrain.py` on a filtered ZINC or ChEMBL SMILES dataset.
b. Multi-agent RL: `python codes/MARL.py --task_id …` for GuacaMol tasks or docking oracles.
- Dependency on external tools: RDKit for chemistry operations, OpenBabel/QuickVina for docking, PyTDC for property evaluation, TensorBoard for logging.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        SMILES["ChEMBL_Smiles.csv"]:::data
        Vocab["vocab.txt"]:::data
        PDB1["7jir+w2.pdbqt"]:::data
        PDB2["RDRP.pdbqt"]:::data
    end

    %% Preprocessing Module
    subgraph "Preprocessing Module"
        Dataset["dataset.py"]:::core
        VocabMod["vocabulary.py"]:::core
    end

    %% Pre-training Pipeline
    subgraph "Pre-training Pipeline"
        Pretrain["pretrain.py"]:::core
        Model["model.py"]:::core
    end

    %% RL Environment & Scoring
    subgraph "RL Environment & Scoring"
        Scoring["scoring_function.py"]:::env
        Utils["utils.py"]:::env
    end

    %% Multi-agent Controller
    subgraph "Multi-agent Controller"
        MARL["MARL.py"]:::core
        Guacamol["MARL_guacamol.py"]:::core
    end

    %% Evaluation Module
    subgraph "Evaluation Module"
        Assess["assess_goal_directed_generation.py"]:::core
    end

    %% Persistence & Logging
    Checkpoints["Model Checkpoints"]:::storage
    TBLogs["TensorBoard Logs"]:::storage

    %% External Tools
    subgraph "External Tools"
        RDKit["RDKit"]:::external
        OpenBabel["OpenBabel"]:::external
        QuickVina["QuickVina"]:::external
        TensorBoard["TensorBoard"]:::external
    end

    %% Data Flows
    SMILES -->|"raw SMILES batch"| Dataset
    Vocab -->|"token vocab"| VocabMod
    Dataset -->|"tokenized data"| Pretrain
    VocabMod -->|"tokenizer"| Pretrain
    Pretrain -->|"trained model"| Model
    Model -->|"checkpoint"| Checkpoints

    %% RL Pipeline
    Checkpoints -->|"init policy"| MARL
    SMILES -->|"initial SMILES"| MARL
    PDB1 -->|"protein structure"| Scoring
    PDB2 -->|"protein structure"| Scoring
    Scoring -->|"scoring/oracle"| MARL
    Utils -->|"env helpers"| MARL

    %% Agent Loop
    MARL -->|"N× agents generate SMILES"| Scoring
    Scoring -->|"reward signal"| MARL
    MARL -->|"training metrics"| Assess
    MARL -->|"logs"| TBLogs

    %% Evaluation and Logging
    Assess -->|"benchmark results"| Researcher["Researcher"]
    TBLogs -->|"visualization"| TensorBoard

    %% External Integrations
    RDKit --> Dataset
    RDKit --> Utils
    OpenBabel --> Utils
    QuickVina --> Scoring

    %% Click Events
    click SMILES "https://github.com/hxyfighter/molrl-mgpt/blob/main/data/ChEMBL_Smiles.csv"
    click Vocab "https://github.com/hxyfighter/molrl-mgpt/blob/main/data/vocab.txt"
    click PDB1 "https://github.com/hxyfighter/molrl-mgpt/blob/main/data/targets/7jir+w2.pdbqt"
    click PDB2 "https://github.com/hxyfighter/molrl-mgpt/blob/main/data/targets/RDRP.pdbqt"
    click Dataset "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/dataset.py"
    click VocabMod "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/vocabulary.py"
    click Pretrain "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/pretrain.py"
    click Model "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/model.py"
    click Scoring "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/scoring_function.py"
    click Utils "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/utils.py"
    click MARL "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/MARL.py"
    click Guacamol "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/MARL_guacamol.py"
    click Assess "https://github.com/hxyfighter/molrl-mgpt/blob/main/codes/assess_goal_directed_generation.py"
    click Researcher "https://github.com/hxyfighter/molrl-mgpt/blob/main/README.md"

    %% Styles
    classDef data fill:#D6EAF8,stroke:#2980B9,color:#154360
    classDef core fill:#D5F5E3,stroke:#27AE60,color:#1E8449
    classDef env fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
    classDef external fill:#D5D8DC,stroke:#7B7D7D,color:#424949
    classDef storage fill:#AED6F1,stroke:#2E86C1,color:#1B4F72
```
