Skip to main content
Docs

Search guides and API endpoints, for example “Idempotency-Key” or “submit job”.

    Tools · Computational Biology

    Thompson Sampling

    Active-learning virtual screening of un-enumerated combinatorial libraries via Thompson Sampling
    On this page

    Prices, workflows, and method papersOpen in the app

    Run it from the API

    Submit with Submit a job and the job_type below. Price it first with Estimate job reservation cost: submitting reserves that amount from your wallet, and the charge settles at the actual runtime.

    Thompson Sampling thompsonsampling

    Job type
    thompsonsampling
    Hardware
    cpu (default)
    Typical runtime
    30 min on CPU

    Payload

    Provide at least one of: reagents, reagent_lists.

    Payload fields
    FieldTypeDescription
    reaction_smartsrequiredstring

    Limits: min length 1

    reagents[]reagent_component[]

    Limits: min items 1

    reagents.smiles[]string[]

    Limits: min items 1

    reagents.filefile_payload
    reagents.file.filenamerequiredstring

    Limits: min length 1

    reagents.file.contentstring

    Limits: min length 1

    reagents.file.content_base64string

    Limits: min length 1

    reagent_lists[]string[][]

    Limits: min items 1

    num_warmup_trialsrequiredinteger

    Limits: ≥ 1

    num_ts_iterationsinteger

    Default: 2000Limits: ≥ 1

    evaluator_class_namerequiredstring

    One of: "FPEvaluator", "MWEvaluator", "MLClassifierEvaluator", "LookupEvaluator"

    evaluator_argobject
    evaluator_arg.query_smilesstring

    Limits: min length 1

    evaluator_arg.ref_colnamestring

    Limits: min length 1

    ts_moderequiredstring

    One of: "maximize", "minimize", "maximize_boltzmann", "minimize_boltzmann"

    max_reagents_per_componentinteger

    Default: 10000Limits: ≥ 1, ≤ 10000

    model_filefile_payload
    model_file.filenamerequiredstring

    Limits: min length 1

    model_file.contentstring

    Limits: min length 1

    model_file.content_base64string

    Limits: min length 1

    lookup_filefile_payload
    lookup_file.filenamerequiredstring

    Limits: min length 1

    lookup_file.contentstring

    Limits: min length 1

    lookup_file.content_base64string

    Limits: min length 1

    known_stdnumber
    minimum_uncertaintynumber

    Example

    from cognichem_client import CogniChem
    
    client = CogniChem.from_env()  # reads COGNICHEM_API_KEY
    payload = {
        "reaction_smarts": "[NH2:2][#6:1].[#6:4][C:3]([OH])=O>>[NH:2]([#6:1])[C:3]([#6:4])=O",
        "reagents": [
            {
                "smiles": [
                    "CNC(=O)c1n[nH]c(N)n1",
                    "N=C(N)CN1CC[C@H](O)C1",
                    "COC[C@@H](O)CN",
                    "NC(=O)CN1CCOCC1",
                    "CNC(=S)NC(=N)N",
                    "… 5 more",
                ],
            },
            {
                "smiles": [
                    "N=C(N)NC[C@@H](N)C(=O)O",
                    "CN(C)C[C@@H](N)C(=O)O",
                    "Nc1nnn(CC(=O)O)n1",
                    "COC(=O)[C@@H](O)CC(=O)O",
                    "N=C(N)NC[C@H](N)C(=O)O",
                    "… 5 more",
                ],
            },
        ],
        "num_warmup_trials": 3,
        "num_ts_iterations": 25,
        "evaluator_class_name": "FPEvaluator",
        "evaluator_arg": {"query_smiles": "CCc1cccc2c(=O)n(C3CNC3)c([C@@H](C)N)nc12"},
        "ts_mode": "maximize",
    }
    
    estimate = client.jobs.estimate(job_type="thompsonsampling", payload=payload, resource="cpu")
    print(f"Reserves ${estimate.cost:.2f}")
    
    job = client.jobs.submit(
        job_name="my-thompsonsampling-run",
        job_type="thompsonsampling",
        payload=payload,
        resource="cpu",
    )
    status = client.jobs.wait(job.process_id)
    if status.status == "completed":
        client.jobs.result(job.process_id, save_path=".")

    Sample data from the job catalog; long values are shortened here. Each job_name must be unique among your jobs.

    Workflow inputs

    None

    Workflow outputs

    • ArchiveZIP
    • MoleculesSMILES