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>. |
Authors: | Global Crop Diversity Trust [cph], Matija Obreza [aut, cre], Nora Castaneda [ctb] |
Maintainer: | Matija Obreza <[email protected]> |
License: | Apache License 2.0 |
Version: | 2.1.1 |
Built: | 2025-02-18 03:56:04 UTC |
Source: | https://github.com/cran/genesysr |
Get partial API v1 URL for the provided path
api1_url(path)
api1_url(path)
path |
relative path of the API v1 endpoint (e.g. |
Returns "/api/v1" + path
api1_url("/me")
api1_url("/me")
Get partial API v2 URL for the provided path
api2_url(path)
api2_url(path)
path |
relative path of the API v2 endpoint (e.g. |
Returns "/api/v2" + path
api2_url("/me")
api2_url("/me")
Provide OAuth2 token to use for authorization with Genesys
authorization(authorization)
authorization(authorization)
authorization |
OAuth2 Authorization header obtained from somewhere else (e.g. an ENV variable) |
Run Land-or-Sea check on MCPD data. Uploads only rows where ORIGCTY, DECLATITUDE and DECLONGITUDE are provided.
check_country(mcpd)
check_country(mcpd)
mcpd |
Accession passport data in MCPD format |
Results from validator
## Not run: geoCheck <- genesysr::check_country(mcpd) ## End(Not run)
## Not run: geoCheck <- genesysr::check_country(mcpd) ## End(Not run)
Run Land-or-Sea check on MCPD data using https://validator.genesys-pgr.org. Uploads only rows where DECLATITUDE and DECLONGITUDE are provided. In practice it is better to use 'check_country' if ORIGCTY data exists.
check_landorsea(mcpd)
check_landorsea(mcpd)
mcpd |
Accession passport data in MCPD format |
Results from validator
## Not run: waterCheck <- genesysr::check_landorsea(mcpd) ## End(Not run)
## Not run: waterCheck <- genesysr::check_landorsea(mcpd) ## End(Not run)
Duplicate input rows are removed using dplyr::distinct() and results are returned for unique rows.
check_taxonomy(mcpd, toCurrentTaxa = FALSE)
check_taxonomy(mcpd, toCurrentTaxa = FALSE)
mcpd |
Accession passport data in MCPD format |
toCurrentTaxa |
Should obsoleted names be reported? |
Results from validator
## Not run: taxaCheck <- genesysr::check_taxonomy(mcpd) ## End(Not run)
## Not run: taxaCheck <- genesysr::check_taxonomy(mcpd) ## End(Not run)
The client must be enabled for Client Credential grant on Genesys.
client_login()
client_login()
Download passport data for one genebank in Excel format and save it to disk
download_mcpd(instituteCode, file = NULL)
download_mcpd(instituteCode, file = NULL)
instituteCode |
FAO WIEWS institute code |
file |
Target file name. Defaults to Genesys-provided file name in the current working directory. |
The downloaded MCPD file name
## Not run: # Download MCPD passport data for NGA039 excelFile <- download_mcpd("NGA039") ## End(Not run)
## Not run: # Download MCPD passport data for NGA039 excelFile <- download_mcpd("NGA039") ## End(Not run)
Download PDCI data for one genebank in Excel format and save it to disk.
download_pdci(instituteCode, file = NULL)
download_pdci(instituteCode, file = NULL)
instituteCode |
FAO WIEWS institute code |
file |
Target file name. Defaults to Genesys-provided file name in the current working directory. |
The downloaded PDCI file name
## Not run: # Download PDCI data for NGA039 excelData <- download_pdci("NGA039") ## End(Not run)
## Not run: # Download PDCI data for NGA039 excelData <- download_pdci("NGA039") ## End(Not run)
get_accessions
might be more useful as it returns a data table.Fetch accession passport data and return the paged data structure for further processing.
get_accessions
might be more useful as it returns a data table.
fetch_accessions( filters = list(), page = NULL, size = 1000, selector = NULL, at.least = NULL )
fetch_accessions( filters = list(), page = NULL, size = 1000, selector = NULL, at.least = NULL )
filters |
an R |
page |
the page index (0-based) |
size |
number of records to load per page (page size) |
selector |
NULL or a function to "select" variables of interest |
at.least |
stop fetching when at.least records are received from Genesys |
Paged data structure
## Not run: # Retrieve all accession data by country of origin accessions <- genesysr::fetch_accessions(mcpd_filter(ORIGCTY = c("DEU", "SVN"))) # Fetch Musa musa <- genesysr::fetch_accessions(list(taxonomy.genus = c('Musa'))) # Apply selector function accessions <- genesysr::fetch_accessions( mcpd_filter(ORIGCTY = c("DEU", "SVN")), selector = function(x) { list(id = x$id, acceNumb = x$acceNumb, instCode = x$institute$code) } ) ## End(Not run)
## Not run: # Retrieve all accession data by country of origin accessions <- genesysr::fetch_accessions(mcpd_filter(ORIGCTY = c("DEU", "SVN"))) # Fetch Musa musa <- genesysr::fetch_accessions(list(taxonomy.genus = c('Musa'))) # Apply selector function accessions <- genesysr::fetch_accessions( mcpd_filter(ORIGCTY = c("DEU", "SVN")), selector = function(x) { list(id = x$id, acceNumb = x$acceNumb, instCode = x$institute$code) } ) ## End(Not run)
Add filter on accession DOI
filter_DOI(filter = list(), DOI)
filter_DOI(filter = list(), DOI)
filter |
Existing filters (or blank list if not provided) |
DOI |
Accession DOI |
Add filter by genus
filter_GENUS(filter = list(), GENUS)
filter_GENUS(filter = list(), GENUS)
filter |
Existing filters (or blank list if not provided) |
GENUS |
List of genera |
Add filter by genus
filter_INSTCODE(filter = list(), INSTCODE)
filter_INSTCODE(filter = list(), INSTCODE)
filter |
Existing filters (or blank list if not provided) |
INSTCODE |
List of WIEWS institute codes |
Add filter on Country of origin of material
filter_ORIGCTY(filter = list(), ORIGCTY)
filter_ORIGCTY(filter = list(), ORIGCTY)
filter |
Existing filters (or blank list if not provided) |
ORIGCTY |
Country of origin |
Add filter on Biological status of sample
filter_SAMPSTAT(filter = list(), SAMPSTAT)
filter_SAMPSTAT(filter = list(), SAMPSTAT)
filter |
Existing filters (or blank list if not provided) |
SAMPSTAT |
Biological status of sample |
Add filter on specific epithet
filter_SPECIES(filter = list(), SPECIES)
filter_SPECIES(filter = list(), SPECIES)
filter |
Existing filters (or blank list if not provided) |
SPECIES |
List of specific epithets |
Get accession passport data as a data table.
get_accessions( filters = list(), page = 0, size = 1000, fields = NULL, exclude = NULL, selector = NULL, at.least = NULL )
get_accessions( filters = list(), page = 0, size = 1000, fields = NULL, exclude = NULL, selector = NULL, at.least = NULL )
filters |
an R |
page |
the page index (0-based) |
size |
number of records to load per page (page size) |
fields |
list of fields to fetch from Genesys |
exclude |
list of field prefixes to exclude from the Genesys response |
selector |
NULL or a function to "select" variables of interest |
at.least |
stop fetching when at.least records are received from Genesys |
Data table
## Not run: # Retrieve all accession data by country of origin (Slovenia, Ivory Coast) accessions <- genesysr::get_accessions(list(countryOfOrigin = list(code3 = c('SVN', 'CIV')))) # Fetch Musa, but only geographic data and accessionNumber musa <- genesysr::get_accessions(list(taxonomy = list(genus = c('Musa'))), fields = c("accessionNumber", "geo")) # Apply selector function accessions <- genesysr::get_accessions(mcpd_filter(ORIGCTY = c('DEU', 'SVN')), selector = function(x) { list(id = x$id, acceNumb = x$accessionNumber, instCode = x$instituteCode) }, at.least = 100) ## End(Not run)
## Not run: # Retrieve all accession data by country of origin (Slovenia, Ivory Coast) accessions <- genesysr::get_accessions(list(countryOfOrigin = list(code3 = c('SVN', 'CIV')))) # Fetch Musa, but only geographic data and accessionNumber musa <- genesysr::get_accessions(list(taxonomy = list(genus = c('Musa'))), fields = c("accessionNumber", "geo")) # Apply selector function accessions <- genesysr::get_accessions(mcpd_filter(ORIGCTY = c('DEU', 'SVN')), selector = function(x) { list(id = x$id, acceNumb = x$accessionNumber, instCode = x$instituteCode) }, at.least = 100) ## End(Not run)
Fetch Genesys crops. Note that the list of Genesys crops does not fully correspond with various CROPNAME in MCPD provided by genebanks.
list_crops()
list_crops()
Genesys crops
## Not run: # Retrieve all Genesys crops crops <- genesysr::list_crops() ## End(Not run)
## Not run: # Retrieve all Genesys crops crops <- genesysr::list_crops() ## End(Not run)
Institute filters: - code: list of WIEWS institute codes - accessions: boolean, TRUE list only institutes with accessions in Genesys, FALSE without accessions - country$code3: list of ISO3166 country codes
list_institutes(filters = list(), at.least = NULL)
list_institutes(filters = list(), at.least = NULL)
filters |
an R |
at.least |
stop fetching when at.least records are received from Genesys |
List of institutes
## Not run: # Retrieve taxa of selected accessions filters <- c(); filters$accessions = TRUE; # Has accessions in Genesys institutes <- genesysr::list_institutes(filters) ## End(Not run)
## Not run: # Retrieve taxa of selected accessions filters <- c(); filters$accessions = TRUE; # Has accessions in Genesys institutes <- genesysr::list_institutes(filters) ## End(Not run)
Fetch taxonomic data of selected accessions.
list_species(filters = list())
list_species(filters = list())
filters |
an R |
Taxonomic records of selected accessions
## Not run: # Retrieve taxa of selected accessions taxa <- genesysr::list_species(mcpd_filter(INSTCODE = c("LBN002", "MEX002"))) ## End(Not run)
## Not run: # Retrieve taxa of selected accessions taxa <- genesysr::list_species(mcpd_filter(INSTCODE = c("LBN002", "MEX002"))) ## End(Not run)
See FAO/Bioversity Multi-Crop Passport Descriptors.
mcpd_filter( filter = list(), INSTCODE = NULL, DOI = NULL, ORIGCTY = NULL, SAMPSTAT = NULL, GENUS = NULL, SPECIES = NULL )
mcpd_filter( filter = list(), INSTCODE = NULL, DOI = NULL, ORIGCTY = NULL, SAMPSTAT = NULL, GENUS = NULL, SPECIES = NULL )
filter |
Existing filters (or blank list if not provided) |
INSTCODE |
WIEWS Institute Code of the holding institute |
DOI |
Accession DOI |
ORIGCTY |
Country of origin |
SAMPSTAT |
Biological status of sample |
GENUS |
List of genera |
SPECIES |
List of specific epithets (within specified genera) |
# Filter accessions from Mexico and Slovenia mcpd_filter(ORIGCTY = c("MEX", "SVN"))
# Filter accessions from Mexico and Slovenia mcpd_filter(ORIGCTY = c("MEX", "SVN"))
Who am i? Loads and prints the user profile from Genesys as JSON. You need to be logged in.
me()
me()
## Not run: # Login setup_production() user_login() me() ## End(Not run)
## Not run: # Login setup_production() user_login() me() ## End(Not run)
Print Genesys client configuration
print_setup()
print_setup()
Configure the Genesys environment
setup(server = NULL, client_id = NULL, client_secret = NULL)
setup(server = NULL, client_id = NULL, client_secret = NULL)
server |
Server base URL (e.g. "https://api.genesys-pgr.org" or "https://api.sandbox.genesys-pgr.org") |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
See utility methods setup_production
, setup_sandbox
# Link with sandbox setup_sandbox()
# Link with sandbox setup_sandbox()
Use the Genesys R Client with <https://api.genesys-pgr.org> requiring user_login
setup_production()
setup_production()
Use the Genesys R Client with <https://api.sandbox.genesys-pgr.org> requiring user_login
setup_sandbox()
setup_sandbox()
The authorization URL will open in a browser, ask the user to grant permissions to R. After successful authentication the browser will display a message:
user_login(redirect_uri = "http://127.0.0.1:48913")
user_login(redirect_uri = "http://127.0.0.1:48913")
redirect_uri |
a custom redirect_uri to submit as part of the authentication request. This is most useful if the default port is blocked and you wish to specify another port: redirect_uri = "http://127.0.0.1:44211" Note that "http://127.0.0.1" is requred and that "http://localhost" will not work. |
“' Authentication complete. Please close this page and return to R. “'
Close the browser and return to R.