TS Second Opinion

v0.3.0
io.github.tammy357/ts-second-opinion Checked 1 day ago Published 14 days ago

Second opinion on ML transition-state guesses: trust, check with DFT or re-generate

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_reactions

List reactions in the RDB7 test set (1,194 reactions, 8 GoFlow guesses each) with their triage verdict. verdict: 'green' (trust), 'amber' (check with DFT) or 'red' (re-generate). mirror_repaired: filter repaired ones.

ParameterTypeDescription
limitinteger
mirror_repaired
offsetinteger
verdict

triage_reaction

Triage one RDB7 test reaction: run every gated rule on all 8 GoFlow guesses, pick the consensus among guesses that pass, repair a wrong-handed stereocentre by mirroring if that makes it pass, and return a verdict with reasons and the recommended TS geometry (xyz). score_against_reference adds D-MAE and stereo correctness against the reference DFT TS (evaluation only).

ParameterTypeDescription
reaction_id *integer
score_against_referenceboolean

triage_structures

Triage your own reaction, from any TS generator and with any elements. Give the reactant and product geometries and one or more TS guesses as xyz text (multi-frame xyz allowed); several guesses enable the model-disagreement signal. mapped_reaction_smiles is optional: without it, bonds, bond orders and stereocentres are read from the reactant and product geometries (every file must then list the same atoms in the same order) and the inferred SMILES is returned for checking; charge and multiplicity then default to 0 and 1. With a SMILES (every atom, hydrogens too, mapped 1..N…

ParameterTypeDescription
guesses_xyz *array
product_xyz *string
reactant_xyz *string
charge
mapped_reaction_smilesstring
multiplicity
orderstring

triage_batch

Triage many reactions on disk at once. path: a folder with one sub-folder per reaction (reactant.xyz, product.xyz, the TS guess .xyz files, optional reaction.smi), or a .csv with columns id, reactant, product, guesses (and optional smiles, charge, multiplicity). Writes out_dir/verdicts.csv, the recommended geometry per reaction and ORCA inputs for reactions to check with DFT or re-generate. charge/multiplicity apply to reactions without a SMILES.

ParameterTypeDescription
path *string
chargeinteger
multiplicityinteger
out_dirstring
reportsboolean

list_rules

List the plain-English rules, their gate results, and whether each is used in triage.

get_rule_source

Show the Python code of a rule, so you can read it or use it as an example.

ParameterTypeDescription
name *string

gate_check

Test a candidate rule check against 9,540 real DFT transition states (RDB7 training set) and distorted ones. python_source must define check(rxn, xyz) -> (passed: bool, detail: str); numpy is available as np and math as math; no imports. rxn offers: n, atoms, symbols, reactant_xyz, product_xyz, reactant_bonds, product_bonds ({(i, j): order}), changed_bonds, reaction_centre, neighbours('reactant'|'product'), reactant_chiral_tags, product_chiral_tags. Accepted if it passes >= 99% of real TSs, never crashes, and rejects >= 1% of mirrored or noisy TSs. Returns failing examples…

ParameterTypeDescription
python_source *string
rule_text *string

save_rule

Save a rule check that passes the gate (re-tested on save). By default it goes to tsso/checks_user and is not used in triage; set use_in_triage=True only when a person has asked for it.

ParameterTypeDescription
name *string
python_source *string
rule_text *string
use_in_triageboolean

write_orca_input

Write an ORCA TS-optimisation input (wB97X-D4/def2-TZVP OptTS Freq, as in GoFlow's tsopt.inp) for the recommended guess of a test reaction. Returns the file paths and input text.

ParameterTypeDescription
reaction_id *integer

audit_rdb7_dataset

Data-quality audit of RDB7: reactions whose reactant or product geometry contradicts the atom-mapped SMILES (atoms at single-bond distance that the SMILES does not bond, or a SMILES bond whose atoms are far apart). Uploaded reactions get the same check automatically (input_warnings in triage_structures).

evaluate_predictions

Stereo-aware evaluation of any TS generator: multi-frame xyz text of predictions and of reference TSs (one frame per reaction, same order) plus the atom-mapped reaction SMILES. Returns D-MAE, RMSD with and without the mirror image allowed, success rate, share with correct handedness, and success with correct handedness.

ParameterTypeDescription
predictions_xyz *string
reaction_smiles *array
references_xyz *string
orderstring

certify_trust

Certified trust (conformal selection): calibrate on a random half of the RDB7 test reactions, then return which of the other half can be trusted so that, on average, at most target_error_rate of the trusted ones are wrong. count: 'geometry' (D-MAE > 0.2 A; what matters for barriers) or 'geometry_or_handedness'. The guarantee assumes new reactions are drawn like the calibration ones; recalibrate when the generator or data change.

ParameterTypeDescription
countstring
seedinteger
target_error_ratenumber

benchmark_summary

Headline results, split into geometry errors and handedness errors: rates before and after, how many wrong-handed guesses the rules catch and how many are whole mirror images (same energy, so even DFT would not flag them), certified-trust numbers, and risk-coverage curves.