-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/cboettig/taxald
- Loading branch information
Showing
9 changed files
with
142 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
^\.manifest\.json$ | ||
^schema\.md$ | ||
^README\.Rmd$ | ||
^LICENSE\.md$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ data/* | |
*.sqlite | ||
*.sql | ||
*.sqlite.bz2 | ||
.Rbuildignore | ||
taxadb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Package: taxald | ||
Version: 0.0.0.9000 | ||
Title: Taxonomic Linked Data | ||
Description: Creates a local database of many commonly used taxonomic authorities | ||
and provides functions that can quickly query this data. | ||
Authors@R: person("Carl", "Boettiger", , "cboettig@gmail.com", c("aut", "cre")) | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
LazyData: true | ||
ByteCompile: true | ||
Imports: | ||
dplyr, | ||
dbplyr, | ||
DBI, | ||
MonetDBLite, | ||
arkdb, | ||
piggyback, | ||
fs | ||
Remotes: cboettig/arkdb, cboettig/piggyback | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 6.0.1.9000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2018 | ||
COPYRIGHT HOLDER: Carl Boettiger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2018 Carl Boettiger | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
#' create a local taxonomic database | ||
#' | ||
#' @param path a location on your computer where the database should be installed. | ||
#' By default, will install to `.taxald` in your home directory. | ||
#' @param authorities a list (character vector) of authorities to be included in the | ||
#' database. By default, will install all authorities. Choose a subset for a faster | ||
#' install. | ||
#' @return path where database has been installed (invisibly) | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' tmp <- tempdir() | ||
#' create_taxadb(tmp, authorities = "itis") | ||
#' | ||
#' } | ||
create_taxadb <- function(path = fs::path(fs::path_home(), ".taxald"), | ||
authorities = c("itis", "ncbi", "col", "tpl", | ||
"gbif", "fb", "slb", "wiki")){ | ||
## FIXME offer more fine-grained support over which authorities to install | ||
## FIXME include some messaging about the large downloads etc? | ||
|
||
|
||
## FIXME generate list of data files to download based on requested | ||
## authorities | ||
|
||
## FIXME eventually will pull from Zenodo, not piggyback | ||
tmp <- tempdir() | ||
piggyback::pb_download(dest = tmp, repo="cboettig/taxald") | ||
|
||
|
||
files <- fs::dir_ls("data/", glob="*.tsv.bz2") | ||
|
||
|
||
dbdir <- fs::dir_create(path) | ||
con <- DBI::dbConnect(MonetDBLite::MonetDBLite(), dbdir) | ||
db <- dbplyr::src_dbi(con) | ||
arkdb::unark(files, db, lines = 1e6) | ||
|
||
## Clean up imported files | ||
fs::dir_delete(fs::path(tmp, "data")) | ||
|
||
## Set id as primary key in each table? | ||
# tbls <- DBI::dbListTables(db$con) | ||
# lapply(tbls, function(table) | ||
# glue::glue("ALTER TABLE {table} ADD PRIMARY KEY ({key});", | ||
# table = table, key = "id")) | ||
|
||
DBI::dbDisconnect(db$con) | ||
|
||
invisible(dbdir) | ||
} | ||
## Consider shipping the original database pre-compressed? | ||
|
||
#R.utils::bzip2("taxa.sqlite", remove = FALSE) | ||
## Set up database connection from compressed file | ||
#R.utils::bunzip2("taxa.sqlite.bz2", remove = FALSE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters