Mercurial > repos > tomnl > anticipated_purity_lcms
annotate create_sqlite_db.R @ 9:5969d72028f3 draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 0aa10df0ec1ed71601f932cfb11d7d4d4f620d80-dirty
| author | tomnl | 
|---|---|
| date | Wed, 02 May 2018 14:13:46 -0400 | 
| parents | b83bcc259b76 | 
| children | 3c4a548b5237 | 
| 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){ | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 10 | 
| 
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 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 44 return(list(pa, xset)) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 45 } | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 46 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 47 | 
| 
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 option_list <- list( | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 50 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 | 51 make_option("--pa", type="character"), | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 52 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 | 53 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 | 54 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 | 55 make_option("--cores", default=4), | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 56 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 | 57 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 | 58 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 | 59 make_option("--db_name", type="character", default='lcms_data.sqlite'), | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 60 make_option("--raw_rt_columns", action="store_true") | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 61 ) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 62 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 63 # store options | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 64 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 | 65 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 66 loadRData <- function(rdata_path, name){ | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 67 #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 | 68 load(rdata_path) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 69 return(get(ls()[ls() == name])) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 70 } | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 71 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 72 print(paste('pa', opt$pa)) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 73 print(opt$xset) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 74 print(opt$xcms_camera_option) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 75 # Requires | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 76 pa <- loadRData(opt$pa, 'pa') | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 77 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 78 print('TESTETSTESTETE') | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 79 print(pa@fileList) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 80 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 81 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 82 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 | 83 xset <- loadRData(opt$xset, 'xset') | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 84 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 | 85 pa <- fix[[1]] | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 86 xset <- fix[[2]] | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 87 xa <- NULL | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 88 }else{ | 
| 
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 xa <- loadRData(opt$xset, 'xa') | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 91 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 | 92 pa <- fix[[1]] | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 93 xa@xcmsSet <- fix[[2]] | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 94 xset <- NULL | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 95 } | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 96 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 97 | 
| 
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 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 100 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 101 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 | 102 grp_peaklist = NA | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 103 }else{ | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 104 grp_peaklist = opt$grp_peaklist | 
| 
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 print(pa@fileList) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 109 print(xset@filepaths) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 110 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 111 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 112 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 | 113 grp_peaklist=grp_peaklist, db_name=opt$db_name) | 
| 
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 if (!is.null(opt$eic)){ | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 117 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 | 118 rtrawColumns <- FALSE | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 119 }else{ | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 120 rtrawColumns <- TRUE | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 121 } | 
| 
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 # 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 | 124 px <- msPurity::purityX(xset, saveEIC = TRUE, | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 125 cores=opt$cores, sqlitePth=db_pth, | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 126 rtrawColumns = rtrawColumns) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 127 } | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 128 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 129 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 130 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 131 con <- DBI::dbConnect(RSQLite::SQLite(), db_pth) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 132 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 133 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 | 134 '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 | 135 '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 | 136 '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 | 137 '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 | 138 '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 | 139 '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 | 140 '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 | 141 '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 | 142 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 143 print(cmd) | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 144 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 | 145 | 
| 
c64891642e41
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2e847122cf605951c334858455fc1d3ebdb189e9-dirty
 tomnl parents: diff
changeset | 146 write.table(cpeakgroup_msms, file.path(opt$out_dir, 'cpeakgroup_msms.tsv'), row.names=FALSE, sep='\t') | 
