comparison w4mcorcov_wrapper.R @ 8:342570ad880c draft

planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 0c81f4f1416129dd7061042b12cd28c0b8927aab
author eschen42
date Sat, 04 Aug 2018 17:43:16 -0400
parents 7bd523ca1f9a
children 06c51af11531
comparison
equal deleted inserted replaced
7:066b1f409e9f 8:342570ad880c
20 options(stringsAsFactors = FALSE) 20 options(stringsAsFactors = FALSE)
21 21
22 ## subroutines 22 ## subroutines
23 ##---------- 23 ##----------
24 24
25 source("w4mcorcov_lib.R") 25 # from: https://github.com/molgenis/molgenis-pipelines/wiki/How-to-source-another_file.R-from-within-your-R-script
26 source("w4mcorcov_util.R") 26 LocationOfThisScript = function() # Function LocationOfThisScript returns the location of this .R script (may be needed to source other files in same dir)
27 source("w4mcorcov_input.R") 27 {
28 source("w4mcorcov_salience.R") 28 this.file = NULL
29 source("w4mcorcov_calc.R") 29 # This file may be 'sourced'
30 source("w4mcorcov_output.R") 30 for (i in -(1:sys.nframe())) {
31 if (identical(sys.function(i), base::source)) this.file = (normalizePath(sys.frame(i)$ofile))
32 }
33
34 if (!is.null(this.file)) return(dirname(this.file))
35
36 # But it may also be called from the command line
37 cmd.args = commandArgs(trailingOnly = FALSE)
38 cmd.args.trailing = commandArgs(trailingOnly = TRUE)
39 cmd.args = cmd.args[seq.int(from=1, length.out=length(cmd.args) - length(cmd.args.trailing))]
40 res = gsub("^(?:--file=(.*)|.*)$", "\\1", cmd.args)
41
42 # If multiple --file arguments are given, R uses the last one
43 res = tail(res[res != ""], 1)
44 if (0 < length(res)) return(dirname(res))
45
46 # Both are not the case. Maybe we are in an R GUI?
47 return(NULL)
48 }
49
50 script.dir <- LocationOfThisScript()
51
52 source(paste(script.dir, "w4mcorcov_lib.R", sep="/"))
53 source(paste(script.dir, "w4mcorcov_util.R", sep="/"))
54 source(paste(script.dir, "w4mcorcov_input.R", sep="/"))
55 source(paste(script.dir, "w4mcorcov_salience.R", sep="/"))
56 source(paste(script.dir, "w4mcorcov_calc.R", sep="/"))
57 source(paste(script.dir, "w4mcorcov_output.R", sep="/"))
58 #source("w4mcorcov_lib.R")
59 #source("w4mcorcov_util.R")
60 #source("w4mcorcov_input.R")
61 #source("w4mcorcov_salience.R")
62 #source("w4mcorcov_calc.R")
63 #source("w4mcorcov_output.R")
31 64
32 ## log file 65 ## log file
33 ##--------- 66 ##---------
34 67
35 my_log <- function(x, ...) { cat(paste(iso8601.znow(), " ", x, ..., nl, sep=""))} 68 my_log <- function(x, ...) { cat(paste(iso8601.znow(), " ", x, ..., nl, sep=""))}