annotate preprocess.R @ 0:4d539083cf7f draft

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