Mercurial > repos > galaxyp > data_manager_custom
comparison data_manager/customProDB_annotation.R @ 0:3c2c36beddb1 draft default tip
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/data_manager_customProDB commit 141369f97aa2804d2bbfd9ed620ea2a5574994c2-dirty
| author | galaxyp |
|---|---|
| date | Fri, 15 Jan 2016 15:52:56 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:3c2c36beddb1 |
|---|---|
| 1 #!/usr/bin/env Rscript | |
| 2 | |
| 3 initial.options <- commandArgs(trailingOnly = FALSE) | |
| 4 script_parent_dir <- dirname(sub("--file=", "", initial.options[grep("--file=", initial.options)])) | |
| 5 | |
| 6 ## begin warning handler | |
| 7 withCallingHandlers({ | |
| 8 | |
| 9 library(methods) # Because Rscript does not always do this | |
| 10 | |
| 11 options('useFancyQuotes' = FALSE) | |
| 12 | |
| 13 suppressPackageStartupMessages(library("optparse")) | |
| 14 suppressPackageStartupMessages(library("RGalaxy")) | |
| 15 | |
| 16 | |
| 17 option_list <- list() | |
| 18 option_list$dbkey <- make_option('--dbkey', type='character') | |
| 19 option_list$outputFile <- make_option('--outputFile', type='character') | |
| 20 | |
| 21 opt <- parse_args(OptionParser(option_list=option_list)) | |
| 22 | |
| 23 | |
| 24 customProDB_annotation <- function( | |
| 25 dbkey = GalaxyCharacterParam(required=TRUE), | |
| 26 outputFile = GalaxyOutput("output","json")) | |
| 27 { | |
| 28 if (file.exists(outputFile)) | |
| 29 { | |
| 30 if (file.info(outputFile)$size > 0) { gstop("output file already exists") } | |
| 31 else | |
| 32 { | |
| 33 tryCatch( | |
| 34 { | |
| 35 file.remove(outputFile) | |
| 36 }, error=function(err) | |
| 37 { | |
| 38 gstop("failed to remove empty existing file") | |
| 39 }) | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 gstop("what you talkin bout willis?!") | |
| 44 } | |
| 45 | |
| 46 | |
| 47 params <- list() | |
| 48 for(param in names(opt)) | |
| 49 { | |
| 50 if (!param == "help") | |
| 51 params[param] <- opt[param] | |
| 52 } | |
| 53 | |
| 54 setClass("GalaxyRemoteError", contains="character") | |
| 55 wrappedFunction <- function(f) | |
| 56 { | |
| 57 tryCatch(do.call(f, params), | |
| 58 error=function(e) new("GalaxyRemoteError", conditionMessage(e))) | |
| 59 } | |
| 60 | |
| 61 | |
| 62 suppressPackageStartupMessages(library(RGalaxy)) | |
| 63 do.call(customProDB_annotation, params) | |
| 64 | |
| 65 ## end warning handler | |
| 66 }, warning = function(w) { | |
| 67 cat(paste("Warning:", conditionMessage(w), "\n")) | |
| 68 invokeRestart("muffleWarning") | |
| 69 }) |
