
Resolve PubChem CIDs to CompTox DTXSIDs
Source:R/util_pubchem_resolve_dtxsid.R
util_pubchem_resolve_dtxsid.RdExtracts DTXSIDs from PubChem synonym lists, with a CAS-based CompTox fallback for compounds not directly annotated with DTXSIDs.
Value
A named character vector where names are CIDs (as character) and
values are DTXSID strings. NA_character_ for CIDs that could not be
resolved.
Details
Resolution uses a two-step approach:
PubChem synonyms: Fetches synonym lists via
pubchem_synonyms()and searches for DTXSID patterns using regex (\\bDTXSID\\d+\\b).CAS fallback: For unresolved CIDs, extracts CAS numbers from the synonym list, validates their check digits, and performs a single batched lookup against the CompTox Dashboard via
ct_chemical_search_equal_bulk(). This step requires a CompTox API key (ctx_api_key).
Session caching stores resolved CID-to-DTXSID mappings so repeated calls for the same CIDs are instant.
See also
pubchem_synonyms() for raw synonym lists,
chemi_resolver_pubchem_section() for EPA's curated PubChem resolver,
ct_chemical_search_equal_bulk() for CompTox batch search.
Examples
if (FALSE) { # \dontrun{
# Single CID (aspirin)
util_pubchem_resolve_dtxsid(2244)
# Multiple CIDs
util_pubchem_resolve_dtxsid(c(2244, 6623))
# Disable session cache
util_pubchem_resolve_dtxsid(2244, cache = FALSE)
} # }