Learn R Programming

Genesys R client

The genesysr R package provides functions for authentication with Genesys and functions to fetch accession data from https://www.genesys-pgr.org database.

Note: See NEWS.md

Installing the development version

devtools::install_git('https://gitlab.croptrust.org/genesys-pgr/genesysr')

Using genesysr

  1. Setup and configure
  2. Authenticate
  3. User authentication
  4. Client authentication
  5. Query

Setup and configuration

library('genesysr')

# www.genesys-pgr.org
genesysr::setup_production()

# or sandbox.genesys-pgr.org
genesysr::setup_sandbox()

# or custom
genesysr::setup(server = "http://localhost:8080",
  client_id = "...", client_secret = "...")

User authentication

The package is configured with default Genesys R client credentials that require user authentication:

# Setup
genesysr::setup_production()

# Open Genesys web page in browser and get verifier code
genesysr::user_login()

Client authentication

Accessing Genesys without user interaction requires that a client is registered on Genesys with client credentials grant. Contact helpdesk@genesys-pgr.org{.email} for assistance.

# Setup
library('genesysr')
genesysr::setup(server = "https://api.genesys-pgr.org",
  client_id = "someId.....@www.genesys-pgr.org",
  client_secret = "your-private-secret")

# Obtain access tokens
genesysr::client_login()

Query Genesys

filters <- mcpd_filter(ORIGCTY = c("DEU", "SVN"))
accessions <- genesysr::get_accessions(filters)

# Sort columns, hand-pick first few columns
require(data.table)
setcolorder(accessions, unique(c("id", "instituteCode", "accessionNumber", "taxonomy.genus", sort(names(accessions)))))

Copy Link

Version

Install

install.packages('genesysr')

Monthly Downloads

195

Version

2.1.1

License

Apache License 2.0

Maintainer

Matija Obreza

Last Published

February 23rd, 2024

Functions in genesysr (2.1.1)

.fetch_json_page

Fetch a page of data from Genesys
list_institutes

List FAO WIEWS institutes.
.fetch_csv_page

Fetch a page of data from Genesys
filter_INSTCODE

Add filter by genus
filter_SAMPSTAT

Add filter on Biological status of sample
mcpd_filter

Make or adjust filter using MCPD terminology
me

Who am i? Loads and prints the user profile from Genesys as JSON. You need to be logged in.
print_setup

Print Genesys client configuration
setup

Configure the Genesys environment
list_species

Fetch taxonomic data of selected accessions.
filter_ORIGCTY

Add filter on Country of origin of material
filter_SPECIES

Add filter on specific epithet
user_login

Login to Genesys as a user
list_crops

Fetch Genesys crops. Note that the list of Genesys crops does not fully correspond with various CROPNAME in MCPD provided by genebanks.
download_mcpd

Download passport data for one genebank in Excel format and save it to disk
setup_production

Setup for Genesys Production
.post

HTTP POST method
get_accessions

Get accession passport data as a data table.
setup_sandbox

Setup for Genesys Sandbox
check_country

Run Land-or-Sea check on MCPD data. Uploads only rows where ORIGCTY, DECLATITUDE and DECLONGITUDE are provided.
authorization

Provide OAuth2 token to use for authorization with Genesys
client_login

Login to Genesys as a service client (system-to-system)
api1_url

Get partial API v1 URL for the provided path
.MAX_ALLOWED_PAGES

Max pages to retrieve
check_landorsea

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.
api2_url

Get partial API v2 URL for the provided path
.fetch_accessions_page

Fetch accession passport data page.
.check_auth

Ensure that environment has OAuth token
check_taxonomy

Check MCPD taxonomic data (GENUS, SPECIES, SPAUTHOR, SUBTAXA, SUBTAUTHOR) using https://validator.genesys-pgr.org.
fetch_accessions

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.
filter_GENUS

Add filter by genus
download_pdci

Download PDCI data for one genebank in Excel format and save it to disk.
filter_DOI

Add filter on accession DOI
.list_accessions_page

List accession passport data (paginated)
.onLoad

Configure package defaults on load