Skip to content

Commit

Permalink
fix works when a single different than is selected (#16) 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
c1au6i0 committed Dec 6, 2024
1 parent 9c50feb commit 419936a
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 49 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

# extractox 0.1.1

* fix: #15 now `extr_iris` extracts the correct number of chemicals with no repetition.
* Fixed `extr_iris` extracts the correct number of chemicals with no repetition (#15}.
* Fixed `extr_comtox` works when a single `download_items` different than `DTXCID` is selected (#16).

# extractox 0.1.0

Expand Down
5 changes: 3 additions & 2 deletions R/extr_comptox.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#' @param ids A character vector containing the items to be searched within the CompTox Chemistry Dashboard. These can be chemical names, CAS Registry Numbers (CASRN), InChIKeys, or DSSTox substance identifiers (DTXSID).
#' @param download_items A character vector of items to be downloaded. This includes a comprehensive set of chemical properties, identifiers, predictive data, and other relevant information. By Default, it download all the info
#' \describe{
#' \item{DTXCID}{The unique identifier for a chemical in the EPA's CompTox Chemicals Dashboard.}
#' \item{CASRN}{The Chemical Abstracts Service Registry Number, a unique numerical identifier for chemical substances.}
#' \item{INCHIKEY}{The hashed version of the full International Chemical Identifier (InChI) string.}
#' \item{IUPAC_NAME}{The International Union of Pure and Applied Chemistry (IUPAC) name of the chemical.}
Expand Down Expand Up @@ -94,7 +93,6 @@
#' }
extr_comptox <- function(ids,
download_items = c(
"DTXCID",
"CASRN",
"INCHIKEY",
"IUPAC_NAME",
Expand Down Expand Up @@ -209,6 +207,9 @@ extr_comptox_ <- function(ids,
identifier_types <- c("chemical_name", "CASRN", "INCHIKEY", "dtxsid")
input_type <- "IDENTIFIER"


download_items <- c("DTXCID", download_items)

params <- list(
identifierTypes = identifier_types,
massError = mass_error,
Expand Down
3 changes: 2 additions & 1 deletion docs/news/index.html

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

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pandoc: '3.2'
pkgdown: 2.1.1
pkgdown_sha: ~
articles: {}
last_built: 2024-12-06T11:08Z
last_built: 2024-12-06T12:06Z
urls:
reference: https://c1au6i0.github.io/extractox/reference
article: https://c1au6i0.github.io/extractox/articles
28 changes: 12 additions & 16 deletions docs/reference/extr_comptox.html

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

2 changes: 1 addition & 1 deletion docs/reference/write_dataframes_to_excel.html

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

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions man/extr_comptox.Rd

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

28 changes: 14 additions & 14 deletions tests/testthat/_snaps/comptox.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
result[!names(result) %in% "comptox_cover_sheet"]
Output
$comptox_main_data
# A tibble: 1 x 6
INPUT FOUND_BY DTXSID PREFERRED_NAME DTXCID CASRN
<chr> <chr> <chr> <chr> <chr> <chr>
1 Aspirin Approved Name DTXSID5020108 Aspirin DTXCID50108 50-78-2
# A tibble: 1 x 7
INPUT FOUND_BY DTXSID PREFERRED_NAME DTXCID...5 DTXCID...6 CASRN
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 Aspirin Approved Name DTXSID5020108 Aspirin DTXCID501~ DTXCID501~ 50-7~

# Valid CASRN input
Expand All @@ -16,10 +16,10 @@
result[!names(result) %in% "comptox_cover_sheet"]
Output
$comptox_main_data
# A tibble: 1 x 6
INPUT FOUND_BY DTXSID PREFERRED_NAME DTXCID CASRN
<chr> <chr> <chr> <chr> <chr> <chr>
1 50-00-0 CASRN DTXSID7020637 Formaldehyde DTXCID30637 50-00-0
# A tibble: 1 x 7
INPUT FOUND_BY DTXSID PREFERRED_NAME DTXCID...5 DTXCID...6 CASRN
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 50-00-0 CASRN DTXSID7020637 Formaldehyde DTXCID30637 DTXCID30637 50-00-0

# Valid inputs
Expand All @@ -28,11 +28,11 @@
result[!names(result) %in% "comptox_cover_sheet"]
Output
$comptox_main_data
# A tibble: 3 x 6
INPUT FOUND_BY DTXSID PREFERRED_NAME DTXCID CASRN
<chr> <chr> <chr> <chr> <chr> <chr>
1 50-00-0 CASRN DTXSID7020637 Formaldehyde DTXCID30~ 50-0~
2 Aspirin Approved Name DTXSID5020108 Aspirin DTXCID50~ 50-7~
3 DTXSID5020023 DSSTox_Substance_Id DTXSID5020023 Acrolein DTXCID80~ 107-~
# A tibble: 3 x 7
INPUT FOUND_BY DTXSID PREFERRED_NAME DTXCID...5 DTXCID...6 CASRN
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 50-00-0 CASRN DTXSI~ Formaldehyde DTXCID306~ DTXCID306~ 50-0~
2 Aspirin Approved Name DTXSI~ Aspirin DTXCID501~ DTXCID501~ 50-7~
3 DTXSID5020023 DSSTox_Substa~ DTXSI~ Acrolein DTXCID8023 DTXCID8023 107-~

7 changes: 7 additions & 0 deletions tests/testthat/test-comptox.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ test_that("Missing required parameter", {
"The argument ids is required."
)
})


test_that("extr_comptox when download_items is set to one val", {
expect_no_error(
result <- extr_comptox(c("31-12-5", "80-05-7"), download_items = "TOXVAL_DETAILS")
)
})

0 comments on commit 419936a

Please sign in to comment.