Mercurial > repos > melpetera > batchcorrection
comparison BC/batch_correction_docker_wrapper.R @ 4:23314e1192d4 draft default tip
Uploaded
author | melpetera |
---|---|
date | Thu, 14 Jan 2021 09:56:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:73892ef177e3 | 4:23314e1192d4 |
---|---|
1 #!/usr/bin/env Rscript | |
2 | |
3 ################################################################################################ | |
4 # batch_correction_main_wrapper # | |
5 # # | |
6 # Author: Nils Paulhe # | |
7 # User: Galaxy # | |
8 # Original data: -- # | |
9 # Starting date: 2017-12-11 # | |
10 # Version 1: 2017-12-11 # | |
11 # # | |
12 # # | |
13 # # | |
14 ################################################################################################ | |
15 | |
16 library(batch) #necessary for parseCommandArgs function | |
17 | |
18 ##------------------------------ | |
19 ## init. prog. constants | |
20 ##------------------------------ | |
21 | |
22 argv.wrapper <- commandArgs(trailingOnly = FALSE) | |
23 script.path <- sub("--file=", "", argv.wrapper[grep("--file=", argv.wrapper)]) | |
24 prog.name <- basename(script.path) | |
25 | |
26 ##------------------------------ | |
27 ## init. functions | |
28 ##------------------------------ | |
29 | |
30 script_bypass <- function(other.script.name) { | |
31 initial.options <- commandArgs(trailingOnly = FALSE) | |
32 file.arg.name <- "--file=" | |
33 script.name <- sub(file.arg.name, "", initial.options[grep(file.arg.name, initial.options)]) | |
34 script.basename <- dirname(script.name) | |
35 other.script.fullpath <- paste(sep="/", script.basename, other.script.name) | |
36 other.script.cmd <- paste(sep=" ", "Rscript", other.script.fullpath, "-h") | |
37 system(other.script.cmd, wait=TRUE) | |
38 } | |
39 | |
40 source_wrapper <- function(other.script.name){ | |
41 initial.options <- commandArgs(trailingOnly = FALSE) | |
42 file.arg.name <- "--file=" | |
43 script.name <- sub(file.arg.name, "", initial.options[grep(file.arg.name, initial.options)]) | |
44 script.basename <- dirname(script.name) | |
45 other.script.fullpath <- paste(sep="/", script.basename, other.script.name) | |
46 source(other.script.fullpath) | |
47 } | |
48 | |
49 ##------------------------------ | |
50 ## Test Help | |
51 ##------------------------------ | |
52 | |
53 if (length(grep('-h', argv.wrapper)) > 0) { | |
54 cat("Usage: Rscript ", | |
55 prog.name, | |
56 "{args} \n", | |
57 "parameters: \n", | |
58 "\t-h: display this help message, call all scripts with the same option and exit (optional) \n", | |
59 "\t--loess \"TRUE\": call the script as \"batch_correction_all_loess_wrapper.R\"; otherwise call it as \"batch_correction_wrapper.R\" one (optional) \n", | |
60 "for other parameters, please refer to each script specific options and parameters. \n", | |
61 "\n") | |
62 script_bypass("batch_correction_all_loess_wrapper.R") | |
63 script_bypass("batch_correction_wrapper.R") | |
64 quit(status = 0) | |
65 } | |
66 | |
67 ##------------------------------ | |
68 ## check if loess or normal | |
69 ##------------------------------ | |
70 | |
71 if (length(grep('--loess', argv.wrapper)) > 0) { | |
72 source_wrapper("batch_correction_all_loess_wrapper.R") | |
73 } else { | |
74 source_wrapper("batch_correction_3Lwrapper.R") | |
75 } | |
76 |