Skip to content

Commit

Permalink
preparing for release
Browse files Browse the repository at this point in the history
  • Loading branch information
c1au6i0 committed Jan 1, 2025
1 parent 31e2627 commit 14a77e1
Show file tree
Hide file tree
Showing 23 changed files with 330 additions and 198 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: extractox
Title: Extract Tox Info from Various Databases
Version: 0.1.9001
Version: 0.1.9003
Authors@R: c(
person("Claudio", "Zanettini", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-5043-8033")),
Expand All @@ -12,9 +12,11 @@ Description: Extract toxicological and chemical information from databases
Comparative Toxicogenomics Database <https://ctdbase.org/>, the
Integrated Chemical Environment <https://ice.ntp.niehs.nih.gov/>, the
Integrated Risk Information System <https://cfpub.epa.gov/ncea/iris/>,
Provisional Peer-Reviewed Toxicity Values
<https://www.epa.gov/pprtv/provisional-peer-reviewed-toxicity-values-pprtvs-assessments>,
the CompTox Chemicals Dashboard Resource Hub
<https://www.epa.gov/comptox-tools/comptox-chemicals-dashboard-resource-hub>,
and PubChem <https://pubchem.ncbi.nlm.nih.gov/>.
PubChem <https://pubchem.ncbi.nlm.nih.gov/>, and others.
License: MIT + file LICENSE
URL: https://github.com/c1au6i0/extractox,
https://c1au6i0.github.io/extractox/
Expand Down
2 changes: 0 additions & 2 deletions R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ save_to_cache <- function(dat, file_name, verbose = FALSE) {
#' @keywords internal
#' @noRd
read_from_cache <- function(file_name, verbose = FALSE) {

if (base::missing(file_name)) {
cli::cli_abort("The argument {.field {file_name}} is required.")
}
Expand Down Expand Up @@ -95,7 +94,6 @@ read_from_cache <- function(file_name, verbose = FALSE) {
#' with_extr_sandbox(Sys.getenv("R_USER_CACHE_DIR"))
#' with_extr_sandbox(tools::R_user_dir("extractox", "cache"))
with_extr_sandbox <- function(code, temp_dir = tempdir()) {

if (base::missing(code)) {
cli::cli_abort("The argument {.field {file_name}} is required.")
}
Expand Down
9 changes: 6 additions & 3 deletions R/extr_ice.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ extr_ice <- function(casrn,
httr2::request(base_url) |>
httr2::req_retry(max_tries = 2, backoff = ~3) |>
httr2::req_body_json(list(chemids = casrn, assays = assays),
auto_unbox = FALSE) |>
auto_unbox = FALSE
) |>
httr2::req_options(!!!libcurl_opt) |>
httr2::req_perform()
},
Expand All @@ -69,8 +70,10 @@ extr_ice <- function(casrn,
"reference_url", "dtxsid", "substance_name", "pubmed_id"
)

out <- stats::setNames(as.data.frame(matrix(ncol = length(col_names), nrow = 0)),
col_names)
out <- stats::setNames(
as.data.frame(matrix(ncol = length(col_names), nrow = 0)),
col_names
)

# Parse the JSON content
content <- tryCatch(
Expand Down
1 change: 1 addition & 0 deletions R/extr_pprtv.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#' This is was introduced for debugging purposes.
#' @return A data frame with extracted information matching the specified
#' identifiers, or NULL if no matches are found.
#' @seealso \href{https://www.epa.gov/pprtv/provisional-peer-reviewed-toxicity-values-pprtvs-assessments}{EPA PPRTVs}
#' @export
#' @examples
#' \donttest{
Expand Down
18 changes: 11 additions & 7 deletions R/extr_tox.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ extr_tox <- function(casrn, verbose = TRUE, force = TRUE) {

iris_filt <- extr_iris(casrn = casrn, verbose = verbose)

extracted_monographs <- extr_monograph(ids = casrn, search_type = "casrn",
verbose = verbose)
extracted_monographs <- extr_monograph(
ids = casrn, search_type = "casrn",
verbose = verbose
)

extracted_pprtv <- extr_pprtv(ids = casrn, verbose = verbose)

list_1 <- list(who_iarc_monographs = extracted_monographs,
pprtv = extracted_pprtv,
ghs_dat = ghs_dat,
iris = iris_filt,
ice = ice_dat)
list_1 <- list(
who_iarc_monographs = extracted_monographs,
pprtv = extracted_pprtv,
ghs_dat = ghs_dat,
iris = iris_filt,
ice = ice_dat
)
out <- c(list_1, comptox_list)
out
}
10 changes: 6 additions & 4 deletions R/other.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ ice_assays <- function() {
)


ice_invivo_sensitization <- c("Human Maximization Test",
"Human Repeat Insult Patch Test",
"LLNA",
"Guinea Pig Maximization/Buehler")
ice_invivo_sensitization <- c(
"Human Maximization Test",
"Human Repeat Insult Patch Test",
"LLNA",
"Guinea Pig Maximization/Buehler"
)

ice_invivo_irritation <- c(
"Draize Skin Irritation/Corrosion Test",
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ download_db <- function(url,
#' @param col_names Column names to be used when creating a new dataframe in case of no matches.
#' @param chemical_col The name of the column in dat where chemical names are stored.
#' @return A dataframe with search results.
#' @internal
#' @keywords internal
#'
#' @details This function is used in `extr_pprtv` and `extr_monograph`.
#'
Expand Down
67 changes: 40 additions & 27 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extr_ice_assay_names("Rat Acute") # keep empty to retrieve all
```


### IRIS
### EPA IRIS

The IRIS database is managed by the EPA and contains information on the health effects of exposure to various substances found in the environment. It provides qualitative and quantitative health risk information.

Expand All @@ -81,6 +81,19 @@ names(iris_info)
```


### EPA PPRTVs

The `extr_pprtv` function allows you to extract data for specified identifiers (CASRN or chemical names) from the EPA's Provisional Peer-Reviewed Toxicity Values (PPRTVs) database. This function retrieves and processes data, with options to use cached files or force a fresh download if necessary.

```{r}
# Example usage to extract data for a specific CASRN
extr_pprtv(ids = "107-02-8", search_type = "casrn", verbose = TRUE)
# Example usage to extract data for a chemical name
extr_pprtv(ids = "Acrolein", search_type = "name", verbose = TRUE, force = FALSE)
```


### CompTox

The CompTox Chemistry Dashboard, managed by the EPA, provides access to data on chemical structures, properties, and associated bioactivity data. It integrates data from various sources to support chemical safety assessments.
Expand All @@ -99,7 +112,6 @@ The IARC Monographs database is managed by the World Health Organization (WHO) I

The functione `extr_monograph` provides access to the WHO IARC Monographs database and accepts queries using CASRN or the names of chemicals.


```{r}
dat <- extr_monograph(search_type = "casrn", ids = c("105-74-8", "120-58-1"))
str(dat)
Expand All @@ -109,6 +121,32 @@ dat2 <- extr_monograph(search_type = "name", ids = c("Aloe", "Schistosoma", "Sty
```


### PubChem Database

PubChem is an open chemistry database at the NIH. It provides information on chemical structures, identifiers, chemical and physical properties, biological activities, safety and toxicity information, patents, literature citations, and more.

A series of functions that rely on the `webchem` package are used to extract chemical information, Globally Harmonized System (`GHS`) classification data, or flavor classification from PubChem.

The function `extr_chem_info` retrieves chemical information of IUPAC-named chemicals. A warning is displayed if the chemical is not found.

```{r}
chem_info <- extr_chem_info(IUPAC_names = c("Formaldehyde", "Aflatoxin B1"))
names(chem_info)
```


Two functions are used to extract specific sections of PubChem chemical information using CASRN:

- `extr_pubchem_ghs` extracts Globally Harmonized System (GHS) codes.
- `extr_pubchem_fema` extracts flavor profile data.


```{r}
ghs_info <- extr_pubchem_ghs(casrn = c("50-00-0", "64-17-5"))
fema_info <- extr_pubchem_fema(casrn = c("50-00-0", "123-68-2"))
```


### Tox Info

The function `extr_tox` is a wrapper used to call all the above-mentioned functions and retrieve a list of dataframes.
Expand Down Expand Up @@ -166,31 +204,6 @@ tetramer_data <- extr_tetramer(
names(tetramer_data)
```

### PubChem Database

PubChem is an open chemistry database at the NIH. It provides information on chemical structures, identifiers, chemical and physical properties, biological activities, safety and toxicity information, patents, literature citations, and more.

A series of functions that rely on the `webchem` package are used to extract chemical information, Globally Harmonized System (`GHS`) classification data, or flavor classification from PubChem.

The function `extr_chem_info` retrieves chemical information of IUPAC-named chemicals. A warning is displayed if the chemical is not found.

```{r}
chem_info <- extr_chem_info(IUPAC_names = c("Formaldehyde", "Aflatoxin B1"))
names(chem_info)
```


Two functions are used to extract specific sections of PubChem chemical information using CASRN:

- `extr_pubchem_ghs` extracts Globally Harmonized System (GHS) codes.
- `extr_pubchem_fema` extracts flavor profile data.


```{r}
ghs_info <- extr_pubchem_ghs(casrn = c("50-00-0", "64-17-5"))
fema_info <- extr_pubchem_fema(casrn = c("50-00-0", "123-68-2"))
```


## Important Note for Linux Users

Expand Down
6 changes: 4 additions & 2 deletions man/extr_casrn_from_cid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions man/extr_chem_info.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 14a77e1

Please sign in to comment.