data_sources
Thin wrappers over PubChem and ChEMBL endpoints.
- drugs.data_sources.pubchem_properties(cid: int, properties: Iterable[str] = ('IUPACName', 'InChIKey', 'CanonicalSMILES', 'MolecularFormula', 'MolecularWeight', 'XLogP', 'TPSA')) Dict[str, Any]
Fetch core compound properties from PubChem PUG-REST.
- Parameters:
cid (int) – PubChem compound identifier.
properties (Iterable[str], optional) – Property names to request. Defaults to a curated set including IUPAC name, InChIKey, SMILES, formula, and physicochemical descriptors.
- Returns:
First property record returned by PUG-REST, or an empty dict when missing.
- Return type:
dict
- drugs.data_sources.pubchem_pug_view_record(cid: int) Dict[str, Any]
Fetch the full PUG-View record for a compound.
- Parameters:
cid (int) – PubChem compound identifier.
- Returns:
Complete PUG-View record payload in display mode.
- Return type:
dict
- drugs.data_sources.pubchem_text_snippets(cid: int, headings: Iterable[str]) Dict[str, Dict[str, Any]]
Fetch text snippets for selected PUG-View headings.
Invalid headings for the specific compound are skipped silently to avoid PUG-View errors.
- Parameters:
cid (int) – PubChem compound identifier.
headings (Iterable[str]) – Heading labels to fetch for the compound.
- Returns:
Mapping of heading -> payload containing the record title, section tree, and list of readable string snippets.
- Return type:
dict[str, dict]
- drugs.data_sources.list_pubchem_text_headings(cid: int) List[str]
List PUG-View headings available for a compound.
- Parameters:
cid (int) – PubChem compound identifier.
- Returns:
Unique heading labels in first-seen order.
- Return type:
list[str]
- drugs.data_sources.chembl_molecules_by_inchikey(inchikey: str, limit: int = 10) List[Dict[str, Any]]
Query ChEMBL for molecules by InChIKey.
- Parameters:
inchikey (str) – Standard InChIKey to search for.
limit (int, default=10) – Maximum number of molecules to return.
- Returns:
Sequence of molecule records returned by the ChEMBL API.
- Return type:
list[dict]
- drugs.data_sources.chembl_mechanisms(molecule_chembl_id: str, limit: int = 50) List[Dict[str, Any]]
Fetch mechanisms of action for a ChEMBL molecule.
- Parameters:
molecule_chembl_id (str) – ChEMBL molecule identifier.
limit (int, default=50) – Maximum number of mechanism records to fetch.
- Returns:
Mechanism-of-action entries returned by ChEMBL.
- Return type:
list[dict]
- drugs.data_sources.chembl_target_detail(target_chembl_id: str) Dict[str, Any]
Fetch target details from ChEMBL, including components.
- Parameters:
target_chembl_id (str) – ChEMBL target identifier.
- Returns:
Target detail payload containing components, accessions, and synonyms.
- Return type:
dict
- drugs.data_sources.chembl_bioactivities(molecule_chembl_id: str, *, min_pchembl: float = 5.0, assay_types: Iterable[str] = ('B', 'F'), limit: int = 1000) List[Dict[str, Any]]
Fetch bioactivity measurements (pChEMBL/IC50/EC50) for a molecule.
- Parameters:
molecule_chembl_id (str) – ChEMBL molecule identifier.
min_pchembl (float, default=5.0) – Minimum pChEMBL value to include (filters potency).
assay_types (Iterable[str], default=("B", "F")) – Assay type codes to include, e.g.,
B(binding) orF(functional).limit (int, default=1000) – Maximum number of activity rows to fetch.
- Returns:
Activity rows returned by the ChEMBL API.
- Return type:
list[dict]
Fetch drug-drug interaction information from the public RxNav API.
- Parameters:
drug_name (str) – Common name for the drug (e.g.,
"aspirin").- Returns:
Raw RxNav interaction payload.
- Return type:
dict