diff MS2snoop.R @ 7:2a1f120a6874 draft default tip

planemo upload commit d9b3849751af6f74e3371db0c3525dcd08728723
author workflow4metabolomics
date Tue, 10 Jan 2023 11:07:48 +0000
parents 77abacd33c31
children
line wrap: on
line diff
--- a/MS2snoop.R	Fri Sep 30 16:18:56 2022 +0000
+++ b/MS2snoop.R	Tue Jan 10 11:07:48 2023 +0000
@@ -54,7 +54,8 @@
   mzref,
   spectra,
   processing_parameters,
-  background = !TRUE
+  background = !TRUE,
+  show_sirius_outputs = !TRUE
 ) {
   if (is.vector(mzref) && length(mzref) > 1) {
     return(lapply(
@@ -89,13 +90,16 @@
       "-i='%s'",
       "-o='%s'",
       "tree",
-      ## loglevel is not working taken into account during
-      ## sirius startup, so we filter outputs...
-      "2>&1 | grep '^(WARNING|SEVERE)'"
+      "2>&1"
     ),
     input,
     output
   )
+  if (!show_sirius_outputs) {
+    ## loglevel is not taken into account during
+    ## sirius startup, so we filter outputs...
+    command <- paste(command, "| grep '^(WARNING|SEVERE)'")
+  }
   verbose_catf(
     ">> Sirius is running %swith the command: %s\n",
     if (background) "in the background " else "",
@@ -189,7 +193,8 @@
     return(rep(NA, length(mz_list)))
   }
   if (!is.null(trees_filename)) {
-    sirius_results <- cbind(sirius_results, extract_sirius_ppm(trees_filename))
+    extracted_ppm <- extract_sirius_ppm(trees_filename)
+    sirius_results <- cbind(sirius_results, extracted_ppm)
   } else {
     return(rep(NA, length(mz_list)))
   }
@@ -210,7 +215,7 @@
 
   for (index in seq_len(nrow(sirius_results))) {
     result <- sirius_results[index, ]
-    filter <- which(order(abs(fragment_matchings$mz - result$mz)) == 1)
+    filter <- order(abs(fragment_matchings$mz - result$mz))[1]
     fragment_matchings[filter, "formula"] <- result$formula
     fragment_matchings[filter, "ppm"] <- result$ppm
     catf(
@@ -1124,7 +1129,7 @@
 
 zip_pdfs <- function(processing_parameters) {
   if (processing_parameters$do_pdf) {
-    if (zip <- Sys.getenv("R_ZIPCMD", "zip") == "") {
+    if ((zip <- Sys.getenv("R_ZIPCMD", "zip")) == "") {
       catf("R could not fin the zip executable. Trying luck: zip = \"zip\"")
       zip <- "zip"
     } else {