Title: | Interface to Download Data on Pests and Hosts from 'EPPO' |
---|---|
Description: | Set of tools to automatize extraction of data on pests from 'EPPO Data Services' and 'EPPO Global Database' and to put them into tables with human readable format. Those function use 'EPPO database API', thus you first need to register on <https://data.eppo.int> (free of charge). Additional helpers allow to download, check and connect to 'SQLite EPPO database'. |
Authors: | Michal Jan Czyz [aut, cre] |
Maintainer: | Michal Jan Czyz <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.8.2.9000 |
Built: | 2025-01-28 04:09:01 UTC |
Source: | https://github.com/mczyzj/pestr |
check_eppo_token
should be used after create_eppo_token
to check if the token is correctly recognized by EPPO Data Services API.
As a reference it uses link to Xylella fastidiosa hosts database -
XYLEFA eppocode.
If token is recognized there will be no message. In other cases function will
show following messages: No internet connection or Forbidden (HTTP 403).
check_eppo_token(token)
check_eppo_token(token)
token |
object of class pestr_token. |
Silent NULL when there is no error, otherwise message.
To obtain your free EPPO token please register to EPPO Data Services https://data.eppo.int/
## Not run: eppo_token <- create_eppo_token("abcdef123456") check_eppo_token(eppo_token) ## End(Not run)
## Not run: eppo_token <- create_eppo_token("abcdef123456") check_eppo_token(eppo_token) ## End(Not run)
create_eppo_token
makes token thats should be saved in a variable and
used argument for eppo_tabletools_hosts
,
eppo_tabletools_pests
, eppo_tabletools_cat
and
eppo_tabletools_taxo
functions. It contains token of class
string, that is needed to communicate with EPPO Data Services API.
create_eppo_token(x)
create_eppo_token(x)
x |
A string. |
Token to access EPPO Data Services API in format recognized by
eppo_tabletools_*
functions.
To obtain your free EPPO token please register https://data.eppo.int/
## Not run: create_eppo_token("12345678abcdef") ## End(Not run)
## Not run: create_eppo_token("12345678abcdef") ## End(Not run)
Citation returns citation of EPPO Data Services and/or EPPO Global Database
in bibtex format. To save the output into file use
output
argument
with destination file name.
eppo_citation(cite, output = NULL)
eppo_citation(cite, output = NULL)
cite |
string. Possible values: 'data_services', 'global_database' or 'both'. |
output |
string. Name of the file to which output will be saved. If NULL (default) results will be printed to console. |
citation of EPPO Data Services, EPPO Global Database or both in bibtex format.
eppo_citation("data_services") eppo_citation("global_database") eppo_citation("both")
eppo_citation("data_services") eppo_citation("global_database") eppo_citation("both")
eppo_database_check
checks if there is a file eppocodes.sqlite
and informs user if it is outdated and should be downloaded.
eppo_database_download
downloads database in SQLite format directly.
The downloaded file is zip archive. On Linux this database will be
extracted automatically. On Windows user will need to extract the file
manually.
eppo_database_connect
allows user to connect to SQLite database
downloaded from EPPO Data Services.
eppo_database_check(filepath = getwd(), filename = "eppocodes.sqlite") eppo_database_download(filepath = getwd()) eppo_database_connect(filepath = getwd(), filename = "eppocodes.sqlite")
eppo_database_check(filepath = getwd(), filename = "eppocodes.sqlite") eppo_database_download(filepath = getwd()) eppo_database_connect(filepath = getwd(), filename = "eppocodes.sqlite")
filepath |
A string with path where eppocodes.sqlite file is stored. By default it points to working directory. |
filename |
A string with name of the file. By default it takes name eppocodes.sqlite. |
Checks if database file exist in directory, if it is outdated, and establishes SQLite database connection
If you will, you can download database directly from EPPO Data Services https://data.eppo.int
## Not run: #to check if the db file exist in the directory (default working directory) eppo_database_check(filepath = getwd()) #to download EPPO SQLite database into directory (default working directory). #If you are Windows user, after download finishes you will need to unzip file #manualy. eppo_database_download(filepath = getwd()) #prior to use functions that check pest names in SQLite database, #you need to set up connection to SQLite database. Doing so is #straightforward with function below (once per sesion): eppo_connection <- eppo_database_connect(filepath = getwd(), filename = "eppocodes.sqlite") ## End(Not run)
## Not run: #to check if the db file exist in the directory (default working directory) eppo_database_check(filepath = getwd()) #to download EPPO SQLite database into directory (default working directory). #If you are Windows user, after download finishes you will need to unzip file #manualy. eppo_database_download(filepath = getwd()) #prior to use functions that check pest names in SQLite database, #you need to set up connection to SQLite database. Doing so is #straightforward with function below (once per sesion): eppo_connection <- eppo_database_connect(filepath = getwd(), filename = "eppocodes.sqlite") ## End(Not run)
eppo_names_table
checks if string (names or parts of the names)
provided by user match any name in the EPPO database. If strings match any
name in database, data frame with all names matching codeid, as well as
preferred (binary), language and EPPOcode is returned.
names_vector |
A vector with organism or viruses names (or part of the names) to be checked for existence in EPPO SQLite Database. |
sqlConnection |
connection to SQLite EPPO Database. By default NULL; function will automatically connect to database with default credentials. |
Check if provided names are present in EPPO SQLite Database. Creates
list which contains: data frame with matching names in database and their
codeids, character vector of names from names_vector
which do not
match any entry in database, data frame with preferred names and their
codeids, and data frame containing all names matching codeids of preferred
names. Last data frame contains also column with preferred (binary),
codelang (two letter character with language code), and EPPOcode.
Output of the function might be passed to functions:
eppo_tabletools_names
eppo_tabletools_cat
eppo_tabletools_hosts
eppo_tabletools_distribution
## Not run: ##This code needs SQLite dabatase in working directory test_names <- c("Xylella", "dog", "leafhopper") test_names_table <- eppo_names_table(test_names) ## End(Not run)
## Not run: ##This code needs SQLite dabatase in working directory test_names <- c("Xylella", "dog", "leafhopper") test_names_table <- eppo_names_table(test_names) ## End(Not run)
eppo_table_full
creates table in human friendly format with data on
pest preferred name, synonyms and common names, hosts, categorization,
taxonomy and its distribution.
eppo_table_full(names_vector, sqlConnection, token)
eppo_table_full(names_vector, sqlConnection, token)
names_vector |
A vector with organism names (or part of the names) to be checked for existence in EPPO SQLite Database. |
sqlConnection |
connection to SQLite EPPO Database. By default NULL; function will automatically connect to database with default credentials. |
token |
An object containing EPPO API token created via create_eppo_token. |
Wraps results of function from eppo_tabletools
, namely:
eppo_tabletools_names, eppo_tabletools_hosts,
eppo_tabletools_cat, eppo_tabletools_taxo, and
eppo_tabletools_distri into one compact, human readable table.
eppo_tabletools_names
creates tables with names – preferred, common
and synonyms – of pests. It is particularly useful for creating whole table
with eppo_table_full, otherwise it might be more informative to use
eppo_names_tables which provides additional information for your
query.
eppo_tabletools_hosts
creates tables with hosts of pests.
eppo_tabletools_cat
creates tables with categorization of pests.
eppo_tabletools_taxo
creates tables with taxonomy of pests/hosts.
eppo_tabletools_distri
creates tables with distribution of pests.
eppo_tabletools_pests
creates table with pests of host.
All functions return both long table and compact, human friendly table.
eppo_tabletools_names(names_tables) eppo_tabletools_hosts( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_cat( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_taxo( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_distri( names_tables = NULL, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_pests( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE )
eppo_tabletools_names(names_tables) eppo_tabletools_hosts( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_cat( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_taxo( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_distri( names_tables = NULL, raw_eppocodes = NULL, use_raw_codes = FALSE ) eppo_tabletools_pests( names_tables = NULL, token, raw_eppocodes = NULL, use_raw_codes = FALSE )
names_tables |
A list of tables created via |
token |
An object containing EPPO API token created via
|
raw_eppocodes |
A character vector of eppocodes. Use with caution, and ONLY when sure that provided eppocodes are correct. |
use_raw_codes |
logical. Default FALSE. Set TRUE if you want to provide eppocodes directly. |
List containing two data frames. First is in a long format, and each row contains synonyms and names in other languages in respect to preferred names. The second data frame contains coerced synonyms and other names to single cell for each preferred name.
EPPO Data services https://data.eppo.int/ and EPPO Global Database https://gd.eppo.int/
## Not run: ## the code below requires SQLite DB in the working directory ## which can be downloaded with eppo_database_download function test_names <- eppo_names_tables(c("Xylella", "Poacea")) # get data on naming eppo_tabletools_names(test_names) ## below functions connect to EPPO Global Database or EPPO Global Services ## they need connection to internet. # get data on distribution eppo_tabletools_distri(test_names) # you can also get data using eppocodes directly eppo_tabletools_distri(raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) ## below functions, beside internet connection require also valid token that ## can be obtained after free of charge registration at EPPO Data Services # first create token variable: create_eppo_token("paste_your_token_here") # then use result of eppo_names_tables or raw eppocodes to query REST API # get data on hosts eppo_tabletools_hosts(test_names, eppo_token) eppo_tabletools_hosts(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) # get data on categorization eppo_tabletools_cat(test_names, eppo_token) eppo_tabletools_cat(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) # get data on taxonomy eppo_tabletools_taxo(test_names, eppo_token) eppo_tabletools_taxo(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) # get data on pests eppo_tabletools_pests(test_names, eppo_token) eppo_tabletools_pests(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) ## End(Not run)
## Not run: ## the code below requires SQLite DB in the working directory ## which can be downloaded with eppo_database_download function test_names <- eppo_names_tables(c("Xylella", "Poacea")) # get data on naming eppo_tabletools_names(test_names) ## below functions connect to EPPO Global Database or EPPO Global Services ## they need connection to internet. # get data on distribution eppo_tabletools_distri(test_names) # you can also get data using eppocodes directly eppo_tabletools_distri(raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) ## below functions, beside internet connection require also valid token that ## can be obtained after free of charge registration at EPPO Data Services # first create token variable: create_eppo_token("paste_your_token_here") # then use result of eppo_names_tables or raw eppocodes to query REST API # get data on hosts eppo_tabletools_hosts(test_names, eppo_token) eppo_tabletools_hosts(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) # get data on categorization eppo_tabletools_cat(test_names, eppo_token) eppo_tabletools_cat(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) # get data on taxonomy eppo_tabletools_taxo(test_names, eppo_token) eppo_tabletools_taxo(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) # get data on pests eppo_tabletools_pests(test_names, eppo_token) eppo_tabletools_pests(token = eppo_token, raw_eppocodes = c("XYLEFA", "1GRAF"), use_raw_codes = TRUE) ## End(Not run)