Repository 'mspurity_averagefragspectra'
hg clone https://toolshed.g2.bx.psu.edu/repos/computational-metabolomics/mspurity_averagefragspectra

Changeset 6:52d48bcd3608 (2021-03-04)
Previous changeset 5:e79c1a0654af (2020-11-13) Next changeset 7:94eb1fcfde88 (2022-02-08)
Commit message:
"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2579c8746819670348c378f86116f83703c493eb"
modified:
README.rst
averageFragSpectra.R
combineAnnotations.R
createDatabase.R
createMSP.R
dbconfig.R
dimsPredictPuritySingle.R
filterFragSpectra.R
flagRemove.R
frag4feature.R
macros.xml
purityA.R
purityX.R
spectralMatching.R
test-data/createDatabase_output.sqlite
test-data/createDatabase_output_eic.sqlite
test-data/createMSP_output_av_all_metadata.msp
test-data/createMSP_output_av_all_metadata_custom_adducts.msp
test-data/spectralMatching_db_with_spectral_matching.sqlite
test-data/spectralMatching_db_with_spectral_matching_instrumentTypes.sqlite
test-data/spectralMatching_matched_results.tsv
test-data/spectralMatching_matched_results_instrumentTypes.tsv
test-data/spectralMatching_xcms_matched_results.tsv
test-data/spectralMatching_xcms_matched_results_instrumentTypes.tsv
b
diff -r e79c1a0654af -r 52d48bcd3608 README.rst
--- a/README.rst Fri Nov 13 09:55:01 2020 +0000
+++ b/README.rst Thu Mar 04 12:29:17 2021 +0000
b
@@ -3,13 +3,13 @@
 |Build Status (Travis)| |Git| |Bioconda| |License|
 
 
-Version v1.12.2+galaxy2
-------
+Version v1.16.2+galaxy0
+------------------------
 
   - msPurity
-     - bioconductor-mspurity v1.12.2
+     - bioconductor-mspurity v1.16.2
   - Galaxy tools
-     - v3
+     - v0
 
 About
 ------
@@ -35,17 +35,17 @@
 
 
 Dependencies
-------
-Dependencies for these Galaxy tools should be handled by CONDA. The most recent version of the msPurity R package can found on channel  `tomnl <https://anaconda.org/tomnl/bioconductor-mspurity>`_ on `anaconda <https://anaconda.org/tomnl/bioconductor-mspurity>`_. Warning this will be a different version of the package compared to the BICONDA bioconductor-mspurity.
+------------------
+Dependencies for these Galaxy tools should be handled by CONDA.
 
 
 Galaxy
-------
+------------------
 `Galaxy <https://galaxyproject.org>`_ is an open, web-based platform for data intensive biomedical research. Whether on the free public server or your own instance, you can perform, reproduce, and share complete analyses.
 
 
 Authors, contributors & contacts
--------------------------
+-------------------------------------
 
 - Thomas N. Lawson (t.n.lawson@bham.ac.uk) - `University of Birmingham (UK) <http://www.birmingham.ac.uk/index.aspx>`_
 - Ralf J. M. Weber (r.j.weber@bham.ac.uk) - `University of Birmingham (UK) <http://www.birmingham.ac.uk/index.aspx>`_
@@ -55,6 +55,15 @@
 
 Changes
 -------------------------
+v1.16.2-galaxy0
+  - Version bump
+  - Fix for intra spectral matching
+  - Fix for typo https://github.com/computational-metabolomics/mspurity-galaxy/pull/43
+  - Lint fixes
+
+v1.12.2-galaxy3
+  - Bug fix reference to offsets in conditional #41
+
 v1.12.2-galaxy2
   - Bug fix for using custom library sqlite database from Galaxy UI
   - Bug fix for "allfrag" for createDatabase
@@ -70,7 +79,7 @@
   - Update to version v1.12.2 of `msPurity <https://github.com/computational-metabolomics/msPurity/pull/71>`_
   - Optional summary output for combineAnnotations (for very large output)
   - Extra column added to flagRemove output
-  - Hide probmetab input 
+  - Hide probmetab input
   - Make dimsPredictPuritySingle more compatible with "simple workflow inputs"
 
 
@@ -83,7 +92,7 @@
   - Username updated in Toolshed yaml
 
 v1.12.0-galaxy0
-  - Updates for Bioconductor stable msPurity v1.12.0 release 
+  - Updates for Bioconductor stable msPurity v1.12.0 release
   - Additional columns added for spectral matching (for msnpy use case)
   - Merge of v1.11.4-galaxy1
 
b
diff -r e79c1a0654af -r 52d48bcd3608 averageFragSpectra.R
--- a/averageFragSpectra.R Fri Nov 13 09:55:01 2020 +0000
+++ b/averageFragSpectra.R Thu Mar 04 12:29:17 2021 +0000
[
b'@@ -4,33 +4,33 @@\n print(sessionInfo())\n \n \n-get_av_spectra <- function(x){\n+get_av_spectra <- function(x) {\n \n-  if (length(x$av_intra)>0){\n+  if (length(x$av_intra) > 0) {\n     av_intra_df <- plyr::ldply(x$av_intra)\n \n-    if (nrow(av_intra_df)==0){\n+    if (nrow(av_intra_df) == 0) {\n       av_intra_df <- NULL\n     }else{\n-      av_intra_df$method <- \'intra\'\n+      av_intra_df$method <- "intra"\n     }\n \n   }else{\n     av_intra_df <- NULL\n   }\n \n-  if ((is.null(x$av_inter)) || (nrow(x$av_inter)==0)){\n+  if ((is.null(x$av_inter)) || (nrow(x$av_inter) == 0)) {\n     av_inter_df <- NULL\n   }else{\n     av_inter_df <- x$av_inter\n-    av_inter_df$method <- \'inter\'\n+    av_inter_df$method <- "inter"\n   }\n \n-  if ((is.null(x$av_all)) || (nrow(x$av_all)==0)){\n+  if ((is.null(x$av_all)) || (nrow(x$av_all) == 0)) {\n     av_all_df <- NULL\n   }else{\n     av_all_df <- x$av_all\n-    av_all_df$method <- \'all\'\n+    av_all_df$method <- "all"\n   }\n \n   combined <- plyr::rbind.fill(av_intra_df, av_inter_df, av_all_df)\n@@ -40,126 +40,116 @@\n \n \n option_list <- list(\n-  make_option("--out_rdata", type="character"),\n-  make_option("--out_peaklist", type="character"),\n-  make_option("--pa", type="character"),\n-\n-  make_option("--av_level", type="character"),\n-\n-  make_option("--minfrac", default=0.5),\n-  make_option("--minnum", default=1),\n-  make_option("--ppm", default=5.0),\n-\n-  make_option("--snr", default=0),\n-\n-  make_option("--ra", default=0),\n-\n-  make_option("--av", default="median", type="character"),\n-  make_option("--sumi", action="store_true"),\n-\n-  make_option("--rmp", action="store_true"),\n-  make_option("--cores", default=1)\n+  make_option("--out_rdata", type = "character"),\n+  make_option("--out_peaklist", type = "character"),\n+  make_option("--pa", type = "character"),\n+  make_option("--av_level", type = "character"),\n+  make_option("--minfrac", default = 0.5),\n+  make_option("--minnum", default = 1),\n+  make_option("--ppm", default = 5.0),\n+  make_option("--snr", default = 0),\n+  make_option("--ra", default = 0),\n+  make_option("--av", default = "median", type = "character"),\n+  make_option("--sumi", action = "store_true"),\n+  make_option("--rmp", action = "store_true"),\n+  make_option("--cores", default = 1)\n )\n \n-opt <- parse_args(OptionParser(option_list=option_list))\n+opt <- parse_args(OptionParser(option_list = option_list))\n print(opt)\n \n \n-loadRData <- function(rdata_path, name){\n-#loads an RData file, and returns the named xset object if it is there\n+load_r_data <- function(rdata_path, name) {\n+    #loads an RData file, and returns the named xset object if it is there\n     load(rdata_path)\n     return(get(ls()[ls() %in% name]))\n }\n \n # Requires\n-pa <- loadRData(opt$pa, \'pa\')\n+pa <- load_r_data(opt$pa, "pa")\n \n pa@cores <- opt$cores\n \n-if(is.null(opt$rmp)){\n-  rmp = FALSE\n+if (is.null(opt$rmp)) {\n+  rmp <- FALSE\n }else{\n-  rmp = TRUE\n+  rmp <- TRUE\n }\n \n-if(is.null(opt$sumi)){\n-\n-  sumi = FALSE\n+if (is.null(opt$sumi)) {\n+  sumi <- FALSE\n }else{\n-  sumi = TRUE\n-\n+  sumi <- TRUE\n }\n \n-\n-if(opt$av_level=="intra"){\n-\n+if (opt$av_level == "intra") {\n   pa <- msPurity::averageIntraFragSpectra(pa,\n-                                      minfrac=opt$minfrac,\n-                                      minnum=opt$minnum,\n-                                      ppm=opt$ppm,\n-                                      snr=opt$snr,\n-                                      ra=opt$ra,\n-                                      av=opt$av,\n-                                      sumi=sumi,\n-                                      rmp=rmp,\n-                                      cores=opt$cores)\n+                                          minfrac = opt$minfrac,\n+                                          minnum = opt$minnum,\n+                                          ppm = opt$ppm,\n+                                          snr = opt$snr,\n+                                          ra = opt$ra,\n+                                          av = opt$av,\n+              '..b'                   minfrac=opt$minfrac,\n-                                      minnum=opt$minnum,\n-                                      ppm=opt$ppm,\n-                                      snr=opt$snr,\n-                                      ra=opt$ra,\n-                                      av=opt$av,\n-                                      sumi=sumi,\n-                                      rmp=rmp,\n-                                      cores=opt$cores)\n-} else if(opt$av_level=="all"){\n+                                          minfrac = opt$minfrac,\n+                                          minnum = opt$minnum,\n+                                          ppm = opt$ppm,\n+                                          snr = opt$snr,\n+                                          ra = opt$ra,\n+                                          av = opt$av,\n+                                          sumi = sumi,\n+                                          rmp = rmp,\n+                                          cores = opt$cores)\n+} else if (opt$av_level == "all") {\n \n   pa <- msPurity::averageAllFragSpectra(pa,\n-                                        minfrac=opt$minfrac,\n-                                        minnum=opt$minnum,\n-                                        ppm=opt$ppm,\n-                                        snr=opt$snr,\n-                                        ra=opt$ra,\n-                                        av=opt$av,\n-                                        sumi=sumi,\n-                                        rmp=rmp,\n-                                        cores=opt$cores)\n-\n+                                        minfrac = opt$minfrac,\n+                                        minnum = opt$minnum,\n+                                        ppm = opt$ppm,\n+                                        snr = opt$snr,\n+                                        ra = opt$ra,\n+                                        av = opt$av,\n+                                        sumi = sumi,\n+                                        rmp = rmp,\n+                                        cores = opt$cores)\n }\n \n print(pa)\n-save(pa, file=opt$out_rdata)\n+save(pa, file = opt$out_rdata)\n \n-\n-if (length(pa)>0){\n+if (length(pa) > 0) {\n \n   av_spectra <- plyr::ldply(pa@av_spectra, get_av_spectra)\n \n-  if (nrow(av_spectra)==0){\n-    message(\'No average spectra available\')\n-  } else{\n-    colnames(av_spectra)[1] <- \'grpid\'\n+  if (nrow(av_spectra) == 0) {\n+    message("No average spectra available")\n+  } else {\n+    colnames(av_spectra)[1] <- "grpid"\n     av_spectra$grpid <- names(pa@av_spectra)[av_spectra$grpid]\n-    \n-    if((length(pa@av_intra_params)>0) || (length(pa@av_inter_params)>0) ){\n-        # Add some extra info (only required if av_intra or av_inter performed)\n-        colnames(av_spectra)[2] <- \'fileid\'\n-        av_spectra$avid <- 1:nrow(av_spectra)\n-        \n-        filenames <- sapply(av_spectra$fileid, function(x) names(pa@fileList)[as.integer(x)])\n-        # filenames_galaxy <- sapply(av_spectra$fileid, function(x) basename(pa@fileList[as.integer(x)]))\n-        \n-        av_spectra = as.data.frame(append(av_spectra, list(filename = filenames), after=2))\n+\n+    if ((length(pa@av_intra_params) > 0) || (length(pa@av_inter_params) > 0)) {\n+      # Add some extra info (only required if av_intra or av_inter performed)\n+      colnames(av_spectra)[2] <- "fileid"\n+      av_spectra$avid <- seq_len(nrow(av_spectra))\n+\n+      filenames <- sapply(av_spectra$fileid,\n+                          function(x) names(pa@fileList)[as.integer(x)])\n+      # filenames_galaxy <- sapply(\n+      #    av_spectra$fileid, function(x) basename(pa@fileList[as.integer(x)]))\n+\n+        av_spectra <- as.data.frame(\n+          append(av_spectra, list(filename = filenames), after = 2))\n     }\n \n \n     print(head(av_spectra))\n-    write.table(av_spectra, opt$out_peaklist, row.names=FALSE, sep=\'\\t\')\n+    write.table(av_spectra, opt$out_peaklist, row.names = FALSE, sep = "\\t")\n \n   }\n }\n-\n'
b
diff -r e79c1a0654af -r 52d48bcd3608 combineAnnotations.R
--- a/combineAnnotations.R Fri Nov 13 09:55:01 2020 +0000
+++ b/combineAnnotations.R Thu Mar 04 12:29:17 2021 +0000
[
b'@@ -4,115 +4,120 @@\n \n # Get the parameter\n option_list <- list(\n-  make_option(c("-s","--sm_resultPth"),type="character"),\n-  make_option(c("-m","--metfrag_resultPth"),type="character"),\n-  make_option(c("-c","--sirius_csi_resultPth"),type="character"),\n-  make_option(c("-p","--probmetab_resultPth"),type="character"),\n-  make_option(c("-l","--ms1_lookup_resultPth"),type="character"),\n+  make_option(c("-s", "--sm_resultPth"), type = "character"),\n+  make_option(c("-m", "--metfrag_resultPth"), type = "character"),\n+  make_option(c("-c", "--sirius_csi_resultPth"), type = "character"),\n+  make_option(c("-p", "--probmetab_resultPth"), type = "character"),\n+  make_option(c("-l", "--ms1_lookup_resultPth"), type = "character"),\n \n-  make_option("--ms1_lookup_checkAdducts", action="store_true"),\n-  make_option("--ms1_lookup_keepAdducts", type="character", default=NA),\n-  make_option("--ms1_lookup_dbSource", type="character", default="hmdb"),\n+  make_option("--ms1_lookup_checkAdducts", action = "store_true"),\n+  make_option("--ms1_lookup_keepAdducts", type = "character", default = NA),\n+  make_option("--ms1_lookup_dbSource", type = "character", default = "hmdb"),\n \n-  make_option("--sm_weight", type="numeric"),\n-  make_option("--metfrag_weight", type="numeric"),\n-  make_option("--sirius_csi_weight", type="numeric"),\n-  make_option("--probmetab_weight", type="numeric"),\n-  make_option("--ms1_lookup_weight", type="numeric"),\n-  make_option("--biosim_weight", type="numeric"),\n-  \n-  make_option("--summaryOutput", action="store_true"),\n-  \n-  make_option("--create_new_database", action="store_true"),\n-  make_option("--outdir", type="character", default="."),\n+  make_option("--sm_weight", type = "numeric"),\n+  make_option("--metfrag_weight", type = "numeric"),\n+  make_option("--sirius_csi_weight", type = "numeric"),\n+  make_option("--probmetab_weight", type = "numeric"),\n+  make_option("--ms1_lookup_weight", type = "numeric"),\n+  make_option("--biosim_weight", type = "numeric"),\n+\n+  make_option("--summaryOutput", action = "store_true"),\n \n-  make_option("--compoundDbType", type="character", default="sqlite"),\n-  make_option("--compoundDbPth", type="character", default=NA),\n-  make_option("--compoundDbHost", type="character", default=NA)\n+  make_option("--create_new_database", action = "store_true"),\n+  make_option("--outdir", type = "character", default = "."),\n+\n+  make_option("--compoundDbType", type = "character", default = "sqlite"),\n+  make_option("--compoundDbPth", type = "character", default = NA),\n+  make_option("--compoundDbHost", type = "character", default = NA)\n )\n-opt <- parse_args(OptionParser(option_list=option_list))\n+opt <- parse_args(OptionParser(option_list = option_list))\n \n print(opt)\n \n-if (!is.null(opt$create_new_database)){\n-  sm_resultPth <-  file.path(opt$outdir, \'combined_annotations.sqlite\')\n+if (!is.null(opt$create_new_database)) {\n+  sm_resultPth <- file.path(opt$outdir, "combined_annotations.sqlite")\n   file.copy(opt$sm_resultPth, sm_resultPth)\n }else{\n   sm_resultPth <- opt$sm_resultPth\n }\n \n-if (is.null(opt$ms1_lookup_checkAdducts)){\n+if (is.null(opt$ms1_lookup_checkAdducts)) {\n   opt$ms1_lookup_checkAdducts <- FALSE\n }\n-if (!is.null(opt$ms1_lookup_keepAdducts)){\n+if (!is.null(opt$ms1_lookup_keepAdducts)) {\n     opt$ms1_lookup_keepAdducts <- gsub("__ob__", "[", opt$ms1_lookup_keepAdducts)\n     opt$ms1_lookup_keepAdducts <- gsub("__cb__", "]", opt$ms1_lookup_keepAdducts)\n     ms1_lookup_keepAdducts <- strsplit(opt$ms1_lookup_keepAdducts, ",")[[1]]\n }\n \n-weights <-list(\'sm\'=opt$sm_weight,\n-               \'metfrag\'=opt$metfrag_weight,\n-               \'sirius_csifingerid\'= opt$sirius_csi_weight,\n-               \'probmetab\'=opt$probmetab_weight,\n-               \'ms1_lookup\'=opt$ms1_lookup_weight,\n-               \'biosim\'=opt$biosim_weight\n+weights <- list("sm" = opt$sm_weight,\n+               "metfrag" = opt$metfrag_weight,\n+               "sirius_csifingerid" = opt$sirius_csi_weight,\n+               "probmetab'..b't(weights), 0) == 1)) {\n+  stop(paste0("The weights should sum to 1 not ", sum(unlist(weights))))\n }\n \n-if (is.null(opt$summaryOutput)){\n-  summaryOutput = FALSE\n+if (is.null(opt$summaryOutput)) {\n+  summaryOutput <- FALSE\n }else{\n- summaryOutput = TRUE\n+ summaryOutput <- TRUE\n }\n \n-if (opt$compoundDbType==\'local_config\'){\n+if (opt$compoundDbType == "local_config") {\n   # load in compound config\n   # Soure local function taken from workflow4metabolomics\n-  source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) }\n+  source_local <- function(fname) {\n+    argv <- commandArgs(trailingOnly = FALSE)\n+    base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))\n+    source(paste(base_dir, fname, sep = "/"))\n+  }\n   source_local("dbconfig.R")\n }else{\n-  compoundDbPth = opt$compoundDbPth\n-  compoundDbType = opt$compoundDbType\n-  compoundDbName = NA\n-  compoundDbHost = NA\n-  compoundDbPort = NA\n-  compoundDbUser = NA\n-  compoundDbPass = NA\n+  compoundDbPth <- opt$compoundDbPth\n+  compoundDbType <- opt$compoundDbType\n+  compoundDbName <- NA\n+  compoundDbHost <- NA\n+  compoundDbPort <- NA\n+  compoundDbUser <- NA\n+  compoundDbPass <- NA\n }\n \n summary_output <- msPurity::combineAnnotations(\n-                            sm_resultPth = sm_resultPth,\n-                            compoundDbPth = compoundDbPth,\n-                            metfrag_resultPth = opt$metfrag_resultPth,\n-                            sirius_csi_resultPth = opt$sirius_csi_resultPth,\n-                            probmetab_resultPth = opt$probmetab_resultPth,\n-                            ms1_lookup_resultPth = opt$ms1_lookup_resultPth,\n-                            ms1_lookup_keepAdducts = ms1_lookup_keepAdducts,\n-                            ms1_lookup_checkAdducts = opt$ms1_lookup_checkAdducts,\n+                          sm_resultPth = sm_resultPth,\n+                          compoundDbPth = compoundDbPth,\n+                          metfrag_resultPth = opt$metfrag_resultPth,\n+                          sirius_csi_resultPth = opt$sirius_csi_resultPth,\n+                          probmetab_resultPth = opt$probmetab_resultPth,\n+                          ms1_lookup_resultPth = opt$ms1_lookup_resultPth,\n+                          ms1_lookup_keepAdducts = ms1_lookup_keepAdducts,\n+                          ms1_lookup_checkAdducts = opt$ms1_lookup_checkAdducts,\n \n-                            compoundDbType = compoundDbType,\n-                            compoundDbName = compoundDbName,\n-                            compoundDbHost = compoundDbHost,\n-                            compoundDbPort = compoundDbPort,\n-                            compoundDbUser = compoundDbUser,\n-                            compoundDbPass = compoundDbPass,\n-                            weights = weights,\n-                            summaryOutput = summaryOutput)\n-if (summaryOutput){\n-  write.table(summary_output, file.path(opt$outdir, \'combined_annotations.tsv\'), sep = \'\\t\', row.names = FALSE)\n+                         compoundDbType = compoundDbType,\n+                         compoundDbName = compoundDbName,\n+                         compoundDbHost = compoundDbHost,\n+                         compoundDbPort = compoundDbPort,\n+                         compoundDbUser = compoundDbUser,\n+                         compoundDbPass = compoundDbPass,\n+                         weights = weights,\n+                         summaryOutput = summaryOutput)\n+if (summaryOutput) {\n+  write.table(summary_output,\n+              file.path(opt$outdir, "combined_annotations.tsv"),\n+              sep = "\\t", row.names = FALSE)\n }\n \n-\n-write.table(summary_output, file.path(opt$outdir, \'combined_annotations.tsv\'), sep = \'\\t\', row.names = FALSE)\n-\n+write.table(summary_output,\n+            file.path(opt$outdir, "combined_annotations.tsv"),\n+            sep = "\\t", row.names = FALSE)\n \n closeAllConnections()\n-\n'
b
diff -r e79c1a0654af -r 52d48bcd3608 createDatabase.R
--- a/createDatabase.R Fri Nov 13 09:55:01 2020 +0000
+++ b/createDatabase.R Thu Mar 04 12:29:17 2021 +0000
[
@@ -3,19 +3,18 @@
 library(xcms)
 library(CAMERA)
 print(sessionInfo())
-print('CREATING DATABASE')
+print("CREATING DATABASE")
 
-xset_pa_filename_fix <- function(opt, pa, xset){
+xset_pa_filename_fix <- function(opt, pa, xset) {
 
-  if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)){
+  if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)) {
     # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables
     # needs to be done due to Galaxy moving the files around and screwing up any links to files
 
-    filepaths <- trimws(strsplit(opt$mzML_files, ',')[[1]])
+    filepaths <- trimws(strsplit(opt$mzML_files, ",")[[1]])
     filepaths <- filepaths[filepaths != ""]
-    new_names <- basename(filepaths)
 
-    galaxy_names <- trimws(strsplit(opt$galaxy_names, ',')[[1]])
+    galaxy_names <- trimws(strsplit(opt$galaxy_names, ",")[[1]])
     galaxy_names <- galaxy_names[galaxy_names != ""]
 
     nsave <- names(pa@fileList)
@@ -28,10 +27,10 @@
   }
 
 
- if(!all(basename(pa@fileList)==basename(xset@filepaths))){
-    if(!all(names(pa@fileList)==basename(xset@filepaths))){
-       print('FILELISTS DO NOT MATCH')
-       message('FILELISTS DO NOT MATCH')
+ if (!all(basename(pa@fileList) == basename(xset@filepaths))) {
+    if (!all(names(pa@fileList) == basename(xset@filepaths))) {
+       print("FILELISTS DO NOT MATCH")
+       message("FILELISTS DO NOT MATCH")
        quit(status = 1)
     }else{
       xset@filepaths <- unname(pa@fileList)
@@ -48,23 +47,23 @@
 
 
 option_list <- list(
-  make_option(c("-o", "--outDir"), type="character"),
-  make_option("--pa", type="character"),
-  make_option("--xset_xa", type="character"),
-  make_option("--xcms_camera_option", type="character"),
-  make_option("--eic", action="store_true"),
-  make_option("--cores", default=4),
-  make_option("--mzML_files", type="character"),
-  make_option("--galaxy_names", type="character"),
-  make_option("--grpPeaklist", type="character")
+  make_option(c("-o", "--outDir"), type = "character"),
+  make_option("--pa", type = "character"),
+  make_option("--xset_xa", type = "character"),
+  make_option("--xcms_camera_option", type = "character"),
+  make_option("--eic", action = "store_true"),
+  make_option("--cores", default = 4),
+  make_option("--mzML_files", type = "character"),
+  make_option("--galaxy_names", type = "character"),
+  make_option("--grpPeaklist", type = "character")
 )
 
 
 # store options
-opt<- parse_args(OptionParser(option_list=option_list))
+opt <- parse_args(OptionParser(option_list = option_list))
 print(opt)
 
-loadRData <- function(rdata_path, name){
+loadRData <- function(rdata_path, name) {
 #loads an RData file, and returns the named xset object if it is there
     load(rdata_path)
     return(get(ls()[ls() %in% name]))
@@ -73,36 +72,36 @@
 getxcmsSetObject <- function(xobject) {
     # XCMS 1.x
     if (class(xobject) == "xcmsSet")
-        return (xobject)
+        return(xobject)
     # XCMS 3.x
     if (class(xobject) == "XCMSnExp") {
         # Get the legacy xcmsSet object
-        suppressWarnings(xset <- as(xobject, 'xcmsSet'))
-        sampclass(xset) <- xset@phenoData$sample_group
-        return (xset)
+        suppressWarnings(xset <- as(xobject, "xcmsSet"))
+        xcms::sampclass(xset) <- xset@phenoData$sample_group
+        return(xset)
     }
 }
 
 
-print(paste('pa', opt$pa))
+print(paste("pa", opt$pa))
 print(opt$xset)
 
 print(opt$xcms_camera_option)
 # Requires
-pa <- loadRData(opt$pa, 'pa')
+pa <- loadRData(opt$pa, "pa")
 
 
 print(pa@fileList)
 
 # Missing list element causes failures (should be updated
 # in msPurity R package for future releases)
-if (!exists('allfrag', where=pa@filter_frag_params)){
+if (!exists("allfrag", where = pa@filter_frag_params)) {
     pa@filter_frag_params$allfrag <- FALSE
 }
 
-if (opt$xcms_camera_option=='xcms'){
+if (opt$xcms_camera_option == "xcms") {
 
-  xset <- loadRData(opt$xset, c('xset','xdata'))
+  xset <- loadRData(opt$xset, c("xset", "xdata"))
   xset <- getxcmsSetObject(xset)
   fix <- xset_pa_filename_fix(opt, pa, xset)
   pa <- fix[[1]]
@@ -110,7 +109,7 @@
   xa <- NULL
 }else{
 
-  xa <- loadRData(opt$xset, 'xa')
+  xa <- loadRData(opt$xset, "xa")
   fix <- xset_pa_filename_fix(opt, pa, xa@xcmsSet)
   pa <- fix[[1]]
   xa@xcmsSet <- fix[[2]]
@@ -118,36 +117,33 @@
 }
 
 
-
-if(is.null(opt$grpPeaklist)){
-  grpPeaklist = NA
+if (is.null(opt$grpPeaklist)) {
+  grpPeaklist <- NA
 }else{
-  grpPeaklist = opt$grpPeaklist
+  grpPeaklist <- opt$grpPeaklist
 }
 
-
-
 dbPth <- msPurity::createDatabase(pa,
-                                   xset=xset,
-                                   xsa=xa,
-                                   outDir=opt$outDir,
-                                   grpPeaklist=grpPeaklist,
-                                   dbName='createDatabase_output.sqlite'
+                                   xset = xset,
+                                   xsa = xa,
+                                   outDir = opt$outDir,
+                                   grpPeaklist = grpPeaklist,
+                                   dbName = "createDatabase_output.sqlite"
 )
 
 
 
 
 
-if (!is.null(opt$eic)){
+if (!is.null(opt$eic)) {
 
-  if (is.null(xset)){
+  if (is.null(xset)) {
       xset <- xa@xcmsSet
   }
   # previous check should have matched filelists together
   xset@filepaths <- unname(pa@fileList)
 
-  convert2Raw <- function(x, xset){
+  convert2Raw <- function(x, xset) {
     sid <- unique(x$sample)
     # for each file get list of peaks
     x$rt_raw <- xset@rt$raw[[sid]][match(x$rt, xset@rt$corrected[[sid]])]
@@ -157,13 +153,14 @@
 
   }
 
-  xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset))
+  xset@peaks <- as.matrix(
+    plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset = xset))
 
   # Saves the EICS into the previously created database
   px <- msPurity::purityX(xset,
                           saveEIC = TRUE,
-                          cores=1,
-                          sqlitePth=dbPth,
+                          cores = 1,
+                          sqlitePth = dbPth,
                           rtrawColumns = TRUE)
 
 }
b
diff -r e79c1a0654af -r 52d48bcd3608 createMSP.R
--- a/createMSP.R Fri Nov 13 09:55:01 2020 +0000
+++ b/createMSP.R Thu Mar 04 12:29:17 2021 +0000
[
@@ -4,39 +4,40 @@
 
 # Get the parameter
 option_list <- list(
-  make_option("--rdata_input",type="character"),
-  make_option("--method",type="character"),
-  make_option("--metadata",type="character"),
-  make_option("--metadata_cols",type="character"),
-  make_option("--metadata_cols_filter",type="character"),
-  make_option("--adduct_split", action="store_true"),
-  make_option("--xcms_groupids",type="character"),
-  make_option("--filter",action="store_true"),
-  make_option("--intensity_ra",type="character"),
-  make_option("--include_adducts",type="character"),
-  make_option("--msp_schema",type="character"),
-  make_option("--include_adducts_custom",type="character", default=""),
-  make_option("--out_dir",type="character", default=".")
+  make_option("--rdata_input", type = "character"),
+  make_option("--method", type = "character"),
+  make_option("--metadata", type = "character"),
+  make_option("--metadata_cols", type = "character"),
+  make_option("--metadata_cols_filter", type = "character"),
+  make_option("--adduct_split", action = "store_true"),
+  make_option("--xcms_groupids", type = "character"),
+  make_option("--filter", action = "store_true"),
+  make_option("--intensity_ra", type = "character"),
+  make_option("--include_adducts", type = "character"),
+  make_option("--msp_schema", type = "character"),
+  make_option("--include_adducts_custom", type = "character", default = ""),
+  make_option("--out_dir", type = "character", default = ".")
 )
-opt <- parse_args(OptionParser(option_list=option_list))
+opt <- parse_args(OptionParser(option_list = option_list))
 
 print(opt)
 
 load(opt$rdata_input)
 
-if (is.null(opt$metadata)){
+if (is.null(opt$metadata)) {
   metadata <- NULL
 }else{
-  metadata <- read.table(opt$metadata,  header = TRUE, sep='\t', stringsAsFactors = FALSE, check.names = FALSE)
+  metadata <- read.table(opt$metadata,  header = TRUE, sep = "\t",
+                         stringsAsFactors = FALSE, check.names = FALSE)
 
-  if(!opt$metadata_cols_filter==''){
-     metadata_cols_filter <- strsplit(opt$metadata_cols_filter, ',')[[1]]
+  if (!opt$metadata_cols_filter == "") {
+     metadata_cols_filter <- strsplit(opt$metadata_cols_filter, ",")[[1]]
 
-     metadata <- metadata[,metadata_cols_filter, drop=FALSE]
+     metadata <- metadata[, metadata_cols_filter, drop = FALSE]
      print(metadata)
 
-     if (!"grpid" %in% colnames(metadata)){
-       metadata$grpid <- 1:nrow(metadata)
+     if (!"grpid" %in% colnames(metadata)) {
+       metadata$grpid <- seq_len(nrow(metadata))
      }
 
      print(metadata)
@@ -47,7 +48,7 @@
 
 
 
-if (is.null(opt$metadata_cols) || opt$metadata_cols==''){
+if (is.null(opt$metadata_cols) || opt$metadata_cols == "") {
     metadata_cols <- NULL
 }else{
     metadata_cols <- opt$metadata_cols
@@ -55,36 +56,33 @@
 }
 
 
-if(is.null(opt$adduct_split)){
+if (is.null(opt$adduct_split)) {
   adduct_split <- FALSE
 }else{
   adduct_split <- TRUE
 }
 
-if (is.null(opt$xcms_groupids)){
+if (is.null(opt$xcms_groupids)) {
   xcms_groupids <- NULL
 }else{
-  xcms_groupids <- trimws(strsplit(opt$xcms_groupids, ',')[[1]])
+  xcms_groupids <- trimws(strsplit(opt$xcms_groupids, ",")[[1]])
 }
 
 
-
-
-
-if (is.null(opt$include_adducts_custom)){
-  include_adducts_custom <- ''
+if (is.null(opt$include_adducts_custom)) {
+  include_adducts_custom <- ""
 }else{
   include_adducts_custom <- opt$include_adducts_custom
 }
 
 
-if (opt$include_adducts=='None'){
-  include_adducts <- ''
+if (opt$include_adducts == "None") {
+  include_adducts <- ""
 }else{
   include_adducts <- opt$include_adducts
 }
 
-include_adducts_all <- paste(include_adducts_custom, ',', include_adducts, sep="")
+include_adducts_all <- paste(include_adducts_custom, ",", include_adducts, sep = "")
 
 include_adducts_all <- gsub("^,", "", include_adducts_all)
 include_adducts_all <- gsub(",$", "", include_adducts_all)
@@ -96,7 +94,7 @@
 
 
 
-if(is.null(opt$filter)){
+if (is.null(opt$filter)) {
   filter <- FALSE
 }else{
   filter <- TRUE
@@ -105,15 +103,15 @@
 
 
 msPurity::createMSP(pa,
-                    msp_file_pth = file.path(opt$out_dir, 'lcmsms_spectra.msp'),
+                    msp_file_pth = file.path(opt$out_dir, "lcmsms_spectra.msp"),
                     metadata = metadata,
                     metadata_cols = metadata_cols,
                     method = opt$method,
                     adduct_split = adduct_split,
                     xcms_groupids = xcms_groupids,
                     filter = filter,
-                    intensity_ra=opt$intensity_ra,
-                    include_adducts=include_adducts_all,
-                    msp_schema=opt$msp_schema)
+                    intensity_ra = opt$intensity_ra,
+                    include_adducts = include_adducts_all,
+                    msp_schema = opt$msp_schema)
 
-print('msp created')
+print("msp created")
b
diff -r e79c1a0654af -r 52d48bcd3608 dbconfig.R
--- a/dbconfig.R Fri Nov 13 09:55:01 2020 +0000
+++ b/dbconfig.R Thu Mar 04 12:29:17 2021 +0000
b
@@ -1,9 +1,9 @@
-compoundDbType <- 'mysql'
+compoundDbType <- "mysql"
 compoundDbPth <- NA
-compoundDbName <- 'metab_compound'
-compoundDbPort <- '3306'
-compoundDbUser <- 'metab_compound'
-compoundDbPass <- 'metab_compound'
+compoundDbName <- "metab_compound"
+compoundDbPort <- "3306"
+compoundDbUser <- "metab_compound"
+compoundDbPass <- "metab_compound"
 
 q_dbPth <- NA
 q_dbType <- NA
b
diff -r e79c1a0654af -r 52d48bcd3608 dimsPredictPuritySingle.R
--- a/dimsPredictPuritySingle.R Fri Nov 13 09:55:01 2020 +0000
+++ b/dimsPredictPuritySingle.R Thu Mar 04 12:29:17 2021 +0000
[
b'@@ -3,27 +3,27 @@\n print(sessionInfo())\n \n option_list <- list(\n-  make_option(c("--mzML_file"), type="character"),\n-  make_option(c("--mzML_files"), type="character"),\n-  make_option(c("--mzML_filename"), type="character", default=\'\'),\n-  make_option(c("--mzML_galaxy_names"), type="character", default=\'\'),\n-  make_option(c("--peaks_file"), type="character"),\n-  make_option(c("-o", "--out_dir"), type="character"),\n-  make_option("--minoffset", default=0.5),\n-  make_option("--maxoffset", default=0.5),\n-  make_option("--ilim", default=0.05),\n-  make_option("--ppm", default=4),\n-  make_option("--dimspy", action="store_true"),\n-  make_option("--sim", action="store_true"),\n-  make_option("--remove_nas", action="store_true"),\n-  make_option("--iwNorm", default="none", type="character"),\n-  make_option("--file_num_dimspy", default=1),\n-  make_option("--exclude_isotopes", action="store_true"),\n-  make_option("--isotope_matrix", type="character")\n+  make_option(c("--mzML_file"), type = "character"),\n+  make_option(c("--mzML_files"), type = "character"),\n+  make_option(c("--mzML_filename"), type = "character", default = ""),\n+  make_option(c("--mzML_galaxy_names"), type = "character", default = ""),\n+  make_option(c("--peaks_file"), type = "character"),\n+  make_option(c("-o", "--out_dir"), type = "character"),\n+  make_option("--minoffset", default = 0.5),\n+  make_option("--maxoffset", default = 0.5),\n+  make_option("--ilim", default = 0.05),\n+  make_option("--ppm", default = 4),\n+  make_option("--dimspy", action = "store_true"),\n+  make_option("--sim", action = "store_true"),\n+  make_option("--remove_nas", action = "store_true"),\n+  make_option("--iwNorm", default = "none", type = "character"),\n+  make_option("--file_num_dimspy", default = 1),\n+  make_option("--exclude_isotopes", action = "store_true"),\n+  make_option("--isotope_matrix", type = "character")\n )\n \n # store options\n-opt<- parse_args(OptionParser(option_list=option_list))\n+opt <- parse_args(OptionParser(option_list = option_list))\n \n print(sessionInfo())\n print(opt)\n@@ -31,119 +31,118 @@\n print(opt$mzML_files)\n print(opt$mzML_galaxy_names)\n \n-str_to_vec <- function(x){\n+str_to_vec <- function(x) {\n     print(x)\n-    x <- trimws(strsplit(x, \',\')[[1]])\n+    x <- trimws(strsplit(x, ",")[[1]])\n     return(x[x != ""])\n }\n \n-find_mzml_file <- function(mzML_files, galaxy_names, mzML_filename){\n+find_mzml_file <- function(mzML_files, galaxy_names, mzML_filename) {\n     mzML_filename <- trimws(mzML_filename)\n     mzML_files <- str_to_vec(mzML_files)\n     galaxy_names <- str_to_vec(galaxy_names)\n-    if (mzML_filename %in% galaxy_names){\n-        return(mzML_files[galaxy_names==mzML_filename])\n+    if (mzML_filename %in% galaxy_names) {\n+        return(mzML_files[galaxy_names == mzML_filename])\n     }else{\n         stop(paste("mzML file not found - ", mzML_filename))\n     }\n }\n \n \n-if (is.null(opt$dimspy)){\n-    df <- read.table(opt$peaks_file, header = TRUE, sep=\'\\t\')\n-    if (file.exists(opt$mzML_file)){\n+if (is.null(opt$dimspy)) {\n+    df <- read.table(opt$peaks_file, header = TRUE, sep = "\\t")\n+    if (file.exists(opt$mzML_file)) {\n         mzML_file <- opt$mzML_file\n-    }else if (!is.null(opt$mzML_files)){\n-        mzML_file <- find_mzml_file(opt$mzML_files, opt$mzML_galaxy_names, \n+    }else if (!is.null(opt$mzML_files)) {\n+        mzML_file <- find_mzml_file(opt$mzML_files, opt$mzML_galaxy_names,\n                                     opt$mzML_filename)\n     }else{\n-        mzML_file <- file.path(opt$mzML_file, filename)    \n-    }\t\n+        mzML_file <- file.path(opt$mzML_file, filename)\n+    }\n }else{\n     indf <- read.table(opt$peaks_file,\n-                       header = TRUE, sep=\'\\t\', stringsAsFactors = FALSE)\n-    \n+                       header = TRUE, sep = "\\t", stringsAsFactors = FALSE)\n+\n     filename <- colnames(indf)[8:ncol(indf)][opt$file_num_dimspy]\n     print(filename)\n     # check if the data file is mzML or RAW (can only use mzML currently) so\n     # we expe'..b' (!is.null(opt$mzML_files)) {\n         mzML_file <- find_mzml_file(opt$mzML_files, opt$mzML_galaxy_names, filename)\n     }else{\n-        mzML_file <- file.path(opt$mzML_file, filename)    \n-    }\t\n-    \n-    # Update the dimspy output with the correct information \n-    df <- indf[4:nrow(indf),]\n-    if (\'blank_flag\' %in% colnames(df)){\n-        df <- df[df$blank_flag==1,]\n+        mzML_file <- file.path(opt$mzML_file, filename)\n     }\n-    colnames(df)[colnames(df)==\'m.z\'] <- \'mz\'\n-    \n-    if (\'nan\' %in% df$mz){\n-        df[df$mz==\'nan\',]$mz <- NA\n+\n+    # Update the dimspy output with the correct information\n+    df <- indf[4:nrow(indf), ]\n+    if ("blank_flag" %in% colnames(df)) {\n+        df <- df[df$blank_flag == 1, ]\n+    }\n+    colnames(df)[colnames(df) == "m.z"] <- "mz"\n+\n+    if ("nan" %in% df$mz) {\n+        df[df$mz == "nan", ]$mz <- NA\n     }\n     df$mz <- as.numeric(df$mz)\n }\n \n-if (!is.null(opt$remove_nas)){\n-  df <- df[!is.na(df$mz),]\n+if (!is.null(opt$remove_nas)) {\n+  df <- df[!is.na(df$mz), ]\n }\n \n-if (is.null(opt$isotope_matrix)){\n+if (is.null(opt$isotope_matrix)) {\n     im <- NULL\n }else{\n     im <- read.table(opt$isotope_matrix,\n-                     header = TRUE, sep=\'\\t\', stringsAsFactors = FALSE)\n+                     header = TRUE, sep = "\\t", stringsAsFactors = FALSE)\n }\n \n-if (is.null(opt$exclude_isotopes)){\n+if (is.null(opt$exclude_isotopes)) {\n     isotopes <- FALSE\n }else{\n     isotopes <- TRUE\n }\n \n-if (is.null(opt$sim)){\n-    sim=FALSE\n+if (is.null(opt$sim)) {\n+    sim <- FALSE\n }else{\n-    sim=TRUE\n+    sim <- TRUE\n }\n \n-minOffset = as.numeric(opt$minoffset)\n-maxOffset = as.numeric(opt$maxoffset)\n+minOffset <- as.numeric(opt$minoffset)\n+maxOffset <- as.numeric(opt$maxoffset)\n \n-if (opt$iwNorm==\'none\'){\n-    iwNorm = FALSE\n-    iwNormFun = NULL\n-}else if (opt$iwNorm==\'gauss\'){\n-    iwNorm = TRUE\n-    iwNormFun = msPurity::iwNormGauss(minOff=-minOffset, maxOff=maxOffset)\n-}else if (opt$iwNorm==\'rcosine\'){\n-    iwNorm = TRUE\n-    iwNormFun = msPurity::iwNormRcosine(minOff=-minOffset, maxOff=maxOffset)\n-}else if (opt$iwNorm==\'QE5\'){\n-    iwNorm = TRUE\n-    iwNormFun = msPurity::iwNormQE.5()\n+if (opt$iwNorm == "none") {\n+    iwNorm <- FALSE\n+    iwNormFun <- NULL\n+}else if (opt$iwNorm == "gauss") {\n+    iwNorm <- TRUE\n+    iwNormFun <- msPurity::iwNormGauss(minOff = -minOffset, maxOff = maxOffset)\n+}else if (opt$iwNorm == "rcosine") {\n+    iwNorm <- TRUE\n+    iwNormFun <- msPurity::iwNormRcosine(minOff = -minOffset, maxOff = maxOffset)\n+}else if (opt$iwNorm == "QE5") {\n+    iwNorm <- TRUE\n+    iwNormFun <- msPurity::iwNormQE.5()\n }\n \n-print(\'FIRST ROWS OF PEAK FILE\')\n+print("FIRST ROWS OF PEAK FILE")\n print(head(df))\n print(mzML_file)\n predicted <- msPurity::dimsPredictPuritySingle(df$mz,\n-                                     filepth=mzML_file,\n-                                     minOffset=minOffset,\n-                                     maxOffset=maxOffset,\n-                                     ppm=opt$ppm,\n-                                     mzML=TRUE,\n+                                     filepth = mzML_file,\n+                                     minOffset = minOffset,\n+                                     maxOffset = maxOffset,\n+                                     ppm = opt$ppm,\n+                                     mzML = TRUE,\n                                      sim = sim,\n                                      ilim = opt$ilim,\n                                      isotopes = isotopes,\n@@ -154,10 +153,8 @@\n predicted <- cbind(df, predicted)\n \n print(head(predicted))\n-print(file.path(opt$out_dir, \'dimsPredictPuritySingle_output.tsv\'))\n+print(file.path(opt$out_dir, "dimsPredictPuritySingle_output.tsv"))\n \n-write.table(predicted, \n-            file.path(opt$out_dir, \'dimsPredictPuritySingle_output.tsv\'),\n-            row.names=FALSE, sep=\'\\t\')\n-\n-\n+write.table(predicted,\n+            file.path(opt$out_dir, "dimsPredictPuritySingle_output.tsv"),\n+            row.names = FALSE, sep = "\\t")\n'
b
diff -r e79c1a0654af -r 52d48bcd3608 filterFragSpectra.R
--- a/filterFragSpectra.R Fri Nov 13 09:55:01 2020 +0000
+++ b/filterFragSpectra.R Thu Mar 04 12:29:17 2021 +0000
[
@@ -5,96 +5,95 @@
 
 
 option_list <- list(
-  make_option("--out_rdata", type="character"),
-  make_option("--out_peaklist_prec", type="character"),
-  make_option("--out_peaklist_frag", type="character"),
-  make_option("--pa", type="character"),
+  make_option("--out_rdata", type = "character"),
+  make_option("--out_peaklist_prec", type = "character"),
+  make_option("--out_peaklist_frag", type = "character"),
+  make_option("--pa", type = "character"),
 
-  make_option("--ilim", default=0.0),
-  make_option("--plim", default=0.0),
+  make_option("--ilim", default = 0.0),
+  make_option("--plim", default = 0.0),
 
-  make_option("--ra", default=0.0),  
-  make_option("--snr", default=0.0),
+  make_option("--ra", default = 0.0),
+  make_option("--snr", default = 0.0),
 
-  make_option("--rmp", action="store_true"),
-  make_option("--snmeth", default="median", type="character")
+  make_option("--rmp", action = "store_true"),
+  make_option("--snmeth", default = "median", type = "character")
 )
 
-opt <- parse_args(OptionParser(option_list=option_list))
+opt <- parse_args(OptionParser(option_list = option_list))
 print(opt)
 
 
-loadRData <- function(rdata_path, name){
+loadRData <- function(rdata_path, name) {
     #loads an RData file, and returns the named xset object if it is there
     load(rdata_path)
     return(get(ls()[ls() %in% name]))
 }
 
 # Requires
-pa <- loadRData(opt$pa, 'pa')
+pa <- loadRData(opt$pa, "pa")
 
-if(is.null(opt$rmp)){
-  opt$rmp = FALSE
+if (is.null(opt$rmp)) {
+  opt$rmp <- FALSE
 }else{
-  opt$rmp = TRUE
+  opt$rmp <- TRUE
 }
 
-pa <- filterFragSpectra(pa, 
-                        ilim=opt$ilim, 
-                        plim=opt$plim,
-                        ra=opt$ra,
-                        snr=opt$snr,
-                        rmp=opt$rmp,
-                        snmeth=opt$snmeth)
+pa <- filterFragSpectra(pa,
+                        ilim = opt$ilim,
+                        plim = opt$plim,
+                        ra = opt$ra,
+                        snr = opt$snr,
+                        rmp = opt$rmp,
+                        snmeth = opt$snmeth)
 
 print(pa)
-save(pa, file=opt$out_rdata)
+save(pa, file = opt$out_rdata)
 
 # get the msms data for grpid from the purityA object
-msmsgrp <- function(grpid, pa){
+msmsgrp <- function(grpid, pa) {
   msms <- pa@grped_ms2[grpid]
-  
-  grpinfo <- pa@grped_df[pa@grped_df$grpid==grpid,]
-  
-  grpinfo$subsetid <- 1:nrow(grpinfo)
-  result <- plyr::ddply(grpinfo, ~subsetid, setid, msms=msms)
+
+  grpinfo <- pa@grped_df[pa@grped_df$grpid == grpid, ]
+
+  grpinfo$subsetid <- seq_len(nrow(grpinfo))
+  result <- plyr::ddply(grpinfo, ~subsetid, setid, msms = msms)
   return(result)
 }
 
-# Set the relevant details 
-setid <- function(grpinfo_i, msms){
+# Set the relevant details
+setid <- function(grpinfo_i, msms) {
   msms_i <- msms[[1]][[grpinfo_i$subsetid]]
   n <- nrow(msms_i)
   msms_i <- data.frame(msms_i)
-  colnames(msms_i)[1:2] <- c('mz', 'i')
-  m <- cbind('grpid'=rep(grpinfo_i$grpid,n), 'pid'=rep(grpinfo_i$pid,n), 'fileid'=rep(grpinfo_i$fileid,n), msms_i)
+  colnames(msms_i)[1:2] <- c("mz", "i")
+  m <- cbind("grpid" = rep(grpinfo_i$grpid, n), "pid" = rep(grpinfo_i$pid, n), "fileid" = rep(grpinfo_i$fileid, n), msms_i)
   return(m)
 }
 
 
 
-if (length(pa)>0){
+if (length(pa) > 0) {
 
-  if (length(pa@grped_ms2)==0){
-    message('No spectra available')
-  } else{
+  if (length(pa@grped_ms2) == 0) {
+    message("No spectra available")
+  } else {
 
     # get group ids
     grpids <- unique(as.character(pa@grped_df$grpid))
 
     # loop through all the group ids
-    df_fragments = plyr::adply(grpids, 1, msmsgrp, pa=pa)
-    df_fragments = merge(df_fragments, pa@puritydf[,c("pid", "acquisitionNum", "precursorScanNum")], by="pid")
-    df_fragments = df_fragments[order(df_fragments$grpid, df_fragments$pid, df_fragments$mz),]
+    df_fragments <- plyr::adply(grpids, 1, msmsgrp, pa = pa)
+    df_fragments <- merge(df_fragments, pa@puritydf[, c("pid", "acquisitionNum", "precursorScanNum")], by = "pid")
+    df_fragments <- df_fragments[order(df_fragments$grpid, df_fragments$pid, df_fragments$mz), ]
     #select and reorder columns
-    df_fragments = df_fragments[,c("grpid", "pid", "precursorScanNum", "acquisitionNum", "fileid", "mz", "i", "snr", "ra", "purity_pass_flag", "intensity_pass_flag", "ra_pass_flag", "snr_pass_flag", "pass_flag")]
+    df_fragments <- df_fragments[, c("grpid", "pid", "precursorScanNum", "acquisitionNum", "fileid", "mz", "i", "snr", "ra", "purity_pass_flag", "intensity_pass_flag", "ra_pass_flag", "snr_pass_flag", "pass_flag")]
 
-    pa@grped_df$filename = sapply(pa@grped_df$fileid, function(x) names(pa@fileList)[as.integer(x)])
+    pa@grped_df$filename <- sapply(pa@grped_df$fileid, function(x) names(pa@fileList)[as.integer(x)])
 
-    print(head(pa@grped_df))    
-    write.table(pa@grped_df, opt$out_peaklist_prec, row.names=FALSE, sep='\t')
+    print(head(pa@grped_df))
+    write.table(pa@grped_df, opt$out_peaklist_prec, row.names = FALSE, sep = "\t")
     print(head(df_fragments))
-    write.table(df_fragments, opt$out_peaklist_frag, row.names=FALSE, sep='\t')
+    write.table(df_fragments, opt$out_peaklist_frag, row.names = FALSE, sep = "\t")
   }
 }
-
b
diff -r e79c1a0654af -r 52d48bcd3608 flagRemove.R
--- a/flagRemove.R Fri Nov 13 09:55:01 2020 +0000
+++ b/flagRemove.R Thu Mar 04 12:29:17 2021 +0000
[
b'@@ -2,105 +2,100 @@\n library(optparse)\n print(sessionInfo())\n option_list <- list(\n-  make_option(c("-o", "--out_dir"), type="character", default=getwd(),\n-              help="Output folder for resulting files [default = %default]"\n+  make_option(c("-o", "--out_dir"), type = "character", default = getwd(),\n+              help = "Output folder for resulting files [default = %default]"\n   ),\n-  make_option(c("-x", "--xset_path"), type="character", default=file.path(getwd(),"xset.rds"),\n-              help="The path to the xcmsSet object [default = %default]"\n+  make_option(c("-x", "--xset_path"), type = "character", default = file.path(getwd(), "xset.rds"),\n+              help = "The path to the xcmsSet object [default = %default]"\n   ),\n-  make_option("--polarity", default=NA,\n-              help="polarity (just used for naming purpose for files being saved) [positive, negative, NA] [default %default]"\n+  make_option("--polarity", default = NA,\n+              help = "polarity (just used for naming purpose for files being saved) [positive, negative, NA] [default %default]"\n   ),\n-  make_option("--rsd_i_blank", default=100,\n-              help="RSD threshold for the blank [default = %default]"\n+  make_option("--rsd_i_blank", default = 100,\n+              help = "RSD threshold for the blank [default = %default]"\n   ),\n-  make_option("--minfrac_blank", default=0.5,\n-              help="minimum fraction of files for features needed for the blank [default = %default]"\n+  make_option("--minfrac_blank", default = 0.5,\n+              help = "minimum fraction of files for features needed for the blank [default = %default]"\n   ),\n-  make_option("--rsd_rt_blank", default=100,\n-              help="RSD threshold for the RT of the blank [default = %default]"\n+  make_option("--rsd_rt_blank", default = 100,\n+              help = "RSD threshold for the RT of the blank [default = %default]"\n   ),\n \n-  make_option("--ithres_blank", default=0,\n-              help="Intensity threshold for the blank [default = %default]"\n+  make_option("--ithres_blank", default = 0,\n+              help = "Intensity threshold for the blank [default = %default]"\n   ),\n-  make_option("--s2b", default=10,\n-              help="fold change (sample/blank) needed for sample peak to be allowed. e.g.\n+  make_option("--s2b", default = 10,\n+              help = "fold change (sample/blank) needed for sample peak to be allowed. e.g.\n                     if s2b set to 10 and the recorded sample \'intensity\' value was 100 and blank was 10.\n                     1000/10 = 100, so sample has fold change higher than the threshold and the peak\n                     is not considered a blank [default = %default]"\n   ),\n-  make_option("--blank_class", default=\'blank\', type="character",\n-              help="A string representing the class that will be used for the blank.[default = %default]"\n+  make_option("--blank_class", default = "blank", type = "character",\n+              help = "A string representing the class that will be used for the blank.[default = %default]"\n   ),\n-  make_option("--egauss_thr", default=NA,\n-              help="Threshold for filtering out non gaussian shaped peaks. Note this only works\n+  make_option("--egauss_thr", default = NA,\n+              help = "Threshold for filtering out non gaussian shaped peaks. Note this only works\n                             if the \'verbose columns\' and \'fit gauss\' was used with xcms\n                             [default = %default]"\n   ),\n-  make_option("--rsd_i_sample", default=100,\n-              help="RSD threshold for the samples [default = %default]"\n+  make_option("--rsd_i_sample", default = 100,\n+              help = "RSD threshold for the samples [default = %default]"\n   ),\n-  make_option("--minfrac_sample", default=0.8,\n-              help="minimum fraction of files for features needed for the samples [default = %default]"\n+  make_option("--minfrac_sample", default = 0.8,\n+              help = "minimum fraction of files for f'..b' is currently allowed to be used with this tool\')\n+    if (length(chosen_blank) > 1) {\n+        print("ERROR: only 1 blank is currently allowed to be used with this tool")\n         quit()\n     }\n     blank_class <- as.character(chosen_blank)\n@@ -145,47 +140,47 @@\n }\n \n \n-if (is.null(opt$multilist)){\n+if (is.null(opt$multilist)) {\n     ffrm_out <- flag_remove(xset,\n-                        pol=opt$polarity,\n-                        rsd_i_blank=opt$rsd_i_blank,\n-                        minfrac_blank=opt$minfrac_blank,\n-                        rsd_rt_blank=opt$rsd_rt_blank,\n-                        ithres_blank=opt$ithres_blank,\n-                        s2b=opt$s2b,\n-                        ref.class=blank_class,\n-                        egauss_thr=opt$egauss_thr,\n-                        rsd_i_sample=opt$rsd_i_sample,\n-                        minfrac_sample=opt$minfrac_sample,\n-                        rsd_rt_sample=opt$rsd_rt_sample,\n-                        ithres_sample=opt$ithres_sample,\n-                        minfrac_xcms=opt$minfrac_xcms,\n-                        mzwid=opt$mzwid,\n-                        bw=opt$bw,\n-                        out_dir=opt$out_dir,\n-                        temp_save=temp_save,\n-                        remove_spectra=remove_spectra,\n-                        grp_rm_ids=unlist(strsplit(as.character(opt$grp_rm_ids), split=", "))[[1]])\n-    print(\'flag remove finished\')\n+                        pol = opt$polarity,\n+                        rsd_i_blank = opt$rsd_i_blank,\n+                        minfrac_blank = opt$minfrac_blank,\n+                        rsd_rt_blank = opt$rsd_rt_blank,\n+                        ithres_blank = opt$ithres_blank,\n+                        s2b = opt$s2b,\n+                        ref.class = blank_class,\n+                        egauss_thr = opt$egauss_thr,\n+                        rsd_i_sample = opt$rsd_i_sample,\n+                        minfrac_sample = opt$minfrac_sample,\n+                        rsd_rt_sample = opt$rsd_rt_sample,\n+                        ithres_sample = opt$ithres_sample,\n+                        minfrac_xcms = opt$minfrac_xcms,\n+                        mzwid = opt$mzwid,\n+                        bw = opt$bw,\n+                        out_dir = opt$out_dir,\n+                        temp_save = temp_save,\n+                        remove_spectra = remove_spectra,\n+                        grp_rm_ids = unlist(strsplit(as.character(opt$grp_rm_ids), split = ", "))[[1]])\n+    print("flag remove finished")\n     xset <- ffrm_out[[1]]\n     grp_peaklist <- ffrm_out[[2]]\n     removed_peaks <- ffrm_out[[3]]\n \n-    save.image(file=file.path(opt$out_dir, \'xset_filtered.RData\'), version=2)\n+    save.image(file = file.path(opt$out_dir, "xset_filtered.RData"), version = 2)\n \n     # grpid needed for mspurity ID needed for deconrank... (will clean up at some up)\n-    peak_pth <- file.path(opt$out_dir, \'peaklist_filtered.tsv\')\n+    peak_pth <- file.path(opt$out_dir, "peaklist_filtered.tsv")\n     print(peak_pth)\n-    write.table(data.frame(\'grpid\'=rownames(grp_peaklist), \'ID\'=rownames(grp_peaklist), grp_peaklist),\n-                peak_pth, row.names=FALSE, sep=\'\\t\')\n+    write.table(data.frame("grpid" = rownames(grp_peaklist), "ID" = rownames(grp_peaklist), grp_peaklist),\n+                peak_pth, row.names = FALSE, sep = "\\t")\n \n     removed_peaks <- data.frame(removed_peaks)\n-    write.table(data.frame(\'ID\'=rownames(removed_peaks),removed_peaks),\n-        file.path(opt$out_dir, \'removed_peaks.tsv\'), row.names=FALSE, sep=\'\\t\')\n+    write.table(data.frame("ID" = rownames(removed_peaks), removed_peaks),\n+        file.path(opt$out_dir, "removed_peaks.tsv"), row.names = FALSE, sep = "\\t")\n \n }else{\n \n-   \n+   # nolint start\n    # TODO\n    #xsets <- split(xset, multilist_df$multlist)\n    #\n@@ -193,12 +188,10 @@\n    #\n    #for (mgrp in mult_grps){\n    #   xset_i <- xsets[mgrp]\n-   #   xcms::group(xset_i, \n+   #   xcms::group(xset_i,\n    #\n    # }\n-\n+   # nolint end\n \n \n }\n-\n-\n'
b
diff -r e79c1a0654af -r 52d48bcd3608 frag4feature.R
--- a/frag4feature.R Fri Nov 13 09:55:01 2020 +0000
+++ b/frag4feature.R Thu Mar 04 12:29:17 2021 +0000
[
@@ -3,18 +3,18 @@
 library(xcms)
 print(sessionInfo())
 
-xset_pa_filename_fix <- function(opt, pa, xset=NULL){
+xset_pa_filename_fix <- function(opt, pa, xset=NULL) {
 
 
-  if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)){
+  if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)) {
     # NOTE: Relies on the pa@fileList having the names of files given as 'names' of the variables
     # needs to be done due to Galaxy moving the files around and screwing up any links to files
 
-    filepaths <- trimws(strsplit(opt$mzML_files, ',')[[1]])
+    filepaths <- trimws(strsplit(opt$mzML_files, ",")[[1]]) # nolint
+
     filepaths <- filepaths[filepaths != ""]
-    new_names <- basename(filepaths)
 
-    galaxy_names <- trimws(strsplit(opt$galaxy_names, ',')[[1]])
+    galaxy_names <- trimws(strsplit(opt$galaxy_names, ",")[[1]])
     galaxy_names <- galaxy_names[galaxy_names != ""]
 
     nsave <- names(pa@fileList)
@@ -28,14 +28,14 @@
   }
   print(pa@fileList)
 
-  if(!is.null(xset)){
+  if (!is.null(xset)) {
 
     print(xset@filepaths)
 
-    if(!all(basename(pa@fileList)==basename(xset@filepaths))){
-       if(!all(names(pa@fileList)==basename(xset@filepaths))){
-          print('FILELISTS DO NOT MATCH')
-          message('FILELISTS DO NOT MATCH')
+    if (!all(basename(pa@fileList) == basename(xset@filepaths))) {
+       if (!all(names(pa@fileList) == basename(xset@filepaths))) {
+          print("FILELISTS DO NOT MATCH")
+          message("FILELISTS DO NOT MATCH")
           quit(status = 1)
        }else{
           xset@filepaths <- unname(pa@fileList)
@@ -48,26 +48,26 @@
 
 
 option_list <- list(
-  make_option(c("-o", "--out_dir"), type="character"),
-  make_option("--pa", type="character"),
-  make_option("--xset", type="character"),
-  make_option("--ppm", default=10),
-  make_option("--plim", default=0.0),
-  make_option("--convert2RawRT", action="store_true"),
-  make_option("--intense", action="store_true"),
-  make_option("--createDB", action="store_true"),
-  make_option("--cores", default=4),
-  make_option("--mzML_files", type="character"),
-  make_option("--galaxy_names", type="character"),
-  make_option("--grp_peaklist", type="character"),
-  make_option("--useGroup", action="store_true")
+  make_option(c("-o", "--out_dir"), type = "character"),
+  make_option("--pa", type = "character"),
+  make_option("--xset", type = "character"),
+  make_option("--ppm", default = 10),
+  make_option("--plim", default = 0.0),
+  make_option("--convert2RawRT", action = "store_true"),
+  make_option("--intense", action = "store_true"),
+  make_option("--createDB", action = "store_true"),
+  make_option("--cores", default = 4),
+  make_option("--mzML_files", type = "character"),
+  make_option("--galaxy_names", type = "character"),
+  make_option("--grp_peaklist", type = "character"),
+  make_option("--useGroup", action = "store_true")
 )
 
 # store options
-opt<- parse_args(OptionParser(option_list=option_list))
+opt <- parse_args(OptionParser(option_list = option_list))
 print(opt)
 
-loadRData <- function(rdata_path, name){
+loadRData <- function(rdata_path, name) {
 #loads an RData file, and returns the named xset object if it is there
     load(rdata_path)
     return(get(ls()[ls() %in% name]))
@@ -78,19 +78,19 @@
 getxcmsSetObject <- function(xobject) {
     # XCMS 1.x
     if (class(xobject) == "xcmsSet")
-        return (xobject)
+        return(xobject)
     # XCMS 3.x
     if (class(xobject) == "XCMSnExp") {
         # Get the legacy xcmsSet object
-        suppressWarnings(xset <- as(xobject, 'xcmsSet'))
+        suppressWarnings(xset <- as(xobject, "xcmsSet"))
         sampclass(xset) <- xset@phenoData$sample_group
-        return (xset)
+        return(xset)
     }
 }
 
 # Requires
-pa <- loadRData(opt$pa, 'pa')
-xset <- loadRData(opt$xset, c('xset','xdata'))
+pa <- loadRData(opt$pa, "pa")
+xset <- loadRData(opt$xset, c("xset", "xdata"))
 xset <- getxcmsSetObject(xset)
 
 pa@cores <- opt$cores
@@ -98,63 +98,60 @@
 print(pa@fileList)
 print(xset@filepaths)
 
-if(is.null(opt$intense)){
-  intense = FALSE
+if (is.null(opt$intense)) {
+  intense <- FALSE
 }else{
-  intense = TRUE
+  intense <- TRUE
 }
 
-if(is.null(opt$convert2RawRT)){
-    convert2RawRT = FALSE
+if (is.null(opt$convert2RawRT)) {
+    convert2RawRT <- FALSE
 }else{
-    convert2RawRT= TRUE
+    convert2RawRT <- TRUE
 }
 
-if(is.null(opt$createDB)){
-    createDB = FALSE
+if (is.null(opt$createDB)) {
+    createDB <- FALSE
 }else{
-    createDB = TRUE
+    createDB <- TRUE
 }
 
-if(is.null(opt$useGroup)){
+if (is.null(opt$useGroup)) {
     fix <- xset_pa_filename_fix(opt, pa, xset)
     pa <- fix[[1]]
     xset <- fix[[2]]
-    useGroup=FALSE
+    useGroup <- FALSE
 }else{
     # if are only aligning to the group not eah file we do not need to align the files between the xset and pa object
-    print('useGroup')
+    print("useGroup")
     fix <- xset_pa_filename_fix(opt, pa)
     pa <- fix[[1]]
-    useGroup=TRUE
+    useGroup <- TRUE
 }
 
 
-if(is.null(opt$grp_peaklist)){
-    grp_peaklist = NA
+if (is.null(opt$grp_peaklist)) {
+    grp_peaklist <- NA
 }else{
-    grp_peaklist = opt$grp_peaklist
+    grp_peaklist <- opt$grp_peaklist
 }
 print(useGroup)
 
-
-
-pa <- msPurity::frag4feature(pa=pa,
-                             xset=xset,
-                             ppm=opt$ppm,
-                             plim=opt$plim,
-                             intense=intense,
-                             convert2RawRT=convert2RawRT,
-                             db_name='alldata.sqlite',
-                             out_dir=opt$out_dir,
-                             grp_peaklist=grp_peaklist,
-                             create_db=createDB,
-                             use_group=useGroup)
-
+pa <- msPurity::frag4feature(pa = pa,
+                             xset = xset,
+                             ppm = opt$ppm,
+                             plim = opt$plim,
+                             intense = intense,
+                             convert2RawRT = convert2RawRT,
+                             db_name = "alldata.sqlite",
+                             out_dir = opt$out_dir,
+                             grp_peaklist = grp_peaklist,
+                             create_db = createDB,
+                             use_group = useGroup)
 print(pa)
-save(pa, file=file.path(opt$out_dir, 'frag4feature_output.RData'))
+save(pa, file = file.path(opt$out_dir, "frag4feature_output.RData"))
 
 pa@grped_df$filename <- sapply(pa@grped_df$fileid, function(x) names(pa@fileList)[as.integer(x)])
 
 print(head(pa@grped_df))
-write.table(pa@grped_df, file.path(opt$out_dir, 'frag4feature_output.tsv'), row.names=FALSE, sep='\t')
+write.table(pa@grped_df, file.path(opt$out_dir, "frag4feature_output.tsv"), row.names = FALSE, sep = "\t")
b
diff -r e79c1a0654af -r 52d48bcd3608 macros.xml
--- a/macros.xml Fri Nov 13 09:55:01 2020 +0000
+++ b/macros.xml Thu Mar 04 12:29:17 2021 +0000
b
@@ -1,17 +1,17 @@
 <?xml version="1.0"?>
 <macros>
-    <token name="@TOOL_VERSION@">1.12.2</token>
-    <token name="@GALAXY_TOOL_VERSION@">3</token>
+    <token name="@TOOL_VERSION@">1.16.2</token>
+    <token name="@GALAXY_TOOL_VERSION@">0</token>
 
     <xml name="requirements">
         <requirements>
            <requirement type="package" version="@TOOL_VERSION@" >bioconductor-mspurity</requirement>
-           <requirement type="package" version="1.42.0" >bioconductor-camera</requirement>
-           <requirement type="package" version="3.8.0" >bioconductor-xcms</requirement>
-           <requirement type="package" version="1.14.0" >bioconductor-mspuritydata</requirement>
-           <requirement type="package" version="1.6.4">r-optparse</requirement>
-           <requirement type="package" version="1.1.1">r-rpostgres</requirement>
-           <requirement type="package" version="0.10.17">r-rmysql</requirement>
+           <requirement type="package" version="1.46.0" >bioconductor-camera</requirement>
+           <requirement type="package" version="3.12.0" >bioconductor-xcms</requirement>
+           <requirement type="package" version="1.16.0" >bioconductor-mspuritydata</requirement>
+           <requirement type="package" version="1.6.6">r-optparse</requirement>
+           <requirement type="package" version="1.3.1">r-rpostgres</requirement>
+           <requirement type="package" version="0.10.21">r-rmysql</requirement>
             <yield />
         </requirements>
     </xml>
@@ -23,13 +23,13 @@
     <xml name="offsets">
         <param argument="--minoffset" type="float" label="minoffset" value="0.5"
                help="Offset to the 'left' for the precursor range e.g. if precursor of interest is
-               100.0 then the range would be from 999.5 to 100.0"/>
+               100.0 then the range would be from 99.5 to 100.0"/>
         <param argument="--maxoffset" type="float" label="maxoffset" value="0.5"
                help="Offset to the 'right' for the precursor range  e.g. if precursor of interest is
                100.0 then the range would be from 100.0 to 100.5"/>
     </xml>
     <xml name="general_params">
-        <param argument="--ilim" type="float" value="0.05" 
+        <param argument="--ilim" type="float" value="0.05"
                label="Threshold to remove peaks below x % of the relative intensity of
                precursor of interest"
                help="All peaks less than this percentage of the precursor ion of interest will be
@@ -337,8 +337,8 @@
                 <when value="true">
                     <param argument="--@QL_SHRT@_spectraTypes" type="select" multiple="true"  label="Spectra type" >
                         <option value="av_all" selected="true">Averaged all spectra ignoring inter-intra relationships </option>
-                        <option value="av_inter">Averaged inter spectra</option>
-                        <option value="av_intra">Averaged intra spectra </option>
+                        <option value="inter">Averaged inter spectra</option>
+                        <option value="intra">Averaged intra spectra </option>
                         <option value="scans">All individual scans</option>
                         <option value="NA">Not applicable/defined</option>
                     </param>
b
diff -r e79c1a0654af -r 52d48bcd3608 purityA.R
--- a/purityA.R Fri Nov 13 09:55:01 2020 +0000
+++ b/purityA.R Thu Mar 04 12:29:17 2021 +0000
[
@@ -3,91 +3,90 @@
 print(sessionInfo())
 
 option_list <- list(
-  make_option(c("-o", "--out_dir"), type="character"),
-  make_option("--mzML_files", type="character"),
-  make_option("--galaxy_names", type="character"),
-  make_option("--minOffset", type="numeric"),
-  make_option("--maxOffset", type="numeric"),
-  make_option("--ilim", type="numeric"),
-  make_option("--iwNorm", default="none", type="character"),
-  make_option("--exclude_isotopes", action="store_true"),
-  make_option("--isotope_matrix", type="character"),
-  make_option("--mostIntense", action="store_true"),
-  make_option("--plotP", action="store_true"),
-  make_option("--nearest", action="store_true"),
-  make_option("--cores", default=4),
-  make_option("--ppmInterp", default=7)
+  make_option(c("-o", "--out_dir"), type = "character"),
+  make_option("--mzML_files", type = "character"),
+  make_option("--galaxy_names", type = "character"),
+  make_option("--minOffset", type = "numeric"),
+  make_option("--maxOffset", type = "numeric"),
+  make_option("--ilim", type = "numeric"),
+  make_option("--iwNorm", default = "none", type = "character"),
+  make_option("--exclude_isotopes", action = "store_true"),
+  make_option("--isotope_matrix", type = "character"),
+  make_option("--mostIntense", action = "store_true"),
+  make_option("--plotP", action = "store_true"),
+  make_option("--nearest", action = "store_true"),
+  make_option("--cores", default = 4),
+  make_option("--ppmInterp", default = 7)
 )
 
-opt <- parse_args(OptionParser(option_list=option_list))
+opt <- parse_args(OptionParser(option_list = option_list))
 print(opt)
 
-
-if (opt$iwNorm=='none'){
-    iwNorm = FALSE
-    iwNormFun = NULL
-}else if (opt$iwNorm=='gauss'){
-    iwNorm = TRUE
-    if (is.null(opt$minOffset) || is.null(opt$maxOffset)){
-      print('User has to define offsets if using Gaussian normalisation')
+if (opt$iwNorm == "none") {
+    iwNorm <- FALSE
+    iwNormFun <- NULL
+}else if (opt$iwNorm == "gauss") {
+    iwNorm <- TRUE
+    if (is.null(opt$minOffset) || is.null(opt$maxOffset)) {
+      print("User has to define offsets if using Gaussian normalisation")
     }else{
-      iwNormFun = msPurity::iwNormGauss(minOff=-as.numeric(opt$minOffset), 
-                                      maxOff=as.numeric(opt$maxOffset))
+      iwNormFun <- msPurity::iwNormGauss(minOff = -as.numeric(opt$minOffset),
+                                         maxOff = as.numeric(opt$maxOffset))
     }
-}else if (opt$iwNorm=='rcosine'){
-    iwNorm = TRUE
-    if (is.null(opt$minOffset) || is.null(opt$maxOffset)){
-      print('User has to define offsets if using R-cosine normalisation')
+}else if (opt$iwNorm == "rcosine") {
+    iwNorm <- TRUE
+    if (is.null(opt$minOffset) || is.null(opt$maxOffset)) {
+      print("User has to define offsets if using R-cosine normalisation")
     }else{
-      iwNormFun = msPurity::iwNormRcosine(minOff=-as.numeric(opt$minOffset), 
-                                          maxOff=as.numeric(opt$maxOffset))
+      iwNormFun <- msPurity::iwNormRcosine(minOff = -as.numeric(opt$minOffset),
+                                           maxOff = as.numeric(opt$maxOffset))
     }
-}else if (opt$iwNorm=='QE5'){
-    iwNorm = TRUE
-    iwNormFun = msPurity::iwNormQE.5()
+}else if (opt$iwNorm == "QE5") {
+    iwNorm <- TRUE
+    iwNormFun <- msPurity::iwNormQE.5()
 }
 
-filepaths <- trimws(strsplit(opt$mzML_files, ',')[[1]])
+filepaths <- trimws(strsplit(opt$mzML_files, ",")[[1]])
 filepaths <- filepaths[filepaths != ""]
 
 
 
-if(is.null(opt$minOffset) || is.null(opt$maxOffset)){
-    offsets = NA
+if (is.null(opt$minOffset) || is.null(opt$maxOffset)) {
+    offsets <- NA
 }else{
-    offsets = as.numeric(c(opt$minOffset, opt$maxOffset))
+    offsets <- as.numeric(c(opt$minOffset, opt$maxOffset))
 }
 
 
-if(is.null(opt$mostIntense)){
-    mostIntense = FALSE
+if (is.null(opt$mostIntense)) {
+    mostIntense <- FALSE
 }else{
-    mostIntense = TRUE
+    mostIntense <- TRUE
 }
 
-if(is.null(opt$nearest)){
-    nearest = FALSE
+if (is.null(opt$nearest)) {
+    nearest <- FALSE
 }else{
-    nearest = TRUE
+    nearest <- TRUE
 }
 
-if(is.null(opt$plotP)){
-    plotP = FALSE
-    plotdir = NULL
+if (is.null(opt$plotP)) {
+    plotP <- FALSE
+    plotdir <- NULL
 }else{
-    plotP = TRUE
-    plotdir = opt$out_dir
+    plotP <- TRUE
+    plotdir <- opt$out_dir
 }
 
 
-if (is.null(opt$isotope_matrix)){
+if (is.null(opt$isotope_matrix)) {
     im <- NULL
 }else{
     im <- read.table(opt$isotope_matrix,
-                     header = TRUE, sep='\t', stringsAsFactors = FALSE)
+                     header = TRUE, sep = "\t", stringsAsFactors = FALSE)
 }
 
-if (is.null(opt$exclude_isotopes)){
+if (is.null(opt$exclude_isotopes)) {
     isotopes <- FALSE
 }else{
     isotopes <- TRUE
@@ -110,20 +109,16 @@
                         ppmInterp = opt$ppmInterp)
 
 
-if (!is.null(opt$galaxy_names)){
-    galaxy_names <- trimws(strsplit(opt$galaxy_names, ',')[[1]])
+if (!is.null(opt$galaxy_names)) {
+    galaxy_names <- trimws(strsplit(opt$galaxy_names, ",")[[1]])
     galaxy_names <- galaxy_names[galaxy_names != ""]
     names(pa@fileList) <- galaxy_names
 }
 
 print(pa)
-save(pa, file=file.path(opt$out_dir, 'purityA_output.RData'))
+save(pa, file = file.path(opt$out_dir, "purityA_output.RData"))
 
 pa@puritydf$filename <- sapply(pa@puritydf$fileid, function(x) names(pa@fileList)[as.integer(x)])
 
 print(head(pa@puritydf))
-write.table(pa@puritydf, file.path(opt$out_dir, 'purityA_output.tsv'), row.names=FALSE, sep='\t')
-
-# removed_peaks <- data.frame(removed_peaks)
-# write.table(data.frame('ID'=rownames(removed_peaks),removed_peaks),
-#         file.path(opt$out_dir, 'removed_peaks.txt'), row.names=FALSE, sep='\t')
+write.table(pa@puritydf, file.path(opt$out_dir, "purityA_output.tsv"), row.names = FALSE, sep = "\t")
b
diff -r e79c1a0654af -r 52d48bcd3608 purityX.R
--- a/purityX.R Fri Nov 13 09:55:01 2020 +0000
+++ b/purityX.R Thu Mar 04 12:29:17 2021 +0000
[
b'@@ -3,67 +3,66 @@\n print(sessionInfo())\n \n option_list <- list(\n-  make_option(c("--xset_path"), type="character"),\n-  make_option(c("-o", "--out_dir"), type="character"),\n-  make_option(c("--mzML_path"), type="character"),\n-  make_option("--minOffset", default=0.5),\n-  make_option("--maxOffset", default=0.5),\n-  make_option("--ilim", default=0.05),\n-  make_option("--iwNorm", default="none", type="character"),\n-  make_option("--exclude_isotopes", action="store_true"),\n-  make_option("--isotope_matrix", type="character"),\n-  make_option("--purityType", default="purityFWHMmedian"),\n-  make_option("--singleFile", default=0),\n-  make_option("--cores", default=4),\n-  make_option("--xgroups", type="character"),\n-  make_option("--rdata_name", default=\'xset\'),\n-  make_option("--camera_xcms", default=\'xset\'),\n-  make_option("--files", type="character"),\n-  make_option("--galaxy_files", type="character"),\n-  make_option("--choose_class", type="character"),\n-  make_option("--ignore_files", type="character"),\n-  make_option("--rtraw_columns",  action="store_true")\n+  make_option(c("--xset_path"), type = "character"),\n+  make_option(c("-o", "--out_dir"), type = "character"),\n+  make_option(c("--mzML_path"), type = "character"),\n+  make_option("--minOffset", default = 0.5),\n+  make_option("--maxOffset", default = 0.5),\n+  make_option("--ilim", default = 0.05),\n+  make_option("--iwNorm", default = "none", type = "character"),\n+  make_option("--exclude_isotopes", action = "store_true"),\n+  make_option("--isotope_matrix", type = "character"),\n+  make_option("--purityType", default = "purityFWHMmedian"),\n+  make_option("--singleFile", default = 0),\n+  make_option("--cores", default = 4),\n+  make_option("--xgroups", type = "character"),\n+  make_option("--rdata_name", default = "xset"),\n+  make_option("--camera_xcms", default = "xset"),\n+  make_option("--files", type = "character"),\n+  make_option("--galaxy_files", type = "character"),\n+  make_option("--choose_class", type = "character"),\n+  make_option("--ignore_files", type = "character"),\n+  make_option("--rtraw_columns",  action = "store_true")\n )\n \n \n-opt<- parse_args(OptionParser(option_list=option_list))\n+opt <- parse_args(OptionParser(option_list = option_list))\n print(opt)\n \n \n-if (!is.null(opt$xgroups)){\n-    xgroups = as.numeric(strsplit(opt$xgroups, \',\')[[1]])\n+if (!is.null(opt$xgroups)) {\n+    xgroups <- as.numeric(strsplit(opt$xgroups, ",")[[1]])\n }else{\n-    xgroups = NULL\n+    xgroups <- NULL\n }\n \n \n-\n print(xgroups)\n \n-if (!is.null(opt$remove_nas)){\n-  df <- df[!is.na(df$mz),]\n+if (!is.null(opt$remove_nas)) {\n+  df <- df[!is.na(df$mz), ]\n }\n \n-if (is.null(opt$isotope_matrix)){\n+if (is.null(opt$isotope_matrix)) {\n     im <- NULL\n }else{\n     im <- read.table(opt$isotope_matrix,\n-                     header = TRUE, sep=\'\\t\', stringsAsFactors = FALSE)\n+                     header = TRUE, sep = "\\t", stringsAsFactors = FALSE)\n }\n \n-if (is.null(opt$exclude_isotopes)){\n+if (is.null(opt$exclude_isotopes)) {\n     isotopes <- FALSE\n }else{\n     isotopes <- TRUE\n }\n \n-if (is.null(opt$rtraw_columns)){\n+if (is.null(opt$rtraw_columns)) {\n     rtraw_columns <- FALSE\n }else{\n     rtraw_columns <- TRUE\n }\n \n-loadRData <- function(rdata_path, xset_name){\n+loadRData <- function(rdata_path, xset_name) {\n #loads an RData file, and returns the named xset object if it is there\n     load(rdata_path)\n     return(get(ls()[ls() == xset_name]))\n@@ -71,7 +70,7 @@\n \n target_obj <- loadRData(opt$xset_path, opt$rdata_name)\n \n-if (opt$camera_xcms==\'camera\'){\n+if (opt$camera_xcms == "camera") {\n     xset <- target_obj@xcmsSet\n }else{\n     xset <- target_obj\n@@ -79,36 +78,35 @@\n \n print(xset)\n \n-minOffset = as.numeric(opt$minOffset)\n-maxOffset = as.numeric(opt$maxOffset)\n-\n+minOffset <- as.numeric(opt$minOffset)\n+maxOffset <- as.numeric(opt$maxOffset)\n \n-if (opt$iwNorm==\'none\'){\n-    iwNorm = FALSE\n-    iwNormFun = NULL\n-}else if (opt$iwNorm==\'gauss\'){\n-    iwNorm = TRUE\n-    iwNormFun = msPurity::iwNormGauss(mi'..b'rimws(strsplit(opt$galaxy_files, ",")[[1]])\n         galaxy_files <- galaxy_files[galaxy_files != ""]\n         xset@filepaths <- galaxy_files[update_idx]\n     }else{\n@@ -116,27 +114,26 @@\n     }\n }\n \n-if (!is.null(opt$choose_class)){\n-  classes <- trimws(strsplit(opt$choose_class, \',\')[[1]])\n-\n+if (!is.null(opt$choose_class)) {\n+  classes <- trimws(strsplit(opt$choose_class, ",")[[1]])\n \n   ignore_files_class <- which(!as.character(xset@phenoData$class) %in% classes)\n \n-  print(\'choose class\')\n+  print("choose class")\n   print(ignore_files_class)\n }else{\n   ignore_files_class <- NA\n }\n \n-if (!is.null(opt$ignore_files)){\n-  ignore_files_string <- trimws(strsplit(opt$ignore_files, \',\')[[1]])\n+if (!is.null(opt$ignore_files)) {\n+  ignore_files_string <- trimws(strsplit(opt$ignore_files, ",")[[1]])\n   filenames <- rownames(xset@phenoData)\n   ignore_files <- which(filenames %in% ignore_files_string)\n \n   ignore_files <- unique(c(ignore_files, ignore_files_class))\n   ignore_files <- ignore_files[ignore_files != ""]\n }else{\n-  if (anyNA(ignore_files_class)){\n+  if (anyNA(ignore_files_class)) {\n     ignore_files <- NULL\n   }else{\n     ignore_files <- ignore_files_class\n@@ -144,41 +141,40 @@\n \n }\n \n-print(\'ignore_files\')\n+print("ignore_files")\n print(ignore_files)\n \n \n-ppLCMS <- msPurity::purityX(xset=xset,\n-                                offsets=c(minOffset, maxOffset),\n-                                cores=opt$cores,\n-                                xgroups=xgroups,\n-                                purityType=opt$purityType,\n-                                ilim = opt$ilim,\n-                                isotopes = isotopes,\n-                                im = im,\n-                                iwNorm = iwNorm,\n-                                iwNormFun = iwNormFun,\n-                                singleFile = opt$singleFile,\n-                                fileignore = ignore_files,\n-                                rtrawColumns=rtraw_columns)\n-\n+ppLCMS <- msPurity::purityX(xset = xset,\n+                            offsets = c(minOffset, maxOffset),\n+                            cores = opt$cores,\n+                            xgroups = xgroups,\n+                            purityType = opt$purityType,\n+                            ilim = opt$ilim,\n+                            isotopes = isotopes,\n+                            im = im,\n+                            iwNorm = iwNorm,\n+                            iwNormFun = iwNormFun,\n+                            singleFile = opt$singleFile,\n+                            fileignore = ignore_files,\n+                            rtrawColumns = rtraw_columns)\n \n dfp <- ppLCMS@predictions\n \n # to make compatable with deconrank\n-colnames(dfp)[colnames(dfp)==\'grpid\'] = \'peakID\'\n-colnames(dfp)[colnames(dfp)==\'median\'] = \'medianPurity\'\n-colnames(dfp)[colnames(dfp)==\'mean\'] = \'meanPurity\'\n-colnames(dfp)[colnames(dfp)==\'sd\'] = \'sdPurity\'\n-colnames(dfp)[colnames(dfp)==\'stde\'] = \'sdePurity\'\n-colnames(dfp)[colnames(dfp)==\'RSD\'] = \'cvPurity\'\n-colnames(dfp)[colnames(dfp)==\'pknm\'] = \'pknmPurity\'\n-if(sum(is.na(dfp$medianPurity))>0){\n-    dfp[is.na(dfp$medianPurity),]$medianPurity = 0\n+colnames(dfp)[colnames(dfp) == "grpid"] <- "peakID"\n+colnames(dfp)[colnames(dfp) == "median"] <- "medianPurity"\n+colnames(dfp)[colnames(dfp) == "mean"] <- "meanPurity"\n+colnames(dfp)[colnames(dfp) == "sd"] <- "sdPurity"\n+colnames(dfp)[colnames(dfp) == "stde"] <- "sdePurity"\n+colnames(dfp)[colnames(dfp) == "RSD"] <- "cvPurity"\n+colnames(dfp)[colnames(dfp) == "pknm"] <- "pknmPurity"\n+\n+if (sum(is.na(dfp$medianPurity)) > 0) {\n+  dfp[is.na(dfp$medianPurity), ]$medianPurity <- 0\n }\n \n+print(head(dfp))\n+write.table(dfp, file.path(opt$out_dir, "purityX_output.tsv"), row.names = FALSE, sep = "\\t")\n \n-print(head(dfp))\n-write.table(dfp, file.path(opt$out_dir, \'purityX_output.tsv\'), row.names=FALSE, sep=\'\\t\')\n-\n-save.image(file.path(opt$out_dir, \'purityX_output.RData\'))\n+save.image(file.path(opt$out_dir, "purityX_output.RData"))\n'
b
diff -r e79c1a0654af -r 52d48bcd3608 spectralMatching.R
--- a/spectralMatching.R Fri Nov 13 09:55:01 2020 +0000
+++ b/spectralMatching.R Thu Mar 04 12:29:17 2021 +0000
[
b'@@ -3,107 +3,111 @@\n library(optparse)\n print(sessionInfo())\n # load in library spectra config\n-source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) }\n+source_local <- function(fname) {\n+  argv <- commandArgs(trailingOnly = FALSE)\n+  base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))\n+  source(paste(base_dir, fname, sep = "/"))\n+}\n source_local("dbconfig.R")\n \n option_list <- list(\n-  make_option(c("-o", "--outDir"), type="character"),\n-  make_option("--q_dbPth", type="character"),\n-  make_option("--l_dbPth", type="character"),\n+  make_option(c("-o", "--outDir"), type = "character"),\n+  make_option("--q_dbPth", type = "character"),\n+  make_option("--l_dbPth", type = "character"),\n \n-  make_option("--q_dbType", type="character", default=NA),\n-  make_option("--l_dbType", type="character", default=NA),\n+  make_option("--q_dbType", type = "character", default = NA),\n+  make_option("--l_dbType", type = "character", default = NA),\n \n-  make_option("--q_msp", type="character", default=NA),\n-  make_option("--l_msp", type="character", default=NA),\n+  make_option("--q_msp", type = "character", default = NA),\n+  make_option("--l_msp", type = "character", default = NA),\n \n-  make_option("--q_defaultDb", action="store_true"),\n-  make_option("--l_defaultDb", action="store_true"),\n+  make_option("--q_defaultDb", action = "store_true"),\n+  make_option("--l_defaultDb", action = "store_true"),\n \n-  make_option("--q_ppmPrec", type="double"),\n-  make_option("--l_ppmPrec", type="double"),\n+  make_option("--q_ppmPrec", type = "double"),\n+  make_option("--l_ppmPrec", type = "double"),\n \n-  make_option("--q_ppmProd", type="double"),\n-  make_option("--l_ppmProd", type="double"),\n+  make_option("--q_ppmProd", type = "double"),\n+  make_option("--l_ppmProd", type = "double"),\n \n-  make_option("--q_raThres", type="double", default=NA),\n-  make_option("--l_raThres", type="double", default=NA),\n+  make_option("--q_raThres", type = "double", default = NA),\n+  make_option("--l_raThres", type = "double", default = NA),\n \n-  make_option("--q_polarity", type="character", default=NA),\n-  make_option("--l_polarity", type="character", default=NA),\n+  make_option("--q_polarity", type = "character", default = NA),\n+  make_option("--l_polarity", type = "character", default = NA),\n \n-  make_option("--q_purity", type="double", default=NA),\n-  make_option("--l_purity", type="double", default=NA),\n+  make_option("--q_purity", type = "double", default = NA),\n+  make_option("--l_purity", type = "double", default = NA),\n \n-  make_option("--q_xcmsGroups", type="character", default=NA),\n-  make_option("--l_xcmsGroups", type="character", default=NA),\n+  make_option("--q_xcmsGroups", type = "character", default = NA),\n+  make_option("--l_xcmsGroups", type = "character", default = NA),\n \n-  make_option("--q_pids", type="character", default=NA),\n-  make_option("--l_pids", type="character", default=NA),\n+  make_option("--q_pids", type = "character", default = NA),\n+  make_option("--l_pids", type = "character", default = NA),\n \n-  make_option("--q_rtrangeMin", type="double", default=NA),\n-  make_option("--l_rtrangeMin", type="double", default=NA),\n+  make_option("--q_rtrangeMin", type = "double", default = NA),\n+  make_option("--l_rtrangeMin", type = "double", default = NA),\n \n-  make_option("--q_rtrangeMax", type="double", default=NA),\n-  make_option("--l_rtrangeMax", type="double", default=NA),\n+  make_option("--q_rtrangeMax", type = "double", default = NA),\n+  make_option("--l_rtrangeMax", type = "double", default = NA),\n \n-  make_option("--q_accessions", type="character", default=NA),\n-  make_option("--l_accessions", type="character", default=NA),\n+  make_option("--q_accessions", type = "character", default = NA),\n+  make_option("--l_accessions", type = "character", default = NA),\n \n-  make_option("--q_sources", type="character", default=NA),\n'..b'(opt$q_spectraFilter)){\n+if (!is.null(opt$q_spectraFilter)) {\n   q_spectraFilter <- TRUE\n }else{\n   q_spectraFilter <- FALSE\n }\n \n-if(!is.null(opt$updateDb)){\n+if (!is.null(opt$updateDb)) {\n   updateDb <- TRUE\n }else{\n   updateDb <- FALSE\n }\n \n-if(!is.null(opt$copyDb)){\n+if (!is.null(opt$copyDb)) {\n   copyDb <- TRUE\n }else{\n   copyDb <- FALSE\n }\n \n-if(!is.null(opt$l_rtrangeMax)){\n+if (!is.null(opt$l_rtrangeMax)) {\n   l_rtrangeMax <- opt$l_rtrangeMax\n }else{\n   l_rtrangeMax <- NA\n }\n \n-if(!is.null(opt$q_rtrangeMax)){\n+if (!is.null(opt$q_rtrangeMax)) {\n   q_rtrangeMax <- opt$q_rtrangeMax\n }else{\n   q_rtrangeMax <- NA\n }\n \n-if(!is.null(opt$l_rtrangeMin)){\n+if (!is.null(opt$l_rtrangeMin)) {\n   l_rtrangeMin <- opt$l_rtrangeMin\n }else{\n   l_rtrangeMin <- NA\n }\n \n-if(!is.null(opt$q_rtrangeMin)){\n+if (!is.null(opt$q_rtrangeMin)) {\n   q_rtrangeMin <- opt$q_rtrangeMin\n }else{\n   q_rtrangeMin <- NA\n }\n \n-q_check <- checkSPeakMeta(opt$q_dbPth, \'query\')\n-l_check <- checkSPeakMeta(opt$l_dbPth, \'library\')\n+q_check <- checkSPeakMeta(opt$q_dbPth, "query")\n+l_check <- checkSPeakMeta(opt$l_dbPth, "library")\n \n \n-if (q_check && l_check){\n+if (q_check && l_check) {\n     sm <- msPurity::spectralMatching(\n         q_purity =  opt$q_purity,\n         l_purity =  opt$l_purity,\n-        \n+\n         q_ppmProd =  opt$q_ppmProd,\n         l_ppmProd =  opt$l_ppmProd,\n-        \n+\n         q_ppmPrec =  opt$q_ppmPrec,\n         l_ppmPrec =  opt$l_ppmPrec,\n-        \n+\n         q_raThres =  opt$q_raThres,\n         l_raThres =  opt$l_raThres,\n-        \n+\n         q_pol =  q_polarity,\n         l_pol =  l_polarity,\n-        \n+\n+        q_spectraFilter = q_spectraFilter,\n+        l_spectraFilter = l_spectraFilter,\n+\n         q_xcmsGroups = q_xcmsGroups,\n         l_xcmsGroups = l_xcmsGroups,\n-        \n+\n         q_pids = q_pids,\n         l_pids = l_pids,\n-        \n+\n         q_sources = q_sources,\n         l_sources = l_sources,\n-        \n+\n         q_instrumentTypes = q_instrumentTypes,\n         l_instrumentTypes = l_instrumentTypes,\n-        \n-        q_spectraFilter= q_spectraFilter,\n-        l_spectraFilter= l_spectraFilter,\n-        \n-        l_rtrange=c(l_rtrangeMin, l_rtrangeMax),\n-        q_rtrange=c(q_rtrangeMin, q_rtrangeMax),\n-        \n+\n+        q_spectraTypes = q_spectraTypes,\n+        l_spectraTypes = l_spectraTypes,\n+\n+        l_rtrange = c(l_rtrangeMin, l_rtrangeMax),\n+        q_rtrange = c(q_rtrangeMin, q_rtrangeMax),\n+\n         q_accessions = opt$q_accessions,\n-        l_accessions= opt$l_accessions,\n-        \n+        l_accessions = opt$l_accessions,\n+\n         raW = opt$raW,\n         mzW = opt$mzW,\n-        rttol=opt$rttol,\n-        cores=opt$cores,\n-        \n-        copyDb=copyDb,\n-        updateDb=updateDb,\n+        rttol = opt$rttol,\n+        cores = opt$cores,\n+\n+        copyDb = copyDb,\n+        updateDb = updateDb,\n         outPth = "db_with_spectral_matching.sqlite",\n-        \n+\n         q_dbPth = q_dbPth,\n         q_dbType = q_dbType,\n         q_dbName = q_dbName,\n@@ -347,7 +355,7 @@\n         q_dbUser = q_dbUser,\n         q_dbPass = q_dbPass,\n         q_dbPort = q_dbPort,\n-        \n+\n         l_dbPth = l_dbPth,\n         l_dbType = l_dbType,\n         l_dbName = l_dbName,\n@@ -355,15 +363,15 @@\n         l_dbUser = l_dbUser,\n         l_dbPass = l_dbPass,\n         l_dbPort = l_dbPort\n-        \n+\n     )\n-    \n+\n     sm <- addQueryNameColumn(sm)\n     # Get name of the query results (and merged with the data frames)\n-    write.table(sm$matchedResults, \'matched_results.tsv\', sep = \'\\t\', row.names = FALSE, col.names = TRUE)\n-    write.table(sm$xcmsMatchedResults, \'xcms_matched_results.tsv\', sep = \'\\t\', row.names = FALSE, col.names = TRUE)\n-    \n-    if(updateDb){\n+    write.table(sm$matchedResults, "matched_results.tsv", sep = "\\t", row.names = FALSE, col.names = TRUE)\n+    write.table(sm$xcmsMatchedResults, "xcms_matched_results.tsv", sep = "\\t", row.names = FALSE, col.names = TRUE)\n+\n+    if (updateDb) {\n         updateDbF(q_con, l_con)\n     }\n }\n'
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/createDatabase_output.sqlite
b
Binary file test-data/createDatabase_output.sqlite has changed
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/createDatabase_output_eic.sqlite
b
Binary file test-data/createDatabase_output_eic.sqlite has changed
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/createMSP_output_av_all_metadata.msp
--- a/test-data/createMSP_output_av_all_metadata.msp Fri Nov 13 09:55:01 2020 +0000
+++ b/test-data/createMSP_output_av_all_metadata.msp Thu Mar 04 12:29:17 2021 +0000
b
@@ -10,7 +10,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
@@ -28,7 +28,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/createMSP_output_av_all_metadata_custom_adducts.msp
--- a/test-data/createMSP_output_av_all_metadata_custom_adducts.msp Fri Nov 13 09:55:01 2020 +0000
+++ b/test-data/createMSP_output_av_all_metadata_custom_adducts.msp Thu Mar 04 12:29:17 2021 +0000
b
@@ -10,7 +10,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
@@ -28,7 +28,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
@@ -46,7 +46,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
@@ -64,7 +64,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
@@ -82,7 +82,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
@@ -100,7 +100,7 @@
 CH$LINK: PUBCHEM CID:5328
 CH$NAME Unknown
 XCMS groupid (grpid): 12
-COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.12.2 
+COMMENT: Exported from msPurity purityA object using function createMSP, using method 'av_all' msPurity version:1.16.2 
 PK$NUM_PEAK: 2
 PK$PEAK: m/z int. rel.int.
 112.050884246826 502873.46875 100
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/spectralMatching_db_with_spectral_matching.sqlite
b
Binary file test-data/spectralMatching_db_with_spectral_matching.sqlite has changed
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/spectralMatching_db_with_spectral_matching_instrumentTypes.sqlite
b
Binary file test-data/spectralMatching_db_with_spectral_matching_instrumentTypes.sqlite has changed
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/spectralMatching_matched_results.tsv
--- a/test-data/spectralMatching_matched_results.tsv Fri Nov 13 09:55:01 2020 +0000
+++ b/test-data/spectralMatching_matched_results.tsv Thu Mar 04 12:29:17 2021 +0000
[
@@ -1,3 +1,3 @@
 "pid" "grpid" "mz" "mzmin" "mzmax" "rt" "rtmin" "rtmax" "npeaks" "sample" "LCMSMS_2" "LCMSMS_1" "LCMS_2" "LCMS_1" "grp_name" "lpid" "mid" "dpc" "rdpc" "cdpc" "mcount" "allcount" "mpercent" "library_rt" "query_rt" "rtdiff" "library_precursor_mz" "query_precursor_mz" "library_precursor_ion_purity" "query_precursor_ion_purity" "library_accession" "library_precursor_type" "library_entry_name" "inchikey" "library_source_name" "library_compound_name" "query_entry_name"
-1663 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 1 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
-1664 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 2 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1665 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 1 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1666 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 2 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/spectralMatching_matched_results_instrumentTypes.tsv
--- a/test-data/spectralMatching_matched_results_instrumentTypes.tsv Fri Nov 13 09:55:01 2020 +0000
+++ b/test-data/spectralMatching_matched_results_instrumentTypes.tsv Thu Mar 04 12:29:17 2021 +0000
[
@@ -1,3 +1,3 @@
 "pid" "grpid" "mz" "mzmin" "mzmax" "rt" "rtmin" "rtmax" "npeaks" "sample" "LCMSMS_2" "LCMSMS_1" "LCMS_2" "LCMS_1" "grp_name" "lpid" "mid" "dpc" "rdpc" "cdpc" "mcount" "allcount" "mpercent" "library_rt" "query_rt" "rtdiff" "library_precursor_mz" "query_precursor_mz" "library_precursor_ion_purity" "query_precursor_ion_purity" "library_accession" "library_precursor_type" "library_entry_name" "inchikey" "library_source_name" "library_compound_name" "query_entry_name"
-1663 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 1 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
-1664 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 2 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1665 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 1 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1666 14 113.035283604395 113.035156497997 113.03541992282 80.50932 77.16429 83.64567 4 4 88462324.9597518 92812020.095242 77298864.2688328 77198465.9156761 "M113T81" 56653 2 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/spectralMatching_xcms_matched_results.tsv
--- a/test-data/spectralMatching_xcms_matched_results.tsv Fri Nov 13 09:55:01 2020 +0000
+++ b/test-data/spectralMatching_xcms_matched_results.tsv Thu Mar 04 12:29:17 2021 +0000
[
@@ -1,3 +1,3 @@
 "qpid" "lpid" "mid" "dpc" "rdpc" "cdpc" "mcount" "allcount" "mpercent" "library_rt" "query_rt" "rtdiff" "library_precursor_mz" "query_precursor_mz" "library_precursor_ion_purity" "query_precursor_ion_purity" "library_accession" "library_precursor_type" "library_entry_name" "inchikey" "library_source_name" "library_compound_name" "query_entry_name"
-1663 56653 1 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
-1664 56653 2 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1665 56653 1 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1666 56653 2 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
b
diff -r e79c1a0654af -r 52d48bcd3608 test-data/spectralMatching_xcms_matched_results_instrumentTypes.tsv
--- a/test-data/spectralMatching_xcms_matched_results_instrumentTypes.tsv Fri Nov 13 09:55:01 2020 +0000
+++ b/test-data/spectralMatching_xcms_matched_results_instrumentTypes.tsv Thu Mar 04 12:29:17 2021 +0000
[
@@ -1,3 +1,3 @@
 "qpid" "lpid" "mid" "dpc" "rdpc" "cdpc" "mcount" "allcount" "mpercent" "library_rt" "query_rt" "rtdiff" "library_precursor_mz" "query_precursor_mz" "library_precursor_ion_purity" "query_precursor_ion_purity" "library_accession" "library_precursor_type" "library_entry_name" "inchikey" "library_source_name" "library_compound_name" "query_entry_name"
-1663 56653 1 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
-1664 56653 2 0.942265461847349 0.996860823822942 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1665 56653 1 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA
+1666 56653 2 0.942265461847349 0.945232713864488 0.753812369477879 1 4 0.25 NA 80.50932 NA "113.03508" 113.035283604395 NA 1 "PR100037" "[M+H]+" "Uracil" "ISAKRJDGNUQOIC-UHFFFAOYSA-N" "massbank" "Uracil" NA