Commit 9f0512cc authored by Jean-Francois Rey's avatar Jean-Francois Rey
Browse files

shiny app : update values check

parent e8718e7b
......@@ -133,13 +133,46 @@ checkCultivarsTable <- function(data) {
isok <- TRUE
shiny::removeUI(selector = "#cultivarsNameError")
if( sum(as.character(data[,1]) == "") != 0 | sum(grepl("^\\s*$",as.character(data[,1]))) != 0) {
if( sum(as.character(data[,"cultivarName"]) == "") != 0
|| sum(grepl("^\\s*$",as.character(data[,"cultivarName"]))) != 0) {
showErrorMessage(id = "cultivarsNameError", selectorafter= "#generateLandscape",
message = "Cultivars name have to be a string")
#shinyjs::disable(id = "generateLandscape")
isok <- FALSE
}
shiny::removeUI(selector = "#cultivarsZeroError")
if( sum(data[,-1] < 0) != 0 ) {
showErrorMessage(id = "cultivarsZeroError", selectorafter= "#generateLandscape",
message = "Cultivars values should be >=0")
isok <- FALSE
}
shiny::removeUI(selector = "#cultivarsStricZeroError")
if( sum(data[,"max_density"] <= 0) != 0 || sum(data[,"max_density"] > VALUEMAX) != 0) {
showErrorMessage(id = "cultivarsStricZeroError", selectorafter= "#generateLandscape",
message = paste0("Cultivars max_density values should be between >0 and ",VALUEMAX))
isok <- FALSE
}
shiny::removeUI(selector = "#cultivarsmaxvalueError")
if( sum(data[,c("growth_rate","reproduction_rate","death_rate")] > 1) != 0) {
showErrorMessage(id = "cultivarsmaxvalueError", selectorafter= "#generateLandscape",
message = paste0("Cultivars growth_rate/reproduction_rate/death_rate values should be lower than 1"))
isok <- FALSE
}
shiny::removeUI(selector = "#cultivarsValueError")
if( sum(data[,- which(c("cultivarName", "growth_rate","reproduction_rate","death_rate") %in% colnames(data))] < 0) != 0
|| sum(data[,- which(c("cultivarName", "growth_rate","reproduction_rate","death_rate") %in% colnames(data))] > VALUEMAX) != 0) {
showErrorMessage(id = "cultivarsValueError", selectorafter= "#generateLandscape",
message = paste0("Cultivars values should be lower than ",VALUEMAX))
isok <- FALSE
}
return(invisible(isok))
......@@ -154,6 +187,13 @@ checkCultivarsTable <- function(data) {
checkCultivarsGenesTable <- function(data){
isok <- TRUE
shiny::removeUI(selector = "#cultivarsGenesValueError")
if( sum(data != 0) + sum(data != 1) != nrow(data)*ncol(data) ) {
showErrorMessage(id = "cultivarsGenesValueError", selectorafter= "#generateLandscape",
message = paste0("Genes selection in Cultivars Genes should 0 or 1"))
isok <- FALSE
}
return(invisible(isok))
}
......@@ -165,12 +205,51 @@ checkGenesTable <- function(data){
isok <- TRUE
shiny::removeUI(selector = "#GenesNameError")
if( sum(as.character(data[,1]) == "") != 0 | sum(grepl("^\\s*$",as.character(data[,1]))) != 0) {
showErrorMessage(id = "GenesNameError", selectorafter= "#generateLandscape",
message = "Genes name have to be a string")
#shinyjs::disable(id = "generateLandscape")
isok <- FALSE
}
shiny::removeUI(selector = "#GenesNegatifError")
if( sum(data[,- which(colnames(data) %in% c("genesName","target_trait"))] < 0) != 0 ) {
showErrorMessage(id = "GenesNegatifError", selectorafter= "#generateLandscape",
message = "Genes values should be > 0")
isok <- FALSE
}
shiny::removeUI(selector = "#GenesValueMaxError")
if( sum(data[, c("time_to_activ_exp", "time_to_activ_var", "Nlevels_aggressiveness", "tradeoff_strength")] > VALUEMAX) != 0 ) {
showErrorMessage(id = "GenesValueMaxError", selectorafter= "#generateLandscape",
message = paste0("Genes values should lower than ",VALUEMAX))
isok <- FALSE
}
shiny::removeUI(selector = "#GenesStrictZeroError")
if( sum(data[, c("tradeoff_strength")] <= 0) != 0 ) {
showErrorMessage(id = "GenesStrictZeroError", selectorafter= "#generateLandscape",
message = paste0("Genes tradeoff_strength value should be greater than 0"))
isok <- FALSE
}
shiny::removeUI(selector = "#GenesUpper1Error")
if( sum(data[, c("efficiency", "mutation_prob", "fitness_cost")] > 1) != 0) {
showErrorMessage(id = "GenesUpper1Error", selectorafter= "#generateLandscape",
message = paste0("Genes efficiency mutation_prob fitness_cost values should lower than 1"))
isok <- FALSE
}
shiny::removeUI(selector = "#GenesTraitError")
if( sum(data[, c("target_trait")] == "IR") +
sum(data[, c("target_trait")] == "LAT") +
sum(data[, c("target_trait")] == "IP") != nrow(data)) {
showErrorMessage(id = "GenesTraitError", selectorafter= "#generateLandscape",
message = paste0("Genes target_trait values can be IR, LAT and IP"))
isok <- FALSE
}
return(invisible(isok))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment