Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CompTox webtest_query() #251

Closed
wants to merge 200 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
119fcc1
Add functions to customize communication with PubChem REST-API
stitam Apr 16, 2020
76249f3
Merge remote-tracking branch 'upstream/master' into i206
stitam Apr 16, 2020
419c692
New functions for the PubChem PUG-REST API
stitam Apr 16, 2020
c13b7e1
Updates documentation for pc_pugrest
stitam Apr 16, 2020
8735236
Multiple ways to post http requests
stitam Apr 16, 2020
5058dc5
Merge remote-tracking branch 'upstream/master' into i206
stitam Apr 17, 2020
407f272
Remove pc_pugrest, pc_validate, add get_sid
stitam Apr 18, 2020
575e59f
Add ... argument to get_sid documentation
stitam Apr 19, 2020
34ac653
Tests to check examples in article
stitam Apr 23, 2020
0e5824c
Merge remote-tracking branch 'upstream/master' into article
stitam Apr 23, 2020
7d629a3
Increase version number
stitam Apr 23, 2020
a10646a
Revert "Increase version number"
stitam Apr 23, 2020
394adcc
Remove cas.etox_basic() from extractors.R
stitam Apr 23, 2020
1f910eb
Add new function cs_image()
stitam Apr 28, 2020
d891a9c
Merge remote-tracking branch 'upstream/master' into i206
stitam Apr 28, 2020
30bcfa7
Update get_cid() to handle complex queries
stitam Apr 29, 2020
ec60d27
Export get_sid() and fix some tests
stitam Apr 29, 2020
4d76660
Include article tests in test files
stitam Apr 30, 2020
feba94e
Fix conflict in test-chebi.R
stitam Apr 30, 2020
e6b7fb5
Updates to articles tests
stitam Apr 30, 2020
b467673
Small fixes in tests
stitam Apr 30, 2020
252d70c
Merge remote-tracking branch 'upstream/master' into article
stitam Apr 30, 2020
94c5665
Fix some tests in test-chemspider.R
stitam Apr 30, 2020
c8941ce
Merge remote-tracking branch 'upstream/master' into chemspider
stitam May 4, 2020
356bc1c
Updates to cs_image()
stitam May 4, 2020
d501eb1
changes to tests including: replacing expect_is with expect_s3_class …
Aariq May 4, 2020
26696e9
added codecov.yml
Aariq May 4, 2020
c4f8000
changed email to tamas instead of eduard
Aariq May 4, 2020
0a53d26
added codecov
Aariq May 4, 2020
9b6c8be
travis should now run tests because it's NOT_CRAN
Aariq May 4, 2020
1db4a3f
added codecov
Aariq May 4, 2020
1cc2d93
changed codecov badge to master branch since we're not using test bra…
Aariq May 4, 2020
9176cda
changed codecov badge to master branch since we don't use test branch…
Aariq May 4, 2020
cbd929e
skip tests if service is down
Aariq May 5, 2020
226f1dc
just skip some tests for now so I can get a passing build
Aariq May 5, 2020
6e37e43
change email
Aariq May 5, 2020
fbb6d67
fix merge
Aariq May 5, 2020
93d729c
rearranged tests by service rather than function.
Aariq May 5, 2020
b5ea772
properly deprecate first=TRUE
Aariq May 5, 2020
24a7d2b
check if services are down before testing
Aariq May 5, 2020
1314044
Fix merge conflict
stitam May 5, 2020
b3e5982
used queries with more unique results to better test cs_control(). o…
Aariq May 5, 2020
58db4bc
CORRECTLY deprecated first=
Aariq May 5, 2020
ec5c54b
fixing expect_ functions
Aariq May 5, 2020
3781efe
skip failing tests for now to test codecov
Aariq May 5, 2020
52bf304
try installing r-cran-rjava to deal with error in test-utils.R on lib…
Aariq May 5, 2020
283d686
skip failing tests for now to check codecov
Aariq May 5, 2020
7230cc7
try adding rcdk to Suggests instead. (facepalm)
Aariq May 5, 2020
224bfa9
set appveyor to run as NOT_CRAN
Aariq May 5, 2020
532c3d7
attempt to get appveyor to load rcdk correctly using suggestion here:…
Aariq May 5, 2020
c300992
one more try to get 64 bit build to work with rJava
Aariq May 5, 2020
f29f8ac
push logs as artifact upon failure
Aariq May 5, 2020
8a750a2
change email to tamas
Aariq May 5, 2020
a0bc643
unskip failing tests
Aariq May 5, 2020
23f3aba
Merge remote-tracking branch 'upstream/master' into chemspider
stitam May 6, 2020
93d17f3
added ping_*() functions to aid in testing. Closes #118.
Aariq May 6, 2020
5d730ec
molecular weights of two compound are equal so order is fine like this.
Aariq May 6, 2020
18fbdb0
moved ping_()s outside of tests so only pings service once.
Aariq May 6, 2020
5cf42d8
skiped a test that only seems to fail on R CMD check
Aariq May 6, 2020
d022eaa
added webtest_query()
andschar May 7, 2020
58c6f70
Finalise cs_img() before PR
stitam May 8, 2020
00522b2
Remove irrelevant edits
stitam May 8, 2020
680ab27
wrote a single exported ping_service function.
Aariq May 8, 2020
69a3cc2
changed tests to use new ping_service() function
Aariq May 8, 2020
7ddf680
CHEMID is back up and most of the tests are failing. Seems like it's…
Aariq May 8, 2020
79fe8fe
really having problems with chemid, so just skipping everything for now.
Aariq May 8, 2020
ce79d1b
minor edits to tests
Aariq May 8, 2020
7b7d56e
changed to match travis.yml
Aariq May 8, 2020
0803bea
Merge pull request #248 from Aariq/codecov
stitam May 9, 2020
2fc70eb
Fix merge conflicts
stitam May 11, 2020
d984b2e
chenged to testthat::expect_s3_class()
andschar May 12, 2020
5233e61
Merge remote-tracking branch 'upstream/master' into i206
stitam May 13, 2020
125f840
Add NEWS.md
Aariq May 13, 2020
32e05ec
switch NEWS to .md file
Aariq May 13, 2020
60f3fb7
severely reduced README length
Aariq May 13, 2020
2c1c106
added vignette for "getting started"
Aariq May 13, 2020
77463fb
added pkgdown config
Aariq May 13, 2020
2ff71bd
added instructions for previewing pkgdown site
Aariq May 13, 2020
5363ace
Update get_cid() to query substance and assay domains as well
stitam May 14, 2020
d3bc549
Fix failed tests
stitam May 14, 2020
3cc6ad3
Minor fix in pubchem tests
stitam May 14, 2020
25eea87
Add URLencoding and uncomment a failed test
stitam May 15, 2020
786d074
Merge pull request #239 from stitam/i206
stitam May 15, 2020
8ee6cf1
Fix get_cid() etc. related tests
stitam May 15, 2020
92a489a
Small fix for unused connections in scrapers
stitam May 15, 2020
3a790a9
Skip some tests when ChemSpider is down
stitam May 16, 2020
5396e1e
Make PubChem tests less sensitive to web service updates
stitam May 16, 2020
984c343
Trigger retest
stitam May 16, 2020
7d89a4f
Trigger retest
stitam May 16, 2020
d97dff8
Trigger retest
stitam May 17, 2020
552e033
Remove tests that might take a long time
stitam May 17, 2020
000d110
Remove handle from PubChem requests
stitam May 17, 2020
a1c3be0
Trigger retest
stitam May 17, 2020
757b00d
fixed typos
Aariq May 18, 2020
5a7d1f9
reverted changes to related projects, added link to survey at top.
Aariq May 18, 2020
20021a0
update from master
Aariq May 18, 2020
acb42e4
relaxed testing condition.
Aariq May 18, 2020
409a888
fixed pkgdown build error
Aariq May 19, 2020
cd14385
added ChemPhys CRAN task view
Aariq May 19, 2020
14b4deb
try switching to open ssl for curl backend.
Aariq May 19, 2020
51fb6b2
tried using GET rather than fromJSON directly. Not sure if this will…
Aariq May 19, 2020
95c4d0a
Merge pull request #256 from Aariq/gh-pages
stitam May 19, 2020
437684f
Trigger retest
stitam May 19, 2020
7ed0c9f
Update AppVeyor badge
stitam May 19, 2020
5325778
Merge pull request #243 from stitam/article
stitam May 19, 2020
5854211
Fix merge conflict
stitam May 24, 2020
2ba051b
Update citation
stitam May 24, 2020
1987d25
Fix ci_query()
stitam May 24, 2020
98ee9f5
Update pan_query() not to convert to numeric
stitam May 24, 2020
99572c0
Add web services to Description, update version number
stitam May 24, 2020
d746658
fixing bugs related to NAs. May have fixed some other bugs by accident.
Aariq May 14, 2020
e3ef522
Revert "added instructions for previewing pkgdown site"
Aariq May 14, 2020
35579f6
Changed default behavior of extractors to error rather than guessing.…
Aariq May 14, 2020
fcc5fcd
give opsin query a class
Aariq May 24, 2020
ed15fac
removed tests for cts since it returns a named vector not a list.
Aariq May 24, 2020
6e3d9bf
switched cts tests to chemical name since inchikey translations are b…
Aariq May 24, 2020
87e1e9d
minor changes
Aariq May 24, 2020
e8b15f1
Merge pull request #259 from Aariq/aariq-nas
stitam May 25, 2020
bc5dc9a
Merge remote-tracking branch 'upstream/master' into article
stitam May 25, 2020
381ce2e
Fix Description line breaks
stitam May 25, 2020
a3e854a
Add reference to JSS article
stitam May 25, 2020
e235f46
Skip failing test that works locally
stitam May 25, 2020
6d0e63c
Skip all chemid tests. Tests work locally
stitam May 25, 2020
4a7a864
Update version number to 1.0.0
stitam May 25, 2020
a630eb6
Add special characters to author names
stitam May 26, 2020
765b0af
Update documentation
stitam May 26, 2020
6748181
Correct typo
stitam May 26, 2020
7de95aa
Merge pull request #260 from stitam/article
stitam May 26, 2020
f219aa0
Update chemid url in example
stitam May 27, 2020
be4e536
Merge pull request #261 from stitam/master
stitam May 28, 2020
812b9be
Merge remote-tracking branch 'upstream/master' into chemspider
stitam Jun 8, 2020
b6bdef2
Remove automatically generated files
stitam Jun 8, 2020
e00c1a0
Start new dev version
stitam Jun 8, 2020
b2f518a
Update cs_img()
stitam Jun 9, 2020
deae126
Add dir argument to examples
stitam Jun 13, 2020
b63ed2f
Merge pull request #253 from stitam/chemspider
stitam Jun 13, 2020
edeb0ac
added from arguments to function with match.arg()
Aariq Jun 7, 2020
7a7d7cb
changed "type" argument to "from" for consistency
Aariq Jun 9, 2020
8a853c4
added "query" and "from" arguments
Aariq Jun 9, 2020
94a4994
Made possible "from" arguments more consistent
Aariq Jun 9, 2020
eaffafc
added "cas" as a possible value for "from" and fixed #255 issue with …
Aariq Jun 9, 2020
af8a545
update tests and news
Aariq Jun 9, 2020
1f8e674
added case-insensitive arg matching
Aariq Jun 9, 2020
33852b5
made arguments case-insenstivie
Aariq Jun 9, 2020
eba73cf
added autotranslate function draft
Aariq Jun 9, 2020
ed97036
re-built documentation
Aariq Jun 9, 2020
c67d074
added dots to absorb unused arguments
Aariq Jun 9, 2020
c5e15a8
uniformity of outputs
Aariq Jun 9, 2020
b51ab91
added check_coverage() function
Aariq Jun 9, 2020
aa1f014
updated docs
Aariq Jun 9, 2020
b4db84b
added plot output (for fun and testing). need to eventually change t…
Aariq Jun 11, 2020
1864fa3
added additional translators
Aariq Jun 11, 2020
859f9b7
removed additional translators because they are never used, I think.
Aariq Jun 11, 2020
924af45
moved to separate r file
Aariq Jun 11, 2020
ace8aca
added tests
Aariq Jun 11, 2020
18ee4f5
fixed another skipped test #255
Aariq Jun 11, 2020
91471b2
finishing touches
Aariq Jun 11, 2020
18ab9b9
added Suggests to make plotting work.
Aariq Jun 11, 2020
52b0913
I don't know why these tests are failing. They work when run manually…
Aariq Jun 11, 2020
e910965
fixed a bug in chooser() utility I didn't know existed
Aariq Jun 11, 2020
b3f7a7c
added deprecated arguments to documentation
Aariq Jun 11, 2020
fd220c8
REALLY fixed bug in chooser()
Aariq Jun 11, 2020
bd97009
switched NA to NA_character_
Aariq Jun 12, 2020
b8f9289
Revert "switched NA to NA_character_"
Aariq Jun 12, 2020
6e24d73
fixed merge
Aariq Jun 16, 2020
14ccbd2
changed function name from check_coverage to has_entry
Aariq Jun 19, 2020
398a504
pass NAs through
Aariq Jun 19, 2020
86efab9
switched to base R plotting
Aariq Jun 19, 2020
a41f299
small fixes
Aariq Jun 19, 2020
d0defe7
updated `pc_synonyms` `cts_convert`, and `cir_query` to use `match` i…
Aariq Jun 22, 2020
4deeec3
changed get_etoxid to use matcher() internally. Added warning for ma…
Aariq Jun 23, 2020
f6aa772
changed default match = . updated tests
Aariq Jun 23, 2020
b83aa1a
fix tests
Aariq Jun 23, 2020
7c3a889
addressing review of PR
Aariq Jun 27, 2020
e29b476
add skips for integration function tests.
Aariq Jun 27, 2020
76c32a8
change pan example, update a test.
Aariq Jul 2, 2020
99b5284
lintr suggestions
Aariq Jul 3, 2020
f93a85d
Updates badges, Put databases in alphabetical order
stitam Jul 5, 2020
fb78a71
Generate codemeta.json
stitam Jul 5, 2020
76b31cb
Remove reference to the polite package
stitam Jul 5, 2020
a6a4370
Add guideline for functions that retrieve images
stitam Jul 5, 2020
44f1d15
Ping webservices in test files
stitam Jul 5, 2020
27736fd
Add rOpenSci Code of Conduct
stitam Jul 5, 2020
37bd2f0
Fix Issue 269
stitam Jul 7, 2020
73b8c26
Update URL encoding, unskip tests
stitam Jul 7, 2020
7808a3f
Update URL encoding to include reverse = TRUE
stitam Jul 7, 2020
fdf6547
change autotranslate to with_cts and make unexported. Re-run documen…
Aariq Jul 7, 2020
19ba9d1
changed function name from has_entry to find_db. Other minor changes…
Aariq Jul 8, 2020
f33a964
Merge pull request #264 from Aariq/integration
stitam Jul 8, 2020
5e2e82e
Merge remote-tracking branch 'upstream/master' into documentation
stitam Jul 9, 2020
12c6c9f
Merge pull request #267 from stitam/documentation
stitam Jul 9, 2020
8cc11a4
Merge remote-tracking branch 'upstream/master' into bugs
stitam Jul 9, 2020
2d637ac
Add tests for handling special characters in SMILES
stitam Jul 10, 2020
8b5b18a
Fix failing test
stitam Jul 10, 2020
4b0ed71
Add a line to news and a note to contributing
stitam Jul 10, 2020
4712e9c
Merge pull request #270 from stitam/bugs
Aariq Jul 14, 2020
50bad3c
added webtest_query()
andschar May 7, 2020
2d9d64d
chenged to testthat::expect_s3_class()
andschar May 12, 2020
5a0d2e6
bug
andschar Jun 7, 2020
d8165a3
bug
andschar Jul 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lintr suggestions
Aariq committed Jul 3, 2020
commit 99b528469e7d745121a2ee600c4645b3a2058ba9
42 changes: 32 additions & 10 deletions R/integration.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@

#' Auto-translate identifiers and search databases
#'
#' Supply a query of any type (e.g. SMILES, CAS, name, InChI, etc.) along with any webchem function that has \code{query} and \code{from} arguments. If the function doesn't accept the type of query you've supplied, this will try to automatically translate it using CTS and run the query.
#' Supply a query of any type (e.g. SMILES, CAS, name, InChI, etc.) along with
#' any webchem function that has \code{query} and \code{from} arguments. If the
#' function doesn't accept the type of query you've supplied, this will try to
#' automatically translate it using CTS and run the query.
#'
#' @param query character; the search term
#' @param from character; the format or type of query. Commonly accepted values are "name", "cas", "inchi", and "inchikey"
#' @param from character; the format or type of query. Commonly accepted values
#' are "name", "cas", "inchi", and "inchikey"
#' @param .f character; the (quoted) name of a webchem function
#' @param .verbose logical; print a message when translating query?
#' @param ... other arguments passed to the function specified with \code{.f}
#'
#' @note During the translation step, only the first hit from CTS is used.
#' Therefore, using this function to translate on the fly is not foolproof and
#' care should be taken to verify the results.
#' @return returns results from \code{.f}
#' @importFrom rlang as_function fn_fmls
#' @export
@@ -24,9 +30,15 @@ autotranslate <- function(query, from, .f, .verbose = TRUE, ...) {
if (!from %in% pos_froms) {
pos_froms <- pos_froms[pos_froms != "name"] #cts name conversion broken
new_from <- pos_froms[which(pos_froms %in% cts_to())[1]]
if(.verbose){
if (.verbose) {
message(
paste0(.f, " doesn't accept ", from, ".\n", "Attempting to translate to ", new_from, " with CTS. ")
paste0(.f,
" doesn't accept ",
from,
".\n",
"Attempting to translate to ",
new_from,
" with CTS. ")
)
}
new_query <- cts_convert(query, from = from, to = new_from, match = "first")
@@ -44,11 +56,15 @@ autotranslate <- function(query, from, .f, .verbose = TRUE, ...) {
#' Checks if entries are found in (most) data sources included in webchem
#'
#' @param query character; the search term
#' @param from character; the format or type of query. Commonly accepted values are "name", "cas", "inchi", and "inchikey"
#' @param sources character; which data sources to check. Data sources are identified by the prefix associated with webchem functions that query those databases. If not specified, all data sources listed will be checked.
#' @param from character; the format or type of query. Commonly accepted values
#' are "name", "cas", "inchi", and "inchikey"
#' @param sources character; which data sources to check. Data sources are
#' identified by the prefix associated with webchem functions that query those
#' databases. If not specified, all data sources listed will be checked.
#' @param plot logical; plot a graphical representation of results.
#'
#' @return a tibble of logical values where \code{TRUE} indicates that a data source contains a record for the query
#' @return a tibble of logical values where \code{TRUE} indicates that a data
#' source contains a record for the query
#' @export
#' @import dplyr
#' @examples
@@ -72,7 +88,13 @@ has_entry <- function(query, from,

foo <- function(.f, query, from) {
# if a function errors (e.g. API is down) then return NA
x <- try(autotranslate(query = query, from = from, .f = .f, match = "first"))
x <-
try(autotranslate(
query = query,
from = from,
.f = .f,
match = "first"
))
if (inherits(x, "try-error")) {
return(NA)
}
@@ -99,7 +121,7 @@ has_entry <- function(query, from,
select(all_of(colorder)) %>%
as.matrix()
opar <- graphics::par(no.readonly = TRUE)
graphics::par(mar=c(5.1, 7.1, 4.1, 4.1)) # adapt margins
graphics::par(mar = c(5.1, 7.1, 4.1, 4.1)) # adapt margins
plot(
pmat,
col = c("#C7010B", "#3BC03B"),
17 changes: 12 additions & 5 deletions tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# These all might occasionally fail because cts_translate() is currently somewhat unreliable.
# These all might occasionally fail because cts_translate() is currently
# somewhat unreliable.

fn_up <- ping_service("fn")
up <- ping_service("cts")
@@ -9,7 +10,13 @@ test_that("autotranslate works when no translation needed", {
skip_if_not(up, "CTS service down")

CASs <- c("75-07-0", "64-17-5")
a <- autotranslate(query = CASs, from = "cas", .f = "fn_percept", .verbose = TRUE)
a <-
autotranslate(
query = CASs,
from = "cas",
.f = "fn_percept",
.verbose = TRUE
)
b <- fn_percept(CASs)
expect_equal(a, b)
})
@@ -20,7 +27,8 @@ test_that("autotranslate translates", {
skip_if_not(etox_up, "ETOX down!")
skip_if_not(up, "CTS service down")

x <- autotranslate(query = "XDDAORKBJWWYJS-UHFFFAOYSA-N", from = "inchikey", .f = "get_etoxid")
x <-
autotranslate(query = "XDDAORKBJWWYJS-UHFFFAOYSA-N", from = "inchikey", .f = "get_etoxid")
y <- get_etoxid(query = "1071-83-6", from = "cas")
expect_equal(x, y)
})
@@ -39,5 +47,4 @@ test_that("has_entry() function works", {
etox = c(TRUE, FALSE, FALSE),
fn = c(FALSE, FALSE, FALSE))
expect_equivalent(out, df)
})

})