Skip to content

Commit

Permalink
Changed missing API key errors to warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Kruse committed Nov 8, 2024
1 parent 893ce45 commit 2f7a7db
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 184 deletions.
12 changes: 6 additions & 6 deletions R/bioactivity-APIs-batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ get_bioactivity_details_batch <- function(DTXSID = NULL,
rate_limit = 0L,
verbose = FALSE){
API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (!is.numeric(rate_limit) | (rate_limit < 0)){
Expand Down Expand Up @@ -216,8 +216,8 @@ get_bioactivity_summary_batch <- function(AEID = NULL,
rate_limit = 0L,
verbose = FALSE){
API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (!is.numeric(rate_limit) | (rate_limit < 0)){
Expand Down Expand Up @@ -291,8 +291,8 @@ get_annotation_by_aeid_batch <- function(AEID = NULL,
rate_limit = 0L,
verbose = FALSE){
API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (!is.numeric(rate_limit) | (rate_limit < 0)){
Expand Down
120 changes: 60 additions & 60 deletions R/chemical-APIs-batch.R

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions R/chemical-APIs.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ get_chemical_details <- function(DTXSID = NULL,
stop('Please input either a DTXSID or DTXCID, but not both!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

projection_entries <- c('chemicaldetailall',
Expand Down Expand Up @@ -303,8 +303,8 @@ check_existence_by_dtxsid <- function(DTXSID = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/ghslink/to-dtxsid/', DTXSID),
Expand Down Expand Up @@ -345,8 +345,8 @@ get_chemical_details_by_listname <- function(listname = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/detail/search/by-listname/', listname),
Expand Down Expand Up @@ -393,8 +393,8 @@ get_smiles <- function(name = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/opsin/to-smiles/', prepare_word(name)),
Expand Down Expand Up @@ -439,8 +439,8 @@ get_inchikey <- function(name = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/opsin/to-inchikey/', prepare_word(name)),
Expand Down Expand Up @@ -485,8 +485,8 @@ get_inchi <- function(name = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/opsin/to-inchi/', prepare_word(name)),
Expand Down Expand Up @@ -535,8 +535,8 @@ get_chemical_by_property_range <- function(start = NULL,
Server = chemical_api_server,
verbose = FALSE){
API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (is.null(start) || is.null(end) || !is.numeric(start) || !is.numeric(end)){
Expand Down Expand Up @@ -602,8 +602,8 @@ get_chem_info <- function(DTXSID = NULL,
stop('Please input a DTXSID!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

types <- c("", "predicted", "experimental")
Expand Down Expand Up @@ -677,8 +677,8 @@ get_fate_by_dtxsid <- function(DTXSID = NULL,
stop('Please input a DTXSID!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/fate/search/by-dtxsid/', DTXSID),
Expand Down Expand Up @@ -732,8 +732,8 @@ chemical_starts_with <- function(word = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (!is.null(top)){
Expand Down Expand Up @@ -809,8 +809,8 @@ chemical_equal <- function(word = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

word <- prepare_word(word)
Expand Down Expand Up @@ -875,8 +875,8 @@ chemical_contains <- function(word = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (!is.null(top)){
Expand Down Expand Up @@ -978,8 +978,8 @@ get_msready_by_mass <- function(start = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (start < 0 || end < 0){
Expand Down Expand Up @@ -1040,8 +1040,8 @@ get_msready_by_formula <- function(formula = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/msready/search/by-formula/', formula),
Expand Down Expand Up @@ -1091,8 +1091,8 @@ get_msready_by_dtxcid <- function(DTXCID = NULL,
}

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/msready/search/by-dtxcid/', DTXCID),
Expand Down Expand Up @@ -1132,8 +1132,8 @@ get_all_list_types <- function(API_key = NULL,
verbose = FALSE){

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(chemical_api_server, "/list/type"),
Expand Down Expand Up @@ -1172,8 +1172,8 @@ get_chemical_lists_by_type <- function(type = NULL,
stop('Please input a value for parameter type from the list `federal`, `international`, `state`, and `other`!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}


Expand Down Expand Up @@ -1246,8 +1246,8 @@ get_public_chemical_list_by_name <- function(list_name = NULL,
stop('Please input list_name!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

projection_entries <- c('chemicallistall',
Expand Down Expand Up @@ -1313,8 +1313,8 @@ get_lists_containing_chemical <- function(DTXSID = NULL,
stop('Please input a non-null value for DTXSID!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

response <- httr::GET(url = paste0(Server, '/list/search/by-dtxsid/', DTXSID),
Expand Down Expand Up @@ -1364,8 +1364,8 @@ get_chemicals_in_list <- function(list_name = NULL,
stop('Please input a character value for list_name!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

new_response <- get_public_chemical_list_by_name(list_name = list_name,
Expand Down Expand Up @@ -1430,8 +1430,8 @@ get_chemicals_in_list_start <- function(list_name = NULL,
stop('Please input a character value for word!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}


Expand Down Expand Up @@ -1483,8 +1483,8 @@ get_chemicals_in_list_exact <- function(list_name = NULL,
stop('Please input a character value for word!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}


Expand Down Expand Up @@ -1536,8 +1536,8 @@ get_chemicals_in_list_contain <- function(list_name = NULL,
stop('Please input a character value for word!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}


Expand Down Expand Up @@ -1586,8 +1586,8 @@ get_all_public_chemical_lists <- function(Projection = '',
Server = chemical_api_server,
verbose = FALSE){
API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

projection_entries <- c('chemicallistall',
Expand Down Expand Up @@ -1658,8 +1658,8 @@ get_chemical_mrv <- function(DTXSID = NULL,
stop('Please input either a DTXSID or DTXCID, but not both!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (!is.null(DTXSID)){
Expand Down Expand Up @@ -1718,8 +1718,8 @@ get_chemical_mol <- function(DTXSID = NULL,
stop('Please input either a DTXSID or DTXCID, but not both!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (!is.null(DTXSID)){
Expand Down Expand Up @@ -1794,8 +1794,8 @@ get_chemical_image <- function(DTXSID = NULL,
stop('Please input only one DTXSID, DTXCID, or SMILES, and not multiple!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}

if (format == 'png'){
Expand Down Expand Up @@ -1870,8 +1870,8 @@ get_chemical_synonym <- function(DTXSID = NULL,
stop('Please input a DTXSID!')

API_key <- check_api_key(API_key = API_key, verbose = verbose)
if (is.null(API_key)){
stop('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
if (is.null(API_key) & verbose){
warning('Missing API key. Please supply during function call or save using `register_ctx_api_key()`!')
}


Expand Down
Loading

0 comments on commit 2f7a7db

Please sign in to comment.