Genesys provides data primarily through the `fetch_accessions` function. Data download using **genesysr** is equivalent to downloading data from www.genesys-pgr.org, with the advantage that **genesysr** ensures reproducibility.
Filters to query Genesys are:
[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.
- `fetch_accessions(filters = list(taxonomy.genus = c('Musa')))` - Retrieve all accession data for genus *Musa*
- `fetch_accessions(list(institute.code = c('BEL084')))` - Retrieve all accession data for the Musa International Transit Center, Bioversity International
- `fetch_accessions(list(institute.code = c('BEL084','COL003')))` - Retrieve all accession data for the Musa International Transit Center, Bioversity International (BEL084) and the International Center for Tropical Agriculture (COL003)
**genesysr** uses the [Genesys API](https://www.genesys-pgr.org/doc/0/apis) to query Genesys data.
And also by using [Multi-Crop Passport Descriptors (MCPD)](https://www.genesys-pgr.org/doc/0/basics#mcpd) definitions:
Accessing data with **genesysr** is similar to downloading data in CSV or Excel format and loading
it into R.
- `fetch_accessions(mcpd_filter(ORIGCTY = c("DEU", "SVN")))` - Retrieve data by country of origin (MCPD)
## For the impatient
# Selecting columns for data download
Genesys fetches all accession data by data. One can reduce the amount of data fetched by selecting only the columns of interest:
Accession passport data is retrieved with the `fetch_accessions` function.
- `fetch_accessions(list(taxonomy.genus = c('Musa')), selector = function(x) {list(id = x$id, acceNumb = x$acceNumb, instCode = x$institute$code)`- Fetch only **id**, **acceNumb** and **instCode** for *Musa* data.
The database is queried by providing a `filter` (see Filters below):
```
## Setup: use Genesys Sandbox environment
# genesysr::setup_sandbox()
# genesysr::setup_production() # This is initialized by default when loading genesysr
# Open a browser: login to Genesys and authorize access
genesysr::user_login()
# Retrieve all accession data for genus *Musa*
musa <- fetch_accessions(filters = list(taxonomy.genus = c('Musa')))
# Retrieve all accession data for the Musa International Transit Center, Bioversity International
# Retrieve all accession data for the Musa International Transit Center, Bioversity International (BEL084) and the International Center for Tropical Agriculture (COL003)
some <- fetch_accessions(list(institute.code = c('BEL084','COL003')))
```
**genesysr** provides utility functions to create `filter` objects using [Multi-Crop Passport Descriptors (MCPD)](https://www.genesys-pgr.org/doc/0/basics#mcpd) definitions: