comparison customProDB.R @ 0:8ccfff69dd57 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
author galaxyp
date Tue, 14 Mar 2017 14:14:38 -0400
parents
children ad130eaa3a05
comparison
equal deleted inserted replaced
-1:000000000000 0:8ccfff69dd57
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
19 option_list$bam <- make_option('--bam', type='character')
20 option_list$bai <- make_option('--bai', type='character')
21 option_list$vcf <- make_option('--vcf', type='character')
22 option_list$exon_anno <- make_option('--exon_anno', type='character')
23 option_list$proteinseq <- make_option('--proteinseq', type='character')
24 option_list$procodingseq <- make_option('--procodingseq', type='character')
25 option_list$ids <- make_option('--ids', type='character')
26 option_list$dbsnpinCoding <- make_option('--dbsnpinCoding', type='character')
27 option_list$cosmic <- make_option('--cosmic', type='character')
28 option_list$annotationFromHistory <- make_option('--annotationFromHistory', type='logical', action="store_true", default=FALSE)
29 option_list$rpkmCutoff <- make_option('--rpkmCutoff', type='character')
30 #option_list$outputIndels <- make_option('--outputIndels', type='logical', action="store_true", default=FALSE)
31 #option_list$outputNovelJunctions <- make_option('--outputNovelJunctions', type='logical', action="store_true", default=FALSE)
32 option_list$outputFile <- make_option('--outputFile', type='character')
33
34
35 opt <- parse_args(OptionParser(option_list=option_list))
36
37
38 customProDB <- function(
39 bam_file = GalaxyInputFile(required=TRUE),
40 bai_file = GalaxyInputFile(required=TRUE),
41 vcf_file = GalaxyInputFile(required=TRUE),
42 exon_anno_file = GalaxyInputFile(required=TRUE),
43 proteinseq_file = GalaxyInputFile(required=TRUE),
44 procodingseq_file = GalaxyInputFile(required=TRUE),
45 ids_file = GalaxyInputFile(required=TRUE),
46 dbsnpinCoding_file = GalaxyInputFile(required=FALSE),
47 cosmic_file = GalaxyInputFile(required=FALSE),
48 annotationFromHistory = GalaxyLogicalParam(required=FALSE),
49 rpkmCutoff = GalaxyNumericParam(required=TRUE),
50 #outputIndels = GalaxyLogicalParam(required=FALSE),
51 #outputNovelJunctions = GalaxyLogicalParam(required=FALSE),
52 outputFile = GalaxyOutput("FASTA","fasta"))
53 {
54 file.symlink(exon_anno_file, paste(getwd(), "exon_anno.RData", sep="/"))
55 file.symlink(proteinseq_file, paste(getwd(), "proseq.RData", sep="/"))
56 file.symlink(procodingseq_file, paste(getwd(), "procodingseq.RData", sep="/"))
57 file.symlink(ids_file, paste(getwd(), "ids.RData", sep="/"))
58
59 if (length(dbsnpinCoding_file) > 0)
60 {
61 file.symlink(dbsnpinCoding_file, paste(getwd(), "dbsnpinCoding.RData", sep="/"))
62 labelrsid = T
63 }
64 else
65 {
66 labelrsid = F
67 }
68
69 if (length(cosmic_file) > 0)
70 {
71 file.symlink(cosmic_file, paste(getwd(), "cosmic.RData", sep="/"))
72 cosmic = T
73 }
74 else
75 {
76 cosmic = F
77 }
78
79 bamLink = "input.bam"
80 file.symlink(bam_file, bamLink)
81 file.symlink(bai_file, paste(bamLink, ".bai", sep=""))
82
83 suppressPackageStartupMessages(library(customProDB))
84
85 easyRun(bamFile=bamLink, vcfFile=vcf_file, annotation_path=getwd(),
86 rpkm_cutoff=rpkmCutoff, outfile_path=".", outfile_name="output",
87 nov_junction=F, INDEL=T, lablersid=labelrsid, COSMIC=cosmic)
88 }
89
90
91 params <- list()
92 for(param in names(opt))
93 {
94 if (!param == "help")
95 params[param] <- opt[param]
96 }
97
98 setClass("GalaxyRemoteError", contains="character")
99 wrappedFunction <- function(f)
100 {
101 tryCatch(do.call(f, params),
102 error=function(e) new("GalaxyRemoteError", conditionMessage(e)))
103 }
104
105
106 suppressPackageStartupMessages(library(RGalaxy))
107 do.call(customProDB, params)
108
109 ## end warning handler
110 }, warning = function(w) {
111 cat(paste("Warning:", conditionMessage(w), "\n"))
112 invokeRestart("muffleWarning")
113 })