How mingyuanxu/tree-invent works
Project type and purpose
• Tree-Invent (FBG_3DGen) is a Python‐based, full‐stack molecular graph generative model.
• It integrates graph construction, graph neural network (GNN) modules, reinforcement learning (RL), and external cheminformatics/docking tools to generate 3D‐constrained molecules under user‐defined topological constraints.
File structure
Top‐level directories and their roles:
• FBG_3DGen/graphs – graph‐model data structures and RDKit preprocessing
• FBG_3DGen/gnn – MPNN variants for message passing and aggregation
• FBG_3DGen/model – core generative model classes (Dataset, Model, Model_RL, Z‐matrix utils)
• FBG_3DGen/dock – docking‐related utility functions (external tool interfaces)
• FBG_3DGen/scores – scoring‐function wrappers (QED, SAScore, QSAR, similarity, docking)
• pretrained_models/ – serialized sub‐models (node addition, ring generation, node connection) and datasets
Configuration & entry points:
• setup.py – installable package definition
• TreeInvent.yml – likely experiment/config settings
• README.md – architectural overview and workflow images
README for additional insights
• Three independent sub‐models: node addition, ring generation, node connection.
• User‐specified topology constraints drive generation.
• Scoring‐guided RL loop integrates optional external functions: docking, similarity, QED, etc.
• Workflow comprises: building topological tree → GNN inference → optional RL policy updates → output 3D molecule.
Main components & interactions
a. Inputs & Data Layer
• User topology constraints (YAML/API)
• Preprocessed datasets (SMILES/pickles in pretrained_models/datasets)
• RDKit‐based feature extraction (graphs/rdkitutils.py → features.py)
b. Core Generative Engine
• Graph Representation Module (graphs/Utils3d_np.py, graphroute.py)
• Three Sub‐Models (loaded from pretrained_models):
– Node Addition Model (graph expansion)
– Ring Generation Model (cycle closure)
– Node Connection Model (bond formation)
• Model.py orchestrates sub‐model calls sequentially to build the molecular graph.
• Z-matrix generation/3D coordinate utilities (model/Zmat.py, Utils3d.py)
c. GNN Inference
• MPNN infrastructure (gnn/mpnn.py, aggregation_mpnn.py, edge_mpnn.py, summation_mpnn.py)
• Custom modules for node/edge message passing (gnn/modules.py)
• Aggregation and update functions drive sub‐model predictions
d. Scoring & External Services
• Docking utilities call external binary/APIs via utils_dock.py
e. Reinforcement Learning Loop (optional)
• Model_RL.py wraps Model and Scoring to form environment + policy
• Policy gradients or other RL algorithms adjust sub‐model parameters according to a reward signal
f. Outputs
• Generated molecules (SMILES, 3D coordinates)
• Training logs (pretrained_models/.../Training.log)
• Metrics and scores
Architectural patterns & design principles
• Modular separation: graph preprocessing, model inference, scoring, docking.
• Plug-and-play sub‐models: each generative operation is an independent module.
• Clear data flow: constraints → graph features → GNN inference → molecule assembly → scoring → RL update.
• External integration via adapter pattern (docking, RDKit, YAML config).
Detailed elements
• A small inset showing filesystem mapping (e.g., “pretrained_models/model/*.cpk”)