Skip to content

PubChem

Access chemical compound data via the PubChem PUG REST API.

Overview

PubChem is the world's largest collection of freely accessible chemical information. biodbs provides access to:

  • Compound Data - Properties, structures, synonyms
  • Search - By name, SMILES, InChIKey, formula
  • Bioassays - Biological activity data
  • Safety/Pharmacology - Drug information

Quick Start

from biodbs.fetch import (
    pubchem_get_compound,
    pubchem_search_by_name,
    pubchem_get_properties,
)

# Get compound by CID
compound = pubchem_get_compound(2244)  # Aspirin
print(compound.results)

Compound Retrieval

Get by CID

from biodbs.fetch import pubchem_get_compound, pubchem_get_compounds

# Single compound
compound = pubchem_get_compound(2244)

# Multiple compounds
compounds = pubchem_get_compounds([2244, 2519, 5090])

Get Properties

from biodbs.fetch import pubchem_get_properties

props = pubchem_get_properties(
    2244,
    properties=[
        "MolecularWeight",
        "MolecularFormula",
        "CanonicalSMILES",
        "InChIKey",
        "XLogP",
        "TPSA"
    ]
)

Searching

By Name

from biodbs.fetch import pubchem_search_by_name

results = pubchem_search_by_name("aspirin")
cids = results.get_cids()

By SMILES

from biodbs.fetch import pubchem_search_by_smiles

results = pubchem_search_by_smiles("CC(=O)OC1=CC=CC=C1C(=O)O")

By InChIKey

from biodbs.fetch import pubchem_search_by_inchikey

results = pubchem_search_by_inchikey("BSYNRYMUTXBXSQ-UHFFFAOYSA-N")

By Formula

from biodbs.fetch import pubchem_search_by_formula

results = pubchem_search_by_formula("C9H8O4")

Additional Data

Synonyms

from biodbs.fetch import pubchem_get_synonyms

synonyms = pubchem_get_synonyms(2244)

Description

from biodbs.fetch import pubchem_get_description

desc = pubchem_get_description(2244)

Safety Data

from biodbs.fetch import pubchem_get_safety

safety = pubchem_get_safety(2244)

Pharmacology

from biodbs.fetch import pubchem_get_pharmacology

pharma = pubchem_get_pharmacology(2244)

Drug Information

from biodbs.fetch import pubchem_get_drug_info

drug = pubchem_get_drug_info(2244)

Using the Fetcher Class

from biodbs.fetch.pubchem import PubChem_Fetcher

fetcher = PubChem_Fetcher()
compound = fetcher.get_compound(2244)
  • ChEMBL - Access bioactivity data, drug mechanisms, and target interactions for chemical compounds.
  • FDA - Get FDA approval status and drug labeling information.
  • KEGG - Find compound involvement in metabolic pathways.
  • ID Translation - Translate between PubChem CIDs and other chemical identifiers (SMILES, InChIKey, ChEMBL ID).