Skip to main content

scigantic-chembl

CI PyPI PyPI - Python Version License

Query ChEMBL directly from a public S3 mirror with DuckDB.

import scigantic_chembl as chembl

df = chembl.query("""
    SELECT chembl_id, pref_name
    FROM molecule_dictionary
    WHERE pref_name IS NOT NULL
    LIMIT 5
""")

That query runs against s3://scigantic-chembl over DuckDB's httpfs extension. Nothing is downloaded first, and there's no local database file sitting on disk afterward.

Installation

$ pip install scigantic-chembl

Compared to chembl-downloader

chembl-downloader is the standard way to work with ChEMBL in Python. It covers every release back to chembl_1, and once the SQLite dump is downloaded it works fully offline. This package gives up that range for less setup and two things chembl-downloader doesn't ship on its own: a pre-joined potency table, and similarity search with no separate index build. The mirror here only carries chembl_35 through chembl_37, and only chembl_37 has the pre-joined and similarity layers, so an older release or fully offline work is still a job for chembl-downloader.

Potency data, pre-joined

activities needs a five-table join and a few correctness filters before it's usable for structure-activity work. That join is already done, stored as derived/activities_enriched.parquet:

df = chembl.activities(target_chembl_id="CHEMBL203")  # EGFR: 18,998 rows, 11,202 compounds

The filters already applied are about correctness, not taste: pchembl_value present, standard_relation = '=', no data_validity_comment, not a potential_duplicate. confidence_score and target_type stay as columns rather than filters, since which rows count as usable SAR data is an analysis choice:

df = chembl.activities(target_chembl_id="CHEMBL203", min_confidence=8)

chembl.query() still reaches the raw tables directly for anything the join leaves out.

Similarity search

gefitinib = "COC1=C(C=C2C(=C1)N=CN=C2NC3=CC(=C(C=C3)F)Cl)OCCCN4CCOCC4"
hits = chembl.similar_compounds(gefitinib, top_k=5)
    chembl_id  tanimoto
    CHEMBL939  1.000000
  CHEMBL14699  0.919355
CHEMBL4165375  0.916667
 CHEMBL299672  0.857143
CHEMBL4448162  0.857143

CHEMBL939 is gefitinib itself. Every compound with a comparable potency measurement (1.68M of ChEMBL's 2.9M structures) has a precomputed 2048-bit Morgan fingerprint, kept packed in memory and compared with numpy's bitwise_count rather than unpacked bit by bit. The corpus loads once per process, about 18 seconds on a typical home connection and faster from inside AWS; every call after that in the same process is under half a second. chembl-downloader can do similarity search too, through chemfp, but its own docs put building that index at tens of minutes.

Similarity search needs rdkit to encode the query molecule, so it's kept as an optional extra:

$ pip install "scigantic-chembl[similarity]"

What's mirrored

chembl.releases()
release raw tables pre-joined activities similarity search CYP training set
chembl_37 yes yes yes yes
chembl_36 yes no no yes
chembl_35 yes no no yes

chembl_36 and chembl_35 are raw-table access only: their activities table is missing a column chembl_37's has (modality), so calling activities() or similar_compounds() on either one raises ReleaseCapabilityError up front instead of failing partway through a join with a confusing error.

This table isn't hardcoded. releases() reads a small manifest that the mirror's own weekly cron regenerates by probing the bucket directly, so a new ChEMBL release shows up here without waiting on a new version of this package. If the manifest can't be reached, calls fall back to the snapshot shipped with whatever version you have installed and print a warning, rather than failing outright.

Command line

$ scigantic-chembl info
$ scigantic-chembl query "SELECT count(*) FROM activities" --release chembl_37

License

MIT-0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scigantic_chembl-0.2.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scigantic_chembl-0.2.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file scigantic_chembl-0.2.1.tar.gz.

File metadata

  • Download URL: scigantic_chembl-0.2.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.16

File hashes

Hashes for scigantic_chembl-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0ef1ca89b00b824ec3859288ceea180199441b5f180cedcbce340ca23954428c
MD5 70a2660520a517a6d5e348b38fcf0ba6
BLAKE2b-256 eb9de67017a24ddfdf5eceb50b7713d0e491f196681bfaa326ba6f8d690fb581

See more details on using hashes here.

File details

Details for the file scigantic_chembl-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for scigantic_chembl-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df7d080fd937d64cc0df8290b9bd56f3175eb72adfef12fc0dd4116065d89f38
MD5 ac7f39e81707f2f82feae8640b72b3a5
BLAKE2b-256 772de2ecccb53fe1c3f8bbe7a57e14ef5b732c3e9fd9533ee25e2aa75b97329c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.0

2 files

0.4.5

2 files

0.4.4

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page