Skip to content

Commit

Permalink
improve prompts and messaging to user
Browse files Browse the repository at this point in the history
  • Loading branch information
bvreede committed Apr 7, 2023
1 parent 4a89297 commit 7de60fc
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions R/exp_design.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
#' that formalizes the experimental design so it can be used to
#' analyse the MEA file.
#'
#' @param date date (string, preferably formatted as YYYYMMDD)
#' @param expID identifier for the experiment (string)
#' @param date date (string, preferably formatted as YYYYMMDD), default is prompted
#' @param expID identifier for the experiment (string), default is prompted
#' @param path path to the design file (dir/name.txt)
#'
#' @export
exp_design <- function(date = readline(prompt="What is the date of the experiment? "),
expID = readline(prompt="What is the experiment ID? "),
path="./design.txt"){
exp_design <- function(path="./design.txt",
date = readline(prompt="What is the date of the experiment? (YYYYMMDD) "),
expID = readline(prompt="What is the experiment ID? ")){
# TODO check if file can be created

nwells <- 48 # TODO make this a question also

write_meta(date, expID, nwells, path)

# TODO make this a while loop where wells are scored instead of a Q/A
continue <- TRUE
while(continue){
message("You can now add experimental conditions one by one:")
write_category(nwells=nwells, path=path)
check_cont <- readline(prompt = "Do you want to add another group? (y/n) ")
continue <- stringr::str_detect(check_cont, "y|Y")
Expand All @@ -27,17 +30,23 @@ exp_design <- function(date = readline(prompt="What is the date of the experimen


write_meta <- function(date, expID, nwells, path){
directory <- dirname(path)
if(!dir.exists(directory)){
dir.create(directory, recursive=TRUE)
}
meta <- paste0("Date: ", date, "\n",
"ExperimentID: ", expID, "\n",
"Total_wells: ", nwells, "\n",
"Groups:")
write(meta, file=path)

message(paste("The design metadata has been written to file at",path))
}

write_category <- function(
group = readline(prompt="What is the group name? "),
start = readline(prompt="What is the first well in this category? "),
end = readline(prompt="What is the last well in this category? "),
group = readline(prompt="What is the experimental condition? "),
start = readline(prompt="What is the first well in this category? (e.g.: A1) "),
end = readline(prompt="What is the last well in this category? (e.g.: F8) "),
dirx = readline(
prompt="In what direction ('LR' for left-to-right or 'TB' for top-to-bottom) is the sequence of wells? "),
nwells, path){
Expand Down

0 comments on commit 7de60fc

Please sign in to comment.