Skip to content
Snippets Groups Projects
Unverified Commit 07befabe authored by Todor Kondic's avatar Todor Kondic
Browse files

base, resources, mix: Modify conf and state creation

* R/base.R(gen_uniq_lab): New function.

* R/mix.R(read_conf): Moved from api.R and updated. Now generates
  random names for the files in compound lists. This was needed
  because in its reactive form, a list of reactives needs names.

* R/resources.R(EMPTY_CONF): New parameter. Skeleton conf object.
parent 2e6698ad
No related branches found
No related tags found
No related merge requests found
......@@ -44,3 +44,12 @@ print_table <- function (df) {
}
assert <- function(expr,msg) shiny::validate(shiny::need(expr,message=msg))
gen_uniq_lab <- function(prev,pref='',suff='') {
l <- length(prev)
gen <- function() paste0(pref,as.integer(runif(1,min=l,max=2L*l+1L)),suff)
cand <- gen()
while (cand %in% prev) cand <- gen()
c(prev,cand)
}
......@@ -699,12 +699,35 @@ write_state <- function(m,fn_conf) {
}
new_state <- function(conf,GUI) {
read_conf <- function(fn) {
cf <- yaml::yaml.load_file(fn)
fnl <- cf$compound$lists
if (!is.null(fnl)) {
nms <- character(0)
for (i in 1:length(fnl)) {
nms <- gen_uniq_lab(nms,pref = 'L')
}
names(fnl) <- nms
}
cf$compound$lists <- fnl
cf
}
new_conf <- function() EMPTY_CONF
new_state <- function(conf=NULL,fn_conf="",GUI=F) {
assert(xor(!is.null(conf),nchar(fn_conf)!=0L),
msg="Provide either conf, or fn_conf, not both, not none.")
m <- list()
m$conf <- conf
m$conf <- if (!is.null(conf)) conf else read_conf(fn_conf)
m$GUI <- GUI
m$out$tab <- list()
m$input$tab$mzml <- EMPTY_MZML
m$input$tab$lists <- list(EMPTY_CMPD_LIST)
lab <- gen_uniq_lab(list(),pref="L")
m$input$tab$lists <- list()
m$input$tab[[lab[[1]]]] <- EMPTY_CMPD_LIST
m
}
......
......@@ -146,3 +146,12 @@ FN_DATA_TAB <- "data-files.csv"
## Default number of concurrent workers
NO_WORKERS <- 2
EMPTY_CONF <- list(project="",
compounds=list(lists=list(),
sets=""),
data="",
tolerance=list("ms1 coarse"=MS1_ERR_COARSE,
"ms 1 fine"=MS1_ERR_FINE,
"eic"=EIC_ERR,
"rt"=RT_EXTR_ERR))
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