Skill Tracer
Skills › Scientific Agent Skills › pytdc › oracles.md

oracles.md

278 lines · skills/pytdc/references/oracles.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Molecular generation and PyTDC oracles
2
3This reference targets **PyTDC 1.1.15**, verified 2026-10-01. Oracle names and
4behavior are heterogeneous. Discover the installed registry and classify side
5effects before constructing an `Oracle`.
6

Molecular generation and PyTDC oracles

This reference targets PyTDC 1.1.15, verified 2026-10-01. Oracle names and behavior are heterogeneous. Discover the installed registry and classify side effects before constructing an Oracle.

Raw lines 1 to 6
7## PyTDC's role
8
9Core PyTDC provides:
11- molecular corpora through `tdc.generation.MolGen`;
12- `Evaluator` functions for generated sets;
13- scalar, composite, checkpoint-backed, remote-service, and docking oracles.
15It does not supply one universal trainable molecule generator. Users bring or
16implement the generative model and must define a scientifically justified
17objective, constraints, validation protocol, and experimental follow-up.

PyTDC's role

Core PyTDC provides:

  • molecular corpora through tdc.generation.MolGen;
  • Evaluator functions for generated sets;
  • scalar, composite, checkpoint-backed, remote-service, and docking oracles.

It does not supply one universal trainable molecule generator. Users bring or implement the generative model and must define a scientifically justified objective, constraints, validation protocol, and experimental follow-up.

Raw lines 7 to 18
19## Discover names without calling an oracle
21```bash
22uv run --no-project --isolated --python 3.11 --with "setuptools==80.9.0" --with "PyTDC==1.1.15" \
23 python scripts/discover_metadata.py --kind oracles --limit 100
24```
26This reads `tdc.metadata.oracle_names`; it does not instantiate an oracle, download
27a checkpoint/receptor, or transmit a SMILES string.
29Use exact names. PyTDC fuzzy matching can silently normalize approximate input,
30which is undesirable for expensive or remote operations.

Discover names without calling an oracle

uv run --no-project --isolated --python 3.11 --with "setuptools==80.9.0" --with "PyTDC==1.1.15" \
  python scripts/discover_metadata.py --kind oracles --limit 100

This reads tdc.metadata.oracle_names; it does not instantiate an oracle, download a checkpoint/receptor, or transmit a SMILES string.

Use exact names. PyTDC fuzzy matching can silently normalize approximate input, which is undesirable for expensive or remote operations.

Raw lines 19 to 31
Runs code python scripts/discover_metadata.py :23
32## Side-effect categories in the stable metadata

Side-effect categories in the stable metadata

Raw lines 32 to 33
34### Local scalar property
36Verified direct local scalar name:
38```text
39qed
40```
42`qed` requires RDKit but no PyTDC model artifact. It is the quantitative estimate
43of drug-likeness; higher is more drug-like on its documented 0–1 scale.
45Although upstream metadata groups `logp` and `sa` with “trivial” oracles, source
46and execution verification show that both call `calculateScore`, which downloads
47the `fpscores` artifact when absent. Treat both as download-backed.

Local scalar property

Verified direct local scalar name:

qed

qed requires RDKit but no PyTDC model artifact. It is the quantitative estimate of drug-likeness; higher is more drug-like on its documented 0–1 scale.

Although upstream metadata groups logp and sa with “trivial” oracles, source and execution verification show that both call calculateScore, which downloads the fpscores artifact when absent. Treat both as download-backed.

Raw lines 34 to 48
49### Local composite/GuacaMol-style objectives
51The registry contains rediscovery, similarity, isomer, median, MPO, SMARTS, and hop
52objectives. Some names use fixed targets; `*_meta` variants require constructor
53arguments such as `target_smiles`.
55Do not infer a constructor signature or score direction from the name. Read the
56matching official oracle section and stable source before use. The bundled CLI does
57not execute these objectives.

Local composite/GuacaMol-style objectives

The registry contains rediscovery, similarity, isomer, median, MPO, SMARTS, and hop objectives. Some names use fixed targets; *_meta variants require constructor arguments such as target_smiles.

Do not infer a constructor signature or score direction from the name. Read the matching official oracle section and stable source before use. The bundled CLI does not execute these objectives.

Raw lines 49 to 58
59### Checkpoint-backed models
61Stable download metadata includes:
63```text
64drd2, gsk3b, jnk3, cyp3a4_veith, fpscores,
65drd2_current, gsk3b_current, jnk3_current
66```
68Constructing one can call Harvard Dataverse and write a model file beneath
69`./oracle`. For DRD2/GSK3B/JNK3, PyTDC may normalize the request to a `_current`
70checkpoint according to the installed scikit-learn version.
72Checkpoint files are serialized model artifacts. Review source, origin, local path,
73size, and trust boundary before download/loading. The bundled CLI supports only
74bounded LogP/SA/DRD2/GSK3B/JNK3/CYP3A4_Veith calls and requires both `--execute`
75and `--download`.
77The 1.1.15 `LogP` oracle is not raw octanol/water partition alone. It implements
78the normalized **penalized logP** objective: RDKit MolLogP plus a normalized
79negative synthetic-accessibility term and a large-cycle penalty. Higher is the
80objective's optimization direction. `SA` returns synthetic accessibility, for
81which lower conventionally means easier synthesis. Do not combine either with
82other scores without documenting transformation, scale, and direction.

Checkpoint-backed models

Stable download metadata includes:

drd2, gsk3b, jnk3, cyp3a4_veith, fpscores,
drd2_current, gsk3b_current, jnk3_current

Constructing one can call Harvard Dataverse and write a model file beneath ./oracle. For DRD2/GSK3B/JNK3, PyTDC may normalize the request to a _current checkpoint according to the installed scikit-learn version.

Checkpoint files are serialized model artifacts. Review source, origin, local path, size, and trust boundary before download/loading. The bundled CLI supports only bounded LogP/SA/DRD2/GSK3B/JNK3/CYP3A4_Veith calls and requires both --execute and --download.

The 1.1.15 LogP oracle is not raw octanol/water partition alone. It implements the normalized penalized logP objective: RDKit MolLogP plus a normalized negative synthetic-accessibility term and a large-cycle penalty. Higher is the objective's optimization direction. SA returns synthetic accessibility, for which lower conventionally means easier synthesis. Do not combine either with other scores without documenting transformation, scale, and direction.

Raw lines 59 to 83
84### Distribution evaluators
86The Oracle/Evaluator registries include:
88```text
89novelty, diversity, uniqueness, validity, fcd_distance, kl_divergence
90```
92These operate on collections, and several need a training/reference set. They are
93not interchangeable scalar objectives:
95- validity/uniqueness/novelty/diversity are higher by their documented definitions;
96- `kl_divergence` returns mean `exp(-KL)`, so higher means closer distributions;
97- `fcd_distance` returns transformed similarity with TensorFlow/FCD but raw distance
98 with PyTorch/fcd_torch in 1.1.15; record backend and transformation before ranking;
99- unpatched KL fails on modern SciPy because of removed `scipy.histogram`; see
100 [utilities.md](utilities.md) for the verified compatibility limitation;
101- novelty and distribution comparisons depend on the exact reference corpus and
102 canonicalization;
103- optional chemical-model dependencies may be substantial.
105Use `Evaluator` and the official input signature. Do not send these through the
106bundled scalar-scoring helper.

Distribution evaluators

The Oracle/Evaluator registries include:

novelty, diversity, uniqueness, validity, fcd_distance, kl_divergence

These operate on collections, and several need a training/reference set. They are not interchangeable scalar objectives:

  • validity/uniqueness/novelty/diversity are higher by their documented definitions;
  • kl_divergence returns mean exp(-KL), so higher means closer distributions;
  • fcd_distance returns transformed similarity with TensorFlow/FCD but raw distance with PyTorch/fcd_torch in 1.1.15; record backend and transformation before ranking;
  • unpatched KL fails on modern SciPy because of removed scipy.histogram; see utilities.md for the verified compatibility limitation;
  • novelty and distribution comparisons depend on the exact reference corpus and canonicalization;
  • optional chemical-model dependencies may be substantial.

Use Evaluator and the official input signature. Do not send these through the bundled scalar-scoring helper.

Raw lines 84 to 107
108### Remote synthesis services
110Metadata includes `askcos` and `ibm_rxn`. Official documentation describes extra
111host/API inputs. Calling them can transmit molecular structures and credentials to
112an external service.
114Before any call:
1161. identify the exact service operator and current terms;
1172. determine whether the molecule is confidential or patent-sensitive;
1183. obtain explicit user approval for transmission and cost;
1194. read only the named credential required by that service;
1205. never print or save the credential in JSON, logs, or command arguments;
1216. enforce request/time/call limits.
123The bundled script intentionally refuses these remote services. The 1.1.15 docs may
124show historical endpoints or token flows; verify them with the service provider.

Remote synthesis services

Metadata includes askcos and ibm_rxn. Official documentation describes extra host/API inputs. Calling them can transmit molecular structures and credentials to an external service.

Before any call:

  1. identify the exact service operator and current terms;
  2. determine whether the molecule is confidential or patent-sensitive;
  3. obtain explicit user approval for transmission and cost;
  4. read only the named credential required by that service;
  5. never print or save the credential in JSON, logs, or command arguments;
  6. enforce request/time/call limits.

The bundled script intentionally refuses these remote services. The 1.1.15 docs may show historical endpoints or token flows; verify them with the service provider.

Raw lines 108 to 125
126### Receptor and docking oracles
128The registry contains PDB-specific names ending in `_docking`,
129`_docking_normalize`, and `_docking_vina`, plus specialized names such as
130`pyscreener`, `docking_score`, `smina`, `rmsd`, and `kabsch_rmsd`.
132These paths can involve:
134- receptor PDB/PDBQT downloads;
135- local executables and substantial CPU/storage;
136- user-specified box centers/sizes;
137- generated conformers and temporary files;
138- license restrictions for docking software;
139- remote or proprietary synthesis scoring in benchmark evaluation.
141Raw docking energies and normalized variants have different directions. Never infer
142direction from a generic “Docking” label. The bundled molecular CLI and benchmark
143CLI do not execute docking.

Receptor and docking oracles

The registry contains PDB-specific names ending in _docking, _docking_normalize, and _docking_vina, plus specialized names such as pyscreener, docking_score, smina, rmsd, and kabsch_rmsd.

These paths can involve:

  • receptor PDB/PDBQT downloads;
  • local executables and substantial CPU/storage;
  • user-specified box centers/sizes;
  • generated conformers and temporary files;
  • license restrictions for docking software;
  • remote or proprietary synthesis scoring in benchmark evaluation.

Raw docking energies and normalized variants have different directions. Never infer direction from a generic “Docking” label. The bundled molecular CLI and benchmark CLI do not execute docking.

Raw lines 126 to 144
145## Bounded local scoring
147Plan first:
149```bash
150python scripts/molecular_generation.py score \
151 --oracle QED \
152 --smiles "CCO"
153```
155The JSON plan reports classification, input count, runtime directory, and required
156acknowledgement. It does not instantiate `Oracle`.
158Execute a local scalar only after review:
160```bash
161python scripts/molecular_generation.py score \
162 --oracle QED \
163 --smiles "CCO" \
164 --execute
165```
167Execute a supported checkpoint-backed model only after approving the checkpoint:
169```bash
170python scripts/molecular_generation.py score \
171 --oracle DRD2 \
172 --smiles "CCO" \
173 --runtime-dir .pytdc-oracles \
174 --execute --download
175```
177The helper:
179- accepts at most 500 SMILES and a 1 MiB input file;
180- keeps output in input order with a zero-based index and explicit validity flag;
181- emits `score: null` for invalid or zero-atom structures without scoring them;
182- truncates long strings;
183- never ranks candidates or assumes score direction;
184- changes into the safe runtime directory so upstream `./oracle` writes remain
185 contained;
186- refuses remote services, docking, distribution metrics, and composite objectives.

Bounded local scoring

Plan first:

python scripts/molecular_generation.py score \
  --oracle QED \
  --smiles "CCO"

The JSON plan reports classification, input count, runtime directory, and required acknowledgement. It does not instantiate Oracle.

Execute a local scalar only after review:

python scripts/molecular_generation.py score \
  --oracle QED \
  --smiles "CCO" \
  --execute

Execute a supported checkpoint-backed model only after approving the checkpoint:

python scripts/molecular_generation.py score \
  --oracle DRD2 \
  --smiles "CCO" \
  --runtime-dir .pytdc-oracles \
  --execute --download

The helper:

  • accepts at most 500 SMILES and a 1 MiB input file;
  • keeps output in input order with a zero-based index and explicit validity flag;
  • emits score: null for invalid or zero-atom structures without scoring them;
  • truncates long strings;
  • never ranks candidates or assumes score direction;
  • changes into the safe runtime directory so upstream ./oracle writes remain contained;
  • refuses remote services, docking, distribution metrics, and composite objectives.
Raw lines 145 to 187
Runs code python scripts/molecular_generation.py :150
188## Direct Oracle API
190After side-effect review:
192```python
193from tdc import Oracle
195oracle = Oracle(name="QED", num_max_call=100)
196scores = oracle(["CCO", "c1ccccc1"])
197```
199`num_max_call` bounds accumulated valid scalar calls for supported paths. It is not
200a network timeout, memory limit, or cost limit.
202For list input, PyTDC validates each SMILES with RDKit. Invalid entries can receive
203the oracle's default value (commonly zero) rather than raising. The bundled helper pre-validates
204structures and emits an explicit validity flag plus null score for these inputs;
205do not interpret an upstream default as a measured low score.
207Oracle results are predictions or computed proxies, not experimental evidence.
208Applicability domains, model training data, stereochemistry, protonation,
209tautomerization, salts, and assay context can materially change interpretation.

Direct Oracle API

After side-effect review:

from tdc import Oracle

oracle = Oracle(name="QED", num_max_call=100)
scores = oracle(["CCO", "c1ccccc1"])

num_max_call bounds accumulated valid scalar calls for supported paths. It is not a network timeout, memory limit, or cost limit.

For list input, PyTDC validates each SMILES with RDKit. Invalid entries can receive the oracle's default value (commonly zero) rather than raising. The bundled helper pre-validates structures and emits an explicit validity flag plus null score for these inputs; do not interpret an upstream default as a measured low score.

Oracle results are predictions or computed proxies, not experimental evidence. Applicability domains, model training data, stereochemistry, protonation, tautomerization, salts, and assay context can materially change interpretation.

Raw lines 188 to 210
211## MolGen datasets
213Discover the exact stable registry:
215```bash
216python scripts/discover_metadata.py --kind datasets --task MolGen
217```
219Plan a random split:
221```bash
222python scripts/molecular_generation.py dataset \
223 --dataset MOSES \
224 --seed 42 \
225 --data-dir .pytdc-molgen
226```
228MolGen corpora can contain hundreds of thousands or millions of structures. Review
229the official page, per-dataset license, compressed/decompressed size, free disk,
230and network budget. Execution intentionally requires both flags:
232```bash
233python scripts/molecular_generation.py dataset \
234 --dataset MOSES \
235 --seed 42 \
236 --data-dir .pytdc-molgen \
237 --execute --download
238```
240PyTDC 1.1.15's MolGen loader exposes random split only. The supplied seed controls
241test sampling, while the generic splitter uses fixed `random_state=1` for
242validation sampling.

MolGen datasets

Discover the exact stable registry:

python scripts/discover_metadata.py --kind datasets --task MolGen

Plan a random split:

python scripts/molecular_generation.py dataset \
  --dataset MOSES \
  --seed 42 \
  --data-dir .pytdc-molgen

MolGen corpora can contain hundreds of thousands or millions of structures. Review the official page, per-dataset license, compressed/decompressed size, free disk, and network budget. Execution intentionally requires both flags:

python scripts/molecular_generation.py dataset \
  --dataset MOSES \
  --seed 42 \
  --data-dir .pytdc-molgen \
  --execute --download

PyTDC 1.1.15's MolGen loader exposes random split only. The supplied seed controls test sampling, while the generic splitter uses fixed random_state=1 for validation sampling.

Raw lines 211 to 243
Runs code python scripts/discover_metadata.py :216
Runs code python scripts/molecular_generation.py :222
244## Goal-directed optimization safeguards
246Before optimizing:
248- define whether every objective is maximized, minimized, targeted, or constrained;
249- normalize only with justified transformations;
250- separate train, validation, and final evaluation budgets;
251- cap total unique oracle calls and deduplicate canonical structures;
252- record invalid/failed/time-out results rather than silently dropping them;
253- retain all candidates and scores needed for audit, but keep chat/CLI output
254 bounded;
255- monitor exploitation of model artifacts and out-of-domain structures;
256- evaluate novelty against the exact declared training/reference set;
257- add medicinal-chemistry, synthesizability, selectivity, safety, and diversity
258 review rather than relying on a single score;
259- treat computational hits as hypotheses requiring expert and experimental
260 validation.
262Do not claim a weighted sum is scientifically valid merely because every term is
263numerical.

Goal-directed optimization safeguards

Before optimizing:

  • define whether every objective is maximized, minimized, targeted, or constrained;
  • normalize only with justified transformations;
  • separate train, validation, and final evaluation budgets;
  • cap total unique oracle calls and deduplicate canonical structures;
  • record invalid/failed/time-out results rather than silently dropping them;
  • retain all candidates and scores needed for audit, but keep chat/CLI output bounded;
  • monitor exploitation of model artifacts and out-of-domain structures;
  • evaluate novelty against the exact declared training/reference set;
  • add medicinal-chemistry, synthesizability, selectivity, safety, and diversity review rather than relying on a single score;
  • treat computational hits as hypotheses requiring expert and experimental validation.

Do not claim a weighted sum is scientifically valid merely because every term is numerical.

Raw lines 244 to 264
265## Unsupported historical examples removed
267The stable 1.1.15 metadata/public imports do not support old examples that presented
268the following as generic ready-to-use APIs:
270- `PairMolGen` / `Prodrug`;
271- `MolGen(name="GuacaMol")`;
272- `evaluate_guacamol(...)`;
273- scalar `MW`, `Lipinski`, generic `Docking`, or generic `Vina` oracle names;
274- target oracles such as `5HT2A`, `ACE`, `MAPK`, `CDK`, `P38`, `PARP1`, or
275 `PIK3CA`.
277Do not restore these names without verifying a newer official package registry and
278source implementation.

Unsupported historical examples removed

The stable 1.1.15 metadata/public imports do not support old examples that presented the following as generic ready-to-use APIs:

  • PairMolGen / Prodrug;
  • MolGen(name="GuacaMol");
  • evaluate_guacamol(...);
  • scalar MW, Lipinski, generic Docking, or generic Vina oracle names;
  • target oracles such as 5HT2A, ACE, MAPK, CDK, P38, PARP1, or PIK3CA.

Do not restore these names without verifying a newer official package registry and source implementation.

Raw lines 265 to 278