How tsa87/cgflow works
Project Type and Purpose
• CGFlow is a research-oriented Python library and toolkit for compositional generative flows, combining 3D molecule conformation generation (pose prediction) with synthesis pathway design.
• It integrates and extends three core domains:
• cgflow: co-design of molecule pose + synthesis path
• gflownet: general GFlowNet algorithms
• rxnflow: retrosynthesis pathway sampling via GFlowNets
• synthflow: high-level API and pocket-conditional/specific training
High-Level Architecture Overview
• This is not a monolithic web or full-stack app but a modular ML framework with:
A. Core packages under src/: cgflow, gflownet, rxnflow, synthflow
B. Data preparation & experiment orchestration under experiments/ and scripts/
C. Configuration & metadata: pyproject.toml, yaml sweeps, README, LICENSE
D. Assets & figures for documentation and demo
1) Data Sources
• experiments/data/: raw datasets (PLINDER, LIT-PCBA, CrossDocked, Enamine catalogs)
• assets/: reference images
2) Data Processing & Loading
• experiments/data/scripts/ & scripts/: Python + shell scripts that download, clean, convert SDF → SMILES, build LMDB, create environments
• src/*/data modules (e.g. cgflow/data/datamodules.py, gflownet/data/data_source.py, rxnflow/utils/*)
3) Core Libraries
• cgflow/ buildutil, data, models, util
• gflownet/ algo, data, envs, models, trainer, tasks, utils
• rxnflow/ base, algo, communication, envs, models, policy, tasks, utils
• synthflow/ api, base, pocket_conditional, pocket_specific, tasks, utils
4) Training & Inference Engines
• Trainer classes (cgflow/buildutil/build_trainer.py, gflownet/trainer.py, rxnflow/base/trainer.py, synthflow/base/trainer.py)
• Online trainers & CLI entrypoints (src/gflownet/online_trainer.py, src/rxnflow/base/gflownet/online_trainer.py, synthflow/api/inference.py)
5) Experiment Orchestration & Hyperparameter Sweeps
• experiments/scripts/exp*.py and experiments/sweep/*.yaml drive training, evaluation, wandb sweeps
• Top-level shell wrappers in scripts/*.sh
6) Outputs & Artifacts
• weights/: model checkpoints
• logs/: wandb & local logs
• results: images, tables, saved LMDB datasets
• Data Sources → Data Processing scripts → DataModule (in core libs)
• DataModule → Trainer → Model
• Model ↔ GFlowNet Algorithms (flow_matching, trajectory_balance, A2C, etc.)
• Trainer → Logs & Checkpoints → Experiments & Evaluation scripts
• Evaluation scripts → Metrics & Visualizations (assets/)
• synthflow/api → inference endpoint (e.g. Streamlit demo)
Architectural Patterns & Principles
• Layered modularity: separation of data, model, training, evaluation
• Plugin-style algorithms: gflownet/algo and rxnflow/algo share a common config interface
• Config-driven: YAML sweep files, python config modules (config.py), pyproject.toml
• Extensibility: each flow (cgflow, gflownet, rxnflow, synthflow) can be used standalone or composed