id_mapping
Identifier mapping helpers across UniChem, PubChem, and ChEMBL.
- drugs.id_mapping.chembl_to_pubchem_cid(chembl_id: str, *, first: bool = True, include_obsolete: bool = False) int | List[int] | None
Map a ChEMBL ID to one or more PubChem CIDs via UniChem.
- Parameters:
chembl_id (str) – ChEMBL molecule identifier to translate.
first (bool, default=True) – Return only the first match when
True; otherwise return all.include_obsolete (bool, default=False) – Include obsolete mappings when available.
- Returns:
First CID (default), a list of CIDs, or
Noneif no mapping is found.- Return type:
int or list[int] or None
- drugs.id_mapping.pubchem_cid_from_inchikey(inchikey: str, *, first: bool = True) int | List[int] | None
Resolve PubChem CIDs from an InChIKey.
- Parameters:
inchikey (str) – InChIKey to search for.
first (bool, default=True) – Return only the first match when
True; otherwise return all.
- Returns:
First CID (default), list of CIDs, or
Noneif no match.- Return type:
int or list[int] or None
- drugs.id_mapping.pubchem_cid_to_chembl(cid: int | str, *, first: bool = True, include_obsolete: bool = False) str | List[str] | None
Map a PubChem CID to one or more ChEMBL IDs via UniChem.
- Parameters:
cid (int or str) – PubChem compound identifier.
first (bool, default=True) – Return only the first match when
True; otherwise return all.include_obsolete (bool, default=False) – Include obsolete mappings when available.
- Returns:
First ChEMBL ID (default), list of IDs, or
Noneif unmapped.- Return type:
str or list[str] or None
- drugs.id_mapping.pubchem_cid_to_inchikey(cid: int | str) str | None
Fetch the InChIKey for a PubChem CID using PUG-REST.
- Parameters:
cid (int or str) – PubChem compound identifier.
- Returns:
InChIKey string when available, otherwise
None.- Return type:
str or None
- drugs.id_mapping.unichem_sources() List[Dict[str, Any]]
Retrieve and cache available UniChem sources.
- Returns:
List of UniChem source metadata dictionaries. Empty if the API responds with an unexpected shape.
- Return type:
list[dict]
- drugs.id_mapping.unichem_src_id(name: str) int
Resolve a UniChem source ID by fuzzy name matching.
- Parameters:
name (str) – Canonical or alternative name for a UniChem source (case-insensitive).
- Returns:
Matching UniChem source identifier.
- Return type:
int
- Raises:
ValueError – If no source matches the provided name.