knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
NOTE: Starting with v2.0.0, the database backend changed from MonetDBLite to duckdb. Because of this change, restez v2.0.0 or higher is not compatible with databases built with previous versions of restez.
Download parts of NCBI's GenBank to a local folder and create a simple SQL-like database. Use 'get' tools to query the database by accession IDs. rentrez wrappers are available, so that if sequences are not available locally they can be searched for online through Entrez.
See the detailed tutorials for more information.
Vous entrez, vous rentrez et, maintenant, vous .... restez!
Downloading sequences and sequence information from GenBank and related NCBI taxonomic databases is often performed via the NCBI API, Entrez. Entrez, however, has a limit on the number of requests and downloading large amounts of sequence data in this way can be inefficient. For programmatic situations where multiple Entrez calls are made, downloading may take days, weeks or even months.
This package aims to make sequence retrieval more efficient by allowing a user to download large sections of the GenBank database to their local machine and query this local database either through package specific functions or Entrez wrappers. This process is more efficient as GenBank downloads are made via NCBI's FTP using compressed sequence files. With a good internet connection and a middle-of-the-road computer, a database comprising 20 GB of sequence information can be generated in less than 10 minutes.
Install from CRAN:
install.packages("restez")
Or install the development version from r-universe:
install.packages("restez", repos = "https://ropensci.r-universe.dev")
Or install the development version from GitHub (requires installing the remotes
package first):
# install.packages("remotes") remotes::install_github("ropensci/restez")
For more detailed information on the package's functions and detailed guides on downloading, constructing and querying a database, see the detailed tutorials.
rstz_pth <- tempdir() restez::restez_path_set(filepath = rstz_pth) restez::db_delete(everything = TRUE)
# Warning: running these examples may take a few minutes library(restez) # choose a location to store GenBank files restez_path_set(rstz_pth)
``` {r reassigndownload, include=FALSE, eval=TRUE} db_download <- function() { restez::db_download(preselection = '20') }
```r # Run the download function db_download() # after download, create the local database db_create()
# for reproducibility set.seed(12345) # get a random accession ID from the database id <- sample(list_db_ids(), 1) # you can extract: # sequences seq <- gb_sequence_get(id)[[1]] str(seq) # definitions def <- gb_definition_get(id)[[1]] print(def) # organisms org <- gb_organism_get(id)[[1]] print(org) # or whole records rec <- gb_record_get(id)[[1]] cat(rec)
# use the entrez_* wrappers to access GB data res <- entrez_fetch(db = 'nucleotide', id = id, rettype = 'fasta') cat(res) # if the id is not in the local database # these wrappers will search online via the rentrez package res <- entrez_fetch(db = 'nucleotide', id = c('S71333.1', id), rettype = 'fasta') cat(res)
Want to contribute? Check the contributing page.
MIT
Bennett et al. (2018). restez: Create and Query a Local Copy of GenBank in R. Journal of Open Source Software, 3(31), 1102. https://doi.org/10.21105/joss.01102
Benson, D. A., Karsch-Mizrachi, I., Clark, K., Lipman, D. J., Ostell, J., & Sayers, E. W. (2012). GenBank. Nucleic Acids Research, 40(Database issue), D48–D53. https://doi.org/10.1093/nar/gkr1202
Winter DJ. (2017) rentrez: An R package for the NCBI eUtils API. PeerJ Preprints 5:e3179v2 https://doi.org/10.7287/peerj.preprints.3179v2
This package previously developed and maintained by Dom Bennett
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.