PubChem vs ChEMBL, live search vs curated mirror

Cheminformatics sample notebook on Scigantic.

The same drug, resolved live against PubChem's 122-million-compound registry and pulled from ChEMBL's curated, pre-mirrored bioactivity data.

Figure: A 3D space-filling model of imatinib itself, gray carbon atoms with blue nitrogens and one red oxygen, on a dark field

The notebook

4 code cells, shown with the output each one printed.

PubChem vs ChEMBL: same molecule, two different databases

Both packages are preinstalled on this image, no setup needed:

Neither database is a smaller or bigger version of the other. ChEMBL is deep (curated potency, targets, assays) over a bounded set; PubChem is broad (identity, registry, similarity) over almost everything that's ever been registered as a chemical structure. This notebook follows one real drug through both.

import scigantic_pubchem as pubchem

imatinib = pubchem.resolve("imatinib")
imatinib

Output:

Compound(cid=5291, title='Imatinib', smiles='CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5', inchi='InChI=1S/C29H31N7O/c1-21-5-10-25(18-27(21)34-29-31-13-11-26(33-29)24-4-3-12-30-19-24)32-28(37)23-8-6-22(7-9-23)20-36-16-14-35(2)15-17-36/h3-13,18-19H,14-17,20H2,1-2H3,(H,32,37)(H,31,33,34)', inchi_key='KTUFNOKKBVMGRW-UHFFFAOYSA-N', iupac_name='4-[(4-methylpiperazin-1-yl)methyl]-N-[4-methyl-3-[(4-pyridin-3-ylpyrimidin-2-yl)amino]phenyl]benzamide', molecular_formula='C29H31N7O', molecular_weight=493.6)

Bridging to ChEMBL

chembl_id() isn't a guess or a name match — it's PubChem's own live cross-reference (xrefs/RegistryID) for this exact CID, resolved fresh, every call. chembl_context() goes one step further and joins straight into s3://scigantic-chembl over the same DuckDB connection, a live cross-bucket read rather than anything pre-joined or cached.

chembl_id = pubchem.chembl_id(imatinib.cid, namespace="cid")
print("PubChem CID", imatinib.cid, "->", chembl_id)

context = pubchem.chembl_context(imatinib.cid, namespace="cid")
context

Output:

PubChem CID 5291 -> CHEMBL941
{'molregno': 88797,
 'chembl_id': 'CHEMBL941',
 'pref_name': 'IMATINIB',
 'max_phase': 4.0}

What ChEMBL actually knows about it

scigantic_chembl has no single-compound convenience function — activities() filters by target, not by compound — so this drops to a direct query against the same mirror, same pattern the ChEMBL card next to this one uses when its own functions don't fit the exact question.

import scigantic_chembl as chembl

counts = chembl.query(f"""
    SELECT count(*) AS n_activities, count(DISTINCT target_chembl_id) AS n_targets
    FROM read_parquet('s3://scigantic-chembl/chembl_37/derived/activities_enriched.parquet')
    WHERE compound_chembl_id = '{chembl_id}'
""")
print(f"{counts.n_activities[0]:,} activities across {counts.n_targets[0]:,} distinct targets")

top = chembl.query(f"""
    SELECT target_pref_name, standard_type, standard_value, standard_units, pchembl_value
    FROM read_parquet('s3://scigantic-chembl/chembl_37/derived/activities_enriched.parquet')
    WHERE compound_chembl_id = '{chembl_id}'
    ORDER BY pchembl_value DESC
    LIMIT 5
""")
top

Output:

733 activities across 234 distinct targets
                          target_pref_name standard_type  standard_value  \
0  Receptor tyrosine-protein kinase erbB-2          IC50          0.0600   
1         Epidermal growth factor receptor          IC50          0.1100   
2                                     K562          IC50          0.1500   
3                                     EOL1          IC50          0.1995   
4                                     EOL1          IC50          0.2000   

  standard_units  pchembl_value  
0             nM          10.22  
1             nM           9.96  
2             nM           9.82  
3             nM           9.70  
4             nM           9.70

Imatinib is famous as a BCR-ABL inhibitor — that's the target it was designed and approved for — but the curated data says it's actually *more* potent against ERBB2 and EGFR than against ABL1, its namesake target. That's not a database error, it's the real pharmacology: imatinib is a fairly promiscuous kinase inhibitor, and this is exactly the kind of fact a target-first search would never surface, but a compound-first one does immediately.

The part that's actually a different architecture, not just a different number

PubChem separately carries external registry cross-references — pharmacy and regulatory catalog numbers — that ChEMBL doesn't track at all, because that's not what ChEMBL is for. And the two databases' idea of "similar compounds" is scoped completely differently: ChEMBL's similar_compounds() ranks only the ~1.68M compounds in its own mirror that have a measurement — a bounded, precomputed fingerprint index. PubChem's runs live against the full, current registry, no precomputation, no boundary.

xrefs = pubchem.xrefs(imatinib.cid, xref_type="RegistryID")
print(f"{len(xrefs):,} external registry cross-references on PubChem, zero of them in ChEMBL")
print()

print("ChEMBL similarity -- bounded to its own 1.68M-compound fingerprinted mirror:")
print(chembl.similar_compounds(imatinib.smiles, top_k=5)[["chembl_id", "tanimoto"]])
print()

print("PubChem similarity -- live, full 122M-compound registry:")
print(pubchem.similar_compounds(imatinib.smiles, threshold=90, max_records=5, resolve=False))

Output:

327 external registry cross-references on PubChem, zero of them in ChEMBL

ChEMBL similarity -- bounded to its own 1.68M-compound fingerprinted mirror:
       chembl_id  tanimoto
0      CHEMBL941  1.000000
1     CHEMBL1642  0.942029
2  CHEMBL2386595  0.900000
3  CHEMBL3098615  0.885714
4  CHEMBL3098616  0.873239

PubChem similarity -- live, full 122M-compound registry:
[9865515, 5291, 123596, 4369496, 11478363]

Where they overlap, they agree — several of PubChem's live neighbors are ChEMBL's top mirror neighbors too. But PubChem also surfaces compounds that carry a ChEMBL ID yet never ranked in ChEMBL's own narrower search, because they never had a qualifying bioactivity measurement to be fingerprinted from in the first place. A mirror can only rank what it was built from; a live query can't miss what was added yesterday.

Reach for scigantic_chembl when the question is about measured potency against a target. Reach for scigantic_pubchem when the question is about identity, cross-references, or "what else looks like this" across everything, not just what's been assayed. Ask the assistant panel to run this on a different compound, or to explain any of the columns above.

Run it yourself

This sample opens as a hosted JupyterLab notebook with its datasets already mounted, so nothing has to be downloaded first. The notebook arrives with its outputs already rendered, and an AI assistant in the notebook can explain each step or change the analysis. Open the sample or browse the full catalog.