Skip to content

Commit

Permalink
fix tests and NEW [skipci]
Browse files Browse the repository at this point in the history
  • Loading branch information
c1au6i0 committed Jan 1, 2025
1 parent 008a189 commit 31e2627
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 3,360 deletions.
29 changes: 19 additions & 10 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,46 @@
* `extr_monograph` checks if a substance is listed in WHO IARC monograph and
returns the details of it (#19).
* `extr_pprtv` extracts information from EPA Provisional Peer-Reviewed Toxicity Values
database (#20)
database (#20). Since the all file of chemicals need to be dowloaded, the
functions `save_to_cache` and `load_from_cache`, have been introduced to
avoid re-downloading the file at each function call. See argument `force`.

## Other Breaking Changes
* The argument `cancer_types` in `extr_iris` was removed. The database returns
* The argument `cancer_types` in `extr_iris` has been removed. The database returns
a dataframe with different columns depending on the request args, and implementing
a way around that is much more tedious than just filter the resulting dataframe
after. Plus it's unlikely that someone wouldn't want to know other non-cancer
tox assessments type
tox assessments types.
* `extr_casrn_from_cid` lost the argument `stop_at_warning`. To be consistent
with other functions now it warns and returns data.frame with NA if no
with other functions now it warns and returns a data.frame with NA if no
ids are found.
* `extr_tox` returns a longer list of dataframes, the outputs of `extr_monograph` and
`extr_pprtv`.

## Enhancements and Fixes
* All the `extr_` functions have gained a `verbose` argument (#18).
* All the `extr_` functions now behave similarly when ids are not founds
(#30, #31, #32, #33, #34, #35),
(#30, #31, #32, #33, #34, #35):

- for all the functions but `extr_comptox`, a column `query` reports the ids searched.
For `extr_comptox` that info can be found in the the element `main_sheet` of
the result. Note that for `extr_ice` given the nature of the request
the `query` values contains all the ids found (not single id).
- now the results contains rows with NAs values for all columns except
`query`
`query`.
- Note that `exptr_pprtv` and `extr_monograph` use the internal function
`save_and_match` to output results that have NAs for missing ids.

* All unit tests have been improved and extended.
* Fixed `extr_comptox` now outputs a list of dataframes with "clean" names.
* Fixed `extr_ctd` names: column `pub_med_ids` or `pub_med_i_ds` are now `pubmed_ids`.
* Cache ...........
* More general function for extr_pubchem_section_
* added checks check_na_warn, with_r_sandbox, search_and_match
* Enhancement: An internal function `extr_pubchem_section_` is used to fetch
both FEMA and GHS to avoid repeated code.
* Enhancement: The internal function `check_na_warn` has been introduced to generate
warnings for missing ids.
* Enhancement: `with_extr_sandbox` has been created to handle cache for CRAN
examples

*Breaking change*: note that now `extr_tox`.,

# extractox 0.1.0

Expand Down
2 changes: 2 additions & 0 deletions R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @details The cache directory is determined using [tools::R_user_dir()] with the `cache` subdirectory
#' for the `extractox` package. If the directory does not exist, it is created automatically.
#' The function will overwrite any existing file with the same name.
#' @keywords internal
#' @noRd
save_to_cache <- function(dat, file_name, verbose = FALSE) {
# Sys.getenv("R_USER_CACHE_DIR")
Expand Down Expand Up @@ -55,6 +56,7 @@ save_to_cache <- function(dat, file_name, verbose = FALSE) {
#' @return The R object read from the cache, or NULL if the file does not exist.
#' @details The cache directory is determined using [tools::R_user_dir()] with the `cache` subdirectory
#' for the `extractox` package. If the file does not exist, a message is printed if verbose is TRUE.
#' @keywords internal
#' @noRd
read_from_cache <- function(file_name, verbose = FALSE) {

Expand Down
2 changes: 1 addition & 1 deletion R/extr_ice.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @export
#' @examples
#' \donttest{
#' extr_ice(c("50-00-0"))
#' extr_ice(casrn = c("50-00-0"))
#' }
extr_ice <- function(casrn,
assays = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/extr_iris.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @export
#' @examples
#' \donttest{
#' extr_iris(c("1332-21-4", "50-00-0"))
#' extr_iris(casrn = c("1332-21-4", "50-00-0"))
#' }
extr_iris <- function(casrn = NULL, verbose = TRUE) {
cancer_types <- c("non_cancer", "cancer")
Expand Down
6 changes: 4 additions & 2 deletions R/extr_monograph.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#' Retrieve WHO IARC Monograph Information
#'
#' This function retrieves information regarding Monographs from the World Health
#' This function returns information regarding Monographs from the World Health
#' Organization (WHO) International Agency for Research on Cancer (IARC) based on
#' CAS Registry Number or Name of the chemical.
#' CAS Registry Number or Name of the chemical. Note that the data is not fetched
#' dynamically from the website, but has retrieved and copy hasbeen saved as
#' internal data in the package.
#'
#' @param search_type A character string specifying the type of search to
#' perform. Valid options are "cas_rn" (CAS Registry Number) and "name"
Expand Down
5 changes: 2 additions & 3 deletions R/extr_pprtv.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#'
#' Extracts data for specified identifiers (CASRN or chemical names) from the EPA's
#' Provisional Peer-Reviewed Toxicity Values (PPRTVs) database. The function
#' retrieves and processes data, with options to use cached files or force a
#' fresh download.
#' retrieves and processes data, with options to use cached files or force a
#' fresh download.
#'
#' @param ids Character vector of identifiers to search (e.g., CASRN or chemical
#' names).
Expand All @@ -13,7 +13,6 @@
#' partial match search for the chemical name. NOTE: Since partial mached is
#' use, multiple seraches might match the same chemical, therefore chemical ids
#' might not be uniques.
#'
#' @param verbose Logical indicating whether to display progress messages.
#' Default is TRUE.
#' @param force Logical indicating whether to force a fresh download of the
Expand Down
Loading

0 comments on commit 31e2627

Please sign in to comment.