# Introduction to R functions of BioInstaller

#### Jianfeng Li

#### 2018-11-20

## Introduction

in this vignette, you can learn the R functions usage of BioInstaller R package.

Key points:

- How to set the database to store installation information.
- How to featch the versions of a item?
- How to download and install a tool/script or database?
- How to get the installation information?

## Core R functions

Function `set.biosoftwares.db()` can be used to set a database file saving the information of installed software and database.

Next, you can use the function `install.bioinfo(show.all.names = TRUE)` get all soteware and database supported by BioInstaller.

    library(BioInstaller)
    set.biosoftwares.db(tempfile())
    # Show all avaliable softwares/dependece in default inst/extdata/config/github/github.toml
    # and inst/extdata/config/nongithub/nongithub.toml
    x <- install.bioinfo(show.all.names = TRUE)

When setting the `show.all.versions` to `TRUE`, the versions of software and database will be returned.

    # Fetching versions of softwares
    install.bioinfo(name = 'samtools', show.all.versions = TRUE)
    #> INFO [2018-11-20 23:15:10] Fetching samtools versions....
    #>  [1] "master"     "0.1.16"     "0.1.17"     "0.1.18"     "0.1.19"
    #>  [6] "0.1.20"     "0.2.0-rc1"  "0.2.0-rc2"  "0.2.0-rc3"  "0.2.0-rc4"
    #> [11] "0.2.0-rc5"  "0.2.0-rc6"  "0.2.0-rc7"  "0.2.0-rc8"  "0.2.0-rc9"
    #> [16] "0.2.0-rc10" "0.2.0-rc11" "0.2.0-rc12" "1.0"        "1.1"
    #> [21] "1.2"        "1.3"        "1.3.1"      "1.4"        "1.4.1"
    #> [26] "1.5"        "1.6"        "1.7"        "1.8"        "1.9"

Parameter `verbose` in `install.bioinfo` can be used to show the extra debug information.

Besides, if you only want to download the source code or raw database files to a specific directory, the parameter `download.dir` and `download.only`are required.

    # Install 'demo' with debug infomation
    download.dir <- sprintf('%s/demo_2', tempdir())
    install.bioinfo('demo', download.dir = download.dir, verbose = TRUE)
    #> INFO [2018-11-20 23:15:11] Debug:name:demo
    #> INFO [2018-11-20 23:15:11] Debug:destdir:
    #> INFO [2018-11-20 23:15:11] Debug:db:/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1762b2c80
    #> INFO [2018-11-20 23:15:11] Debug:github.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github.toml
    #> INFO [2018-11-20 23:15:11] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/nongithub/nongithub.toml
    #> INFO [2018-11-20 23:15:11] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_main.toml
    #> INFO [2018-11-20 23:15:11] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_annovar.toml
    #> INFO [2018-11-20 23:15:11] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_blast.toml
    #> INFO [2018-11-20 23:15:12] Fetching demo versions....
    #> INFO [2018-11-20 23:15:12] Install versions:GRCh37
    #> INFO [2018-11-20 23:15:12] Now start to install demo in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo_2.
    #> INFO [2018-11-20 23:15:12] Running before install steps.
    #> INFO [2018-11-20 23:15:12] Now start to download demo in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo_2.
    #> INFO [2018-11-20 23:15:13] Running install steps.
    #> INFO [2018-11-20 23:15:13] Running after install successful steps.
    #> INFO [2018-11-20 23:15:13] Running change.info for demo and be saved to /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1762b2c80
    #> INFO [2018-11-20 23:15:13] Debug:Install by Github configuration file:
    #> INFO [2018-11-20 23:15:13] Debug:Install by Non Github configuration file: demo
    #> INFO [2018-11-20 23:15:13] Installed successful list: demo
    #> $fail.list
    #> [1] ""
    #>
    #> $success.list
    #> [1] "demo"

    # Download demo source code
    download.dir <- sprintf('%s/demo_3', tempdir())
    install.bioinfo('demo', download.dir = download.dir,
      download.only = TRUE, verbose = TRUE)
    #> INFO [2018-11-20 23:15:13] Debug:name:demo
    #> INFO [2018-11-20 23:15:13] Debug:destdir:
    #> INFO [2018-11-20 23:15:13] Debug:db:/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1762b2c80
    #> INFO [2018-11-20 23:15:13] Debug:github.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/nongithub/nongithub.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_main.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_annovar.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_blast.toml
    #> INFO [2018-11-20 23:15:13] Fetching demo versions....
    #> INFO [2018-11-20 23:15:13] Install versions:GRCh37
    #> INFO [2018-11-20 23:15:13] Now start to download demo in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo_3.
    #> INFO [2018-11-20 23:15:13] demo be downloaded in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo_3 successful
    #> [1] TRUE

After finishing the download step, typically, you need to install the software by running several commands or an installation script. BioInstaller stores the related installation script or commands in the configuration files, and you can one-click to install the related software or database.

Besides, BioInstaller will pass several parameters to installation command or script. Just like `destdir` of `./configure --prefix={{destdir}}; make; make install` for compiling C program.

It is optional to create `bin` directory in the `destdir`, and copy all the executable files in it. The `bin` in `destdir` can be set in the variable `PATH` for re-use in any other working directory.

If you want to download the source code in `A` directory and install it to `B` directory, you need to simultaneously set the parameters `destdir` and `download.dir`in function `install.bioinfo`.

    # Set download.dir and destdir (destdir like /usr/local
    # including bin, lib, include and others),
    # destdir will work if install step {{destdir}} be used
    download.dir <- sprintf('%s/demo_source', tempdir())
    destdir <- sprintf('%s/demo', tempdir())
    install.bioinfo('demo', download.dir = download.dir, destdir = destdir)
    #> INFO [2018-11-20 23:15:13] Debug:name:demo
    #> INFO [2018-11-20 23:15:13] Debug:destdir:/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo
    #> INFO [2018-11-20 23:15:13] Debug:db:/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1762b2c80
    #> INFO [2018-11-20 23:15:13] Debug:github.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/nongithub/nongithub.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_main.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_annovar.toml
    #> INFO [2018-11-20 23:15:13] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_blast.toml
    #> INFO [2018-11-20 23:15:14] Fetching demo versions....
    #> INFO [2018-11-20 23:15:14] Install versions:GRCh37
    #> INFO [2018-11-20 23:15:14] Now start to install demo in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo.
    #> INFO [2018-11-20 23:15:14] Running before install steps.
    #> INFO [2018-11-20 23:15:14] Now start to download demo in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo_source.
    #> INFO [2018-11-20 23:15:14] Running install steps.
    #> INFO [2018-11-20 23:15:14] Running after install successful steps.
    #> INFO [2018-11-20 23:15:14] Running change.info for demo and be saved to /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1762b2c80
    #> INFO [2018-11-20 23:15:14] Debug:Install by Github configuration file:
    #> INFO [2018-11-20 23:15:14] Debug:Install by Non Github configuration file: demo
    #> INFO [2018-11-20 23:15:14] Installed successful list: demo
    #> $fail.list
    #> [1] ""
    #>
    #> $success.list
    #> [1] "demo"

## Saved informations after installation

It is important to save related information of installation. This step can help you to use the software or database in the other pipeline. So, after installed the software and database, BioInstaller will save the information, such as software name, version, path, update time, in the database file set by function `set.biosoftwares.db()`, which also defined by environment variable `BIO_SOFWARES_DB_ACTIVE`.

    temp.db <- tempfile()
    set.biosoftwares.db(temp.db)
    is.biosoftwares.db.active(temp.db)
    #> [1] FALSE

    # Install 'demo' quite
    download.dir <- sprintf('%s/demo_1', tempdir())
    install.bioinfo('demo', download.dir = download.dir, verbose = FALSE)
    #> $fail.list
    #> [1] ""
    #>
    #> $success.list
    #> [1] "demo"

Function `get.info()` can be used to get the saved information of installed software and databases.

When you want to delete the saved information, you can use function `del.info`.

    config <- get.info('demo')
    config
    #> $installed
    #> [1] TRUE
    #>
    #> $source.dir
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpK8vw9W/demo_1"
    #>
    #> $bin_dir
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpK8vw9W/demo_1"
    #>
    #> $executable_files
    #> [1] ""
    #>
    #> $install.dir
    #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo_1"
    #>
    #> $version
    #> [1] "GRCh37"
    #>
    #> $last.update.time
    #> [1] "2018-11-20 23:15:15"
    #>
    #> attr(,"config")
    #> [1] "demo"
    #> attr(,"configtype")
    #> [1] "yaml"
    #> attr(,"file")
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpK8vw9W/filebbb1356f0358"

    config <- configr::read.config(temp.db)
    config$demo$comments <- 'This is a demo.'
    params <- list(config.dat = config, file.path = temp.db)
    do.call(configr::write.config, params)
    #> [1] TRUE
    get.info('demo')
    #> $installed
    #> [1] "TRUE"
    #>
    #> $source.dir
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpK8vw9W/demo_1"
    #>
    #> $bin_dir
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpK8vw9W/demo_1"
    #>
    #> $install.dir
    #> [1] "/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/demo_1"
    #>
    #> $version
    #> [1] "GRCh37"
    #>
    #> $last.update.time
    #> [1] "2018-11-20 23:15:15"
    #>
    #> $comments
    #> [1] "This is a demo."
    #>
    #> attr(,"config")
    #> [1] "demo"
    #> attr(,"configtype")
    #> [1] "ini"
    #> attr(,"file")
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpK8vw9W/filebbb1356f0358"
    del.info('demo')
    #> [1] TRUE

## Local mode

Local mode of BioInstaller was useful when you have downloaded the source code or database file, and have not run the install steps.

Tips:

- Github software/database: a cloned directory were required
- Non-github software/database: a decompressed directory or a compressed archive.

    download.dir <- sprintf('%s/github_demo_local', tempdir())
    tryCatch({
    install.bioinfo('github_demo', download.dir = download.dir, download.only = TRUE, verbose = FALSE)
    install.bioinfo('github_demo', local.source = download.dir)}, error = function(e) {
      message("Please check the SSL or connection with GitHub")
    })
    #> cloning into '/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/github_demo_local'...
    #> Receiving objects:  16% (1/6),    0 kb
    #> Receiving objects:  33% (2/6),    0 kb
    #> Receiving objects:  50% (3/6),    0 kb
    #> Receiving objects:  66% (4/6),    0 kb
    #> Receiving objects:  83% (5/6),    0 kb
    #> Receiving objects: 100% (6/6),    0 kb, done.
    #> INFO [2018-11-20 23:15:19] Debug:name:github_demo
    #> INFO [2018-11-20 23:15:19] Debug:destdir:
    #> INFO [2018-11-20 23:15:19] Debug:db:/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1356f0358
    #> INFO [2018-11-20 23:15:19] Debug:github.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github.toml
    #> INFO [2018-11-20 23:15:19] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/nongithub/nongithub.toml
    #> INFO [2018-11-20 23:15:19] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_main.toml
    #> INFO [2018-11-20 23:15:19] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_annovar.toml
    #> INFO [2018-11-20 23:15:19] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_blast.toml
    #> INFO [2018-11-20 23:15:19] Fetching github_demo versions....
    #> INFO [2018-11-20 23:15:20] Install versions:master
    #> INFO [2018-11-20 23:15:20] Now start to install github_demo in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/github_demo.
    #> INFO [2018-11-20 23:15:20] Running before install steps.
    #> INFO [2018-11-20 23:15:20] Running install steps.
    #> INFO [2018-11-20 23:15:20] Running after install successful steps.
    #> INFO [2018-11-20 23:15:20] Running change.info for github_demo and be saved to /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1356f0358
    #> INFO [2018-11-20 23:15:20] Debug:Install by Github configuration file: github_demo
    #> INFO [2018-11-20 23:15:20] Debug:Install by Non Github configuration file:
    #> INFO [2018-11-20 23:15:20] Installed successful list: github_demo
    #> $fail.list
    #> [1] ""
    #>
    #> $success.list
    #> [1] "github_demo"

    download.dir <- sprintf('%s/demo_local', tempdir())
    install.bioinfo('demo_2', download.dir = download.dir, download.only = TRUE, verbose = FALSE)
    #> [1] TRUE
    install.bioinfo('demo_2', download.dir = download.dir, local.source = sprintf('%s/GRCh37_MT_ensGene.txt.gz', download.dir), decompress = TRUE)
    #> INFO [2018-11-20 23:15:21] Debug:name:demo_2
    #> INFO [2018-11-20 23:15:21] Debug:destdir:
    #> INFO [2018-11-20 23:15:21] Debug:db:/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1356f0358
    #> INFO [2018-11-20 23:15:21] Debug:github.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github.toml
    #> INFO [2018-11-20 23:15:21] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/nongithub/nongithub.toml
    #> INFO [2018-11-20 23:15:21] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_main.toml
    #> INFO [2018-11-20 23:15:21] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_annovar.toml
    #> INFO [2018-11-20 23:15:21] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_blast.toml
    #> INFO [2018-11-20 23:15:21] Fetching demo_2 versions....
    #> INFO [2018-11-20 23:15:21] Install versions:GRCh37
    #> INFO [2018-11-20 23:15:21] Now start to install demo_2 in /private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpK8vw9W/demo_local.
    #> INFO [2018-11-20 23:15:21] Running before install steps.
    #> INFO [2018-11-20 23:15:21] Running install steps.
    #> INFO [2018-11-20 23:15:21] Running after install successful steps.
    #> INFO [2018-11-20 23:15:21] Running change.info for demo_2 and be saved to /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1356f0358
    #> INFO [2018-11-20 23:15:21] Debug:Install by Github configuration file:
    #> INFO [2018-11-20 23:15:21] Debug:Install by Non Github configuration file: demo_2
    #> INFO [2018-11-20 23:15:21] Installed successful list: demo_2
    #> $fail.list
    #> [1] ""
    #>
    #> $success.list
    #> [1] "demo_2"

## Download all versions

Function `craw.all.version` is the simplest method to download all available URL files in nongithub or database files.

    download.dir <- sprintf('%s/crawl.all.versions', tempdir())
    crawl.all.versions('demo', download.dir = download.dir)
    #> INFO [2018-11-20 23:15:22] Fetching demo versions....

## Meta information of software and database

Function `get.meta` can be used to get all software and databases meta information, such as description and publication, supported by BioInstaller.

    # Get all meta source files
    meta_files <- get.meta.files()
    meta_files
    #> $db_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_meta.toml"
    #>
    #> $github_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github_meta.toml"
    #>
    #> $nongithub_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/nongithub/nongithub_meta.toml"
    #>
    #> $web_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/web/web_meta.toml"

    # Get all of meta informaton in BioInstaller
    meta <- get.meta()
    names(meta)
    #> [1] "db_meta_file"        "github_meta_file"    "nongithub_meta_file"
    #> [4] "web_meta_file"       "db"                  "github"
    #> [7] "nongithub"           "title"               "web"
    meta[1:4]
    #> $db_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_meta.toml"
    #>
    #> $github_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github_meta.toml"
    #>
    #> $nongithub_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/nongithub/nongithub_meta.toml"
    #>
    #> $web_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/web/web_meta.toml"
    meta$db$cfg_meta
    #> $avaliable_cfg
    #> [1] "db_annovar.toml" "db_blast.toml"   "db_main.toml"
    #>
    #> $cfg_dir
    #> [1] "@>@system.file('extdata', 'config/db', package = 'BioInstaller')@<@"
    #>
    #> $prefix_url
    #> [1] "https://raw.githubusercontent.com/JhuangLab/BioInstaller/master/inst/extdata/config/db/"
    meta$db$item$atcircdb
    #> $description
    #> [1] "Circular RNA not only functions as a potential competitive target for miRNA, but also regulates transcription and interacts with RNA-binding proteins. Because of the structural stability of the circular form, these molecules are promising candidates for intervening in a number of biological pathways, and may be a high value tool for pharmaceutical research in human and photosynthesis in plant.Based on our previous research, we systematically investigated 622 RNA-Seq samples from 87 indepedent studies hosted at NCBI SRA, and extracted all related circular RNAs. To improve the prediction accuracy, we not only applied a straightforward metric to screen and rank the circular RNA, but also incorporated exon boundaries as well as circular RNA candidates from previous studies into this resource to provide robust evidence for experimental biologists. In regards of the interaction between miRNA and circular RNAs, we utilized psRNAtarget and TAPIR to evaluate the statistical significance. Together, this database will host all predicted and validated Arabidopsis circular RNAs, and provide valuable and comprehensive information for studying this newly emerging non-coding RNA."
    #>
    #> $publication
    #> [1] "Ye J, Wang L, Li S, Zhang Q, Zhang Q, Tang W, Wang K, Song K, Sablok G, Sun X*, Zhao H*; AtCircDB: a tissue-specific database for Arabidopsis circular RNAs. Brief Bioinform 2017 bbx089. doi: 10.1093/bib/bbx089."
    #> [2] "Sun X, Wang L, Ding J, Wang Y, Wang J, Zhang X, Che Y, Liu Z, Zhang X, Ye J, Wang J, Sablok G, Deng Z, Zhao H. Integrative analysis of Arabidopsis thaliana transcriptomics reveals intuitive splicing mechanism for circular RNA. FEBS Lett. 2016. 590(20):3510-3516. "
    #>
    #> $url
    #> [1] "http://genome.sdau.edu.cn/circRNA/index.php"

    # Examples of get.meta
    db_cfg_meta <- get.meta(value = "cfg_meta", config = 'db')
    db_cfg_meta
    #> $avaliable_cfg
    #> [1] "db_annovar.toml" "db_blast.toml"   "db_main.toml"
    #>
    #> $cfg_dir
    #> [1] "@>@system.file('extdata', 'config/db', package = 'BioInstaller')@<@"
    #>
    #> $prefix_url
    #> [1] "https://raw.githubusercontent.com/JhuangLab/BioInstaller/master/inst/extdata/config/db/"

    db_cfg_meta_parsed <- get.meta(value = 'cfg_meta', config = 'db', read.config.params = list(rcmd.parse = TRUE))
    db_cfg_meta_parsed
    #> $avaliable_cfg
    #> [1] "db_annovar.toml" "db_blast.toml"   "db_main.toml"
    #>
    #> $cfg_dir
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db"
    #>
    #> $prefix_url
    #> [1] "https://raw.githubusercontent.com/JhuangLab/BioInstaller/master/inst/extdata/config/db/"

    db_cfg_meta <- get.meta(config = 'github', value = 'item')
    db_cfg_meta$bwa
    #> $description
    #> [1] "BWA is a software package for mapping DNA sequences against a large reference genome, such as the human genome. It consists of three algorithms: BWA-backtrack, BWA-SW and BWA-MEM. The first algorithm is designed for Illumina sequence reads up to 100bp, while the rest two for longer sequences ranged from 70bp to a few megabases. BWA-MEM and BWA-SW share similar features such as the support of long reads and chimeric alignment, but BWA-MEM, which is the latest, is generally recommended as it is faster and more accurate. BWA-MEM also has better performance than BWA-backtrack for 70-100bp Illumina reads."
    #>
    #> $publication
    #> [1] "Li H. and Durbin R. (2009) Fast and accurate short read alignment with Burrows-Wheeler transform. Bioinformatics, 25, 1754-1760. [PMID: 19451168]"
    #> [2] "Li H. and Durbin R. (2010) Fast and accurate long-read alignment with Burrows-Wheeler transform. Bioinformatics, 26, 589-595. [PMID: 20080505]"
    #> [3] "Li H. (2013) Aligning sequence reads, clone sequences and assembly contigs with BWA-MEM. arXiv:1303.3997v2 [q-bio.GN]"
    #>
    #> $title
    #> [1] "Burrow-Wheeler Aligner for pairwise alignment between DNA sequences"

    # Get databases meta file
    db_meta_file <- get.meta(config = 'db_meta_file')
    db_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_meta.toml"
    db_meta_file <- meta_files[["db_meta_file"]]
    db_meta_file
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_meta.toml"

## Download database

Database files are required for almost all bioinformatics data analysis pipeline, especially for sequence mapping and annotation steps. We hope BioInstaller can help you to access these resources easily in R, and you can use the function `install.bioinfo` directly download the supported databases.

    # get all database name
    library(stringr)
    x <- install.bioinfo(show.all.names = T)
    x <- x[str_detect(x, "^db_|reffa|bundle")]
    suppressWarnings(
      DT::datatable(matrix(x, ncol=3), caption = sprintf("Database supported by BioInstaller (n=%s)", length(x)))
    )

    # all databases config
    db_cfg_meta <- get.meta(config = 'db', value = 'cfg_meta',
                            read.config.params=list(rcmd.parse = TRUE))
    cfg_dir <- db_cfg_meta$cfg_dir
    cfg_dir
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db"
    avaliable_cfg <- db_cfg_meta$avaliable_cfg
    avaliable_cfg
    #> [1] "db_annovar.toml" "db_blast.toml"   "db_main.toml"
    sprintf("%s/%s", cfg_dir, avaliable_cfg)
    #> [1] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_annovar.toml"
    #> [2] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_blast.toml"
    #> [3] "/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_main.toml"

Just like ANNOVAR and Bioconductor have done, we hope to establish a integrated and shared database pool in this tool.

    # ANNOVAR
    download.dir <- sprintf('%s/db_annovar', tempdir())
    config.toml <- system.file("extdata", "config/db/db_annovar.toml",
      package = "BioInstaller")
    #install.bioinfo('db_ucsc_refgene', download.dir = download.dir,
    #  nongithub.cfg = config.toml, extra.list = list(buildver = "hg19"))

    # db_main
    download.dir <- sprintf('%s/db_main', tempdir())
    config.toml <- system.file("extdata", "config/db/db_main.toml",
      package = "BioInstaller")
    install.bioinfo('db_diseaseenhancer', download.dir = download.dir,
      nongithub.cfg = config.toml)
    #> INFO [2018-11-20 23:15:23] Debug:name:db_diseaseenhancer
    #> INFO [2018-11-20 23:15:23] Debug:destdir:
    #> INFO [2018-11-20 23:15:23] Debug:db:/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/filebbb1356f0358
    #> INFO [2018-11-20 23:15:23] Debug:github.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/github/github.toml
    #> INFO [2018-11-20 23:15:23] Debug:nongithub.cfg:/private/var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T/RtmpAn3eId/Rinstbba16d1b57bc/BioInstaller/extdata/config/db/db_main.toml
    #> INFO [2018-11-20 23:15:23] Fetching db_diseaseenhancer versions....
    #> INFO [2018-11-20 23:15:23] Install versions:enh2target
    #> INFO [2018-11-20 23:15:23] Now start to install db_diseaseenhancer in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/db_main.
    #> INFO [2018-11-20 23:15:23] Running before install steps.
    #> INFO [2018-11-20 23:15:23] Now start to download db_diseaseenhancer in /var/folders/nc/yl5qhkkn6vxf_m7s_yz2kzvh0000gn/T//RtmpK8vw9W/db_main.
    #> INFO [2018-11-20 23:16:39] Debug:Install by Github configuration file:
    #> INFO [2018-11-20 23:16:39] Debug:Install by Non Github configuration file: db_diseaseenhancer
    #> INFO [2018-11-20 23:16:39] Installed fail list: db_diseaseenhancer
    #> $fail.list
    #> [1] "db_diseaseenhancer"
    #>
    #> $success.list
    #> [1] ""

## Write you own configuration file

If the software and database have not been supported by BioInstaller, you can write your own `YAML` or `TOML` format configuration file. A related vignette can help you to do this.

## Session info

Here is the output of `sessionInfo()` on the system on which this document was compiled:

    #> R version 3.5.1 (2018-07-02)
    #> Platform: x86_64-apple-darwin15.6.0 (64-bit)
    #> Running under: macOS  10.14.1
    #>
    #> Matrix products: default
    #> BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
    #> LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
    #>
    #> locale:
    #> [1] C/UTF-8/C/C/C/C
    #>
    #> attached base packages:
    #> [1] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #> [1] rvest_0.3.2        xml2_1.2.0         stringr_1.3.1
    #> [4] RCurl_1.95-4.11    bitops_1.0-6       BioInstaller_0.3.7
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] prettydoc_0.2.1      liteq_1.0.1          remotes_2.0.2
    #>  [4] testthat_2.0.1       htmltools_0.3.6      usethis_1.4.0
    #>  [7] yaml_2.2.0           base64enc_0.1-3      blob_1.1.1
    #> [10] rlang_0.3.0.1        pkgbuild_1.0.2       later_0.7.5
    #> [13] R.oo_1.22.0          glue_1.3.0           withr_2.1.2
    #> [16] DBI_1.0.0            R.utils_2.7.0        rappdirs_0.3.1
    #> [19] bit64_0.9-7          lambda.r_1.2.3       sessioninfo_1.1.1
    #> [22] ini_0.3.1            futile.logger_1.4.3  R.methodsS3_1.7.1
    #> [25] htmlwidgets_1.3      devtools_2.0.1       RcppTOML_0.1.5
    #> [28] memoise_1.1.0        evaluate_0.12        knitr_1.20
    #> [31] callr_3.0.0          crosstalk_1.0.0      httpuv_1.4.5
    #> [34] ps_1.2.1             curl_3.2             Rcpp_1.0.0
    #> [37] xtable_1.8-3         DT_0.5               promises_1.0.1
    #> [40] backports_1.1.2      formatR_1.5          desc_1.2.0
    #> [43] pkgload_1.0.2        jsonlite_1.5         debugme_1.1.0
    #> [46] configr_0.3.4.1      mime_0.6             fs_1.2.6
    #> [49] bit_1.1-14           digest_0.6.18        stringi_1.2.4
    #> [52] processx_3.2.0       shiny_1.2.0          rprojroot_1.3-2
    #> [55] cli_1.0.1            tools_3.5.1          magrittr_1.5
    #> [58] RSQLite_2.1.1        futile.options_1.0.1 crayon_1.3.4
    #> [61] prettyunits_1.0.2    assertthat_0.2.0     rmarkdown_1.10
    #> [64] httr_1.3.1           R6_2.3.0             compiler_3.5.1
    #> [67] git2r_0.23.0