Skip to main content

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__:
Set takes_entry = True if your oracle needs access to RDKit molecule objects and fingerprints from MoleculeEntry.
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

Always cache computed scores in mol_buffer to avoid redundant calculations:
Wrap scoring calculations in try-except blocks to handle invalid molecules:
Set max_possible_oracle_score to help the model understand the score range:
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