comparison data_manager/customProDB_annotation.R @ 5:a0ca66b32792 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/data_manager_customProDB commit 98f3323d4b92a4a3668788b3e1bad1a6529fd6df-dirty
author galaxyp
date Tue, 24 May 2016 11:47:26 -0400
parents b42974daa659
children c922df2f9c2a
comparison
equal deleted inserted replaced
4:b42974daa659 5:a0ca66b32792
14 suppressPackageStartupMessages(library("RGalaxy")) 14 suppressPackageStartupMessages(library("RGalaxy"))
15 15
16 16
17 option_list <- list() 17 option_list <- list()
18 option_list$dbkey <- make_option('--dbkey', type='character') 18 option_list$dbkey <- make_option('--dbkey', type='character')
19 option_list$dbsnp <- make_option('--dbsnp', type='character')
20 option_list$cosmic <- make_option('--cosmic', type='logical')
19 option_list$outputFile <- make_option('--outputFile', type='character') 21 option_list$outputFile <- make_option('--outputFile', type='character')
20 option_list$dbkey_description <- make_option('--dbkey_description', type='character') 22 option_list$dbkey_description <- make_option('--dbkey_description', type='character')
21 23
22 opt <- parse_args(OptionParser(option_list=option_list)) 24 opt <- parse_args(OptionParser(option_list=option_list))
23 25
24 26
25 customProDB_annotation <- function( 27 customProDB_annotation <- function(
26 dbkey = GalaxyCharacterParam(required=TRUE), 28 dbkey = GalaxyCharacterParam(required=TRUE),
29 dbsnp_str = GalaxyCharacterParam(required=FALSE),
30 cosmic = GalaxyLogicalParam(required=FALSE),
27 dbkey_description = GalaxyCharacterParam(required=FALSE), 31 dbkey_description = GalaxyCharacterParam(required=FALSE),
28 outputFile = GalaxyOutput("output","json")) 32 outputFile = GalaxyOutput("output","json"))
29 { 33 {
30 if (!file.exists(outputFile)) 34 if (!file.exists(outputFile))
31 { 35 {
33 } 37 }
34 38
35 if (length(dbkey_description) < 1) 39 if (length(dbkey_description) < 1)
36 { 40 {
37 dbkey_description = dbkey 41 dbkey_description = dbkey
42 }
43
44 if (length(dbsnp_str) > 0)
45 {
46 dbsnp = dbsnp_str
47 }
48 else
49 {
50 dbsnp = NULL
51 }
52
53 if (cosmic && grepl("^hg", dbkey))
54 {
55 use_cosmic = TRUE
56 }
57 else
58 {
59 use_cosmic = NULL
38 } 60 }
39 61
40 suppressPackageStartupMessages(library(rjson)) 62 suppressPackageStartupMessages(library(rjson))
41 params = fromJSON(file=outputFile) 63 params = fromJSON(file=outputFile)
42 target_directory = params$output_data[[1]]$extra_files_path 64 target_directory = params$output_data[[1]]$extra_files_path
63 85
64 cat(paste("Downloading protein FASTA from:", ucscTableProteinFastaURL, "\n")) 86 cat(paste("Downloading protein FASTA from:", ucscTableProteinFastaURL, "\n"))
65 download.file(ucscTableProteinFastaURL, proteinFastaFilepath, quiet=T, mode='wb') 87 download.file(ucscTableProteinFastaURL, proteinFastaFilepath, quiet=T, mode='wb')
66 88
67 cat(paste("Preparing Refseq annotation files\n")) 89 cat(paste("Preparing Refseq annotation files\n"))
68 customProDB::PrepareAnnotationRefseq(genome=dbkey, CDSfasta=codingFastaFilepath, pepfasta=proteinFastaFilepath, annotation_path=target_directory) 90 customProDB::PrepareAnnotationRefseq(genome=dbkey, CDSfasta=codingFastaFilepath, pepfasta=proteinFastaFilepath, annotation_path=target_directory, dbsnp=dbsnp, cosmic=use_cosmic)
69 91
70 outputPath = paste(dbkey, "/customProDB", sep="") 92 outputPath = paste(dbkey, "/customProDB", sep="")
71 output = list(data_tables = list()) 93 output = list(data_tables = list())
72 output[["data_tables"]][["customProDB"]]=c(path=outputPath, name=dbkey_description, dbkey=dbkey, value=dbkey) 94 output[["data_tables"]][["customProDB"]]=c(path=outputPath, name=dbkey_description, dbkey=dbkey, value=dbkey)
73 write(toJSON(output), file=outputFile) 95 write(toJSON(output), file=outputFile)