annotate preprocess.R @ 5:af4f63f27c77 draft

planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
author sblanck
date Wed, 08 Apr 2020 15:34:17 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
1 #!/usr/bin/env Rscript
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
2 # setup R error handling to go to stderr
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
4
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
5 # we need that to not crash galaxy with an UTF8 error on German LC settings.
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
6 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
7
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
8 library("optparse")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
9
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
10 ##### Read options
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
11 option_list=list(
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
12 make_option("--summary",type="character",default=NULL, dest="summary"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
13 make_option("--dataSetName",type="character",default=NULL, dest="dataSetName"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
14 make_option("--new_file_path",type="character",default=NULL, dest="new_file_path"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
15 make_option("--inputcdffull_name",type="character",default=NULL, dest="inputcdffull_name"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
16 make_option("--inputufl_name",type="character",default=NULL, dest="inputufl_name"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
17 make_option("--inputugp_name",type="character",default=NULL, dest="inputugp_name"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
18 make_option("--inputacs_name",type="character",default=NULL, dest="inputacs_name"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
19 make_option("--inputcdffull",type="character",default=NULL, dest="inputcdffull"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
20 make_option("--inputufl",type="character",default=NULL, dest="inputufl"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
21 make_option("--inputugp",type="character",default=NULL, dest="inputugp"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
22 make_option("--inputacs",type="character",default=NULL, dest="inputacs"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
23 make_option("--tumorcsv",type="character",default=NULL, dest="tumorcsv"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
24 make_option("--settingsType",type="character",default=NULL, dest="settingsType"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
25 make_option("--outputgraph",type="character",default=NULL, dest="outputgraph"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
26 make_option("--zipfigures",type="character",default=NULL, dest="zipfigures"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
27 make_option("--outputlog",type="character",default=NULL, dest="outputlog"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
28 make_option("--log",type="character",default=NULL, dest="log"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
29 make_option("--user_id",type="character",default=NULL, dest="user_id"),
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
30 make_option("--input",type="character",default=NULL, dest="input")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
31 );
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
32
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
33 opt_parser = OptionParser(option_list=option_list);
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
34 opt = parse_args(opt_parser);
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
35
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
36 if(is.null(opt$input)){
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
37 print_help(opt_parser)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
38 stop("input required.", call.=FALSE)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
39 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
40
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
41 #loading libraries
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
42
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
43 summary=opt$summary
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
44 dataSetName=opt$dataSetName
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
45 newFilePath=opt$new_file_path
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
46 inputCDFName=opt$inputcdffull_name
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
47 inputUFLName=opt$inputufl_name
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
48 inputUGPName=opt$inputugp_name
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
49 inputACSName=opt$inputacs_name
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
50 inputCDF=opt$inputcdffull
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
51 inputUFL=opt$inputufl
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
52 inputUGP=opt$inputugp
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
53 inputACS=opt$inputacs
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
54 tumorcsv=opt$tumorcsv
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
55 settingsType=opt$settingsType
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
56 outputGraph=opt$outputgraph
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
57 zipfigures=opt$zipfigures
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
58 outputlog=opt$outputlog
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
59 log=opt$log
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
60 userId=opt$user_id
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
61
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
62 destinationPath=file.path(newFilePath, userId, dataSetName)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
63 mpagenomicsDir = file.path(newFilePath,"mpagenomics",userId)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
64 dataDir = file.path(newFilePath, userId)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
65 chipDir = file.path(newFilePath,"mpagenomics",userId,"annotationData","chipTypes")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
66 createArchitecture=TRUE
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
67
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
68 if (dir.exists(chipDir))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
69 system(paste0("rm -r ", chipDir))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
70
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
71 if (!dir.exists(mpagenomicsDir))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
72 dir.create(mpagenomicsDir, showWarnings = TRUE, recursive = TRUE)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
73
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
74 if (!dir.exists(dataDir))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
75 dir.create(dataDir, showWarnings = TRUE, recursive = TRUE)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
76
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
77 listInput <- trimws( unlist( strsplit(trimws(opt$input), ",") ) )
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
78 if(length(listInput)<2){
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
79 stop("To few .CEL files selected : At least 2 .CEL files are required", call.=FALSE)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
80 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
81
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
82
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
83 celList=vector()
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
84 celFileNameList=vector()
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
85
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
86 for (i in 1:length(listInput))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
87 {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
88 inputFileInfo <- unlist( strsplit( listInput[i], ';' ) )
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
89 celList=c(celList,inputFileInfo[1])
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
90 celFileNameList=c(celFileNameList,inputFileInfo[2])
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
91 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
92
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
93
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
94 for (i in 1:length(celFileNameList))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
95 {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
96 source = celList[i]
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
97 destination=file.path(dataDir,celFileNameList[i])
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
98 file.copy(source, destination)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
99 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
100 split=unlist(strsplit(inputCDFName,",",fixed=TRUE))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
101 tag=NULL
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
102 if (length(split) != 0) {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
103 chipType=split[1]
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
104 tagExt=split[2]
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
105 tag=unlist(strsplit(tagExt,".",fixed=TRUE))[1]
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
106 } else {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
107 chipType=split[1]
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
108 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
109
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
110 if(!file.exists(file.path(dataDir,inputCDFName)))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
111 file.symlink(inputCDF,file.path(dataDir,inputCDFName))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
112 if(!file.exists(file.path(dataDir,inputACSName)))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
113 file.symlink(inputACS,file.path(dataDir,inputACSName))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
114 if(!file.exists(file.path(dataDir,inputUFLName)))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
115 file.symlink(inputUFL,file.path(dataDir,inputUFLName))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
116 if(!file.exists(file.path(dataDir,inputUGPName)))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
117 file.symlink(inputUGP,file.path(dataDir,inputUGPName))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
118
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
119 fig_dir = file.path("mpagenomics", userId, "figures", dataSetName, "signal")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
120 abs_fig_dir = file.path(newFilePath, fig_dir)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
121
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
122 chip=chipType
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
123 dataset=dataSetName
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
124 workdir=mpagenomicsDir
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
125 celPath=dataDir
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
126 chipPath=dataDir
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
127 tumor=tumorcsv
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
128 outputgraph=type.convert(outputGraph)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
129
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
130
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
131 library(MPAgenomics)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
132 setwd(workdir)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
133
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
134 if (outputlog){
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
135 sinklog <- file(log, open = "wt")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
136 sink(sinklog ,type = "output")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
137 sink(sinklog, type = "message")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
138 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
139
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
140 if (settingsType=="standard")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
141 {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
142 signalPreProcess(dataSetName=dataset, chipType=chip, dataSetPath=celPath,chipFilesPath=chipPath, path=workdir,createArchitecture=createArchitecture, savePlot=outputgraph, tags=tag)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
143 } else {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
144 signalPreProcess(dataSetName=dataset, chipType=chip, dataSetPath=celPath,chipFilesPath=chipPath, normalTumorArray=tumor, path=workdir,createArchitecture=createArchitecture, savePlot=outputgraph, tags=tag)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
145 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
146 setwd(abs_fig_dir)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
147 files2zip <- dir(abs_fig_dir)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
148 zip(zipfile = "figures.zip", files = files2zip)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
149 file.rename("figures.zip",zipfigures)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
150 summarydf=data.frame(celFileNameList,rep(dataSetName,length(celFileNameList)),rep(chipType,length(celFileNameList)))
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
151 write.table(summarydf,file=summary,quote=FALSE,row.names=FALSE,col.names=FALSE,sep="\t")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
152
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
153 if (outputlog){
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
154 sink(type="output")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
155 sink(type="message")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
156 close(sinklog)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
157 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
158