Mercurial > repos > tomnl > mspurity_flagremove
comparison spectralMatching.R @ 12:2c8b5a640a04 draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit bbbcc75d51c020446fd00d76f908a6250266cfea
| author | tomnl |
|---|---|
| date | Fri, 13 Sep 2019 11:49:43 -0400 |
| parents | 7e4a5ce0877d |
| children | b71677d4f958 |
comparison
equal
deleted
inserted
replaced
| 11:7e4a5ce0877d | 12:2c8b5a640a04 |
|---|---|
| 1 library(msPurity) | 1 library(msPurity) |
| 2 library(msPurityData) | 2 library(msPurityData) |
| 3 library(optparse) | 3 library(optparse) |
| 4 print(sessionInfo()) | 4 print(sessionInfo()) |
| 5 | 5 # load in library spectra config |
| 6 source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } | |
| 7 source_local("dbconfig.R") | |
| 6 | 8 |
| 7 option_list <- list( | 9 option_list <- list( |
| 8 make_option(c("-o", "--outDir"), type="character"), | 10 make_option(c("-o", "--outDir"), type="character"), |
| 9 make_option("--q_dbPth", type="character"), | 11 make_option("--q_dbPth", type="character"), |
| 10 make_option("--l_dbPth", type="character"), | 12 make_option("--l_dbPth", type="character"), |
| 13 | |
| 14 make_option("--q_dbType", type="character", default=NA), | |
| 15 make_option("--l_dbType", type="character", default=NA), | |
| 11 | 16 |
| 12 make_option("--q_msp", type="character", default=NA), | 17 make_option("--q_msp", type="character", default=NA), |
| 13 make_option("--l_msp", type="character", default=NA), | 18 make_option("--l_msp", type="character", default=NA), |
| 14 | 19 |
| 15 make_option("--q_defaultDb", action="store_true"), | 20 make_option("--q_defaultDb", action="store_true"), |
| 96 | 101 |
| 97 } | 102 } |
| 98 | 103 |
| 99 if(!is.null(opt$q_defaultDb)){ | 104 if(!is.null(opt$q_defaultDb)){ |
| 100 q_dbPth <- system.file("extdata", "library_spectra", "library_spectra.db", package="msPurityData") | 105 q_dbPth <- system.file("extdata", "library_spectra", "library_spectra.db", package="msPurityData") |
| 101 }else if (!is.null(opt$q_dbPth)){ | 106 q_dbType <- 'sqlite' |
| 107 }else if (!opt$q_dbType=='local_config'){ | |
| 108 q_dbType <- opt$q_dbType | |
| 102 q_dbPth <- opt$q_dbPth | 109 q_dbPth <- opt$q_dbPth |
| 103 }else{ | |
| 104 message('No query database available') | |
| 105 exit() | |
| 106 } | 110 } |
| 107 | 111 |
| 108 if(!is.null(opt$l_defaultDb)){ | 112 if(!is.null(opt$l_defaultDb)){ |
| 109 l_dbPth <- system.file("extdata", "library_spectra", "library_spectra.db", package="msPurityData") | 113 l_dbPth <- system.file("extdata", "library_spectra", "library_spectra.db", package="msPurityData") |
| 110 }else if (!is.null(opt$l_dbPth)){ | 114 l_dbType <- 'sqlite' |
| 115 }else if (!opt$l_dbType=='local_config'){ | |
| 116 l_dbType <- opt$l_dbType | |
| 111 l_dbPth <- opt$l_dbPth | 117 l_dbPth <- opt$l_dbPth |
| 112 }else{ | 118 } |
| 113 message('No library database available') | 119 |
| 114 exit() | 120 |
| 115 } | |
| 116 | 121 |
| 117 | 122 |
| 118 q_polarity <- extractMultiple(opt$q_polarity) | 123 q_polarity <- extractMultiple(opt$q_polarity) |
| 119 l_polarity <- extractMultiple(opt$l_polarity) | 124 l_polarity <- extractMultiple(opt$l_polarity) |
| 120 | 125 |
| 188 q_rtrangeMin <- NA | 193 q_rtrangeMin <- NA |
| 189 } | 194 } |
| 190 | 195 |
| 191 | 196 |
| 192 | 197 |
| 193 sm <- msPurity::spectralMatching(q_dbPth = q_dbPth, | 198 sm <- msPurity::spectralMatching( |
| 194 l_dbPth = l_dbPth, | |
| 195 | |
| 196 q_purity = opt$q_purity, | 199 q_purity = opt$q_purity, |
| 197 l_purity = opt$l_purity, | 200 l_purity = opt$l_purity, |
| 198 | 201 |
| 199 q_ppmProd = opt$q_ppmProd, | 202 q_ppmProd = opt$q_ppmProd, |
| 200 l_ppmProd = opt$l_ppmProd, | 203 l_ppmProd = opt$l_ppmProd, |
| 234 rttol=opt$rttol, | 237 rttol=opt$rttol, |
| 235 cores=opt$cores, | 238 cores=opt$cores, |
| 236 | 239 |
| 237 copyDb=copyDb, | 240 copyDb=copyDb, |
| 238 updateDb=updateDb, | 241 updateDb=updateDb, |
| 239 outPth = "db_with_spectral_matching.sqlite" | 242 outPth = "db_with_spectral_matching.sqlite", |
| 243 | |
| 244 q_dbPth = q_dbPth, | |
| 245 q_dbType = q_dbType, | |
| 246 q_dbName = q_dbName, | |
| 247 q_dbHost = q_dbHost, | |
| 248 q_dbUser = q_dbUser, | |
| 249 q_dbPass = q_dbPass, | |
| 250 q_dbPort = q_dbPort, | |
| 251 | |
| 252 l_dbPth = l_dbPth, | |
| 253 l_dbType = l_dbType, | |
| 254 l_dbName = l_dbName, | |
| 255 l_dbHost = l_dbHost, | |
| 256 l_dbUser = l_dbUser, | |
| 257 l_dbPass = l_dbPass, | |
| 258 l_dbPort = l_dbPort | |
| 259 | |
| 240 ) | 260 ) |
| 241 | 261 |
| 242 | 262 |
| 243 | 263 |
| 244 write.table(sm$matchedResults, 'matched_results.tsv', sep = '\t', row.names = FALSE, col.names = TRUE) | 264 write.table(sm$matchedResults, 'matched_results.tsv', sep = '\t', row.names = FALSE, col.names = TRUE) |
