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