From a61a6bda4676a33d93224134154c2fb187770bd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Todor=20Kondi=C4=87?= <kontrapunkt@uclmail.net>
Date: Thu, 26 Jan 2023 19:05:11 +0100
Subject: [PATCH] app: app_config_and_status, inputs_metfrag

* app_config_and_status: Updated. Replaced metfrag controls with inject_inputs.
---
 R/inputs_metfrag.R                 |  4 +++
 inst/rmd/app_config_and_status.Rmd | 56 +++++++-----------------------
 2 files changed, 16 insertions(+), 44 deletions(-)

diff --git a/R/inputs_metfrag.R b/R/inputs_metfrag.R
index 4d84051..7423493 100644
--- a/R/inputs_metfrag.R
+++ b/R/inputs_metfrag.R
@@ -6,6 +6,10 @@ mk_shiny_control <- function(name,fun,args) {
     res
 }
 
+inject_inputs<- function(collection,which) {
+    do.call(shiny::tagList,lapply(which,function(nm) collection[[nm]]$content))
+}
+
 INPUTS_METFRAG_NUMERIC = list(mk_shiny_control(name="mf_database_search_relative_mass_deviation",
                                                fun="numericInput",
                                                args=list(label="Database search relative mass deviation",
diff --git a/inst/rmd/app_config_and_status.Rmd b/inst/rmd/app_config_and_status.Rmd
index 8e4229b..f739771 100644
--- a/inst/rmd/app_config_and_status.Rmd
+++ b/inst/rmd/app_config_and_status.Rmd
@@ -159,17 +159,9 @@ shinyscreen::rt_input(input_rt = "ret_time_shift_tol",
 #### Tolerance and Tree Depth Controls
 
 ```{r, echo=F}
-numericInput("mf_database_search_relative_mass_deviation",
-                              label="Database search relative mass deviation",
-                              value=5)
-numericInput("mf_fragment_peak_match_absolute_mass_deviation",
-             label="Fragment peak match absolute mass deviation",
-             value=METFRAG_DEFAULT_ABSMASSDEV)
-numericInput("mf_fragment_peak_match_relative_mass_deviation",
-             label="Fragment peak match relative mass deviation",
-             value=METFRAG_DEFAULT_RELMASSDEV)
-numericInput("mf_maximum_tree_depth", label="MaximumTreeDepth",
-             value=METFRAG_DEFAULT_MAX_TREE_DEPTH)
+inject_inputs(INPUTS_METFRAG,c("mf_fragment_peak_match_absolute_mass_deviation",
+                               "mf_fragment_peak_match_relative_mass_deviation",
+                               "mf_maximum_tree_depth"))
 ```
 </div> <!-- metfrag-conf-tolerance -->
 
@@ -178,20 +170,9 @@ numericInput("mf_maximum_tree_depth", label="MaximumTreeDepth",
 #### Processing
 
 ```{r, echo=F}
-selectInput("mf_pre_processing_candidate_filter",
-                                 label="Preprocessing candidate filter",
-                                 choices=shinyscreen:::METFRAG_PREPFLT_CHOICES,
-                                 selected=shinyscreen:::METFRAG_PREPFLT_DEFAULT,
-                                 multiple=T)
-selectInput("mf_post_processing_candidate_filter",
-            label="Postprocessing candidate filter",
-            choices=shinyscreen:::METFRAG_POSTPFLT_CHOICES,
-            selected=shinyscreen:::METFRAG_POSTPFLT_DEFAULT,
-            multiple=T)
-selectInput("mf_metfrag_candidate_writer",
-            label="MetFrag Candidate Writer",
-            choices=shinyscreen:::METFRAG_WRITER_CHOICES,
-            selected=shinyscreen:::METFRAG_DEFAULT_WRITER)
+inject_inputs(INPUTS_METFRAG,c("mf_pre_processing_candidate_filter",
+                               "mf_post_processing_candidate_filter",
+                               "mf_metfrag_candidate_writer"))
 ```
 </div> <!-- metfrag-conf-processing -->
 
@@ -203,16 +184,10 @@ selectInput("mf_metfrag_candidate_writer",
 #### Databases
 
 ```{r, echo=F}
-selectInput("mf_database_type", label="Database type",
-            choices=METFRAG_DATABASE_TYPE,
-            selected=METFRAG_DEFAULT_DATABASE_TYPE)
-selectInput("mf_local_database",
-            label="Local Database",
-            choices=character(0))
-selectInput("mf_local_db_col_ident",
-            label="Select Identifiers",
-            multiple = T,
-            choices=character(0))
+inject_inputs(INPUTS_METFRAG,c("mf_database_type",
+                               "mf_local_database",
+                               "mf_local_db_col_ident",
+                               "mf_local_db_col_coll"))
 ```
 
 </div> <!-- metfrag-conf-databases -->
@@ -222,11 +197,7 @@ selectInput("mf_local_db_col_ident",
 #### MetFrag Scores
 
 ```{r, echo = F}
-selectInput("mf_scores_intrinsic",
-            label="Select Scoring Types",
-            choices = METFRAG_INTRINSIC_SCORES,
-            multiple = T,
-            selected = names(METFRAG_DEFAULT_SCORES))
+inject_inputs(INPUTS_METFRAG,"mf_scores_intrinsic")
 DT::DTOutput("mf_local_ident")
 ```
 
@@ -236,10 +207,7 @@ DT::DTOutput("mf_local_ident")
 #### Local Database Scoring Terms
 
 ```{r, echo = F}
-selectInput("mf_local_db_col_scores",
-	label="Select local scoring terms",
-    multiple = T,
-	choices=character(0))
+inject_inputs(INPUTS_METFRAG,"mf_local_db_col_scores")
 DT::DTOutput("mf_local_db_scores")
 ```
 
-- 
GitLab