inst/extdata/install.R
82c39039
 
 ##########################
 # FastqCleaner installer
 ##########################
 
 message("\n")
 message("######################")
 message("   FastqCleaner")
 message("######################\n")
 message("Installing dependencies, this may take a while...")
 message("\n")
 
 R_repo <- "https://cloud.r-project.org/"
 
 # set internet options
 options(download.file.method = "libcurl", url.method = "libcurl")
 
 # set library -------------------------------------------------------------------------------------
 where <- normalizePath(Sys.getenv("R_LIBS_USER"))
 if(!dir.exists(where)) {
   dir.create(where, recursive =  TRUE)
 }
 .libPaths(c(.libPaths(), where))
 
 github_where <- paste("--library=", paste0("'", where, "'"))
 
 # Check OS ---------------------------------------------------------------------------------------
 get_os <- function(){
   sysinf <- Sys.info()
   if (!is.null(sysinf)){
     os <- sysinf['sysname']
     if (os == 'Darwin')
       os <- "osx"
   } else { ## mystery machine
     os <- .Platform$OS.type
     if (grepl("^darwin", R.version$os))
       os <- "osx"
     if (grepl("linux-gnu", R.version$os))
       os <- "linux"
   }
   tolower(os)
 }
 
 this_os <- get_os()
 
 # Check dependences for each os
 
 if (this_os == "osx") {
b766b9b7
   test_xcode <- class(try(system2("gcc --version", stdout = TRUE), silent = TRUE))
   if(is(test_xcode, "try-error")) {
82c39039
     
     stop(toupper("Command Line Tools is required. Please paste install Command Line Tools pasting the following 
           command in a Terminal and then selecting install in the popup dialog:\n 
           xcode-select --install"))
   }
   if(length(list.files("/opt/X11/bin", pattern = "Xquartz")) == 0) {
   stop(toupper("X11 is required. Please visit www.xquartz.org to download and install Xquartz."))
   }
 }
 
 if(this_os == "linux") {
   is_ubuntu <- grep("ubuntu", sessionInfo()$running,  ignore.case = TRUE)
   if(length(is_ubuntu) > 0) {
b766b9b7
     p1 <- is(try(system2("dpkg -l |grep libssl-dev", stdout =  TRUE)), 
                 "try-error")
     p2 <- is(try(system2("dpkg -l |grep libcurl4-openssl-dev", stdout =  TRUE)),
                 "try-error")
82c39039
     msg <- ""
     what <- ""
b766b9b7
     if(p1) {
82c39039
       msg <- ("libssl-dev in required\n")
       what <- "libssl-dev "
     }
b766b9b7
     if(p2) {
82c39039
       msg <- c(msg, "libcurl4-openssl-dev in required\n")
       what <- paste0(what, "libcurl4-openssl-dev ")
     }
b766b9b7
     if(p1 || p2) {
82c39039
       stop(toupper(paste0(msg, "Please install the dependences with the following command\n: sudo apt get install ", what)))
     }
   } else {
     cat(toupper("-----------------------------------------------------------------------------------\n
 Important: please check that the 'libcurl' and 'libssl' packages corresponding 
 to your Linux distribution are installed. If the installation fails, 
                     install them and try again.\n
 -----------------------------------------------------------------------------------\n\n"))
   }
   
 }
 
 if(this_os == "windows") {
   if(!require(devtools)) {
   cat(toupper("Installing devtools...\n"))
   try(install.packages("devtools", lib = where, repos = R_repo, quiet = TRUE, verbose = FALSE), silent = TRUE)
   }
   
   if(!require(devtools)) {
     warning(toupper("Cannot install devtools. Trying to install Rtools..."))
     install.packages("installr",lib = where, repos = R_repo)
     rtoolsexit <- installr::install.Rtools()
     if(!rtoolsexit) {
       stop("Failed.\nRtools needs to be manually installed from: https://cran.r-project.org/bin/windows/Rtools/")
     }
   }
 }
 
 
 # install dependences------------------------------------------------------------------------------
 packages <- c("devtools", "Rcpp", "DT", "shiny", "methods", "graphics", "shinyBS", "RCurl")
 
 # install Bioconductor dependences----------------------------------------------------------------
 bpackages <- c("IRanges", "Biostrings", "ShortRead", "S4Vectors")
895a43a1
 bpackages <- c("IRanges", "Biostrings", "ShortRead", "S4Vectors")
0f1d0812
 source("https://bioconductor.org/biocLite.R")
895a43a1
 if (!requireNamespace("BiocManager", quietly=TRUE))
     install.packages("BiocManager")
82c39039
 
895a43a1
 
 for(i in bpackages) {
82c39039
 for(i in bpackages) {
895a43a1
   if (!require(i, character.only = TRUE)) {
82c39039
   if (!require(i, character.only = TRUE)) {
0f1d0812
     biocLite(i, lib = where,suppressUpdates = TRUE, dependencies = TRUE)
895a43a1
     BiocManager::install(i, lib = where,suppressUpdates = TRUE, dependencies = TRUE)
82c39039
   }
895a43a1
   }
 }
82c39039
 }
 
 # install package --------------------------------------------------------------------------------
 library("devtools")
 withr::with_libpaths(where, 
 install_github("leandroroser/FastqCleaner", build_vignettes = TRUE, verbose = TRUE, args = github_where)
 )
 # EOF