Overview
Oracles are scoring functions that evaluate molecular properties during optimization. ChemLactica uses oracles to guide the generation of molecules with desired characteristics.Oracle Structure
A custom oracle is a Python class that implements specific methods and properties. Here’s the basic structure:Step-by-Step Implementation
1
Define the Oracle Class
Create a new class and initialize required attributes in
__init__:2
Implement the Scoring Logic
Define the
__call__ method to compute scores:3
Add Logging Functionality
Implement
log_intermediate() to track optimization progress:4
Implement Required Properties
Add the required properties and methods:
Using Your Oracle
Once your oracle is defined, use it with the optimization workflow:Oracle Configuration
Key configuration parameters for optimization (defined in your YAML config):Example: QED Oracle
Here’s a simpler oracle that maximizes QED (drug-likeness):Best Practices
Caching Strategy
Caching Strategy
Always cache computed scores in
mol_buffer to avoid redundant calculations:Error Handling
Error Handling
Wrap scoring calculations in try-except blocks to handle invalid molecules:
Score Normalization
Score Normalization
Set
max_possible_oracle_score to help the model understand the score range:Logging Frequency
Logging Frequency
Log intermediate results periodically to track progress:
The
takes_entry attribute determines whether __call__ receives MoleculeEntry objects (with .mol and .fingerprint attributes) or just SMILES strings.Next Steps
Property Prediction
Learn how to fine-tune models for property prediction
Benchmarking
Evaluate your oracle’s performance