Commit 67e65134 authored by jlopez's avatar jlopez
Browse files

Add workflows

parent 4026ce02
......@@ -15,6 +15,45 @@ getPackagesWithTitle <- function() {
}
getWorkflows <- function() {
data <- allWORKFLOWS
size <- 0
for (tools in data) {
if(length(tools$install) > 0) {
size <- size + 1
}
}
Tool <- character(size)
Version <- character(size)
Author <- character(size)
Description <- character(size)
Link <- character(size)
i=1
for (tools in data) {
Tool[i] = tools$name
Version[i] = tools$version
Author[i] = tools$author
Description[i] = tools$description
Link[i] = paste0("<a href='", tools$documentation, "'>documentation</a>")
i = i + 1
}
result <- data.frame(Workflow=Tool,
Version=Version,
Author=Author,
Description=Description,
Link=Link)
return(result)
}
getBioconductorPackage <- function() {
......@@ -61,6 +100,38 @@ getBioconductorPackage <- function() {
return(result)
}
getInstallToolPackageWorkflow <- function(tool, containerType) {
data <- allWORKFLOWS
size <- length(data)
intalls <- ""
res <- ""
for (tools in data) {
splitB <- strsplit(tool, "%")
name <- splitB[[1]][1]
version <- splitB[[1]][2]
if(tools$name == name) {
if(tools$version == version) {
for (c in tools$dependencies) {
tt <- paste0(c$name, "%", c$version)
print(tt)
res <- paste0(res, getInstallToolPackageBioContainer(tt, containerType))
res <- paste0(res, "\n")
}
res <- paste0(res, "\t", tools$install, collapse='\n' )
return(res)
}
}
}
return("\t")
}
getInstallToolPackageBioContainer <- function(tool, containerType) {
data <- allBIOCONTAINER
......@@ -76,6 +147,9 @@ getInstallToolPackageBioContainer <- function(tool, containerType) {
if(tools$name == name) {
if(tools$version == version) {
res <- paste0("\t", tools$install, collapse='\n' )
return(res)
}
......@@ -113,5 +187,33 @@ getInstallToolEnvBioContainer <- function(tool, containerType) {
return (FALSE)
}
getInstallToolEnvWorkflows <- function(tool, containerType) {
data <- allWORKFLOWS
size <- length(data)
intalls <- ""
for (tools in data) {
splitB <- strsplit(tool, "%")
name <- splitB[[1]][1]
version <- splitB[[1]][2]
if(tools$name == name) {
if(tools$version == version) {
if(is.null(tools$env)) {
return (FALSE)
} else {
return(tools$env)
}
}
}
}
return (FALSE)
}
......@@ -65,6 +65,20 @@ server <- function( input, output, session) {
i = i + 1
}
allWORKFLOWS <<- list()
TMP <<- yaml.load_file("workflow.yaml")$workflows
i = 1
j = 1
allWORKFLOWS <<- list()
for(x in TMP) {
if(length(TMP[[i]]$install) > 0) {
allWORKFLOWS[[j]] <<- TMP[[i]]
j = j + 1
}
i = i + 1
}
hide("downloadContainerFile")
source("./server/opt_home.R", local=TRUE)
......
......@@ -91,7 +91,14 @@ tabHome = fluidPage(align="left",
selectizeInput('rgithubpackagelist', 'R Github selected:', choices = NULL, multiple=TRUE, options = list(maxItems = 30000)),
br(), br(),
DT::dataTableOutput('dtrgithubpackage')))
DT::dataTableOutput('dtrgithubpackage'))),
tabPanel('Workflows',
div(id = "formWorkflows",
br(),
selectizeInput('selectedWorkflows', 'Workflows selected:', choices = NULL, multiple=TRUE, options = list(maxItems = 30000))),
DT::dataTableOutput('dtWorkflows'))
)
)
......
......@@ -31,6 +31,19 @@ output$dtbiocontainer <- DT::renderDataTable({
return(result)
}, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)
getWorkflows
output$dtWorkflows <- DT::renderDataTable({
result <- data.frame(Workflow=character(),
Author=character(),
Version=character(),
Description=character())
result <- getWorkflows()
return(result)
}, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)
createHeader <- function() {
......@@ -76,7 +89,10 @@ createEnv <- function(result) {
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")
......@@ -85,6 +101,18 @@ createEnv <- function(result) {
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")
}
result <- paste(result, "\texport PATH=/opt/workflows/bin:$PATH", sep = "\n")
result <- createPathWorkflow(result)
}
} else {
if(input$rtemplate == "none" || input$fromTemplate == "r-base") {
......@@ -102,7 +130,9 @@ createEnv <- function(result) {
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")
......@@ -110,6 +140,17 @@ createEnv <- function(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")
......@@ -355,6 +396,40 @@ createBioconductorPackage <- function(result) {
return(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){
to <- getInstallToolEnvWorkflows(tool, input$containerType)
if(is.character(to)) {
result <- paste0(result, "\nRUN ", to)
}
}
}
return(result)
}
createPathBiocontainer <- function(result) {
if(input$containerType == "singularity") {
......@@ -385,6 +460,132 @@ createPathBiocontainer <- function(result) {
return(result)
}
#' Use for create Workflows content
createWorkflows <- function(result, haveR, haveConda) {
if(input$containerType == "singularity") {
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 <- paste(result, "\tTINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o \"/v.*\\\"\" | sed \'s:^..\\(.*\\).$:\\1:\'` && \\",
"\tcurl -L \"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb\" > tini.deb && \\",
"\tdpkg -i tini.deb && \\",
"\trm tini.deb && \\",
"\tapt-get clean", sep = "\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 ##############', sep = "\n")
result <- paste(result, getInstallToolPackageWorkflow(tool, input$containerType), sep="\n\n")
}
} else {
selectBioTool <- input$selectedBiocontainer
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 <- paste(result, "RUN TINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o \"/v.*\\\"\" | sed \'s:^..\\(.*\\).$:\\1:\'` && \\",
"\tcurl -L \"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb\" > tini.deb && \\",
"\tdpkg -i tini.deb && \\",
"\trm tini.deb && \\",
"\tapt-get clean", sep = "\n")
result <- paste0(result, "\n")
result <- paste(result, "RUN mkdir /opt/biotools", sep = "\n")
result <- paste(result, "RUN mkdir /opt/biotools/bin", sep = "\n")
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, "RUN mkdir /opt/workflows", sep = "\n")
result <- paste(result, "RUN mkdir /opt/workflows/bin", sep = "\n")
result <- paste(result, "RUN chmod 777 -R /opt/workflows/", sep = "\n")
result <- paste(result, "ENV PATH=/opt/workflows/bin:${PATH}", sep = "\n")
for (tool in selectBioTool){
result <- paste(result, '############### Install Workflow ##############', sep = "\n")
result <- paste0(result, "\nRUN ", getInstallToolPackageWorkflow(tool, input$containerType))
}
}
result <- paste0(result, "\n")
return(result)
}
#' Use for create Biocontainer content
......@@ -530,10 +731,14 @@ createContentFile <- function() {
result <- createBioconductorPackage(result)
result <- createGithubPackage(result)
haveBiocontainer <- FALSE
if(!is.null(input$selectedBiocontainer)) {
haveBiocontainer <- TRUE
result <- createBiocontainer(result, haveR)
}
result <- createWorkflows(result, haveR, haveBiocontainer)
result <- createExect(result)
result <- paste(result, input$customDataContainer, sep = "\t\n")
......@@ -605,6 +810,25 @@ observe({
})
observe({
if(is.null(input$dtWorkflows_rows_selected)) {
shinyjs::reset("formWorkflows")
} else {
i = 1
selectWorkflows <- list()
for(x in input$dtWorkflows_rows_selected) {
selectWorkflows[i] = paste(allWORKFLOWS[[x]]$name, allWORKFLOWS[[x]]$version, sep = "%")
i = i + 1
}
selectWorkflows <- c(unlist(selectWorkflows))
updateSelectizeInput(session,"selectedWorkflows", choices = selectWorkflows, selected = selectWorkflows, options = list())
}
})
observe({
if(is.null(input$dtrcranpackage_rows_selected)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment