Commit e1e57ef3 authored by mmassaviol's avatar mmassaviol
Browse files

Add an option to force running again from a step

parent 699af2cd
......@@ -540,7 +540,7 @@ generate_pages_server <- function() {
save_params <- "save_params <- function(path_param){\n"
save_params <- save_params + '\tres = ""'
save_params <- save_params + resG
save_params <- save_params + '\t\tres = paste0(res, paste("final_step:", paste0(\'\"\', input$final_step, \'\"\'), "\\n", sep = " "))\n\n'
#save_params <- save_params + '\t\tres = paste0(res, paste("final_step:", paste0(\'\"\', input$final_step, \'\"\'), "\\n", sep = " "))\n\n'
save_params <- save_params + '\ta = yaml.load_file("/workflow/params.total.yml")\n'
save_params <- save_params + '\tp = a[["params"]]\n'
save_params <- save_params + '\ta["params"] = NULL\n'
......@@ -554,36 +554,53 @@ generate_pages_server <- function() {
save_params <- save_params + '\t\treturn(result)\n'
save_params <- save_params + '\t}\n'
save_params <- save_params + '\td = c(d,a)\n'
save_params <- save_params + '\tsamples = yaml.load(system(paste0("python3 /workflow/get_samples.py ",input$sample_dir," /Data/groups.csv ", input$sample_suffix),intern = T))\n'
save_params <- save_params + '\td$samples = names(samples)\n'
save_params <- save_params + '\tnames(samples) = NULL\n'
save_params <- save_params + '\td$groups = unlist(samples)\n'
save_params <- save_params + '\tget_samples = yaml.load(system(paste0("python3 /workflow/get_samples.py ",input$sample_dir," ",input$SeOrPe),intern = T))\n'
save_params <- save_params + '\td$samples = get_samples$samples\n'
save_params <- save_params + '\td$params$sample_suffix = get_samples$suffix\n'
save_params <- save_params + '\twrite_yaml(d,path_param,handlers=list(logical = logical))\n'
save_params <- save_params + '\t}\n\n'
res <- save_params
# Compare parameters (give rules that need to be re-runned)
res <- res + 'compare_params = function(dossierAnalyse){\n'
res <- res + '\tif (!file.exists(paste0(dossierAnalyse,"/lastrun/params.yml"))){\n'
res <- res + '\t\treturn(c())\n'
res <- res + 'force_rule <- function(force_from){\n'
res <- res + '\tif (input$force_from=="none"){\n'
res <- res + '\t\treturn("")\n'
res <- res + '\t}\n'
res <- res + '\telse{\n'
res <- res + '\t\tnew_params = yaml.load_file(paste0(dossierAnalyse,"/params.yml"))\n'
res <- res + '\t\told_params = yaml.load_file(paste0(dossierAnalyse,"/workflow/params.yml"))\n'
res <- res + '\t\tchanged = new_params[!(new_params %in% old_params)]\n'
res <- res + '\t\trules = c()\n'
res <- res + '\t\tif (length(changed)>=1){\n'
res <- res + '\t\t\tfor (param in names(changed)){\n'
res <- res + '\t\t\t\tif (!grepl("_threads$",param)){\n'
res <- res + '\t\t\t\t\trules = c(rules, new_params$params_info[[param]]$rule)\n'
res <- res + '\t\t\t\t}\n'
res <- res + '\t\t\t}\n'
res <- res + '\telse if (input$force_from=="all"){ return("--forcerun all") }\n'
res <- res + '\telse {\n'
res <- res + '\t\tparams = yaml.load_file(paste0(input$results_dir,"/params.yml"))\n'
res <- res + '\t\toutputs = params[["outputs"]]\n'
res <- res + '\t\ttool = params[["params"]][[force_from]]\n'
res <- res + '\t\tif (length(outputs[[tool]])==1)\n'
res <- res + '\t\t\trule = names(outputs[[tool]])[[1]]\n'
res <- res + '\t\telse{\n'
res <- res + '\t\t\trule = names(outputs[[tool]])[[grep(input$SeOrPe,names(outputs[[tool]]))]]\n'
res <- res + '\t\t}\n'
res <- res + '\t\treturn(unique(rules))\n'
res <- res + '\t\treturn(paste0("--forcerun ",rule))\n'
res <- res + '\t}\n'
res <- res + '}\n'
# # Compare parameters (give rules that need to be re-runned)
# res <- res + 'compare_params = function(dossierAnalyse){\n'
# res <- res + '\tif (!file.exists(paste0(dossierAnalyse,"/lastrun/params.yml"))){\n'
# res <- res + '\t\treturn(c())\n'
# res <- res + '\t}\n'
# res <- res + '\telse{\n'
# res <- res + '\t\tnew_params = yaml.load_file(paste0(dossierAnalyse,"/params.yml"))\n'
# res <- res + '\t\told_params = yaml.load_file(paste0(dossierAnalyse,"/workflow/params.yml"))\n'
# res <- res + '\t\tchanged = new_params[!(new_params %in% old_params)]\n'
# res <- res + '\t\trules = c()\n'
# res <- res + '\t\tif (length(changed)>=1){\n'
# res <- res + '\t\t\tfor (param in names(changed)){\n'
# res <- res + '\t\t\t\tif (!grepl("_threads$",param)){\n'
# res <- res + '\t\t\t\t\trules = c(rules, new_params$params_info[[param]]$rule)\n'
# res <- res + '\t\t\t\t}\n'
# res <- res + '\t\t\t}\n'
# res <- res + '\t\t}\n'
# res <- res + '\t\treturn(unique(rules))\n'
# res <- res + '\t}\n'
# res <- res + '}\n'
file.replace(APP$project+"/server/opt_global.R")
#res <- ""
# Event RULEGRAPH
......@@ -640,18 +657,18 @@ generate_pages_server <- function() {
res <- res + '\t\t\tfile.create(paste0(input$results_dir,"/logs/runlog.txt"))\n'
res <- res + '\t\t}\n'
res <- res + '\t\tforcerun = compare_params(input$results_dir)\n'
res <- res + '\t\tif (length(forcerun>1)){\n'
res <- res + '\t\t\trules = paste(forcerun, collapse=" ")\n'
res <- res + '\t\t\tforcerun = paste(" --forcerun ",rules)\n'
res <- res + '\t\t\tshowModal(modalDialog(\n'
res <- res + '\t\t\t\ttitle = "Params have changed since the last run",\n'
res <- res + '\t\t\t\tforcerun\n'
res <- res + '\t\t\t))\n'
res <- res + '\t\t}\n'
res <- res + '\t\telse{\n'
res <- res + '\t\t\tforcerun = ""\n'
res <- res + '\t\t}\n'
# res <- res + '\t\tforcerun = compare_params(input$results_dir)\n'
# res <- res + '\t\tif (length(forcerun>1)){\n'
# res <- res + '\t\t\trules = paste(forcerun, collapse=" ")\n'
# res <- res + '\t\t\tforcerun = paste(" --forcerun ",rules)\n'
# res <- res + '\t\t\tshowModal(modalDialog(\n'
# res <- res + '\t\t\t\ttitle = "Params have changed since the last run",\n'
# res <- res + '\t\t\t\tforcerun\n'
# res <- res + '\t\t\t))\n'
# res <- res + '\t\t}\n'
# res <- res + '\t\telse{\n'
# res <- res + '\t\t\tforcerun = ""\n'
# res <- res + '\t\t}\n'
res <- res + '\t\tsystem(paste0("touch ",input$results_dir,"/logs/workflow.running"),wait = T)\n'
......@@ -659,7 +676,8 @@ generate_pages_server <- function() {
res <- res + '\t\t\tsystem(paste0("snakemake -s /workflow/Snakefile --configfile ",input$results_dir,"/params.yml -d ",input$results_dir," all --rulegraph | dot -Tpng -Gratio=0.75 > ",input$results_dir,"/Rule_graph_mqc.png"))\n'
# RUN
res <- res + '\t\tsystem2("python3",paste0("-u -m snakemake -s /workflow/Snakefile --configfile ", paste0(input$results_dir,"/params.yml") ,\t" --forcerun all -d ", input$results_dir ,\t" --cores ", input$cores, " all ", forcerun),wait = FALSE, stdout = paste0(input$results_dir,"/logs/runlog.txt"), stderr = paste0(input$results_dir,"/logs/runlog.txt"))\n'
res <- res + '\t\tforce = force_rule(input$force_from)\n'
res <- res + '\t\tsystem2("python3",paste0("-u -m snakemake -s /workflow/Snakefile --configfile ", paste0(input$results_dir,"/params.yml") ,\t" -d ", input$results_dir ,\t" --cores ", input$cores, " all ", force),wait = FALSE, stdout = paste0(input$results_dir,"/logs/runlog.txt"), stderr = paste0(input$results_dir,"/logs/runlog.txt"))\n'
res <- res + '\t\ttags$iframe(src="results/multiqc_report.html",width="100%", height="900px")},\n'
res <- res + '\t\terror = function(e){\n'
res <- res + '\t\t\tsystem(paste0("touch ",input$results_dir,"/logs/workflow_end.error"),wait = T)\n'
......@@ -741,12 +759,12 @@ generate_menu <- function() {
res <- res + '\tnumericInput("cores", label = "Threads available", min = 1, max = 24, step = 1, width = "auto", value = 16),\n'
# select step to reach
choices = "list("
# select where to run again from
choices = "list('none'='none',"
for(step in APP$pages[2:length(APP$pages)]){ # all steps but remove global_params page
choices <- choices + "'" + step$label + "'='" + step$name + "',"
}
res <- res + 'selectInput("final_step", label = "Select the step to reach : ", selected = "all", choices = '+choices+'"All"="all")),'
res <- res + 'selectInput("force_from", label = "Start again from a step : ", selected = "none", choices = '+choices+'"All"="all")),'
#
......
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