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