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

api.R: Evaluate inside directory (like scheme wind statement)

api.R (run): New argument.
Use withr:with_dir to evaluate inside dir.

(run_in_dir): New function.
This is where the body will go.

(vrfy_conf): New tests.
parent 9e0a4763
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,15 @@
run <- function(fn_conf) {
conf <- read_conf(fn_conf)
dir.create(conf$project,
showWarnings = F,
recursive = T)
withr::with_dir(new=conf$project,code = run_in_dir(conf))
conf
}
read_conf <- function(fn_conf) {
conf <- yaml::yaml.load_file(fn_conf)
......@@ -22,6 +31,22 @@ read_conf <- function(fn_conf) {
}
vrfy_conf <- function(conf) {
for (fn in unlist(conf,recursive=T)) assertthat::assert_that(file.exists(fn),msg=paste("Data file does not exist:",fn))
for (fn in unlist(conf$data,recursive=T)) assertthat::assert_that(file.exists(fn),msg=paste("Unable to read data file:",fn))
fn_cmpd_known <- conf$compounds$known
fn_cmpd_unk <- conf$compounds$unknown
fn_cmpd_sets <- conf$compounds$sets
assertthat::assert_that(file.exists(fn_cmpd_known),
msg=paste("Unable to read known compounds file:",fn_cmpd_known))
assertthat::assert_that(file.exists(fn_cmpd_sets),
msg=paste("Unable to read compound sets file:",fn_cmpd_sets))
if (!is.null(fn_cmpd_unk)) assertthat::assert_that(file.exists(fn_cmpd_unk),
msg=paste("Unable to read unknown compounds file:",fn_cmpd_unk))
return(conf)
}
run_in_dir <- function(conf) {
conf
}
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