annotate data_manager/customProDB_annotation.R @ 3:9ee512decde8 draft default tip

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit d4b5497065b853ed094aebc9e4185e9995c5e0e0
author galaxyp
date Wed, 01 Nov 2017 19:34:06 -0400
parents 0a9ffebba65d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
1 #!/usr/bin/env Rscript
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
2
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
3 initial.options <- commandArgs(trailingOnly = FALSE)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
4 script_parent_dir <- dirname(sub("--file=", "", initial.options[grep("--file=", initial.options)]))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
5
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
6 ## begin warning handler
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
7 withCallingHandlers({
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
8
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
9 library(methods) # Because Rscript does not always do this
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
10
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
11 options('useFancyQuotes' = FALSE)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
12
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
13 suppressPackageStartupMessages(library("optparse"))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
14 suppressPackageStartupMessages(library("RGalaxy"))
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
15 suppressPackageStartupMessages(library("GetoptLong"))
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
16
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
17
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
18 option_list <- list()
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
19 option_list$dbkey <- make_option('--dbkey', type='character')
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
20 option_list$ensembl_host <- make_option('--ensembl_host', type='character')
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
21 option_list$ensembl_dataset <- make_option('--ensembl_dataset', type='character')
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
22 option_list$dbsnp <- make_option('--dbsnp', type='character')
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
23 option_list$cosmic <- make_option('--cosmic', type='logical')
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
24 option_list$outputFile <- make_option('--outputFile', type='character')
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
25 option_list$dbkey_description <- make_option('--dbkey_description', type='character')
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
26
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
27 opt <- parse_args(OptionParser(option_list=option_list))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
28
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
29
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
30 customProDB_annotation <- function(
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
31 dbkey = GalaxyCharacterParam(required=FALSE),
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
32 ensembl_host = GalaxyCharacterParam(required=FALSE),
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
33 ensembl_dataset = GalaxyCharacterParam(required=FALSE),
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
34 dbsnp_str = GalaxyCharacterParam(required=FALSE),
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
35 cosmic = GalaxyLogicalParam(required=FALSE),
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
36 dbkey_description = GalaxyCharacterParam(required=FALSE),
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
37 outputFile = GalaxyOutput("output","json"))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
38 {
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
39 options(stringsAsFactors = FALSE, gsubfn.engine = "R")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
40
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
41 if (!file.exists(outputFile))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
42 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
43 gstop("json params file does not exist")
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
44 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
45
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
46 if (length(dbkey)+length(ensembl_dataset)+length(ensembl_host) == 0)
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
47 {
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
48 gstop("one of the genome annotation sources must be specified; either dbkey or host and dataset")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
49 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
50 else if (length(dbkey) > 0 &&
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
51 (length(ensembl_dataset) > 0 || length(ensembl_host) > 0))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
52 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
53 gstop("only one genome annotation source can be specified; either dbkey or host and dataset")
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
54 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
55
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
56 if (length(dbsnp_str) > 0)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
57 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
58 dbsnp = dbsnp_str
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
59 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
60 else
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
61 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
62 dbsnp = NULL
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
63 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
64
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
65 use_cosmic = FALSE
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
66 if (length(cosmic) > 0)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
67 {
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
68 if (length(dbkey) > 0 && grepl("^hg", dbkey) ||
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
69 length(ensembl_dataset) > 0 && grepl("^hsapiens", ensembl_dataset))
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
70 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
71 use_cosmic = TRUE
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
72 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
73 else
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
74 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
75 gstop("COSMIC annotation requested but dbkey does not indicate a human genome (e.g. hg19)")
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
76 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
77 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
78
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
79 suppressPackageStartupMessages(library(rjson))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
80 params = fromJSON(file=outputFile)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
81 target_directory = params$output_data[[1]]$extra_files_path
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
82 dir.create(target_directory)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
83
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
84 tryCatch(
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
85 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
86 file.remove(outputFile)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
87 }, error=function(err)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
88 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
89 gstop("failed to remove json params file after reading")
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
90 })
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
91
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
92 # load customProDB from GitHub (NOTE: downloading the zip is faster than cloning the repo with git2r or devtools::install_github)
3
9ee512decde8 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit d4b5497065b853ed094aebc9e4185e9995c5e0e0
galaxyp
parents: 2
diff changeset
93 download.file("https://github.com/chambm/customProDB/archive/9db2223ef9932e50124b92d1bc49206af1f40fb3.zip", "customProDB.zip", quiet=TRUE)
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
94 unzip("customProDB.zip")
3
9ee512decde8 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit d4b5497065b853ed094aebc9e4185e9995c5e0e0
galaxyp
parents: 2
diff changeset
95 devtools::load_all("customProDB-9db2223ef9932e50124b92d1bc49206af1f40fb3")
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
96
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
97 #suppressPackageStartupMessages(library(customProDB))
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
98 options(timeout=3600)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
99
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
100 # download protein and coding sequences for UCSC annotation
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
101 if (length(dbkey) > 0)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
102 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
103 proteinFastaFilepath = paste(dbkey, ".protein.fa", sep="")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
104
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
105 cat(paste("Downloading protein FASTA from:", getProteinFastaUrlFromUCSC(dbkey), "\n"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
106 download.file(getProteinFastaUrlFromUCSC(dbkey), proteinFastaFilepath, quiet=T, mode='wb')
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
107
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
108 local_cache_path = paste0("customProDB_annotation_", dbkey, "-", tools::md5sum(proteinFastaFilepath)[[1]])
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
109 codingFastaFilepath = paste0(local_cache_path, "/", dbkey, ".cds.fa")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
110 dir.create(local_cache_path, showWarnings=FALSE)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
111
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
112 if (!file.exists(codingFastaFilepath)) {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
113 cat(paste("Downloading coding FASTA from:", getCodingFastaUrlFromUCSC(dbkey), "\n"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
114 download.file(getCodingFastaUrlFromUCSC(dbkey), codingFastaFilepath, quiet=T, mode='wb')
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
115 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
116
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
117 cat(paste("Preparing Refseq annotation files\n"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
118 PrepareAnnotationRefseq(genome=dbkey, CDSfasta=codingFastaFilepath, pepfasta=proteinFastaFilepath, annotation_path=target_directory, dbsnp=dbsnp, COSMIC=use_cosmic, local_cache_path=local_cache_path)
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
119
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
120 if (length(dbkey_description) < 1)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
121 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
122 dbkey_description = dbkey
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
123 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
124 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
125 else
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
126 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
127 local_cache_path = paste0("customProDB_annotation_", ensembl_dataset, "_", ensembl_host)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
128
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
129 suppressPackageStartupMessages(library(biomaRt))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
130 cat(paste("Preparing Ensembl annotation files\n"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
131 ensembl_mart = useMart("ENSEMBL_MART_ENSEMBL", dataset=ensembl_dataset, host=ensembl_host)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
132 PrepareAnnotationEnsembl(mart=ensembl_mart, annotation_path=target_directory, dbsnp=dbsnp, COSMIC=use_cosmic, local_cache_path=local_cache_path)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
133
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
134 metadata = sqldf::sqldf("SELECT value FROM metadata WHERE name='BioMart database version' OR name='BioMart dataset description' OR name='BioMart dataset version'",
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
135 dbname=file.path(target_directory, "txdb.sqlite"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
136 version = metadata$value[1] # Ensembl Genes 87
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
137 assembly = metadata$value[3]
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
138 dbkey = paste0(ensembl_dataset, "_", sub(".*?(\\d+)", "\\1", version, perl=TRUE))
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
139
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
140 # convert Ensembl chromosome names to UCSC for Galaxy compatibility
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
141 chromosomeMappingsBaseUrl = "https://raw.githubusercontent.com/dpryan79/ChromosomeMappings/master"
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
142 assemblyNoGrcPatch = sub("(\\S+?)(\\.p\\S+)?$", "\\1", assembly, perl=TRUE)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
143 chromosomeMappingsUrl = qq("@{chromosomeMappingsBaseUrl}/@{assemblyNoGrcPatch}_ensembl2UCSC.txt")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
144 if (RCurl::url.exists(chromosomeMappingsUrl))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
145 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
146 cat(qq("Converting Ensembl chromosome names from: @{chromosomeMappingsUrl}\n"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
147 e2u = read.delim(chromosomeMappingsUrl, header=FALSE, col.names=c("ensembl", "ucsc"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
148 e2u = setNames(as.list(e2u$ucsc), e2u$ensembl)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
149 load(file.path(target_directory, "exon_anno.RData"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
150 exon$chromosome_name = sapply(exon$chromosome_name, function(x) e2u[[as.character(x)]])
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
151 exon = exon[nzchar(exon$chromosome_name), ] # omit genome patches with no mapping
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
152 save(exon, file=file.path(target_directory, "exon_anno.RData"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
153 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
154 else
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
155 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
156 gwarning(qq("unable to convert Ensembl chromosome names to UCSC; mapping file @{assemblyNoGrcPatch}_ensembl2UCSC.txt does not exist"))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
157 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
158
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
159 if (length(dbkey_description) < 1)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
160 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
161 dbkey_description = qq("@{ensembl_dataset} (@{version}) (@{assembly})")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
162 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
163 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
164
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
165 qualified_dbkey = dbkey
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
166
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
167 if (length(dbsnp_str) > 0 && nzchar(dbsnp_str))
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
168 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
169 qualified_dbkey = qq("@{qualified_dbkey}_db@{dbsnp_str}")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
170 dbkey_description = qq("@{dbkey_description} (db@{dbsnp_str})")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
171 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
172
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
173 if (length(cosmic) > 0)
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
174 {
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
175 qualified_dbkey = qq("@{qualified_dbkey}_cosmic")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
176 dbkey_description = qq("@{dbkey_description} (COSMIC)")
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
177 }
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
178
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
179 outputPath = paste0(qualified_dbkey, "/customProDB")
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
180 output = list(data_tables = list())
1
9b4ee836e35b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 2174137cf8a15deefed5910ffa152c4ce9c81af6
galaxyp
parents: 0
diff changeset
181 output[["data_tables"]][["customProDB"]]=c(path=outputPath, name=dbkey_description, dbkey=qualified_dbkey, value=qualified_dbkey)
0
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
182 write(toJSON(output), file=outputFile)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
183 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
184
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
185
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
186 params <- list()
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
187 for(param in names(opt))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
188 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
189 if (!param == "help")
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
190 params[param] <- opt[param]
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
191 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
192
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
193 setClass("GalaxyRemoteError", contains="character")
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
194 wrappedFunction <- function(f)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
195 {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
196 tryCatch(do.call(f, params),
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
197 error=function(e) new("GalaxyRemoteError", conditionMessage(e)))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
198 }
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
199
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
200
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
201 suppressPackageStartupMessages(library(RGalaxy))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
202 do.call(customProDB_annotation, params)
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
203
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
204 ## end warning handler
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
205 }, warning = function(w) {
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
206 cat(paste("Warning:", conditionMessage(w), "\n"))
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
207 invokeRestart("muffleWarning")
45755942ae7b planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/custom_pro_db commit 4bb5b663989d5f04e8fb74b111456f16d6edaa66
galaxyp
parents:
diff changeset
208 })