# HG changeset patch
# User workflow4metabolomics
# Date 1710430544 0
# Node ID 8242376d9f351004ddfb91f50a3919825248274c
# Parent  36480435e92bc29ce9edd99cf52f0fb649a184ad
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit cc13a2654ccf6f9e55bc0120ea5518df3b045712
diff -r 36480435e92b -r 8242376d9f35 abims_xcms_refine.xml
--- a/abims_xcms_refine.xml	Mon Sep 11 09:21:15 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,264 +0,0 @@
-
-
-    Remove or merge chromatographic peaks based on specific criteria.
-
-    
-        macros.xml
-        macros_xcms.xml
-    
-
-    
-
-    
-
-    
-
-    
-        
-        
-            
-                
-                
-                
-            
-            
-                
-            
-            
-                
-                
-                
-                    
-                    
-                    
-                
-            
-            
-                
-                
-                
-                
-            
-        
-        
-
-        
-    
-
-    
-        
-    
-
-    
-        
-        
-            
-            
-                
-                
-                
-                
-                
-            
-            
-            
-                
-                
-                
-                
-                
-            
-            
-                
-                
-                
-                
-            
-        
-        
-        
-            
-            
-                
-                
-                
-                
-            
-            
-            
-                
-            
-            
-                
-                
-                
-                
-            
-        
-        
-        
-            
-            
-                
-                
-            
-            
-            
-                
-            
-            
-                
-                
-                
-                
-            
-        
-    
-
-    
-
-    
-      10.5281/zenodo.3909299
-      
-      10.1021/ac051437y
-    
-
-
-
diff -r 36480435e92b -r 8242376d9f35 abims_xcms_retcor.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/abims_xcms_retcor.xml	Thu Mar 14 15:35:44 2024 +0000
@@ -0,0 +1,383 @@
+
+
+    Retention Time Correction
+
+    
+        macros.xml
+        macros_xcms.xml
+    
+
+    
+    
+
+    
+
+    
+        
+        
+            
+                
+                
+            
+            
+                
+                
+                
+                    
+                        
+                        
+                    
+                    
+                        
+                            
+                            
+                                
+                                
+                            
+                        
+                    
+                    
+                
+            
+            
+                
+                
+                    
+                    
+                    
+                        
+                            
+                            
+                            
+                            
+                            
+                        
+                        
+                            
+                            
+                        
+                        
+                            
+                            
+                        
+                        
+                            
+                            
+                        
+                        
+                            
+                            
+                        
+                        
+                            
+                            
+                        
+                    
+                    
+                    
+                    
+                        
+                            
+                            
+                        
+                        
+                            
+                        
+                        
+                            
+                        
+                    
+                
+            
+        
+
+        
+
+    
+
+    
+        
+        
+    
+
+    
+        
+            
+            
+                
+                
+                
+                
+                    
+                    
+                
+            
+            
+            
+                
+                
+                
+                
+                
+                
+                
+                
+                
+            
+        
+        
+        
+    
+
+    
+
+
+    
+
+
diff -r 36480435e92b -r 8242376d9f35 xcms_refine.r
--- a/xcms_refine.r	Mon Sep 11 09:21:15 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-#!/usr/bin/env Rscript
-
-# ----- LOG FILE -----
-log_file <- file("log.txt", open  =  "wt")
-sink(log_file)
-sink(log_file, type = "output")
-
-
-# ----- PACKAGE -----
-cat("\tSESSION INFO\n")
-
-#Import the different functions
-source_local <- function(fname) {
-  argv <- commandArgs(trailingOnly = FALSE)
-  base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
-  source(paste(base_dir, fname, sep = "/"))
-}
-source_local("lib.r")
-
-pkgs <- c("xcms", "batch", "RColorBrewer")
-loadAndDisplayPackages(pkgs)
-cat("\n\n")
-
-# ----- ARGUMENTS -----
-cat("\tARGUMENTS INFO\n")
-# interpretation of arguments given in command line as an R list of objects
-args <- parseCommandArgs(evaluate = FALSE)
-write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t")
-
-cat("\n\n")
-
-# ----- PROCESSING INFILE -----
-cat("\tARGUMENTS PROCESSING INFO\n")
-
-#saving the specific parameters
-args_method  <- args$method
-args_image   <- args$image
-args_msLevel <- args$msLevel
-param_args <- list()
-
-if (args_method == "CleanPeaks") {
-  param_args$maxPeakwidth <- args$maxPeakwidth
-} else if (args_method == "FilterIntensity") {
-  param_args$threshold <- args$threshold
-  param_args$value <- args$value
-  param_args$nValues <- args$nValues
-} else if (args_method == "MergeNeighboringPeaks") {
-  param_args$expandRt <- args$expandRt
-  param_args$expandMz <- args$expandMz
-  param_args$ppm      <- args$ppm
-  param_args$minProp  <- args$minProp
-}
-
-cat("\n\n")
-
-
-# ----- ARGUMENTS PROCESSING -----
-cat("\tINFILE PROCESSING INFO\n")
-
-#image is an .RData file necessary to use xset variable given by previous tools
-load(args_image)
-if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. Such RData as this might have been created by an old version of XMCS 2.*")
-
-# Handle infiles
-if (!exists("singlefile")) singlefile <- NULL
-if (!exists("zipfile")) zipfile <- NULL
-rawFilePath <- retrieveRawfileInTheWorkingDir(singlefile, zipfile, args)
-zipfile <- rawFilePath$zipfile
-singlefile <- rawFilePath$singlefile
-
-cat("\n\n")
-
-
-# ----- MAIN PROCESSING INFO -----
-cat("\tMAIN PROCESSING INFO\n")
-
-
-cat("\t\tPREPARE PARAMETERS\n\n")
-
-if (args_method == "CleanPeaks") {
-  refineChromPeaksParam <- CleanPeaksParam(maxPeakwidth = param_args$maxPeakwidth)
-} else if (args_method == "FilterIntensity") {
-  refineChromPeaksParam <- FilterIntensityParam(
-    threshold = param_args$threshold,
-    nValues = param_args$nValues,
-    value = param_args$value
-  )
-} else if (args_method == "MergeNeighboringPeaks") {
-  refineChromPeaksParam <- MergeNeighboringPeaksParam(
-    expandRt = param_args$expandRt,
-    expandMz = param_args$expandMz,
-    ppm = param_args$ppm,
-    minProp = param_args$minProp
-  )
-}
-
-cat(str(refineChromPeaksParam))
-
-cat("\n\n\t\tCOMPUTE\n")
-
-xdata <- updateObject(xdata)
-
-xdata <- refineChromPeaks(xdata, param = refineChromPeaksParam)
-
-cat("\n\n")
-
-# ----- EXPORT -----
-
-cat("\tXCMSnExp OBJECT INFO\n")
-print(xdata)
-cat("\n\n")
-
-cat("\txcmsSet OBJECT INFO\n")
-# Get the legacy xcmsSet object
-xset <- getxcmsSetObject(xdata)
-print(xset)
-cat("\n\n")
-
-#saving R data in .Rdata file to save the variables used in the present tool
-objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList")
-save(list = objects2save[objects2save %in% ls()], file = "xcmsSet.RData")
-
-cat("\n\n")
-
-
-cat("\tDONE\n")
diff -r 36480435e92b -r 8242376d9f35 xcms_retcor.r
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms_retcor.r	Thu Mar 14 15:35:44 2024 +0000
@@ -0,0 +1,107 @@
+#!/usr/bin/env Rscript
+
+# ----- LOG FILE -----
+log_file <- file("log.txt", open = "wt")
+sink(log_file)
+sink(log_file, type = "output")
+
+
+# ----- PACKAGE -----
+cat("\tSESSION INFO\n")
+
+#Import the different functions
+source_local <- function(fname) {
+  argv <- commandArgs(trailingOnly = FALSE)
+  base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
+  source(paste(base_dir, fname, sep = "/"))
+}
+source_local("lib.r")
+
+pkgs <- c("xcms", "batch", "RColorBrewer")
+loadAndDisplayPackages(pkgs)
+cat("\n\n")
+
+
+# ----- ARGUMENTS -----
+cat("\tARGUMENTS INFO\n")
+args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects
+write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t")
+
+cat("\n\n")
+
+# ----- PROCESSING INFILE -----
+cat("\tARGUMENTS PROCESSING INFO\n")
+
+#saving the specific parameters
+method <- args$method
+
+cat("\n\n")
+
+
+# ----- ARGUMENTS PROCESSING -----
+cat("\tINFILE PROCESSING INFO\n")
+
+#image is an .RData file necessary to use xset variable given by previous tools
+load(args$image)
+args$image <- NULL
+if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*")
+
+# Handle infiles
+if (!exists("singlefile")) singlefile <- NULL
+if (!exists("zipfile")) zipfile <- NULL
+rawFilePath <- retrieveRawfileInTheWorkingDir(singlefile, zipfile, args)
+zipfile <- rawFilePath$zipfile
+singlefile <- rawFilePath$singlefile
+
+cat("\n\n")
+
+
+# ----- MAIN PROCESSING INFO -----
+cat("\tMAIN PROCESSING INFO\n")
+
+
+cat("\t\tCOMPUTE\n")
+
+cat("\t\t\tAlignment/Retention Time correction\n")
+# clear the arguement list to remove unexpected key/value as singlefile_galaxyPath or method ...
+args <- args[names(args) %in% slotNames(do.call(paste0(method, "Param"), list()))]
+
+adjustRtimeParam <- do.call(paste0(method, "Param"), args)
+print(adjustRtimeParam)
+
+if (hasAdjustedRtime(xdata)) {
+  cat("WARNING: a retention time ajustment had already been applied to your data.\nThe function applyAdjustedRtime was processed to cumulate the ajustment")
+  cat("Replace raw retention times with adjusted retention times.\n")
+  xdata <- applyAdjustedRtime(xdata)
+}
+xdata <- adjustRtime(xdata, param = adjustRtimeParam)
+
+cat("\n\n")
+
+
+# -- TIC --
+cat("\t\tDRAW GRAPHICS\n")
+getPlotAdjustedRtime(xdata)
+
+cat("\n\n")
+
+# ----- EXPORT -----
+
+cat("\tXCMSnExp OBJECT INFO\n")
+print(xdata)
+cat("\n\n")
+
+cat("\txcmsSet OBJECT INFO\n")
+# Get the legacy xcmsSet object
+xset <- getxcmsSetObject(xdata)
+print(xset)
+cat("\n\n")
+
+#saving R data in .Rdata file to save the variables used in the present tool
+objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList")
+save(list = objects2save[objects2save %in% ls()], file = "retcor.RData")
+
+cat("\n\n")
+
+
+cat("\tDONE\n")