Skip to content
Snippets Groups Projects
Commit 339e84a2 authored by Todor Kondić's avatar Todor Kondić
Browse files

app: shiny-*: Refactor config updates.

parent 1fe2508d
No related branches found
No related tags found
No related merge requests found
...@@ -263,28 +263,33 @@ unpack_app_state <- function(session,envopts,input,top_data_dir,project_path,pac ...@@ -263,28 +263,33 @@ unpack_app_state <- function(session,envopts,input,top_data_dir,project_path,pac
input2conf_setup <- function(input,gui,conf=list()) { input2conf_setup <- function(input,gui,conf=list()) {
if (length(conf)==0L) { if (length(conf)==0L) {
conf$compounds <- list() conf$compounds <- list()
conf$figures <- list()
conf$prescreen <- list()
conf$tolerance <- list()
conf$extract <- list()
conf$summary_table <- list() conf$summary_table <- list()
conf$report <- list()
conf$debug <- F conf$debug <- F
} }
conf$compounds$lists <- gui$compounds$lists conf$compounds$lists <- gui$compounds$lists
conf$compounds$sets <- gui$compounds$sets conf$compounds$sets <- gui$compounds$sets
conf$paths$data = gui$paths$data
conf
}
input2conf_extract <- function(input,conf) {
conf$tolerance = list()
conf$extract = list()
conf$tolerance[["ms1 fine"]] <- paste(input$ms1_fine,input$ms1_fine_unit) conf$tolerance[["ms1 fine"]] <- paste(input$ms1_fine,input$ms1_fine_unit)
conf$tolerance[["ms1 coarse"]] <- paste(input$ms1_coarse,input$ms1_coarse_unit) conf$tolerance[["ms1 coarse"]] <- paste(input$ms1_coarse,input$ms1_coarse_unit)
conf$tolerance[["eic"]] <- paste(input$ms1_eic,input$ms1_eic_unit) conf$tolerance[["eic"]] <- paste(input$ms1_eic,input$ms1_eic_unit)
conf$tolerance[["rt"]] <- paste(input$ms1_rt_win,input$ms1_rt_win_unit) conf$tolerance[["rt"]] <- paste(input$ms1_rt_win,input$ms1_rt_win_unit)
conf$extract$missing_precursor_info <- input$missingprec conf$extract$missing_precursor_info <- input$missingprec
conf conf
} }
input2conf_prescreen <- function(input,conf) { input2conf_prescreen <- function(input,conf) {
conf$prescreen = list()
conf$prescreen[["ms1_int_thresh"]] <- input$ms1_int_thresh conf$prescreen[["ms1_int_thresh"]] <- input$ms1_int_thresh
conf$prescreen[["ms2_int_thresh"]] <- input$ms2_int_thresh conf$prescreen[["ms2_int_thresh"]] <- input$ms2_int_thresh
conf$prescreen[["s2n"]] <- input$s2n conf$prescreen[["s2n"]] <- input$s2n
...@@ -293,6 +298,7 @@ input2conf_prescreen <- function(input,conf) { ...@@ -293,6 +298,7 @@ input2conf_prescreen <- function(input,conf) {
} }
input2conf_figures <- function(input,conf) { input2conf_figures <- function(input,conf) {
conf$figures = list()
conf$figures$rt_min <- paste(input$plot_rt_min,input$plot_rt_min_unit) conf$figures$rt_min <- paste(input$plot_rt_min,input$plot_rt_min_unit)
conf$figures$rt_max <- paste(input$plot_rt_max,input$plot_rt_max_unit) conf$figures$rt_max <- paste(input$plot_rt_max,input$plot_rt_max_unit)
conf$figures$ext <- input$plot_ext conf$figures$ext <- input$plot_ext
...@@ -301,6 +307,7 @@ input2conf_figures <- function(input,conf) { ...@@ -301,6 +307,7 @@ input2conf_figures <- function(input,conf) {
} }
input2conf_report <- function(input,conf) { input2conf_report <- function(input,conf) {
conf$report = list()
conf$report$author <- input$rep_aut conf$report$author <- input$rep_aut
conf$report$title <- input$rep_tit conf$report$title <- input$rep_tit
conf conf
...@@ -338,41 +345,59 @@ input2conf_metfrag <- function(input,conf) { ...@@ -338,41 +345,59 @@ input2conf_metfrag <- function(input,conf) {
} }
input2conf <- function(input,gui,conf=list()) { app_update_conf <- function(input,gui,envopts,fconf,m) {
conf = input2conf_setup(input,gui=gui,conf) for (fstrp in fconf) {
conf = input2conf_prescreen(input,conf) fstr = paste0("input2conf_",fstrp)
conf = input2conf_figures(input,conf) m$conf = do.call(fstr,list(input,conf=m$conf))
conf = input2conf_report(input,conf) }
conf = input2conf_metfrag(input,conf) m$run <- new_runtime_state(project=gui$paths$project,
conf envopts = envopts,
conf=m$conf)
m
} }
app_state2state <- function(input,gui,envopts,m=NULL) { app_state2state <- function(input,gui,envopts,m=NULL) {
if (is.null(m)) m <- new_project(project = gui$paths$project, if (is.null(m)) m = new_project(project = gui$paths$project,
envopts = envopts) envopts = envopts)
## m$run$paths <- shiny::reactiveValuesToList(gui$paths) m$conf = input2conf_setup(input=input,
m$conf = input2conf_setup(input,gui=gui) gui=gui)
m$conf = input2conf_prescreen(input=input,conf=m$conf)
m$conf = input2conf_figures(input,conf=m$conf)
m$conf = input2conf_report(input,conf=m$conf) m = app_update_conf(input=input,
m$conf = input2conf_metfrag(input,conf=m$conf) gui=gui,
m$conf$paths$data <- gui$paths$data envopts=envopts,
fconf = c("extract",
"prescreen",
"figures",
"report",
"metfrag"),
m=m)
## m$conf = input2conf_setup(input,gui=gui)
## m$conf = input2conf_prescreen(input=input,conf=m$conf)
## m$conf = input2conf_figures(input,conf=m$conf)
## m$conf = input2conf_report(input,conf=m$conf)
## m$conf = input2conf_metfrag(input,conf=m$conf)
m$run <- new_runtime_state(project=gui$paths$project, ## m$run <- new_runtime_state(project=gui$paths$project,
envopts = envopts, ## envopts = envopts,
conf=m$conf) ## conf=m$conf)
m$input$tab$mzml <- gui2datatab(gui) m$input$tab$mzml <- gui2datatab(gui)
m m
} }
gen_comp_state <- function(input,gui) { gen_comp_state <- function(input,gui) {
m <- app_state2state(input,gui) m <- app_state2state(input,gui)
run(m=m,phases=c("setup","mk_comp_tab")) run(m=m,phases=c("setup","mk_comp_tab"))
} }
......
...@@ -1131,6 +1131,8 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1131,6 +1131,8 @@ mk_shinyscreen_server <- function(projects,init) {
observeEvent(input$extract_b,{ observeEvent(input$extract_b,{
rvs$m = app_state2state(input,rvs$gui,envopts = init$envopts, m=rvs$m) # Update params from GUI. rvs$m = app_state2state(input,rvs$gui,envopts = init$envopts, m=rvs$m) # Update params from GUI.
## Clear out prescreen data if any.
rvs$m$out$tab$summ=EMPTY_SUMM
m = rvs$m m = rvs$m
shinymsg("Extraction has started. This may take a while.") shinymsg("Extraction has started. This may take a while.")
rvs$status$ms1_coarse_stat = m$conf$tolerance[["ms1 coarse"]] rvs$status$ms1_coarse_stat = m$conf$tolerance[["ms1 coarse"]]
...@@ -1138,9 +1140,8 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1138,9 +1140,8 @@ mk_shinyscreen_server <- function(projects,init) {
rvs$status$ms1_eic_stat = m$conf$tolerance[["eic"]] rvs$status$ms1_eic_stat = m$conf$tolerance[["eic"]]
rvs$status$rt_stat = m$conf$tolerance[["rt"]] rvs$status$rt_stat = m$conf$tolerance[["rt"]]
rvs$status$is_extracted_stat = "In progress." rvs$status$is_extracted_stat = "In progress."
rvs$status$is_qa_stat = "No."
rv_extr_flag(T) rv_extr_flag(T)
rv_presc_flag(F)
}) })
observe({ observe({
...@@ -1168,7 +1169,14 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1168,7 +1169,14 @@ mk_shinyscreen_server <- function(projects,init) {
observeEvent(input$presc_b,{ observeEvent(input$presc_b,{
if (NROW(rvs$m$extr$ms1)>0L) { if (NROW(rvs$m$extr$ms1)>0L) {
rvs$m = app_state2state(input,rvs$gui,envopts = init$envopts, m=rvs$m) # Update params from GUI. ## Update just prescreening conf.
rvs$m = app_update_conf(input=input,
gui=rvs$gui,
envopts=init$envopts,
fconf="prescreen",
m=rvs$m)
## rvs$m = app_state2state(input,rvs$gui,envopts = init$envopts, m=rvs$m) # Update params from GUI.
rvs$status$ms1_int_thresh_stat = rvs$m$conf$prescreen[["ms1_int_thresh"]] rvs$status$ms1_int_thresh_stat = rvs$m$conf$prescreen[["ms1_int_thresh"]]
rvs$status$ms2_int_thresh_stat = rvs$m$conf$prescreen[["ms2_int_thresh"]] rvs$status$ms2_int_thresh_stat = rvs$m$conf$prescreen[["ms2_int_thresh"]]
rvs$status$s2n_stat = rvs$m$conf$prescreen[["s2n"]] rvs$status$s2n_stat = rvs$m$conf$prescreen[["s2n"]]
...@@ -1191,7 +1199,8 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1191,7 +1199,8 @@ mk_shinyscreen_server <- function(projects,init) {
if (rv_presc_flag()) { if (rv_presc_flag()) {
shinymsg("Prescreening started. Please wait.") shinymsg("Prescreening started. Please wait.")
rv_presc_flag(F) rv_presc_flag(F)
m = run(m=rvs$m,phases="prescreen") ## If user changed prescreening params.
rvs$m = run(m=rvs$m,phases="prescreen")
rvs$status$is_qa_stat = "Yes." rvs$status$is_qa_stat = "Yes."
shinymsg("Prescreening has been completed.") shinymsg("Prescreening has been completed.")
} }
...@@ -1634,7 +1643,7 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1634,7 +1643,7 @@ mk_shinyscreen_server <- function(projects,init) {
req(rvs$status$s2n_stat) req(rvs$status$s2n_stat)
}) })
output$ret_time_shift_tol = renderText({ output$ret_time_shift_tol_stat = renderText({
req(rvs$status$ret_time_shift_tol_stat) req(rvs$status$ret_time_shift_tol_stat)
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment