From 651cf4a0a9452b582118c731ce7d1ba4326d0b13 Mon Sep 17 00:00:00 2001 From: Ameen Eetemadi Date: Fri, 9 Jul 2021 14:58:18 -0700 Subject: [PATCH] source_from_here DEV_MODE --- R/convert_to_friendlyname_OMMs.R | 10 +++++++--- R/generate_OMMs.R | 10 +++++++--- R/select_OMMs.R | 12 ++++++++---- R/visualize_OMMs.R | 10 +++++++--- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/R/convert_to_friendlyname_OMMs.R b/R/convert_to_friendlyname_OMMs.R index ac6880c..390f317 100755 --- a/R/convert_to_friendlyname_OMMs.R +++ b/R/convert_to_friendlyname_OMMs.R @@ -20,9 +20,13 @@ get_args <- function() { # source the filename from this script's directory source_from_here <- function(filename) { - initial.options <- commandArgs(trailingOnly = FALSE) - script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) - source(file.path(dirname(script.name), filename)) + if (DEV_MODE){ + source(file.path("R", filename)) + } else { + initial.options <- commandArgs(trailingOnly = FALSE) + script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) + source(file.path(dirname(script.name), filename)) + } } source_from_here("common_OMMs.R") diff --git a/R/generate_OMMs.R b/R/generate_OMMs.R index 1447896..ed3f8fc 100755 --- a/R/generate_OMMs.R +++ b/R/generate_OMMs.R @@ -77,9 +77,13 @@ get_proportions <- function(df_food_glycans, target_glycans){ # source the filename from this script's directory source_from_here <- function(filename) { - initial.options <- commandArgs(trailingOnly = FALSE) - script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) - source(file.path(dirname(script.name), filename)) + if (DEV_MODE){ + source(file.path("R", filename)) + } else { + initial.options <- commandArgs(trailingOnly = FALSE) + script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) + source(file.path(dirname(script.name), filename)) + } } source_from_here("common_OMMs.R") diff --git a/R/select_OMMs.R b/R/select_OMMs.R index b27a5f4..eea37ef 100755 --- a/R/select_OMMs.R +++ b/R/select_OMMs.R @@ -45,9 +45,13 @@ get_args <- function() { # source the filename from this script's directory source_from_here <- function(filename) { - initial.options <- commandArgs(trailingOnly = FALSE) - script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) - source(file.path(dirname(script.name), filename)) + if (DEV_MODE){ + source(file.path("R", filename)) + } else { + initial.options <- commandArgs(trailingOnly = FALSE) + script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) + source(file.path(dirname(script.name), filename)) + } } source_from_here("common_OMMs.R") source_from_here("theme_util_OMMs.R") @@ -94,4 +98,4 @@ selected_MMs <- cand_MMs[idx_selected_meals,] # 6) Save the selected mixed meals save_MMs(selected_MMs, args$output) -print("Completed Successfully!") \ No newline at end of file +print("Completed Successfully!") diff --git a/R/visualize_OMMs.R b/R/visualize_OMMs.R index 1becbc6..7126168 100755 --- a/R/visualize_OMMs.R +++ b/R/visualize_OMMs.R @@ -35,9 +35,13 @@ get_args <- function() { # source the filename from this script's directory source_from_here <- function(filename) { - initial.options <- commandArgs(trailingOnly = FALSE) - script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) - source(file.path(dirname(script.name), filename)) + if (DEV_MODE){ + source(file.path("R", filename)) + } else { + initial.options <- commandArgs(trailingOnly = FALSE) + script.name <- sub("--file=", "", initial.options[grep("--file=", initial.options)]) + source(file.path(dirname(script.name), filename)) + } } source_from_here("common_OMMs.R") source_from_here("theme_util_OMMs.R")