Skip to contents

Extracts DTXSIDs from PubChem synonym lists, with a CAS-based CompTox fallback for compounds not directly annotated with DTXSIDs.

Usage

util_pubchem_resolve_dtxsid(cid, cache = TRUE)

Arguments

cid

Integer or character vector of PubChem CIDs.

cache

Logical. If TRUE (default), results are cached in the session environment (.ComptoxREnv$pubchem_cid_map) to avoid redundant API calls.

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:

  1. PubChem synonyms: Fetches synonym lists via pubchem_synonyms() and searches for DTXSID patterns using regex (\\bDTXSID\\d+\\b).

  2. 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)
} # }