R/searchByFormula.R

Defines functions searchByFormula

Documented in searchByFormula

#search by molecular formula
searchByFormula <- function(formula, returnType = "json") {
  
  #GET request
  if(returnType == "json") {
    
    #return as json
    req <- GET(MONASEARCH,
               add_headers(JSONCONTENT),
               query = list(query = paste0('compound.metaData=q=\'name=="molecular formula" and value=="', formula, '"\'')))
    
  } else if(returnType == "msp") {
    
    #return as msp
    req <- GET(MONASEARCH,
               add_headers(MSPCONTENT),
               query = list(query = paste0('compound.metaData=q=\'name=="molecular formula" and value=="', formula, '"\'')))
    
  }
  
  return(content(req))
  
}
sneumann/RaMoNA documentation built on May 30, 2019, 5:06 a.m.