Skip to content

Commit

Permalink
Merge pull request #705 from metrumresearchgroup/feat/run_nmtran
Browse files Browse the repository at this point in the history
Function to run NMTRAN on a model
  • Loading branch information
barrettk authored Aug 7, 2024
2 parents c2aa415 + 784c3c2 commit 0faf7b7
Show file tree
Hide file tree
Showing 13 changed files with 902 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ S3method(print,bbi_nmboot_summary)
S3method(print,bbi_nonmem_summary)
S3method(print,bbi_process)
S3method(print,model_tree_static)
S3method(print,nmtran_process)
S3method(print_model_files,default)
S3method(submit_model,bbi_base_model)
S3method(submit_model,bbi_nmboot_model)
Expand Down Expand Up @@ -194,6 +195,7 @@ export(replace_model_field)
export(replace_note)
export(replace_tag)
export(run_log)
export(run_nmtran)
export(setup_bootstrap_run)
export(submit_model)
export(submit_models)
Expand Down
3 changes: 2 additions & 1 deletion R/aaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BBI_ARGS = list(
delay = list(
type = "numeric",
flag = "--delay",
description = "Selects a random number of seconds between 1 and this value to stagger / jitter job execution. Assists in dealing with large volumes of work dealing with the same data set. May avoid NMTRAN issues about not being able read / close files"
description = "Selects a random number of seconds between 1 and this value to stagger / jitter job execution. Assists in dealing with large volumes of work dealing with the same data set. May avoid NM-TRAN issues about not being able read / close files"
),
ext_file = list(
type = "character",
Expand Down Expand Up @@ -209,6 +209,7 @@ RUN_LOG_CLASS <- "bbi_run_log_df"
CONF_LOG_CLASS <- "bbi_config_log_df"
SUM_LOG_CLASS <- "bbi_summary_log_df"
LOG_DF_CLASS <- "bbi_log_df"
NMTRAN_PROCESS_CLASS <- "nmtran_process"

# YAML keys that are hard-coded
YAML_YAML_MD5 <- "yaml_md5"
Expand Down
2 changes: 1 addition & 1 deletion R/get-path-from-object.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ get_data_path_nonmem <- function(

if(isTRUE(.check_exists)){
if(!fs::file_exists(data_path)){
# The first error message line is what NMTRAN would return in this situation
# The first error message line is what NM-TRAN would return in this situation
rlang::abort(
c(
"x" = "Input data file does not exist or cannot be opened",
Expand Down
53 changes: 52 additions & 1 deletion R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,58 @@ print.bbi_nmboot_summary <- function(x, .digits = 3, .nrow = 10, ...) {
}
}


#' @describeIn print_bbi Prints the `NM-TRAN` evaluation of a `bbi_nonmem_model`
#' object
#' @export
print.nmtran_process <- function(x, ...){

is_valid_print <- function(.x) {
if (!is.null(.x)) {
length(.x) != 0
} else {
FALSE
}
}

heading <- cli_h1
subheading <- cli_h2
bullet_list <- cat_bullet

status <- x[["status"]]
if (x[["status_val"]] == 0) {
status <- col_green(status)
} else {
status <- col_red(status)
}

heading(cli::col_magenta("NM-TRAN Status"))
subheading(status)

heading("Absolute Model Path")
bullet_list(x[[ABS_MOD_PATH]])

heading("NM-TRAN Specifications")
cli::cli_bullets(
c(
"*" = "NONMEM Version: {.val {x[['nonmem_version']]}}",
"*" = "NM-TRAN Executable: {.path {x[['nmtran_exe']]}}",
"*" = "nmtran_presort: {cli::col_cyan(!is.null(x[['nmtran_presort_exe']]))}"
)
)

# Print run directory if it still exists (clean = FALSE)
if(fs::dir_exists(x[['run_dir']])){
cli::cli_bullets(c("*" = "Run Directory: {.path {x[['run_dir']]}}"))
}

if (is_valid_print(x[["output"]])) {
heading('Output')
cat_line(x[["output"]])
}
}


#' @describeIn print_bbi Draw model tree as a static plot
#' @param x plot to display
#' @param newpage Logical (T/F). If `TRUE`, draw new (empty) page first.
Expand Down Expand Up @@ -471,7 +523,6 @@ print.model_tree_static <- function(x, newpage = is.null(vp), vp = NULL, ...){
return(invisible(x))
}


#####################
# INTERNAL HELPERS
#####################
Expand Down
Loading

0 comments on commit 0faf7b7

Please sign in to comment.