annotate create_sqlite_db.R @ 22:5d47dd174435 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
author tomnl
date Fri, 01 Jun 2018 15:35:04 -0400
parents 7f57d501badb
children a429aae0ebfe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
1 library(msPurity)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
2 library(optparse)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
3 library(xcms)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
4 library(CAMERA)
1
1a88758357ed planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents: 0
diff changeset
5 print(sessionInfo())
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
6 print('CREATING DATABASE')
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
7
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
8
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
9 xset_pa_filename_fix <- function(opt, pa, xset){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
10
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
11
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
12 if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
13 # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
14 # needs to be done due to Galaxy moving the files around and screwing up any links to files
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
15
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
16 filepaths <- trimws(strsplit(opt$mzML_files, ',')[[1]])
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
17 filepaths <- filepaths[filepaths != ""]
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
18 new_names <- basename(filepaths)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
19
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
20 galaxy_names <- trimws(strsplit(opt$galaxy_names, ',')[[1]])
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
21 galaxy_names <- galaxy_names[galaxy_names != ""]
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
22
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
23 nsave <- names(pa@fileList)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
24 old_filenames <- basename(pa@fileList)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
25 pa@fileList <- filepaths[match(names(pa@fileList), galaxy_names)]
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
26 names(pa@fileList) <- nsave
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
27
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
28 pa@puritydf$filename <- basename(pa@fileList[match(pa@puritydf$filename, old_filenames)])
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
29 pa@grped_df$filename <- basename(pa@fileList[match(pa@grped_df$filename, old_filenames)])
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
30 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
31
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
32
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
33 if(!all(basename(pa@fileList)==basename(xset@filepaths))){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
34 if(!all(names(pa@fileList)==basename(xset@filepaths))){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
35 print('FILELISTS DO NOT MATCH')
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
36 message('FILELISTS DO NOT MATCH')
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
37 quit(status = 1)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
38 }else{
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
39 xset@filepaths <- unname(pa@fileList)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
40 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
41 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
42
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
43
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
44 return(list(pa, xset))
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
45 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
46
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
47
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
48
13
4acad02faf32 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535
tomnl
parents: 12
diff changeset
49
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
50 option_list <- list(
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
51 make_option(c("-o", "--out_dir"), type="character"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
52 make_option("--pa", type="character"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
53 make_option("--xset_xa", type="character"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
54 make_option("--xcms_camera_option", type="character"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
55 make_option("--eic", action="store_true"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
56 make_option("--cores", default=4),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
57 make_option("--mzML_files", type="character"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
58 make_option("--galaxy_names", type="character"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
59 make_option("--grp_peaklist", type="character"),
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
60 make_option("--db_name", type="character", default='lcms_data.sqlite'),
11
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
61 make_option("--raw_rt_columns", action="store_true"),
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
62 make_option("--metfrag_result", type="character"),
12
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
63 make_option("--sirius_csifingerid_result", type="character"),
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
64 make_option("--probmetab_result", type="character")
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
65 )
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
66
11
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
67
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
68 # store options
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
69 opt<- parse_args(OptionParser(option_list=option_list))
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
70
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
71 loadRData <- function(rdata_path, name){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
72 #loads an RData file, and returns the named xset object if it is there
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
73 load(rdata_path)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
74 return(get(ls()[ls() == name]))
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
75 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
76
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
77 print(paste('pa', opt$pa))
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
78 print(opt$xset)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
79 print(opt$xcms_camera_option)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
80 # Requires
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
81 pa <- loadRData(opt$pa, 'pa')
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
82
11
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
83
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
84 print(pa@fileList)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
85
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
86
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
87 if (opt$xcms_camera_option=='xcms'){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
88 xset <- loadRData(opt$xset, 'xset')
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
89 fix <- xset_pa_filename_fix(opt, pa, xset)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
90 pa <- fix[[1]]
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
91 xset <- fix[[2]]
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
92 xa <- NULL
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
93 }else{
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
94
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
95 xa <- loadRData(opt$xset, 'xa')
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
96 fix <- xset_pa_filename_fix(opt, pa, xa@xcmsSet)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
97 pa <- fix[[1]]
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
98 xa@xcmsSet <- fix[[2]]
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
99 xset <- NULL
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
100 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
101
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
102
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
103
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
104
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
105
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
106 if(is.null(opt$grp_peaklist)){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
107 grp_peaklist = NA
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
108 }else{
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
109 grp_peaklist = opt$grp_peaklist
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
110 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
111
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
112
13
4acad02faf32 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535
tomnl
parents: 12
diff changeset
113
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
114
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
115
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
116 db_pth <- msPurity::create_database(pa, xset=xset, xsa=xa, out_dir=opt$out_dir,
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
117 grp_peaklist=grp_peaklist, db_name=opt$db_name)
15
cf24c8ca7a57 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535-dirty
tomnl
parents: 14
diff changeset
118
13
4acad02faf32 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535
tomnl
parents: 12
diff changeset
119 print(db_pth)
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
120
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
121 if (!is.null(opt$eic)){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
122 if (is.null(opt$raw_rt_columns)){
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
123 rtrawColumns <- FALSE
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
124 }else{
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
125 rtrawColumns <- TRUE
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
126 }
16
03e7f58e580e planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f396d6689e17cb5537f54ada02a6bd691c7894d7
tomnl
parents: 15
diff changeset
127 if (is.null(xset)){
18
f13a7d89afdd planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit c43e21459ffc8f45349a0af6d60c6783dca6005d-dirty
tomnl
parents: 17
diff changeset
128 xset <- xa@xcmsSet
16
03e7f58e580e planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit f396d6689e17cb5537f54ada02a6bd691c7894d7
tomnl
parents: 15
diff changeset
129 }
13
4acad02faf32 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535
tomnl
parents: 12
diff changeset
130 # previous check should have matched filelists together
4acad02faf32 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535
tomnl
parents: 12
diff changeset
131 xset@filepaths <- unname(pa@fileList)
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
132
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
133 # Saves the EICS into the previously created database
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
134 px <- msPurity::purityX(xset, saveEIC = TRUE,
14
69d5cb5a8e90 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535-dirty
tomnl
parents: 13
diff changeset
135 cores=1, sqlitePth=db_pth,
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
136 rtrawColumns = rtrawColumns)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
137 }
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
138
11
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
139 con <- DBI::dbConnect(RSQLite::SQLite(), db_pth)
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
140
21
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
141 add_extra_table_elucidation <- function(name, pth, db_con){
19
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
142 if (is.null(pth)){
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
143 return(0)
21
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
144 }
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
145
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
146
20
74917d0e89cc planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 19
diff changeset
147 DBI::dbWriteTable(conn=db_con, name=name, value=pth, sep='\t', header=T)
11
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
148
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
149
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
150 }
c59965822dc8 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty
tomnl
parents: 1
diff changeset
151
20
74917d0e89cc planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 19
diff changeset
152 write_to_table <- function(df, db_con, name, append){
12
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
153
19
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
154 df <- df[!df$UID=='UID',]
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
155 print(filter_Score)
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
156 print(filter_Rank)
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
157 print('filter rank and score')
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
158
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
159
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
160 # get peakid, an scan id
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
161 df_ids <- stringr::str_split_fixed(df$UID, '-', 3)
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
162 colnames(df_ids) <- c('grp_id', 'file_id', 'pid')
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
163 df <- cbind(df_ids, df)
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
164 DBI::dbWriteTable(db_con, name=name, value=df, row.names=FALSE, append=append)
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
165 }
906e8e2be944 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 18
diff changeset
166
21
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
167 add_probmetab <- function(pth, xset, con){
12
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
168 if (!is.null(pth)){
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
169
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
170 df <- read.table(pth, header = TRUE, sep='\t', stringsAsFactors = FALSE, comment.char = "")
21
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
171 df$grp_id <- match(df$name, xcms::groupnames(xset))
12
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
172 start <- T
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
173 for (i in 1:nrow(df)){
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
174
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
175 x <- df[i,]
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
176
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
177
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
178 if(is.na(x$proba) | x$proba =='NA'){
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
179
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
180 next
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
181 }
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
182
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
183 mpc <- stringr::str_split(x$mpc, ';')
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
184 proba <- stringr::str_split(x$proba, ';')
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
185
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
186 for (j in 1:length(mpc[[1]])){
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
187
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
188 row <- c(x$grp_id, x$propmz, mpc[[1]][j], proba[[1]][j])
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
189
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
190 if (start){
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
191 df_out <- data.frame(t(row), stringsAsFactors=F)
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
192 start <- F
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
193 }else{
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
194 df_out <- data.frame(rbind(df_out, row), stringsAsFactors=F)
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
195 }
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
196 print(df_out)
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
197
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
198 }
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
199
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
200 }
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
201
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
202 colnames(df_out) <- c('grp_id', 'propmz', 'mpc', 'proba')
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
203 DBI::dbWriteTable(con, name='probmetab_results', value=df_out, row.names=FALSE)
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
204
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
205 }
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
206
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
207
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
208 }
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
209
22
5d47dd174435 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 21
diff changeset
210 add_extra_table_elucidation('metfrag_results', opt$metfrag_result, con)
5d47dd174435 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 21
diff changeset
211 add_extra_table_elucidation('sirius_csifingerid_results', opt$sirius_csifingerid_result, con)
21
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
212
12
225009d1f603 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 97c9122c9af9ddca3a2498185ce8c7919c0df03a
tomnl
parents: 11
diff changeset
213
20
74917d0e89cc planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 19
diff changeset
214 if (is.null(xset)){
74917d0e89cc planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 19
diff changeset
215 DBI::dbWriteTable(con, name='xset_classes', value=xa@xcmsSet@phenoData, row.names=TRUE)
21
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
216 add_probmetab(opt$probmetab_result, xset, con)
20
74917d0e89cc planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 19
diff changeset
217 }else{
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
218
20
74917d0e89cc planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 19
diff changeset
219 DBI::dbWriteTable(con, name='xset_classes', value=xset@phenoData, row.names=TRUE)
21
7f57d501badb planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 20
diff changeset
220 add_probmetab(opt$probmetab_result, xset, con)
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
221
20
74917d0e89cc planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 04023134d8f28e85927ca293373c506484149ead-dirty
tomnl
parents: 19
diff changeset
222 }
0
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
223
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
224 cmd <- paste('SELECT cpg.grpid, cpg.mz, cpg.mzmin, cpg.mzmax, cpg.rt, cpg.rtmin, cpg.rtmax, c_peaks.cid, ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
225 'c_peaks.mzmin AS c_peak_mzmin, c_peaks.mzmax AS c_peak_mzmax, ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
226 'c_peaks.rtmin AS c_peak_rtmin, c_peaks.rtmax AS c_peak_rtmax, s_peak_meta.*, fileinfo.filename, fileinfo.nm_save ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
227 'FROM c_peak_groups AS cpg ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
228 'LEFT JOIN c_peak_X_c_peak_group AS cXg ON cXg.grpid=cpg.grpid ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
229 'LEFT JOIN c_peaks on c_peaks.cid=cXg.cid ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
230 'LEFT JOIN c_peak_X_s_peak_meta AS cXs ON cXs.cid=c_peaks.cid ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
231 'LEFT JOIN s_peak_meta ON cXs.pid=s_peak_meta.pid ',
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
232 'LEFT JOIN fileinfo ON s_peak_meta.fileid=fileinfo.fileid')
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
233
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
234 print(cmd)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
235 cpeakgroup_msms <- DBI::dbGetQuery(con, cmd)
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
236
fe7d7cc95ca5 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
tomnl
parents:
diff changeset
237 write.table(cpeakgroup_msms, file.path(opt$out_dir, 'cpeakgroup_msms.tsv'), row.names=FALSE, sep='\t')