Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ci_query

Retrieve information from ChemIDPlus


Description

Retrieve information from ChemIDPlus https://chem.nlm.nih.gov/chemidplus

Usage

ci_query(
  query,
  from = c("name", "rn", "inchikey", "cas"),
  match = c("first", "best", "ask", "na"),
  verbose = TRUE,
  type
)

Arguments

query

character; query string

from

character; type of query string. "rn" for registry number (see documentation for more details), "name" for common name, or "inchikey" for inchikey as input. "cas" is a synonym for "rn" and provided for consistency across functions.

match

character; How should multiple hits be handled? "first" returns only the first match, "best" the best matching (by name) ID, "ask" enters an interactive mode and the user is asked for input, "na" returns NA if multiple hits are found.

verbose

logical; should a verbose output be printed on the console?

type

deprecated

Value

A list of 8 entries: name (vector), synonyms (vector), cas (vector), inchi (vector), inchikey (vector), smiles(vector), toxicity (data.frame), physprop (data.frame) and source_url.

Note

Please respect the Terms and Conditions of the National Library of Medicine, https://www.nlm.nih.gov/databases/download.html.

Examples

## Not run: 
# might fail if API is not available
# query common name
y1 <- ci_query(c('Formaldehyde', 'Triclosan'), from = 'name')
names(y1)
str(y1[['Triclosan']]) # lots of information inside
y1[['Triclosan']]$inchikey

# Query by CAS
y2 <- ci_query('50-00-0', from = 'rn', match = 'first')
y2[['50-00-0']]$inchikey

# query by inchikey
y3 <- ci_query('WSFSSNUMVMOOMR-UHFFFAOYSA-N', from = 'inchikey')
y3[[1]]$name

# extract lop-P
sapply(y1, function(y){
 if (length(y) == 1 && is.na(y))
   return(NA)
 y$physprop$Value[y$physprop$`Physical Property` == 'log P (octanol-water)']
 })

## End(Not run)

webchem

Chemical Information from the Web

v1.1.1
MIT + file LICENSE
Authors
Eduard Szöcs [aut], Robert Allaway [ctb], Daniel Muench [ctb], Johannes Ranke [ctb], Andreas Scharmüller [ctb], Eric R Scott [ctb], Jan Stanstrup [ctb], João Vitor F Cavalcante [ctb], Gordon Getzinger [ctb], Tamás Stirling [ctb, cre]
Initial release
2021-02-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.