Learn R Programming

webchem (version 0.1.0.0)

ci_query: Retrieve information from ChemIDPlus http://chem.sis.nlm.nih.gov/chemidplus

Description

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

Usage

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

Arguments

query
character; query string
type
character; type of query string. 'rn' for regeistry number or 'name' for common name or 'inchikey' for inchikey as input.
match
character; How should multiple hits be handeled? 'first' returns only the first match, 'best' the best matching (by name) ID, 'ask' is a 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?

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.

Examples

Run this code
## Not run: 
# # might fail if API is not available
# # query common name
# y1 <- ci_query(c('Formaldehyde', 'Triclosan'), type = 'name')
# names(y1)
# str(y1[['Triclosan']]) # lots of information inside
# y1[['Triclosan']]$inchikey
# 
# # Query by CAS
# y2 <- ci_query('50-00-0', type = 'rn', match = 'first')
# y2[['50-00-0']]$inchikey
# 
# # query by inchikey
# y3 <- ci_query('WSFSSNUMVMOOMR-UHFFFAOYSA-N', type = '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)

Run the code above in your browser using DataLab