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