Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jlopez
sagJL
Commits
a81c652e
Commit
a81c652e
authored
May 15, 2020
by
mmassaviol
Browse files
Debug error turning many floats to scientific format
parent
331979e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.R
View file @
a81c652e
...
...
@@ -3,7 +3,6 @@
# Accepts one parameters: path to sag yaml configuration file
# Usage: Rscript /path/to/sag.yaml
args
=
commandArgs
(
trailingOnly
=
TRUE
)
source
(
"tools.R"
)
library
(
yaml
)
...
...
@@ -33,7 +32,7 @@ generate_page_input <- function(res, cnt) {
}
if
(
cnt
$
type
==
"text"
)
{
res
<-
res
+
'\t\ttextInput("'
+
cnt
$
name
+
'", label = "'
+
cnt
$
label
+
'", value = "'
+
cnt
$
value
+
'", width = "'
+
'auto'
+
'")'
res
<-
res
+
'\t\ttextInput("'
+
cnt
$
name
+
'", label = "'
+
cnt
$
label
+
'", value = "'
+
format
(
cnt
$
value
,
scientific
=
F
)
+
'", width = "'
+
'auto'
+
'")'
}
if
(
cnt
$
type
==
"textArea"
)
{
...
...
@@ -43,7 +42,7 @@ generate_page_input <- function(res, cnt) {
}
if
(
cnt
$
type
==
"numeric"
)
{
res
<-
res
+
'\t\tnumericInput("'
+
cnt
$
name
+
'", label = "'
+
cnt
$
label
+
'", min = '
+
cnt
$
min
+
', max = '
+
cnt
$
max
+
', step = '
+
cnt
$
step
+
', width = "'
+
'auto'
+
'", value = '
+
cnt
$
value
+
')'
res
<-
res
+
'\t\tnumericInput("'
+
cnt
$
name
+
'", label = "'
+
cnt
$
label
+
'", min = '
+
cnt
$
min
+
', max = '
+
cnt
$
max
+
', step = '
+
cnt
$
step
+
', width = "'
+
'auto'
+
'", value = '
+
format
(
cnt
$
value
,
scientific
=
F
)
+
')'
}
if
(
cnt
$
type
==
"slider"
)
{
...
...
@@ -421,7 +420,7 @@ generate_pages_server <- function() {
if
(
cnt
$
type
==
'text'
||
cnt
$
type
==
'textArea'
||
cnt
$
type
==
"input_dir"
||
cnt
$
type
==
"output_dir"
)
{
genR
<-
genR
+
'\t\tif(!is.na(as.numeric(input$'
+
id
+
'))) {\n'
genR
<-
genR
+
'\t\t\tres = paste0(res, paste("'
+
id
+
':", input$'
+
id
+
', "\\n", sep = " "))\n'
genR
<-
genR
+
'\t\t\tres = paste0(res, paste("'
+
id
+
':",
format(
input$'
+
id
+
',
scientific=F),
"\\n", sep = " "))\n'
genR
<-
genR
+
'\t\t} else {\n'
genR
<-
genR
+
'\t\t\tres = paste0(res, paste("'
+
id
+
':", paste0(\'\"\', input$'
+
id
+
', \'\"\'), "\\n", sep = " "))\n'
genR
<-
genR
+
'\t\t}'
...
...
@@ -429,7 +428,7 @@ generate_pages_server <- function() {
}
if
(
cnt
$
type
==
'numeric'
)
{
genR
<-
genR
+
'\t\tif(!is.na(as.numeric(input$'
+
id
+
'))) {\n'
genR
<-
genR
+
'\t\t\tres = paste0(res, paste("'
+
id
+
':", input$'
+
id
+
', "\\n", sep = " "))\n'
genR
<-
genR
+
'\t\t\tres = paste0(res, paste("'
+
id
+
':",
format(
input$'
+
id
+
',
scientific=F),
"\\n", sep = " "))\n'
genR
<-
genR
+
'\t\t} else {\n'
genR
<-
genR
+
'\t\t\tres = paste0(res, paste("'
+
id
+
':", paste0(\'\"\', input$'
+
id
+
', \'\"\'), "\\n", sep = " "))\n'
genR
<-
genR
+
'\t\t}'
...
...
@@ -541,10 +540,10 @@ generate_pages_server <- function() {
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
+
'\ta = yaml.load_file("/workflow/params.total.yml")\n'
save_params
<-
save_params
+
'\ta = yaml.load_file("/workflow/params.total.yml"
, handlers=list("float#fix"=function(x){ format(x,scientific=F)})
)\n'
save_params
<-
save_params
+
'\tp = a[["params"]]\n'
save_params
<-
save_params
+
'\ta["params"] = NULL\n'
save_params
<-
save_params
+
'\tb = yaml.load(res)\n'
save_params
<-
save_params
+
'\tb = yaml.load(res
, handlers=list("float#fix"=function(x){ format(x,scientific=F)})
)\n'
save_params
<-
save_params
+
'\tpnotb = subset(names(p), !(names(p)%in%names(b)))\n'
save_params
<-
save_params
+
'\td = list()\n'
save_params
<-
save_params
+
'\td$params = c(p[pnotb],b)\n'
...
...
@@ -554,10 +553,10 @@ 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
+
'\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 + '\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
,"float#fix"=function(x){ format(x,scientific=F) }
))\n'
save_params
<-
save_params
+
'\t}\n\n'
res
<-
save_params
...
...
@@ -568,7 +567,7 @@ generate_pages_server <- function() {
res
<-
res
+
'\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\tparams = yaml.load_file(paste0(input$results_dir,"/params.yml")
, handlers=list("float#fix"=function(x){ format(x,scientific=F)})
)\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'
...
...
@@ -618,7 +617,7 @@ generate_pages_server <- function() {
res
<-
res
+
'\t\tsystem(paste0("rm ",input$results_dir,"/rulegraph*"))\n\n'
res
<-
res
+
'\t\toutUI = tryCatch({\n'
res
<-
res
+
'\t\t\tsystem(paste0("snakemake -s /workflow/Snakefile --configfile ",input$results_dir,"/params.yml -d ",input$results_dir," all --rulegraph > ",input$results_dir,"/rulegraph",i,".dot"),intern=T)\n'
res
<-
res
+
'\t\t\tsystem(paste0("snakemake -s /workflow/Snakefile --configfile ",input$results_dir,"/params.yml -d ",input$results_dir," all --rulegraph
1
> ",input$results_dir,"/rulegraph",i,".dot"),intern=T)\n'
res
<-
res
+
'\t\t\tsystem(paste0("cat ",input$results_dir,"/rulegraph",i,".dot | dot -Tsvg -Gratio=0.75 > ",input$results_dir,"/rulegraph",i,".svg"),intern=T)\n'
res
<-
res
+
'\t\t\ttagList(img(src = paste0("results/rulegraph",i,".svg") ,alt = "Rulegraph of Snakemake jobs",style="max-width: 100%;height: auto;display: block;margin: auto"))},\n'
res
<-
res
+
'\t\terror = function(e){\n'
...
...
@@ -973,7 +972,7 @@ generate_app <- function() {
res
<-
res
+
'reload = function(dossierAnalyse,session,output){\n'
res
<-
res
+
'\t# if params exists reload them\n'
res
<-
res
+
'\tif (file.exists(paste0(dossierAnalyse,"/params.yml"))){\n'
res
<-
res
+
'\t\tparams = read_yaml(paste0(dossierAnalyse,"/params.yml"))\n'
res
<-
res
+
'\t\tparams = read_yaml(paste0(dossierAnalyse,"/params.yml")
, handlers=list("float#fix"=function(x){ format(x,scientific=F)})
)\n'
res
<-
res
+
'\t\tfor (param in names(params$params_info)){\n'
res
<-
res
+
'\t\t\tif (params$params_info[[param]]$type == "text" || params$params_info[[param]]$type == "input_dir" || params$params_info[[param]]$type == "output_dir"){\n'
res
<-
res
+
'\t\t\t\tupdateTextInput(session, param, value = params[["params"]][[param]])\n'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment