[datasets2tools.ui.sections]
order = ["dataset2tools_input_box", "dataset2tools_out_box"]
[datasets2tools.ui.sections.ui_basic]
dataset2tools_input_box = "title = 'Datasets2tools API (http://amp.pharm.mssm.edu/datasets2tools/api)', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"
dataset2tools_out_box = "title = 'Output of Datasets2tools (Table)', status = 'primary', width = 12, collapsed = FALSE, collapsible = TRUE"

[datasets2tools.paramters.dataset2tools_input_box]
# For reading annovarR shiny APP datasets2tools tool input files
section_type = "input"
rcmd_last = """
url = 'http://amp.pharm.mssm.edu/datasets2tools/api/search'
input_params <- c("q", "dataset_accession", "tool_name", "disease_name", "geneset", "canned_analysis_accession")
datasets2tools_params <- c(object_type=object_type, page_size = page_size)
for (i in input_params) {
  i_value <- tryCatch(get(i), error = function(e) {NULL})
  if (!is.null(i_value) && i_value != "") {
  datasets2tools_params <- c(datasets2tools_params, i=i_value)
  names(datasets2tools_params)[length(datasets2tools_params)] <- i}
}
json_dat <- getForm(url, .params=datasets2tools_params)
json_dat <- jsonlite::fromJSON(json_dat)
json_dat <- as.data.frame(json_dat)
if (length(json_dat) > 0) {
  for(i in 1:ncol(json_dat)) {
    if (typeof(json_dat[,i]) == "list") {
      json_dat[,i] <- unlist(lapply(json_dat[,i], function(x) {paste0(x, collapse = ", ")}))
    }
  }
}
"""
progressbar_message = ""
render_id = "datasets2tools_cmds"

#!!!!! input_ui_order required related section
input_ui_order = ["single_input", "start_analysis"]

[datasets2tools.paramters.dataset2tools_input_box.input.single_input]
title = "Parameters:"
title_control = "class = 'input-section-p'"
varname = ["object_type", "q", "dataset_accession", "tool_name", "disease_name", "canned_analysis_accession", "geneset", "page_size"]
input_id = ["input_datasets2tools_1", "input_datasets2tools_2", 
            "input_datasets2tools_3", "input_datasets2tools_4", "input_datasets2tools_5",
            "input_datasets2tools_6", "input_datasets2tools_7","input_datasets2tools_8"]
type = ["shiny::selectInput", "shiny::textInput", "shiny::textInput", "shiny::textInput", "shiny::textInput",
       "shiny::textInput", "shiny::textInput", "shiny::numericInput"]
label = ["Query type", "Key Words", "Dataset Accession (e.g. GSE775)", "Tool name", "Disease name", 
         "Canned nalysis Cccession", "Geneset", "Counts"]

[datasets2tools.paramters.dataset2tools_input_box.input.single_input.choices]
object_type = ["canned_analysis", "dataset", "tool"]

[datasets2tools.paramters.dataset2tools_input_box.input.single_input.value]
page_size = 100

[datasets2tools.paramters.dataset2tools_input_box.input.start_analysis]
input_id = "start_datasets2tools_analysis"
type = "shiny::actionButton"
label = "Run"

[datasets2tools.paramters.dataset2tools_out_box]
section_type = "output"
rcmd_last = """json_dat"""
render_type = "DT::renderDataTable"
render_id = "datasets2tools_output_table"
output_type = "DT::dataTableOutput"
progressbar_message = "datasets2tools Output"
