annotate community.R @ 0:12b4f093e6c4 draft default tip

planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
author bcclaywell
date Mon, 12 Oct 2015 16:46:15 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
1 #!/usr/bin/env Rscript
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
2
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
3 ## begin warning handler
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
4 withCallingHandlers({
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
5
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
6 library(methods) # Because Rscript does not always do this
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
7
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
8 options('useFancyQuotes' = FALSE)
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
9
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
10 suppressPackageStartupMessages(library("optparse"))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
11 suppressPackageStartupMessages(library("RGalaxy"))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
12
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
13
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
14 option_list <- list()
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
15
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
16 option_list$CountsFile <- make_option('--CountsFile', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
17 option_list$SamplesFile <- make_option('--SamplesFile', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
18 option_list$K <- make_option('--K', type='numeric')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
19 option_list$A <- make_option('--A', type='numeric')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
20 option_list$Transform <- make_option('--Transform', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
21 option_list$SampleName <- make_option('--SampleName', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
22 option_list$ColumnClasses <- make_option('--ColumnClasses', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
23 option_list$OutputFile <- make_option('--OutputFile', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
24
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
25
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
26 opt <- parse_args(OptionParser(option_list=option_list))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
27
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
28 suppressPackageStartupMessages(library(microbiomePkg))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
29
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
30 ## function body not needed here, it is in package
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
31
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
32 params <- list()
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
33 for(param in names(opt))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
34 {
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
35 if (!param == "help")
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
36 params[param] <- opt[param]
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
37 }
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
38
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
39 setClass("GalaxyRemoteError", contains="character")
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
40 wrappedFunction <- function(f)
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
41 {
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
42 tryCatch(do.call(f, params),
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
43 error=function(e) new("GalaxyRemoteError", conditionMessage(e)))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
44 }
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
45
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
46
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
47 suppressPackageStartupMessages(library(RGalaxy))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
48 do.call(community, params)
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
49
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
50 ## end warning handler
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
51 }, warning = function(w) {
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
52 cat(paste("Warning:", conditionMessage(w), "\n"))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
53 invokeRestart("muffleWarning")
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
54 })