Python

Python quickstart

Install DeepMedChem, authenticate once, and search chemical space as a Python library.

Suggest an edit

Install the chemistry-thin SDK. It contains no RDKit, model weights, or local chemical-space data.

python -m pip install deepmedchem
deepmedchem login

For a one-off search, import the package and call the scientific operation directly:

import deepmedchem as dmc

hits = dmc.search(
    "CC(=O)Oc1ccccc1C(=O)O",
    database="enamine-real-v5a",
    method="shape",
    limit=9,
)

print(hits)
# SearchResult(9 molecules, method='shape', database='enamine-real-v5a')

hits[:3]       # list[str]
hits.smiles    # list[str]
hits.scores    # list[float | None]
hits.prices    # list[int | None]

SearchResult is an ordered sequence of SMILES. Iteration, indexing, slicing, and smiles all use the same ranking. Typed row access and provenance remain available without another request:

for hit in hits.hits:
    print(hit.rank, hit.smiles, hit.score, hit.price, hit.product_id)

print(hits.meta.release)
print(hits.request_id)
print(hits.raw["timing_ms"])

Prices are positive whole US dollars for US delivery and default to 1 mg where the vendor uses pack sizes. hit.price and the aligned hits.prices list use the original response and require no additional request; an unavailable price is None. See chemical spaces and capabilities for database support.

Use an explicit client when several calls should reuse one connection or when working with selections and durable runs:

from deepmedchem import Client

with Client() as client:
    first = client.search("CCO", database="enamine-real-v5a", method="morgan")
    second = client.search("CCN", database="enamine-real-v5a", method="esp")

In automation, inject DEEPMEDCHEM_API_KEY instead of running interactive login. The compatibility variables DMC_API_KEY and CHEESE_API_KEY remain supported during migration.

Other bounded operations

motif_hits = dmc.substructure(
    "[N;R0]C(=O)[N;R0]",
    database="enamine-real-v5a",
    format="smarts",
    limit=20,
)

molecules = dmc.sample(database="enamine-real-v5a", count=100, seed=12345)
catalog = dmc.catalog()

Substructure and sample results preserve alignment with None scores; the SDK never invents a numeric similarity for an exact or random result. deepmedchem.aio supplies matching short-lived async operations, while AsyncClient supports explicit connection reuse.

On this page