Skip to content

Commit

Permalink
Merge pull request #3 from IBPA/master
Browse files Browse the repository at this point in the history
updates
  • Loading branch information
ameenetemady authored Jul 9, 2021
2 parents f571e29 + 651cf4a commit ad43a6e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
14 changes: 12 additions & 2 deletions R/convert_to_friendlyname_OMMs.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
suppressPackageStartupMessages(library("argparse"))
library(stringr)

source("common_OMMs.R")

get_args <- function() {
parser <- ArgumentParser(description = "Use friendly food names instead of uids for the OMMs.")
parser$add_argument("--glycanDB", required=TRUE,
Expand All @@ -20,6 +18,18 @@ get_args <- function() {
return(args)
}

# source the filename from this script's directory
source_from_here <- function(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")

args <- get_args()

# 1) Load mixed-meals
Expand Down
13 changes: 12 additions & 1 deletion R/generate_OMMs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ library(readxl)
library(stringr)
library(gurobi)

source("common_OMMs.R")
DEV_MODE <- FALSE

# Parse and return command line arguments of this script (return defaults if DEV_MODE is TRUE).
Expand Down Expand Up @@ -76,6 +75,18 @@ get_proportions <- function(df_food_glycans, target_glycans){
return(result$x[1:n])
}

# source the filename from this script's directory
source_from_here <- function(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")

args <- get_args()

# 1) Load food data
Expand Down
18 changes: 15 additions & 3 deletions R/select_OMMs.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ library(ggplot2)
library(reshape2)
library(scales)

source("common_OMMs.R")
source("theme_util_OMMs.R")
DEV_MODE <- FALSE

# Parse and return command line arguments of this script (return defaults if DEV_MODE is TRUE).
Expand Down Expand Up @@ -45,6 +43,20 @@ get_args <- function() {
return(parser$parse_args())
}

# source the filename from this script's directory
source_from_here <- function(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")


args <- get_args()

# 1) Load data
Expand Down Expand Up @@ -86,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!")
print("Completed Successfully!")
16 changes: 14 additions & 2 deletions R/visualize_OMMs.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ library(ggplot2)
library(reshape2)
library(scales)

source("common.R")
source("theme_util.R")
DEV_MODE <- FALSE

# Parse and return command line arguments of this script (return defaults if DEV_MODE is TRUE).
Expand All @@ -35,6 +33,20 @@ get_args <- function() {
return(parser$parse_args())
}

# source the filename from this script's directory
source_from_here <- function(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")


args <- get_args()

# 1) Load data
Expand Down

0 comments on commit ad43a6e

Please sign in to comment.