## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----install, eval=FALSE------------------------------------------------------
#  if (!requireNamespace("BiocManager", quietly = TRUE))
#      install.packages("BiocManager")
#  BiocManager::install("ReUseData")

## ----installDevel, eval=FALSE-------------------------------------------------
#  BiocManager::install("ReUseData", version = "devel")

## ----Load---------------------------------------------------------------------
suppressPackageStartupMessages(library(Rcwl))
library(ReUseData)

## -----------------------------------------------------------------------------
recipeUpdate()
recipeSearch("echo")
echo_out <- recipeLoad("echo_out")
inputs(echo_out)

## -----------------------------------------------------------------------------
echo_out$input <- "Hello World!"
echo_out$outfile <- "outfile"
outdir <- file.path(tempdir(), "SharedData")
res <- getData(echo_out,
               outdir = outdir,
               notes = c("echo", "hello", "world", "txt"))

## -----------------------------------------------------------------------------
res$output

## -----------------------------------------------------------------------------
list.files(outdir, pattern = "echo")

## -----------------------------------------------------------------------------
readLines(res$yml)

## -----------------------------------------------------------------------------
(dh <- dataUpdate(dir = outdir))

## -----------------------------------------------------------------------------
dh[1]
## dh["BFC1"]
dh[dataNames(dh) == "outfile.txt"]
dataNames(dh)
dataParams(dh)
dataNotes(dh)
dataTags(dh)
dataYml(dh)

## -----------------------------------------------------------------------------
(dh1 <- dataSearch(c("echo", "hello", "world")))
toList(dh1)
toList(dh1, format = "yaml")
toList(dh1, format = "json", file = file.path(tempdir(), "data.json"))

## -----------------------------------------------------------------------------
dataSearch()
dataTags(dh[1]) <- "#gatk"
dataSearch("#gatk")

## -----------------------------------------------------------------------------
gcpdir <- file.path(tempdir(), "gcpData")
dataUpdate(gcpdir, cloud=TRUE)

## -----------------------------------------------------------------------------
(dh <- dataSearch(c("ensembl", "GRCh38")))
getCloudData(dh[1], outdir = gcpdir)

## -----------------------------------------------------------------------------
dataUpdate(gcpdir)  ## Update local data cache (without cloud data)
dataSearch()  ## data is available locally!!!

## -----------------------------------------------------------------------------
mt <- meta_data(outdir)
head(mt)

## -----------------------------------------------------------------------------
sessionInfo()