Commit b75c7b23 authored by mmassaviol's avatar mmassaviol
Browse files

Add new button to create DAG with snakemake and display it in a tab

parent b9695b0e
......@@ -566,9 +566,41 @@ generate_pages_server <- function() {
}
file.replace(APP$project+"/server/opt_global.R")
res <- ""
# Event DAG
if ("DAG" %in% names(APP)){
res <- '#\' Event when use DAG button\n'
res <- res + 'observeEvent(input$DAG, {\n\n'
res <- res + '\tpath_param <- "/results/params.yml' + '"\n\n'
res <- res + '\tres <- ""'
res <- res + resG
res <- res + '\ta = yaml.load_file("/workflow/params.total.yml")\n'
res <- res + '\tb = yaml.load(res)\n'
res <- res + '\tanotb = subset(names(a), !(names(a)%in%names(b)))\n'
res <- res + '\tc = c(a[anotb],b)\n'
res <- res + '\tlogical = function(x) {\n'
res <- res + '\t\tresult <- ifelse(x, "True", "False")\n'
res <- res + '\t\tclass(result) <- "verbatim"\n'
res <- res + '\t\treturn(result)\n'
res <- res + '\t}\n'
res <- res + '\twrite_yaml(c,"/results/params.yml",handlers=list(logical = logical))\n'
res <- res + '\tsystem("'+ APP$DAG$command + '")\n'
res <- res + '\taddResourcePath("results", "/results")\n'
res <- res + 'output$DAG = removeUI("#dag_svg")\n'
res <- res + 'output$DAG = insertUI(\n'
res <- res + "selector = '#DAG_placeholder',"
res <- res + "ui = tags$div("
res <- res + 'tags$img(src="results/dag.svg",width="100%"),'
res <- res + 'id = "dag_svg",'
res <- res + 'width = "100%",'
res <- res + 'height = "auto"))})\n'
}
# Event Run
res <- '#\' Event when use '+ run$shiny_button$name +' button\n'
res <- res + '#\' Event when use '+ run$shiny_button$name +' button\n'
res <- res + 'observeEvent(input$'+run$shiny_button$name+', {\n\n'
panel_path <- APP$project + '/params/' + 'params_' + APP$pages[[x]]$name + '.yml'
res <- res + '\tpath_param <- "/results/' + 'params.yml' + '"\n\n'
......@@ -650,11 +682,26 @@ generate_menu <- function() {
menu <- APP$pages[[x]]$label
res <- res + ' menuItem("'+menu+'", tabName="'+name+'", icon=icon("'+icon+'", lib="font-awesome"), newtab=FALSE),\n\n'
}
if("DAG" %in% names(APP)){
name <- "DAG"
icon <- "pencil"
menu <- "DAG"
res <- res + ' menuItem("'+menu+'", tabName="'+name+'", icon=icon("'+icon+'", lib="font-awesome"), newtab=FALSE),\n\n'
}
res <- res + ' tags$br(),\n\n'
res <- res + ' numericInput("cores", label = "Threads availaible", min = 1, max = NA, step = 1, width = "auto", value = 4),\n'
if("DAG" %in% names(APP)){
res <- res + ' tags$br(),\n\n'
res <- res + ' actionButton("DAG", "DAG", icon("pencil") , class="btn btn-info"),\n\n'
}
res <- res + ' tags$br(),\n'
res <- res + ' actionButton("'+ APP$run$shiny_button$name +'", "'+ APP$run$shiny_button$label +'", icon("'+ APP$run$shiny_button$icon +'"), class="'+ APP$run$shiny_button$class +'"),\n\n'
......@@ -728,7 +775,6 @@ generate <- function() {
dir.create.not.exist(APP$project + "/pages")
dir.create.not.exist(APP$project + "/server")
dir.create.not.exist(APP$project + "/params")
dir.create.not.exist(APP$project + "/res")
generate_pages_server()
......@@ -785,6 +831,9 @@ generate_app <- function() {
name <- APP$pages[[x]]$name
res <- res + 'source("./pages/pages_def_'+tolower(name)+'.R", local=T)\n'
}
if("DAG" %in% names(APP)){
res <- res + "tabDAG = fluidPage(box(title = 'Dag :', width = 12, status = 'primary', collapsible = TRUE, solidHeader = TRUE, tags$div(id = 'DAG_placeholder')))\n"
}
res <- res + 'source("./R/menugauche.R", local=T)\n\n'
......@@ -818,7 +867,9 @@ generate_app <- function() {
} else {
res <- res + "\n\n"
}
}
if("DAG" %in% names(APP)){
res <- res + '\t,tabItem(tabName = "DAG", tabDAG)'
}
res <- res + ' )\n\n'
......
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