An R6 client for getting virion data and metadata.
Value
A deposit class (R6 class)
invisibly returns self
dataframe of remote csv file.
String. Path to download location.
data.frame from readr::read_csv()
String. cleaned zenodo id
metadata in the specificed format (invisible)
List. Named list of data frames with the following fields:
name = field name
type = field type
description = characterization of the field
parent_id String. Identifier for a Zenodo deposit with multiple versions.
all_versions Character. All zenodo ids for versions of the deposit.
summary_df Data frame. A table of all zenodo ids for versions of the deposit.
latest_version String. Identifier for the latest version of the zenodo deposit.
working_version String. Identifier for the version of the zenodo deposit you are working with
working_bibtex String. Bibtex for the version of the zenodo deposit you are working with.
working_citation String. Citation for the version of the zenodo deposit you are working with.
working_files Data frame. Working files consist of key (file name) and url (url to file on zenodo)
working_json list. Metadata for the working version.
Methods
Method new()
Create a new deposit object, as an R6
client. This object is connected to the zenodo deposit for virion
and is the gateway for accessing different versions of the data.
Usage
deposit$new(parent_id = "15643003")Method set_working_version()
Set the version of the data you would like to work with. Note that the structure of Virion data may change through time.
Usage
deposit$set_working_version(
zenodo_id = "latest",
style = "apa",
print_bibtex = TRUE,
print_citation = TRUE
)Arguments
zenodo_idString. A zenodo id or latest.
styleString. The citation style to be used.
print_bibtexLogical. Should the bibtex for the working version of the deposit be printed when setting the working version?
print_citationLogical. Should the citation for the working version of the deposit be printed?
Method load_remote_csv_file()
Load a remote csv listed in the working files field directly into the environment.
Can handle either csv or csv.gz files. This function downloads a temporary file to your machine, reads it, then returns a dataframe.
The local file cache is removed when your R session restarts.
Consider using the download_versioned_data to
save a persistent version of the virion dataset on
your machine.
Arguments
file_keyString. A file key as seen in the
working_filesfieldrefreshLogical. Should files be re-downloaded.
...Additional arguments to pass to
readr::read_csv()
Method download_versioned_data()
Download versioned data
Downloads all the files for a particular version of
Virion to dir/zenodo_id.
This function does not change the working version!
Method load_local_csv_file()
Load a local version of the csv.
Assumes you would like to load the file from the current working version.
If the csv file is not present, a persistent version of the file will be downloaded to your machine.
Arguments
file_keystring. Name of file from
working_filesrefreshlogical. Should the file be re-downloaded?
...Additional parameters to pass to
readr::read_csv()
Method check_zenodo_id()
Check the zenodo ID
Look for key words like working or latest and convert
them to integer ids OR pass the zenodo id directly
to sanitize_id()
Method export_metadata()
Export metadata for a version of the deposit.
Method get_data_dictionary()
Create a list of data dictionaries.
Usage
deposit$get_data_dictionary(
file_key = "datapackage.json",
dir = tempdir(),
refresh
)Method get_parent_id()
Get a property of the object that is private
all_versions Character. All zenodo ids for versions of the deposit.
summary_df Data frame. A table of all zenodo ids for versions of the deposit.
latest_version String. Identifier for the latest version of the zenodo deposit.
working_version String. Identifier for the version of the zenodo deposit you are working with.
working_bibtex String. Bibtex for the version of the zenodo deposit you are working with.,
working_citation String. Citation for the version of the zenodo deposit you are working with.
working_files Data frame. Working files consist of key (file name) and url (url to file on zenodo)
working_json list. Metadata for the working version.
Method get_all_versions()
Get a property of the object that is private
Method get_summary_df()
Get a property of the object that is private
latest_version String. Identifier for the latest version of the zenodo deposit.
working_version String. Identifier for the version of the zenodo deposit you are working with.
working_bibtex String. Bibtex for the version of the zenodo deposit you are working with.,
working_citation String. Citation for the version of the zenodo deposit you are working with.
working_files Data frame. Working files consist of key (file name) and url (url to file on zenodo)
working_json list. Metadata for the working version.
Examples
if (FALSE) { # \dontrun{
# make a client
virion_deposit <- deposit$new()
# methods
virion_deposit$set_working_version("latest")
virion_deposit$get_working_files()
# load remote data directly into your session
virion_data <- virion_deposit$load_remote_csv_file(file_key = "virion.csv.gz")
# download remote data to disk - defaults to working version
virion_deposit$download_versioned_data()
} # }
## ------------------------------------------------
## Method `deposit$new`
## ------------------------------------------------
if (FALSE) { # \dontrun{
virion_deposit <- deposit$new()
} # }
## ------------------------------------------------
## Method `deposit$set_working_version`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# set the working version to the latest version of the deposit
virion_deposit$set_working_version("latest")
# set the working versino to an arbitrary deposit
virion_deposit$get_all_versions()
virion_deposit$set_working_version("19502921")
} # }
## ------------------------------------------------
## Method `deposit$load_remote_csv_file`
## ------------------------------------------------
if (FALSE) { # \dontrun{
## see the working files
working_files <- virion$get_working_files()
working_files$file_key
virion_data <- virion_deposit$load_remote_csv_file("virion.csv.gz")
} # }
## ------------------------------------------------
## Method `deposit$download_versioned_data`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# download files for the working version
virion_deposit$download_versioned_data()
# download files for the latest version
virion_deposit$download_versioned_data("latest")
# download files for some zenodo id
virion_deposit$download_versioned_data("19502921")
} # }
## ------------------------------------------------
## Method `deposit$load_local_csv_file`
## ------------------------------------------------
if (FALSE) { # \dontrun{
virion <- deposit$new()
virion$set_working_version()
working_files <- virion$get_working_files()
working_files$file_key
virion$load_local_csv_file("virion.csv.gz")
} # }
## ------------------------------------------------
## Method `deposit$check_zenodo_id`
## ------------------------------------------------
if (FALSE) { # \dontrun{
virion_deposit$check_zenodo_id("latest")
} # }
## ------------------------------------------------
## Method `deposit$export_metadata`
## ------------------------------------------------
if (FALSE) { # \dontrun{
virion_deposit$export_metadata("working")
} # }
## ------------------------------------------------
## Method `deposit$get_data_dictionary`
## ------------------------------------------------
if (FALSE) { # \dontrun{
virion <- deposit$new()
virion$set_working_version()
virion$get_data_dictionary()
} # }