annotate data_manager/customProDB_annotation.R @ 12:1ebf39dd0dca draft

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