scientific-skills/torchdrug/references/molecular_generation.md
Molecular generation involves creating novel molecular structures with desired properties. TorchDrug supports both unconditional generation (exploring chemical space) and conditional generation (optimizing for specific properties).
Generates molecules step-by-step by sequentially adding atoms and bonds. This approach enables fine-grained control and property optimization during generation.
Key Features:
Generation Strategies:
Property Optimization:
Uses reinforcement learning to generate molecules optimized for specific properties.
Components:
Advantages:
Applications:
Normalizing flow model for molecular generation with exact likelihood computation.
Architecture:
Key Features:
Training:
Use Cases:
Generate diverse molecules without specific property targets.
Workflow:
Evaluation Metrics:
Generate molecules optimized for specific properties.
Property Targets:
Workflow:
Generate molecules around a fixed scaffold or core structure.
Applications:
Approaches:
Build molecules from validated fragments.
Benefits:
Methods:
Maximize or minimize a single property (e.g., binding affinity).
Approach:
Challenges:
Balance multiple competing objectives (e.g., potency, selectivity, synthesizability).
Weighting Approaches:
Example Objectives:
Workflow:
from torchdrug import tasks
# Define multi-objective reward
def reward_function(mol):
affinity_score = predict_binding(mol)
druglikeness = calculate_qed(mol)
synthesizability = sa_score(mol)
# Weighted combination
reward = 0.5 * affinity_score + 0.3 * druglikeness + 0.2 * (1 - synthesizability)
return reward
# GCPN task with custom reward
task = tasks.GCPNGeneration(
model,
reward_function=reward_function,
criterion="ppo" # Proximal policy optimization
)
Generate molecules satisfying hard constraints.
Common Constraints:
Implementation:
ZINC (Drug-like compounds):
QM9 (Small organic molecules):
ChEMBL (Bioactive molecules):
Custom Datasets:
SMILES Augmentation:
Graph Augmentation:
For Small Molecules (<30 atoms):
For Drug-like Molecules:
For Macrocycles/Polymers:
Chemical Validity:
Drug-likeness Filters:
Synthesizability:
Property Prediction:
Criteria:
Selection Strategies:
Docking:
Retrosynthesis:
Property Prediction:
Active Learning: