annotate ribbonPlot.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$CommunityFile <- make_option('--CommunityFile', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
17 option_list$Attributes <- make_option('--Attributes', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
18 option_list$ClusteringAlgorithm <- make_option('--ClusteringAlgorithm', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
19 option_list$OutputFile <- make_option('--OutputFile', type='character')
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
20
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
21
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
22 opt <- parse_args(OptionParser(option_list=option_list))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
23
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
24 suppressPackageStartupMessages(library(microbiomePkg))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
25
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
26 ## function body not needed here, it is in package
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
27
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
28 params <- list()
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
29 for(param in names(opt))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
30 {
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
31 if (!param == "help")
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
32 params[param] <- opt[param]
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
33 }
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
34
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
35 setClass("GalaxyRemoteError", contains="character")
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
36 wrappedFunction <- function(f)
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
37 {
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
38 tryCatch(do.call(f, params),
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
39 error=function(e) new("GalaxyRemoteError", conditionMessage(e)))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
40 }
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
41
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
42
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
43 suppressPackageStartupMessages(library(RGalaxy))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
44 do.call(ribbonPlot, params)
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
45
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
46 ## end warning handler
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
47 }, warning = function(w) {
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
48 cat(paste("Warning:", conditionMessage(w), "\n"))
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
49 invokeRestart("muffleWarning")
12b4f093e6c4 planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
bcclaywell
parents:
diff changeset
50 })