Skip to content

Commit

Permalink
Merge pull request #2 from USEPA/1-prepare-for-cran-release
Browse files Browse the repository at this point in the history
1 prepare for cran release
  • Loading branch information
rachmaninoffpk authored Jul 3, 2024
2 parents 79da6d3 + 0400b43 commit 3e2b446
Show file tree
Hide file tree
Showing 26 changed files with 323 additions and 373 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Authors@R: c(
)
Description: Access chemical, hazard, bioactivity, and exposure data from the
Computational Toxicology and Exposure ('CTX') APIs
<https://api-ccte.epa.gov/docs/>. 'ccdR' was developed to streamline the
<https://api-ccte.epa.gov/docs/>. 'ctxR' was developed to streamline the
process of accessing the information available through the 'CTX' APIs
without requiring prior knowledge of how to use APIs. Most data is also
available on the CompTox Chemical Dashboard ('CCD')
Expand Down Expand Up @@ -54,8 +54,8 @@ Suggests:
rmarkdown,
testthat (>= 3.0.0),
XML
URL: https://github.com/USEPA/ccdR
BugReports: https://github.com/USEPA/ccdR/issues
URL: https://github.com/USEPA/ctxR
BugReports: https://github.com/USEPA/ctxR/issues
VignetteBuilder: knitr
Config/testthat/edition: 3
Depends:
Expand Down
12 changes: 6 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Generated by roxygen2: do not edit by hand

S3method(print,ctx_credentials)
export(ccdr_hide_api_key)
export(ccdr_show_api_key)
export(chemical_contains)
export(chemical_contains_batch)
export(chemical_equal)
export(chemical_equal_batch)
export(chemical_starts_with)
export(chemical_starts_with_batch)
export(ctxR_hide_api_key)
export(ctxR_show_api_key)
export(ctx_key)
export(get_all_assays)
export(get_all_public_chemical_lists)
Expand Down Expand Up @@ -81,9 +81,9 @@ export(get_public_chemical_list_by_name_batch)
export(get_skin_eye_hazard)
export(get_skin_eye_hazard_batch)
export(get_smiles)
export(has_ccdr_option)
export(has_ccdr_options)
export(has_ctxR_option)
export(has_ctxR_options)
export(has_ctx_key)
export(register_ccdr)
export(set_ccdr_option)
export(register_ctx_api_key)
export(set_ctxR_option)
export(showing_key)
7 changes: 3 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ccdR 1.0.0
# ctxR 1.0.0

# ccdR 0.1.0
* Initial release. Renamed package from `ccdR` package for better alignment
with US EPA CTX APIs.

* Added a `NEWS.md` file to track changes to the package.
* Initial release.
16 changes: 8 additions & 8 deletions R/attach.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cite <- paste0(
cli::col_green(cli::symbol$info),
' ',
'Please cite ', cli::col_blue('ccdR'), ' if you use it! Use `citation(\'ccdR\')` for details.'
'Please cite ', cli::col_blue('ctxR'), ' if you use it! Use `citation(\'ctxR\')` for details.'
)

rlang::inform(
Expand All @@ -20,18 +20,18 @@
)

.getKeyIntoPkgEnv(silent = FALSE)
bootstrap_ccdr()
bootstrap_ctxR()

}

.onLoad <- function(...) {
.getKeyIntoPkgEnv(silent = TRUE)
bootstrap_ccdr()
bootstrap_ctxR()
}


bootstrap_ccdr <- function() {
set_ccdr_option(
bootstrap_ctxR <- function() {
set_ctxR_option(
'ctx' = structure(
list(

Expand All @@ -46,9 +46,9 @@ bootstrap_ccdr <- function() {

.defaultFile <- function() {
if (getRversion() >= "4.0.0") {
ccdRdir <- tools::R_user_dir("ccdR")
if (dir.exists(ccdRdir)) {
fname <- file.path(ccdRdir, "api.dcf")
ctxRdir <- tools::R_user_dir("ctxR")
if (dir.exists(ctxRdir)) {
fname <- file.path(ctxRdir, "api.dcf")
if (file.exists(fname)) {
return(fname)
}
Expand Down
86 changes: 0 additions & 86 deletions R/ccdr_options.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/chemical-APIs.R
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ get_chem_info <- function(DTXSID = NULL,
#' @param Server The root address for the API endpoint
#' @param verbose A logical indicating if some “progress report” should be given.
#'
#' @return @return A data.frame containing chemical information for the chemical with
#' @return A data.frame containing chemical information for the chemical with
#' DTXSID matching the input parameter.
#' @export
#' @examplesIf has_ctx_key() & is.na(ctx_key() == 'FAKE_KEY')
Expand Down
86 changes: 86 additions & 0 deletions R/ctxr_options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#' ctxR Options
#'
#' ctxR stores options as a named list in R's global options, i.e.
#' `getOption('ctxR')`. It currently stores two such options, one for CCTE
#' credentialing and one to suppress private API information in the URLs printed
#' to the screen when web queries are placed. For both of those, see
#' [register_ctx_api_key()].
#'
#' @param ... a named listing of options to set
#' @param option a specific option to query, e.g. `display_api_key`
#' @name ctxR_options
#' @returns
#' * `set_ctxR_option()` does not have a return value but has the side effect
#' of setting options used by other functions.
#'
#' * `has_ctxR_option()` returns a Boolean.
#'
#' * `has_ctxR_options()` returns a Boolean.
#' @seealso [register_ctx_api_key()]
#'
#'
#'






#' @rdname ctxR_options
#' @export
#' @examplesIf has_ctx_key() & is.na(ctx_key() == 'FAKE_KEY')
#' # Set ctxR options
#' set_ctxR_option('display_api_key' = FALSE)
set_ctxR_option <- function(...) {

# if there is no ctxR option create the list with the arguments and return
if (!has_ctxR_options()) {
options('ctxR' = list(...))
return(invisible())
}

# otherwise, go through arguments sequentially and add/update
# them in the list ctxR options
ctxR <- getOption('ctxR')
arg_list <- lapply(as.list(match.call())[-1], eval, envir = parent.frame())
for (k in seq_along(arg_list)) {
if (names(arg_list)[k] %in% names(ctxR)) {
ctxR[names(arg_list)[k]] <- arg_list[k]
} else {
ctxR <- c(ctxR, arg_list[k])
}
}

# set new ctxR
options('ctxR' = ctxR)

# return
invisible()
}



#' @rdname ctxR_options
#' @export
#' @examplesIf has_ctx_key() & is.na(ctx_key() == 'FAKE_KEY')
#' # Check if there are options registered to 'ctxR'
#' has_ctxR_options()

has_ctxR_options <- function() {
!is.null(getOption('ctxR'))
}

#' @rdname ctxR_options
#' @export
#' @examplesIf has_ctx_key() & is.na(ctx_key() == 'FAKE_KEY')
#' # Check if a specific option is registered for 'ctxR'
#' has_ctxR_option('display_api_key')

has_ctxR_option <- function(option) {

if (has_ctxR_options()){
option %in% names(getOption('ctxR'))
} else {
FALSE
}
}
Loading

0 comments on commit 3e2b446

Please sign in to comment.