Skip to content

Commit

Permalink
version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mobreza authored and cran-robot committed Dec 4, 2022
1 parent fe4ac0c commit f641e96
Show file tree
Hide file tree
Showing 18 changed files with 713 additions and 186 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
@@ -1,5 +1,5 @@
Package: genesysr
Version: 1.0.0
Version: 1.0.1
Title: Genesys PGR Client
Description: Access data on plant genetic resources from genebanks around the world published on Genesys (<https://www.genesys-pgr.org>).
Your use of data is subject to terms and conditions available at <https://www.genesys-pgr.org/content/legal/terms>.
Expand All @@ -8,17 +8,17 @@ Authors@R: c(person(family = "Global Crop Diversity Trust", role = c("cph")),
person("Nora", "Castaneda", email = "nora.castaneda@croptrust.org", role = c("ctb")))
Maintainer: Matija Obreza <matija.obreza@croptrust.org>
Depends: R (>= 3.1.0)
Imports: httr, jsonlite, dplyr
Imports: httr, jsonlite, dplyr, readr
License: Apache License 2.0
RoxygenNote: 6.1.1
RoxygenNote: 7.2.2
URL: https://gitlab.croptrust.org/genesys-pgr/genesysr
BugReports: https://gitlab.croptrust.org/genesys-pgr/genesysr/issues
BugReports: https://gitlab.croptrust.org/genesys-pgr/genesysr/-/issues
Suggests: knitr, rmarkdown, tidyverse
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2019-11-22 08:02:20 UTC; mobreza
Packaged: 2022-12-04 19:23:49 UTC; mobreza
Author: Global Crop Diversity Trust [cph],
Matija Obreza [aut, cre],
Nora Castaneda [ctb]
Repository: CRAN
Date/Publication: 2019-11-22 09:00:02 UTC
Date/Publication: 2022-12-04 19:40:06 UTC
34 changes: 17 additions & 17 deletions MD5
@@ -1,44 +1,44 @@
907f7ea60a224b58a860b4ce567f72bf *DESCRIPTION
bdb408bc6c11624b21bc5215aa068254 *NAMESPACE
29fa1fa0a2edd80bbbe20c4b836263d8 *NEWS.md
b4c01786e54f7330daed0c2ce4d9bfd5 *DESCRIPTION
dc756d77e4b4a45c6ba141752ec38dde *NAMESPACE
f4fc2c0ef0f99519d53a52c4c7259e1c *NEWS.md
1497f74c12546203f181f3d63415605c *R/api-client.R
110db0929fd635f18da1b784793a4734 *R/filters.R
6689e7e2a7216aa227db5f5f7d4f6502 *R/genesys.R
f2a673e3cd2911388d34c57b0829a82c *R/validator.R
13399387dfb4ac445dab7fb89d9ac2c0 *R/genesys.R
eb71556e6334bbed2c0e25f3b338836b *R/validator.R
6e67a1eca11c3451a4112dd38a45d4ab *README.md
7fa50f2d490be54be282ae6a36b269d3 *build/vignette.rds
d892ef9f029d47539c5d1fc405cd9f45 *inst/doc/tutorial.Rmd
5fe3e8a6443016e21e1a13f7ba839088 *inst/doc/tutorial.html
1607a8bfbf546732fe9457c00066d9b9 *build/vignette.rds
f68a40e6c5d064381d2baadb74340315 *inst/doc/tutorial.Rmd
b84e6108aaf2143b1cf6fdd132982330 *inst/doc/tutorial.html
6dc91108d4df58376962045ec059c7a1 *inst/doc/validation.Rmd
44a111ee19c0f95100385819f62f5254 *inst/doc/validation.html
0d86c1236f83fac0b86f628eb943ae36 *inst/doc/validation.html
b19d70c471dca9cab0e9be7bf99e18d4 *man/api1_url.Rd
71368433538ec6bed7d6e4383ec1c4bd *man/api2_url.Rd
3c89e0e5581c109333bd2c32c8affd80 *man/authorization.Rd
a8b50a6b59651d70191249bb1e7018d5 *man/check_country.Rd
7db048bae2a7ca1df855349eb00a0af0 *man/check_landorsea.Rd
534baf02d256d1db04eecfae44b88571 *man/check_taxonomy.Rd
b977ae83784900d75d756d2946920d63 *man/client_login.Rd
829788c42a3c3a63c11940868a24b80e *man/dot-MAX_ALLOWED_PAGES.Rd
92adc2d83a8ef3856c7e901a9ba8d8e0 *man/dot-MAX_ALLOWED_PAGES.Rd
3205dbf82835e36f0137bcbbb519d27e *man/dot-check_auth.Rd
a1f2b3a3fc5b8074a6ec59958302172f *man/dot-fetch_accessions_page.Rd
2ccfa4acb65391dfedd29508660948fa *man/dot-list_accessions_page.Rd
fa88763e5ad594f695917036ac179f9f *man/dot-fetch_accessions_page.Rd
ebdf43d8be8dc40cb81e7efe5b11d85d *man/dot-list_accessions_page.Rd
62e4b4878e8abaeb12835c7c0c14c113 *man/dot-onLoad.Rd
a3068cf459d16fa049d165daf44de6bf *man/dot-post.Rd
cb92ad2fb9435cb1437c8d19d63341ac *man/dot-post.Rd
78e4c5eeb52e4816ecc51dd377075da5 *man/download_mcpd.Rd
f4709b7d7e9d603627f955ae939a7692 *man/download_pdci.Rd
a4e2f7a68c9b341c04a80b23844ae3f0 *man/fetch_accessions.Rd
755ad4be7fe6dedd5162a68056d7c227 *man/fetch_accessions.Rd
2db62806b45ddc904228f7dad30cb932 *man/filter_DOI.Rd
6ba5ade289d3567c37c9651f1c22dc61 *man/filter_GENUS.Rd
1a26ce7d5cd01e2375640e029940359f *man/filter_ORIGCTY.Rd
f5e9d08ec3ee48022daea3ba8491c9b8 *man/filter_SAMPSTAT.Rd
3ebc1e757f1856f9b7742d7241aeb5f6 *man/filter_SPECIES.Rd
bde889e2c3d9b4b3966aee8f8d6281a3 *man/get_accessions.Rd
36ac508927d859dcfb67762bcd812907 *man/mcpd_filter.Rd
2b602baafa12aed1e58682cdf6ee4063 *man/get_accessions.Rd
9008f907597c430f8bdc883c7b4e58eb *man/mcpd_filter.Rd
2ba6fb516ae56d6124cb4b514ebf6b4e *man/me.Rd
8a6fbe344291d152f27e1329998747d7 *man/print_setup.Rd
f562d7cc9ec22b8e692370d584361330 *man/setup.Rd
a5d181cf2b629e0fd4d28356bd185422 *man/setup_production.Rd
5c09b4337f8f2c69dad1d9c47427ef08 *man/setup_sandbox.Rd
8e92387d911827f80c26ef8ce7ee7a9e *man/user_login.Rd
d892ef9f029d47539c5d1fc405cd9f45 *vignettes/tutorial.Rmd
f68a40e6c5d064381d2baadb74340315 *vignettes/tutorial.Rmd
6dc91108d4df58376962045ec059c7a1 *vignettes/validation.Rmd
2 changes: 1 addition & 1 deletion NAMESPACE
Expand Up @@ -23,6 +23,6 @@ export(setup)
export(setup_production)
export(setup_sandbox)
export(user_login)
importFrom(readr,read_delim)
importFrom(utils,browseURL)
importFrom(utils,read.csv)
importFrom(utils,write.table)
18 changes: 11 additions & 7 deletions NEWS.md
@@ -1,14 +1,18 @@
# November 2019
## version 1.0.1

Updated from Genesys API v0 calls to API v1.
- Updated API calls to validator.genesys-pgr.org with `escapeChar`
- Better handling of CSV response from validator

Note: The filter structure has changed. See Tutorial.
## version 1.0.0

# August 2019
- Updated from Genesys API v0 calls to API v1.

Updated for API at api.genesys-pgr.org
### Notes

# June 2018
The filter structure has changed. See Tutorial.

First version of the Genesys API client for R is released.
## version 0.9

- August 2019: Updated for API at api.genesys-pgr.org
- June 2018: First version of the Genesys API client for R is released.

2 changes: 1 addition & 1 deletion R/genesys.R
Expand Up @@ -143,7 +143,7 @@ fetch_accessions <- function(filters = list(), page = NULL, size = 1000, selecto
message(paste("Received 0 bytes"))
data <- data.frame()
} else {
data <- read.csv(text = body, quote = '"', sep = '\t', stringsAsFactors = FALSE)
data <- utils::read.csv(text = body, quote = '"', sep = '\t', stringsAsFactors = FALSE)

# Apply selector
if (is.function(selector)) {
Expand Down
47 changes: 24 additions & 23 deletions R/validator.R
Expand Up @@ -15,24 +15,25 @@
#'
#' @return Results from valdator
#' @export
#' @importFrom utils read.csv write.table
#' @importFrom utils write.table
#' @importFrom readr read_delim
check_taxonomy <- function(mcpd, toCurrentTaxa = FALSE) {
DT <- dplyr::distinct(mcpd)
# print(DT)

CSV <- tempfile(pattern = "file", tmpdir = tempdir(), fileext = "")
write.table(DT, file = CSV, row.names = FALSE, dec=".", sep = "\t", quote = FALSE, na = "")
TMP <- tempfile(pattern = "file", tmpdir = tempdir(), fileext = "")
CSV <- tempfile(pattern = "taxa", tmpdir = tempdir(), fileext = ".csv")
utils::write.table(DT, file = CSV, row.names = FALSE, dec=".", sep = "\t", quote = TRUE, na = "")

TMP <- tempfile(pattern = "taxa-res", tmpdir = tempdir(), fileext = ".csv")

# Requires toCurrentTaxa
response <- httr::POST("https://validator.genesys-pgr.org/process", body = list(
toCurrentTaxa = toCurrentTaxa,
separator = "\t", decimalMark = ".",
separator = "\t", decimalMark = ".", escapeChar = "\\",
encoding = "UTF-8", csvText = readChar(CSV, file.info(CSV)$size)
), encode = "multipart", httr::accept("text/csv"), httr::write_disk(TMP)) # , httr::verbose())
R <- read.csv(TMP, fileEncoding = "UTF-8", sep = "\t")

R <- readr::read_delim(TMP, delim='\t', quote='"', escape_double=FALSE, escape_backslash=TRUE, show_col_types = FALSE)
file.remove(CSV, TMP)
invisible(R)
}
Expand All @@ -50,24 +51,23 @@ check_taxonomy <- function(mcpd, toCurrentTaxa = FALSE) {
#'
#' @return Results from valdator
#' @export
#' @importFrom utils read.csv write.table
#' @importFrom utils write.table
#' @importFrom readr read_delim
check_landorsea <- function(mcpd) {
GEO <- dplyr::filter(mcpd, ! is.na(mcpd$DECLATITUDE) & ! is.na(mcpd$DECLONGITUDE))
# print(GEO)
CSV <- tempfile(pattern = "landorsea", tmpdir = tempdir(), fileext = ".csv")
utils::write.table(GEO, file = CSV, row.names = FALSE, dec=".", sep = "\t", quote = TRUE, na = "")

CSV <- tempfile(pattern = "landorsea", tmpdir = tempdir(), fileext = "")
write.table(GEO, file = CSV, row.names = FALSE, dec=".", sep = "\t", quote = FALSE, na = "")
readChar(CSV, file.info(CSV)$size)
TMP <- tempfile(pattern = "landorsea-res", tmpdir = tempdir(), fileext = ".csv")

TMP <- tempfile(pattern = "landorsea", tmpdir = tempdir(), fileext = "")

response <- httr::POST("https://validator.genesys-pgr.org/process", body = list(
validateType = "landorsea",
separator = "\t", decimalMark = ".",
separator = "\t", decimalMark = ".", escapeChar = "\\",
encoding = "UTF-8", csvText = readChar(CSV, file.info(CSV)$size)
), encode = "multipart", httr::accept("text/csv"), httr::write_disk(TMP)) # , httr::verbose())

R <- read.csv(TMP, fileEncoding = "UTF-8", sep = "\t")
R <- readr::read_delim(TMP, delim='\t', quote='"', escape_double=FALSE, escape_backslash=TRUE, show_col_types = FALSE)
# print(R)
file.remove(CSV, TMP)
invisible(R)
Expand All @@ -85,24 +85,25 @@ check_landorsea <- function(mcpd) {
#'
#' @return Results from valdator
#' @export
#' @importFrom utils read.csv write.table
#' @importFrom utils write.table
#' @importFrom readr read_delim
check_country <- function(mcpd) {
GEO <- dplyr::filter(mcpd, is.character(mcpd$ORIGCTY) & ! is.na(mcpd$DECLATITUDE) & ! is.na(mcpd$DECLONGITUDE))
# print(GEO)

CSV <- tempfile(pattern = "landorsea", tmpdir = tempdir(), fileext = "")
write.table(GEO, file = CSV, row.names = FALSE, dec=".", sep = "\t", quote = FALSE, na = "")
readChar(CSV, file.info(CSV)$size)
CSV <- tempfile(pattern = "country", tmpdir = tempdir(), fileext = ".csv")
utils::write.table(GEO, file = CSV, row.names = FALSE, dec=".", sep = "\t", quote = TRUE, na = "")
# readChar(CSV, file.info(CSV)$size)

TMP <- tempfile(pattern = "landorsea", tmpdir = tempdir(), fileext = "")
TMP <- tempfile(pattern = "country-res", tmpdir = tempdir(), fileext = ".csv")

response <- httr::POST("https://validator.genesys-pgr.org/process", body = list(
validateType = "country",
separator = "\t", decimalMark = ".",
separator = "\t", decimalMark = ".", escapeChar = "\\",
encoding = "UTF-8", csvText = readChar(CSV, file.info(CSV)$size)
), encode = "multipart", httr::accept("text/csv"), httr::write_disk(TMP)) # , httr::verbose())

R <- read.csv(TMP, fileEncoding = "UTF-8", sep = "\t")
R <- readr::read_delim(TMP, delim='\t', quote='"', escape_double=FALSE, escape_backslash=TRUE, show_col_types = FALSE)
# print(R)
file.remove(CSV, TMP)
invisible(R)
Expand Down
Binary file modified build/vignette.rds
Binary file not shown.
2 changes: 1 addition & 1 deletion inst/doc/tutorial.Rmd
Expand Up @@ -15,7 +15,7 @@ Querying Genesys PGR
[Genesys PGR](https://www.genesys-pgr.org) is the global database on plant genetic resources
maintained *ex situ* in national, regional and international genebanks around the world.

**genesysr** uses the [Genesys API](https://www.genesys-pgr.org/doc/0/apis) to query Genesys data.
**genesysr** uses the [Genesys API](https://www.genesys-pgr.org/documentation/apis) to query Genesys data.
The API is accessible at https://api.genesys-pgr.org.

Accessing data with **genesysr** is similar to downloading data in CSV or Excel format and loading
Expand Down

0 comments on commit f641e96

Please sign in to comment.