From fef81172c5afee50f9b50386ee033c4cc9648a3b Mon Sep 17 00:00:00 2001 From: khalid <khalid.belkhir@umontpellier.fr> Date: Tue, 9 Nov 2021 08:41:19 +0100 Subject: [PATCH] singularity def is generated from docker def --- R/menugauche.R | 28 ++- pages/pages_def_home.R | 33 +-- server/opt_home.R | 486 ++++++++++------------------------------- 3 files changed, 141 insertions(+), 406 deletions(-) diff --git a/R/menugauche.R b/R/menugauche.R index d5412ab..899ba01 100644 --- a/R/menugauche.R +++ b/R/menugauche.R @@ -1,11 +1,23 @@ library("shinydashboard") MenuGauche = sidebarMenu(id = "sidebarmenu", - menuItem("Home", tabName = "Home", icon = icon("home", lib="font-awesome")), - - tags$br(), tags$br(), tags$br(), - - menuItem("Team", icon = icon("book", lib="font-awesome"), - menuItem("Jimmy Lopez", href = "http://www.isem.univ-montp2.fr/recherche/les-plate-formes/bioinformatique-labex/personnel/", newtab = TRUE, icon = shiny::icon("male"), selected = NULL ) - ) - + menuItem("Home", tabName = "Home", icon = icon("home", lib="font-awesome")), + br(), + textInput("imageName", "Image Name", ""), + + selectizeInput('fromTemplate', 'From:', choices = c(`ubuntu:16.04` = 'ubuntu:16.04', `ubuntu:18.04` = 'ubuntu:18.04', `ubuntu:20.04` = 'ubuntu:20.04'), selected = "ubuntu:20.04", multiple = FALSE), + + radioButtons("containerType", "Container type:", choices = list("Singularity" = "singularity", "Docker" = "docker"), selected = "singularity"), + br(), + #selectizeInput('rcranpackagelist', 'R CRAN:', choices = NULL, multiple=TRUE, options = list(maxItems = 30000)), + selectizeInput('rtemplate', 'R origin:', choices = c(`None` = 'none', `R from source 3.4.3` = 'source', `R from source 3.4.4` = 'source2', `R from source 3.5.0` = 'source3', `R from source 3.6.0` = 'source4', `R from source 4.0.1` = 'source5', `R from r-base` = 'base', `R from CRAN depo` = 'cran'), selected = "none", multiple = FALSE), + #selectizeInput('biocontainers', 'BioContainers tools :', choices = getBioconductorPackage(), multiple = TRUE), + + textAreaInput("customDataContainer", "Add custom line to container file:"), + br(), + actionButton("createContainer", label = "Generate", icon("paper-plane"), style="color: #fff; background-color: #337ab7; border-color: #2e6da4"), + downloadButton('downloadContainerFile', label = "Dowload", style="color: #fff; background-color: #337ab7; border-color: #2e6da4"), + br(),br(), br(), + menuItem("Team", icon = icon("book", lib="font-awesome"), + menuItem("Jimmy Lopez", href = "http://www.isem.univ-montp2.fr/recherche/les-plate-formes/bioinformatique-labex/personnel/", newtab = TRUE, icon = shiny::icon("male"), selected = NULL ) + ) ) diff --git a/pages/pages_def_home.R b/pages/pages_def_home.R index 08ea62c..2a8c69d 100755 --- a/pages/pages_def_home.R +++ b/pages/pages_def_home.R @@ -5,6 +5,7 @@ tabHome = fluidPage(align="left", title = "Help", width = NULL, collapsible = TRUE, + collapsed = T, status="primary", solidHeader = TRUE, tags$b("Bioinformatics tools: "), @@ -23,36 +24,8 @@ tabHome = fluidPage(align="left", p("singularity exec ubuntu6.10_stacks2.0.simg python -c 'import pysam; print 2*2'") )), - column(width = 2, - box( - title = "Params", - width = NULL, - collapsible = TRUE, - solidHeader = TRUE, - status="primary", - - textInput("imageName", "Image Name", ""), - br(), - #selectizeInput('fromTemplate', 'From:', choices = c(`ubuntu:16.04` = 'ubuntu:16.04', `r-base` = 'r-base'), selected = "r-base", multiple = FALSE), - selectizeInput('fromTemplate', 'From:', choices = c(`ubuntu:16.04` = 'ubuntu:16.04', `ubuntu:18.04` = 'ubuntu:18.04', `ubuntu:20.04` = 'ubuntu:20.04'), selected = "ubuntu:20.04", multiple = FALSE), - - br(), - radioButtons("containerType", "Container type:", choices = list("Singularity" = "singularity", "Docker" = "docker"), selected = "singularity"), - br(), - #selectizeInput('rcranpackagelist', 'R CRAN:', choices = NULL, multiple=TRUE, options = list(maxItems = 30000)), - selectizeInput('rtemplate', 'R origin:', choices = c(`None` = 'none', `R from source 3.4.3` = 'source', `R from source 3.4.4` = 'source2', `R from source 3.5.0` = 'source3', `R from source 3.6.0` = 'source4', `R from source 4.0.1` = 'source5', `R from r-base` = 'base', `R from CRAN depo` = 'cran'), selected = "none", multiple = FALSE), - #selectizeInput('biocontainers', 'BioContainers tools :', choices = getBioconductorPackage(), multiple = TRUE), - - - - textAreaInput("customDataContainer", "Add custom line to container file:"), - br(), br(), - - actionButton("createContainer", label = "Generate", icon("paper-plane"), style="color: #fff; background-color: #337ab7; border-color: #2e6da4"), - downloadButton('downloadContainerFile', label = "Dowload", style="color: #fff; background-color: #337ab7; border-color: #2e6da4") - - )), - column(width = 10, + + column(width = 12, box( id = "boxPackage", title = "Packages and tools", diff --git a/server/opt_home.R b/server/opt_home.R index 17e61f4..ea42ba9 100755 --- a/server/opt_home.R +++ b/server/opt_home.R @@ -51,23 +51,17 @@ output$dtWorkflows <- DT::renderDataTable({ createHeader <- function() { - result <- "" - - if(input$containerType == "singularity") { - result <- "Bootstrap: docker" - result <- paste0(result, "\nFrom: ", input$fromTemplate) - result <- paste(result, "IncludeCmd: yes", sep = "\n") - } else { # else docker - result <- paste0("FROM ", input$fromTemplate) - } - + result <- paste0("FROM ", input$fromTemplate) result <- paste0(result, "\n") return(result) } createEnv <- function(result) { - + result <- paste(result, "ARG DEBIAN_FRONTEND=noninteractive","ARG TZ=Europe/Paris", sep="\n") + result <- paste(result, "export DEBIAN_FRONTEND=noninteractive","export TZ=Europe/Paris", sep="\n")#for singularity + + result <- paste0(result, "\n") Rversion = "3.4.3" if(input$rtemplate == "source2") { Rversion = "3.4.4" @@ -79,87 +73,49 @@ createEnv <- function(result) { Rversion = "4.0.1" } - if(input$containerType == "singularity") { - result <- paste(result, "%environment", sep = "\n") - - if(input$rtemplate == "none" || input$fromTemplate == "r-base") { - - } else if(input$rtemplate == "base") { - result <- paste(result, "\tR_VERSION=3.2.5", sep = "\n") - result <- paste(result, "\texport R_VERSION", sep = "\n") - result <- paste(result, "\tR_CONFIG_DIR=/etc/R/", sep = "\n") - result <- paste(result, "\texport R_CONFIG_DIR", sep = "\n") - } else { - - result <- paste0(result, "\n\tR_VERSION=", Rversion) - result <- paste(result, "\texport R_VERSION", sep = "\n") - result <- paste(result, "\tR_CONFIG_DIR=/etc/R/", sep = "\n") - result <- paste(result, "\texport R_CONFIG_DIR", sep = "\n") - } - - - haveB <- FALSE - if(!is.null(input$dtbiocontainer_rows_all)) { - haveB <- TRUE - result <- paste(result, "\texport PATH=/opt/conda/bin:$PATH", sep = "\n") - result <- paste(result, "\texport PATH=/opt/biotools/bin:$PATH", sep = "\n") - result <- paste(result, "\texport ROOTSYS=/opt/biotools/root", sep = "\n") - result <- paste(result, "\texport LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$ROOTSYS/lib'", sep = "\n") - - result <- createPathBiocontainer(result) - } - - if(!is.null(input$dtWorkflows_rows_all)) { - if(!haveB) { - result <- paste(result, "\texport PATH=/opt/conda/bin:$PATH", sep = "\n") - result <- paste(result, "\texport PATH=/opt/biotools/bin:$PATH", sep = "\n") - result <- paste(result, "\texport ROOTSYS=/opt/biotools/root", sep = "\n") - result <- paste(result, "\texport LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$ROOTSYS/lib'", sep = "\n") - } + selectCRAN <- input$selectedCRAN + sizeCRAN <- length(selectCRAN) + selectBIO <- input$selectedConductor + sizeBIO <- length(selectBIO) + selectGithub <- input$rgithubpackagelist + sizeGITHUB <- length(selectGithub) - result <- paste(result, "\texport PATH=/opt/workflows/bin:$PATH", sep = "\n") - result <- createPathWorkflow(result) - } - - + if(input$rtemplate == "none" & sizeCRAN == 0 & sizeBIO == 0 & sizeGITHUB == 0) { + + } else if(input$rtemplate == "base") { + result <- paste0(result, "ENV R_VERSION=", Rversion) + #result <- paste(result, "RUN export R_VERSION", sep = "\n") + result <- paste(result, "ENV R_CONFIG_DIR=/etc/R/", sep = "\n") + result <- paste(result, "RUN export R_CONFIG_DIR", sep = "\n") + } else { - if(input$rtemplate == "none" || input$fromTemplate == "r-base") { - - } else if(input$rtemplate == "base") { - result <- paste0(result, "ENV R_VERSION=", Rversion) - result <- paste(result, "RUN export R_VERSION", sep = "\n") - result <- paste(result, "ENV R_CONFIG_DIR=/etc/R/", sep = "\n") - result <- paste(result, "RUN export R_CONFIG_DIR", sep = "\n") - - } else { - result <- paste(result, "ENV R_VERSION=3.4.3", sep = "\n") - result <- paste(result, "RUN export R_VERSION", sep = "\n") - result <- paste(result, "ENV R_CONFIG_DIR=/etc/R/", sep = "\n") - result <- paste(result, "RUN export R_CONFIG_DIR", sep = "\n") - } - - haveB <- FALSE - if(!is.null(input$dtbiocontainer_rows_all)) { - haveB <- TRUE - result <- paste(result, "RUN export PATH=/opt/conda/bin:$PATH", sep = "\n") - result <- paste(result, "RUN export PATH=/opt/biotools/bin:$PATH", sep = "\n") - result <- paste(result, "RUN export ROOTSYS=/opt/biotools/root", sep = "\n") - result <- paste(result, "RUN export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$ROOTSYS/lib'", sep = "\n") - - result <- createPathBiocontainer(result) - } + result <- paste(result, "ENV R_VERSION=3.4.3", sep = "\n") + #result <- paste(result, "RUN export R_VERSION", sep = "\n") + result <- paste(result, "ENV R_CONFIG_DIR=/etc/R/", sep = "\n") + result <- paste(result, "RUN export R_CONFIG_DIR", sep = "\n") + } + + haveB <- FALSE + if(!is.null(input$dtbiocontainer_rows_all)) { + haveB <- TRUE + result <- paste(result, "RUN export PATH=/opt/conda/bin:$PATH", sep = "\n") + result <- paste(result, "RUN export PATH=/opt/biotools/bin:$PATH", sep = "\n") + result <- paste(result, "RUN export ROOTSYS=/opt/biotools/root", sep = "\n") + result <- paste(result, "RUN export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$ROOTSYS/lib'", sep = "\n") - if(!is.null(input$dtWorkflows_rows_all)) { - if(!haveB) { - result <- paste(result, "RUN export PATH=/opt/conda/bin:$PATH", sep = "\n") - result <- paste(result, "RUN export PATH=/opt/biotools/bin:$PATH", sep = "\n") - result <- paste(result, "RUN export ROOTSYS=/opt/biotools/root", sep = "\n") - result <- paste(result, "RUN export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$ROOTSYS/lib'", sep = "\n") - } - result <- paste(result, "RUN export PATH=/opt/workflows/bin:$PATH", sep = "\n") - result <- createPathWorkflow(result) - } + result <- createPathBiocontainer(result) + } + if(!is.null(input$dtWorkflows_rows_all)) { + if(!haveB) { + result <- paste(result, "RUN export PATH=/opt/conda/bin:$PATH", sep = "\n") + result <- paste(result, "RUN export PATH=/opt/biotools/bin:$PATH", sep = "\n") + result <- paste(result, "RUN export ROOTSYS=/opt/biotools/root", sep = "\n") + result <- paste(result, "RUN export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$ROOTSYS/lib'", sep = "\n") + } + result <- paste(result, "RUN export PATH=/opt/workflows/bin:$PATH", sep = "\n") + result <- createPathWorkflow(result) } + result <- paste0(result, "\n") return(result) @@ -167,59 +123,36 @@ createEnv <- function(result) { createLabel <- function(result) { - if(input$containerType == "singularity") { - result <- paste(result, "%labels", sep = "\n") - result <- paste(result, "\tAuthor YourName", sep = "\n") - result <- paste(result, "\tVersion v0.0.1", sep = "\n") - result <- paste0(result, "\n\tbuild_date ", format(Sys.time(), "%Y %b %d")) - } else { result <- paste(result, "LABEL Author YourName", sep = "\n") result <- paste(result, "LABEL Version v0.0.1", sep = "\n") result <- paste0(result, "\n", "LABEL build_date ", format(Sys.time(), "%Y %b %d")) - } result <- paste0(result, "\n") return(result) } createExect <- function(result) { - - if(input$containerType == "singularity") { - result <- paste(result, "%apprun run", sep = "\n") - result <- paste(result, '\texec /bin/bash "$@"', sep = "\n") - result <- paste0(result, "\n") - result <- paste(result, "%runscript", sep = "\n") - result <- paste(result, '\texec /bin/bash "$@"', sep = "\n") - } else { - result <- paste(result, "CMD exec /bin/bash \"$@\"", sep = "\n") - } - + + result <- paste(result, "CMD exec /bin/bash \"$@\"", sep = "\n") result <- paste0(result, "\n") return(result) } createLibPrePost <- function(result) { - if(input$containerType == "singularity") { - result <- paste(result, "%post", sep = "\n") - result <- paste(result, "\tapt-get update", sep = "\n") - result <- paste(result, "\tapt-get install -y wget libblas3 libblas-dev liblapack-dev liblapack3 curl", sep = "\n") - result <- paste(result, "\tapt-get install -y gcc fort77 aptitude", sep = "\n") - result <- paste(result, "\taptitude install -y g++ xorg-dev libreadline-dev gfortran", sep = "\n") - result <- paste(result, "\tapt-get install -y libssl-dev libxml2-dev libpcre3-dev liblzma-dev libbz2-dev libcurl4-openssl-dev git", sep = "\n") - result <- paste(result, "\tapt-get update", sep = "\n") - } else { result <- paste(result, "RUN apt-get update", sep = "\n") + result <- paste(result, "RUN apt-get install -y wget libblas3 libblas-dev liblapack-dev liblapack3 curl", sep = "\n") result <- paste(result, "RUN apt-get install -y gcc fort77 aptitude", sep = "\n") result <- paste(result, "RUN aptitude install -y g++ xorg-dev libreadline-dev gfortran", sep = "\n") result <- paste(result, "RUN apt-get install -y libssl-dev libxml2-dev libpcre3-dev liblzma-dev libbz2-dev libcurl4-openssl-dev openjdk-8-jre", sep = "\n") + result <- paste(result, "RUN apt-get install -y autotools-dev automake cmake curl grep sed dpkg fuse git zip openjdk-8-jre build-essential pkg-config python3 python3-dev python3-pip bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion zlib1g-dev libncurses5-dev libncursesw5-dev",sep="\n") + result <- paste(result, "RUN apt-get update", sep = "\n") result <- paste(result, "ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64", sep = "\n") - - } + + result <- paste0(result, "\n") - result <- paste0(result, "\n") return(result) } @@ -227,13 +160,9 @@ createLibPrePost <- function(result) { createRBase <- function(result) { result <- paste(result, '############### Install R From RBase ##############', sep = "\n") - - if(input$containerType == "singularity") { - result <- paste(result, "\tapt-get install -y r-base r-base-dev", sep = "\n") - } else { - result <- paste(result, "RUN apt-get install -y r-base r-base-dev", sep = "\n") - } - + result <- paste(result, "RUN apt-get install -y r-base r-base-dev", sep = "\n") + result <- paste0(result, "\n") + result <- paste0(result, "ENV R_VERSION=$(Rscript -e 'vers=paste(R.Version()[c(\"major\", \"minor\")], collapse = \".\"); cat(vers)')") result <- paste0(result, "\n") return(result) } @@ -243,25 +172,18 @@ createRSource <- function(result, Rversion) { result <- paste(result, '############### Install R From Source ##############', sep = "\n") - if(input$containerType == "singularity") { - result <- paste(result, '\tcd $HOME', sep = "\n") - result <- paste0(result, '\n\twget https://cran.rstudio.com/src/base/R-',strsplit(Rversion, "")[[1]][1],'/R-', Rversion, '.tar.gz') - result <- paste0(result, '\n\ttar xvf R-', Rversion, '.tar.gz') - result <- paste0(result, '\n\tcd R-', Rversion) - result <- paste(result, "\t./configure --enable-R-static-lib --with-blas --with-lapack --enable-R-shlib=yes ", sep = "\n") - result <- paste(result, "\tmake", sep = "\n") - result <- paste(result, "\tmake install", sep = "\n") - } else { result <- paste(result, 'RUN cd $HOME \\', sep = "\n") + if( Rversion == "4.0.1") + result <- paste0(result, '\n\t&& wget https://cran.rstudio.com/src/base/R-4/R-', Rversion, '.tar.gz \\') + else result <- paste0(result, '\n\t&& wget https://cran.rstudio.com/src/base/R-3/R-', Rversion, '.tar.gz \\') + result <- paste0(result, '\n\t&& tar xvf R-', Rversion, '.tar.gz \\') result <- paste0(result, '\n\t&& cd R-', Rversion, ' \\') result <- paste(result, "\t&& ./configure --enable-R-static-lib --with-blas --with-lapack --enable-R-shlib=yes \\", sep = "\n") result <- paste(result, "\t&& make \\", sep = "\n") result <- paste(result, "\t&& make install \\", sep = "\n") - } - - result <- paste0(result, "\n") + result <- paste0(result, "\n") return(result) } @@ -269,20 +191,11 @@ createRSource <- function(result, Rversion) { createRCran <- function(result) { result <- paste(result, '############### Install R From CRAN ##############', sep = "\n") - - if(input$containerType == "singularity") { - result <- paste(result, "\tapt-get install -y software-properties-common", sep = "\n") - result <- paste(result, "\tadd-apt-repository 'deb http://cloud.r-project.org/bin/linux/ubuntu xenial/'", sep = "\n") - result <- paste(result, "\tapt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9", sep = "\n") - result <- paste(result, "\tapt-get update", sep = "\n") - result <- paste(result, "\tapt-get install -y r-base r-base-dev", sep = "\n") - } else { - result <- paste(result, "RUN apt-get install -y software-properties-common", sep = "\n") - result <- paste(result, "RUN add-apt-repository 'deb http://cloud.r-project.org/bin/linux/ubuntu xenial/'", sep = "\n") - result <- paste(result, "RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9", sep = "\n") - result <- paste(result, "RUN apt-get update", sep = "\n") - result <- paste(result, "RUN apt-get install -y r-base r-base-dev", sep = "\n") - } + result <- paste(result, "RUN apt-get install -y software-properties-common", sep = "\n") + result <- paste(result, "RUN add-apt-repository 'deb http://cloud.r-project.org/bin/linux/ubuntu xenial/'", sep = "\n") + result <- paste(result, "RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9", sep = "\n") + result <- paste(result, "RUN apt-get update", sep = "\n") + result <- paste(result, "RUN apt-get install -y r-base r-base-dev", sep = "\n") result <- paste0(result, "\n") return(result) @@ -291,23 +204,16 @@ createRCran <- function(result) { #' Use for create CRAN content createCRANPackage <- function(result) { - - selectCRAN <- input$selectedCRAN sizeCRAN <- length(selectCRAN) - - if(!is.null(sizeCRAN)) { + if(sizeCRAN > 0) { if(sizeCRAN < length(allCRAN[,"Package"])) { if(sizeCRAN >= 1) { result <- paste(result, '############### Install CRAN Package ##############', sep = "\n") - if(input$containerType == "singularity") { - listRCRAN <- '\tR --slave -e "install.packages( c(' - } else { - listRCRAN <- 'RUN R --slave -e "install.packages( c(' - } + listRCRAN <- 'RUN R --slave -e "install.packages( c(' for (pkg in 1:sizeCRAN){ if(pkg < sizeCRAN) { @@ -338,13 +244,7 @@ createGithubPackage <- function(result) { result <- paste(result, '############### Install Github Package ##############', sep = "\n") - - if(input$containerType == "singularity") { - listRGITHUB <- '\tR --slave -e "install_github(c(' - } else { - listRGITHUB <- 'RUN R --slave -e "install_github(c(' - } - + listRGITHUB <- 'RUN R --slave -e "install_github(c(' for (pkg in 1:sizeGITHUB){ if(pkg < sizeGITHUB) { @@ -369,9 +269,6 @@ createBioconductorPackage <- function(result) { selectBIO <- input$selectedConductor sizeBIO <- length(selectBIO) - - - if(!is.null(sizeBIO)) { if(sizeBIO < length(allBIO[,"Package"])) { if(sizeBIO >= 1) { @@ -379,13 +276,9 @@ createBioconductorPackage <- function(result) { result <- paste(result, '############### Install Bioconductor Package ##############', sep = "\n") - if(input$containerType == "singularity") { - result <- paste(result, '\tR --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(); "', sep = "\n") - listRBIO <- '\tR --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(' - } else { - result <- paste(result, 'RUN R --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(); "', sep = "\n") - listRBIO <- 'RUN R --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(' - } + result <- paste(result, 'RUN R --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(); "', sep = "\n") + listRBIO <- 'RUN R --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(' + for (pkg in 1:sizeBIO){ if(pkg < sizeBIO) { @@ -407,19 +300,6 @@ createBioconductorPackage <- function(result) { createPathWorkflow <- function(result) { - if(input$containerType == "singularity") { - selectBioTool <- input$selectedWorkflows - for (tool in selectBioTool){ - - to <- getInstallToolEnvWorkflows(tool, input$containerType) - - if(is.character(to)) { - result <- paste0(result, "\n\t", to) - } - - } - - } else { selectBioTool <- input$selectedWorkflows for (tool in selectBioTool){ @@ -431,8 +311,6 @@ createPathWorkflow <- function(result) { } - } - return(result) } @@ -440,19 +318,6 @@ createPathWorkflow <- function(result) { createPathBiocontainer <- function(result) { - if(input$containerType == "singularity") { - selectBioTool <- input$selectedBiocontainer - for (tool in selectBioTool){ - - to <- getInstallToolEnvBioContainer(tool, input$containerType) - - if(is.character(to)) { - result <- paste0(result, "\n\t", to) - } - - } - - } else { selectBioTool <- input$selectedBiocontainer for (tool in selectBioTool){ @@ -464,91 +329,19 @@ createPathBiocontainer <- function(result) { } - } - return(result) } #' Use for create Workflows content createWorkflows <- function(result, haveR, haveConda) { - if(input$containerType == "singularity") { - selectWorkflows <- input$selectedWorkflows + selectWorkflows <- input$selectedWorkflows result <- paste0(result, "\n") if(!haveConda) { - result <- paste(result, "\tapt-get install -y autotools-dev automake cmake curl grep sed dpkg fuse git zip openjdk-8-jre build-essential pkg-config python python-dev python-pip bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion zlib1g-dev libncurses5-dev libncursesw5-dev", sep = "\n") - result <- paste(result, "\tapt-get update", sep = "\n") - - result <- paste0(result, "\n") - - result <- paste(result, "\techo \'export PATH=/opt/conda/bin:$PATH\' > /etc/profile.d/conda.sh && \\", - "\twget --quiet https://repo.continuum.io/miniconda/Miniconda2-4.0.5-Linux-x86_64.sh -O ./miniconda.sh && \\", - "\t/bin/bash ./miniconda.sh -b -p /opt/conda && \\", - "\trm ./miniconda.sh", sep = "\n") - - result <- paste0(result, "\n") - - - - result <- paste0(result, "\n") - - result <- paste(result, '\tif [ ! -d "/opt/biotools" ];then mkdir /opt/biotools; fi', sep = "\n") - result <- paste(result, '\tif [ ! -d "/opt/biotools/bin" ];then mkdir /opt/biotools/bin; fi', sep = "\n") - result <- paste(result, "\tchmod 777 -R /opt/biotools/", sep = "\n") - result <- paste(result, "\texport PATH=/opt/biotools/bin:$PATH", sep = "\n") - - result <- paste(result, "\tchmod 777 -R /opt/conda/", sep = "\n") - result <- paste(result, "\texport PATH=/opt/conda/bin:$PATH", sep = "\n") - - if(!haveR) { - result <- paste(result, "\tconda config --add channels r", sep = "\n") - } - - result <- paste(result, "\tconda config --add channels bioconda", sep = "\n") - result <- paste(result, "\tconda upgrade conda", sep = "\n") - - result <- paste0(result, "\n") - - } - - result <- paste(result, '\tif [ ! -d "/opt/workflows" ];then mkdir /opt/workflows; fi', sep = "\n") - result <- paste(result, '\tif [ ! -d "/opt/workflows/bin" ];then mkdir /opt/workflows/bin; fi', sep = "\n") - result <- paste(result, "\tchmod 777 -R /opt/workflows/", sep = "\n") - result <- paste(result, "\texport PATH=/opt/workflows/bin:$PATH", sep = "\n") - - for (tool in selectWorkflows){ - - result <- paste(result, '############### Install Workflow tools ##############\n', sep = "\n") - - - for(i in getInstallToolPackageWorkflow(tool, input$containerType)) { - result <- paste0(result, i, "\n") - } - - } - } else { - selectWorkflows <- input$selectedWorkflows - - result <- paste0(result, "\n") - - if(!haveConda) { - - result <- paste(result, "RUN apt-get install -y autotools-dev automake cmake curl grep sed dpkg fuse git zip openjdk-8-jre build-essential pkg-config python python-dev python-pip bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion zlib1g-dev libncurses5-dev libncursesw5-dev", sep = "\n") - result <- paste(result, "RUN apt-get update", sep = "\n") - - result <- paste0(result, "\n") - - result <- paste(result, "RUN echo \'export PATH=/opt/conda/bin:$PATH\' > /etc/profile.d/conda.sh && \\", - "\twget --quiet https://repo.continuum.io/miniconda/Miniconda2-4.0.5-Linux-x86_64.sh -O ./miniconda.sh && \\", - "\t/bin/bash ./miniconda.sh -b -p /opt/conda && \\", - "\trm ./miniconda.sh", sep = "\n") - - result <- paste0(result, "\n") - - + result <- paste0(result, "\n") @@ -557,17 +350,15 @@ createWorkflows <- function(result, haveR, haveConda) { result <- paste(result, "RUN chmod 777 -R /opt/biotools/", sep = "\n") result <- paste(result, "ENV PATH=/opt/biotools/bin:${PATH}", sep = "\n") - result <- paste(result, "RUN chmod 777 -R /opt/conda/", sep = "\n") - result <- paste(result, "ENV PATH=/opt/conda/bin:${PATH}", sep = "\n") + + + result <- paste0(result, "\n") if(!haveR) { result <- paste(result, "RUN conda config --add channels r", sep = "\n") } - result <- paste(result, "RUN conda config --add channels bioconda", sep = "\n") - result <- paste(result, "RUN conda upgrade conda", sep = "\n") - - result <- paste0(result, "\n") + } @@ -585,7 +376,7 @@ createWorkflows <- function(result, haveR, haveConda) { } } - } + result <- paste0(result, "\n") return(result) @@ -595,68 +386,11 @@ createWorkflows <- function(result, haveR, haveConda) { #' Use for create Biocontainer content createBiocontainer <- function(result, haveR) { - if(input$containerType == "singularity") { - selectBioTool <- input$selectedBiocontainer - - result <- paste0(result, "\n") - - result <- paste(result, "\tapt-get install -y autotools-dev automake cmake curl grep sed dpkg fuse git zip openjdk-8-jre build-essential pkg-config python python-dev python-pip bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion zlib1g-dev libncurses5-dev libncursesw5-dev", sep = "\n") - result <- paste(result, "\tapt-get update", sep = "\n") - - result <- paste0(result, "\n") - - result <- paste(result, "\techo \'export PATH=/opt/conda/bin:$PATH\' > /etc/profile.d/conda.sh && \\", - "\twget --quiet https://repo.continuum.io/miniconda/Miniconda2-4.0.5-Linux-x86_64.sh -O ./miniconda.sh && \\", - "\t/bin/bash ./miniconda.sh -b -p /opt/conda && \\", - "\trm ./miniconda.sh", sep = "\n") - - result <- paste0(result, "\n") - - - result <- paste0(result, "\n") - - result <- paste(result, '\tif [ ! -d "/opt/biotools" ];then mkdir /opt/biotools; fi', sep = "\n") - result <- paste(result, '\tif [ ! -d "/opt/biotools/bin" ];then mkdir /opt/biotools/bin; fi', sep = "\n") - result <- paste(result, "\tchmod 777 -R /opt/biotools/", sep = "\n") - result <- paste(result, "\texport PATH=/opt/biotools/bin:$PATH", sep = "\n") - - result <- paste(result, "\tchmod 777 -R /opt/conda/", sep = "\n") - result <- paste(result, "\texport PATH=/opt/conda/bin:$PATH", sep = "\n") - - if(!haveR) { - result <- paste(result, "\tconda config --add channels r", sep = "\n") - } - - result <- paste(result, "\tconda config --add channels bioconda", sep = "\n") - result <- paste(result, "\tconda upgrade conda", sep = "\n") - - result <- paste0(result, "\n") - - for (tool in selectBioTool){ - - result <- paste(result, '############### Install BioContainer tools ##############\n', sep = "\n") - - - result <- paste(result, getInstallToolPackageBioContainer(tool, input$containerType), sep="\n\n") - } - } else { + selectBioTool <- input$selectedBiocontainer result <- paste0(result, "\n") - result <- paste(result, "RUN apt-get install -y autotools-dev automake cmake curl grep sed dpkg fuse git zip openjdk-8-jre build-essential pkg-config python python-dev python-pip bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion zlib1g-dev libncurses5-dev libncursesw5-dev", sep = "\n") - result <- paste(result, "RUN apt-get update", sep = "\n") - - result <- paste0(result, "\n") - - result <- paste(result, "RUN echo \'export PATH=/opt/conda/bin:$PATH\' > /etc/profile.d/conda.sh && \\", - "\twget --quiet https://repo.continuum.io/miniconda/Miniconda2-4.0.5-Linux-x86_64.sh -O ./miniconda.sh && \\", - "\t/bin/bash ./miniconda.sh -b -p /opt/conda && \\", - "\trm ./miniconda.sh", sep = "\n") - - result <- paste0(result, "\n") - - result <- paste0(result, "\n") result <- paste(result, "RUN mkdir /opt/biotools", sep = "\n") @@ -664,28 +398,18 @@ createBiocontainer <- function(result, haveR) { result <- paste(result, "RUN chmod 777 -R /opt/biotools/", sep = "\n") result <- paste(result, "ENV PATH=/opt/biotools/bin:${PATH}", sep = "\n") - result <- paste(result, "RUN chmod 777 -R /opt/conda/", sep = "\n") - result <- paste(result, "ENV PATH=/opt/conda/bin:${PATH}", sep = "\n") if(!haveR) { result <- paste(result, "RUN conda config --add channels r", sep = "\n") } - result <- paste(result, "RUN conda config --add channels bioconda", sep = "\n") - result <- paste(result, "RUN conda upgrade conda", sep = "\n") - - result <- paste0(result, "\n") + + result <- paste(result, '############### Install BioContainer tools ##############\n', sep = "\n") for (tool in selectBioTool){ - - result <- paste(result, '############### Install BioContainer tools ##############\n', sep = "\n") - - - result <- paste0(result, "RUN ", getInstallToolPackageBioContainer(tool, input$containerType)) + result <- paste0(result, "RUN ", getInstallToolPackageBioContainer(tool, input$containerType),"\n") } - - } - + result <- paste0(result, "\n") return(result) } @@ -700,7 +424,17 @@ createContentFile <- function() { result <- createLabel(result) result <- createLibPrePost(result) - if(input$rtemplate != "none" && input$fromTemplate != "r-base") { + selectCRAN <- input$selectedCRAN + sizeCRAN <- length(selectCRAN) + + selectBIO <- input$selectedConductor + sizeBIO <- length(selectBIO) + + selectGithub <- input$rgithubpackagelist + sizeGITHUB <- length(selectGithub) + + if (!is.null(sizeCRAN) ) print(sizeCRAN) + if(input$rtemplate != "none" | sizeCRAN > 0 | sizeBIO > 0 | sizeGITHUB > 0) { haveR = TRUE @@ -716,7 +450,7 @@ createContentFile <- function() { Rversion = "4.0.1" } result <- createRSource(result, Rversion) - } else if(input$rtemplate == "base") { + } else if(input$rtemplate == "base" | input$rtemplate == "none") { result <- createRBase(result) } else if(input$rtemplate == "cran") { result <- createRCran(result) @@ -724,9 +458,9 @@ createContentFile <- function() { } - result <- createCRANPackage(result) - result <- createBioconductorPackage(result) - result <- createGithubPackage(result) + result <- createCRANPackage(result) + result <- createBioconductorPackage(result) + result <- createGithubPackage(result) haveBiocontainer <- FALSE if(!is.null(input$selectedBiocontainer)) { @@ -751,6 +485,25 @@ observeEvent(input$createContainer, { result <- createContentFile() + if(input$containerType == "singularity") { + # will convert result using spython https://singularityhub.github.io/ + #save result in a tmp file + dockerfile = tempfile(pattern = "Dockerfile") + tmpSingularityFile = tempfile(pattern = "Singularity") + write.table(result, dockerfile, row.names=F, col.names=F, quote=F) + cmd = paste0("sed -i 's/R_VERSION=.*/R_VERSION=getRversion/' ",dockerfile) + system(cmd) + cmd = paste0("spython recipe ", dockerfile, " > ", tmpSingularityFile) + system(cmd) + # read tmpSingularityFile in result var + cmd = paste0("sed -i 's/getRversion/$(Rscript -e \"vers=paste(R.Version()[c(\"major\",\"minor\")],collapse =\".\");cat(vers)\")/' ", tmpSingularityFile) + system(cmd) + + result <- paste(readLines(tmpSingularityFile, n=-1),"\n", collapse = '') + unlink(dockerfile) + unlink(tmpSingularityFile) + + } updateTextAreaInput(session, "previewContainer", label = "", value = result) @@ -778,11 +531,8 @@ observeEvent(input$createContainer, { output$downloadContainerFile <- downloadHandler( filename = function() { name <- "" - if(input$containerType == "singularity") { - name <- paste("Singularity",input$imageName, sep = ".") - } else { - name <- paste("Dockerfile",input$imageName, sep = ".") - } + name <- paste("Dockerfile",input$imageName, sep = ".") + }, content = function(file) { result <- input$previewContainer -- GitLab