diff purityA.R @ 8:e98ae5c1f4e7 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
author computational-metabolomics
date Wed, 12 Jun 2024 16:01:28 +0000
parents 52d48bcd3608
children
line wrap: on
line diff
--- a/purityA.R	Tue Feb 08 13:54:03 2022 +0000
+++ b/purityA.R	Wed Jun 12 16:01:28 2024 +0000
@@ -3,20 +3,20 @@
 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))
@@ -25,23 +25,27 @@
 if (opt$iwNorm == "none") {
     iwNorm <- FALSE
     iwNormFun <- NULL
-}else if (opt$iwNorm == "gauss") {
+} 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))
+        print("User has to define offsets if using Gaussian normalisation")
+    } else {
+        iwNormFun <- msPurity::iwNormGauss(
+            minOff = -as.numeric(opt$minOffset),
+            maxOff = as.numeric(opt$maxOffset)
+        )
     }
-}else if (opt$iwNorm == "rcosine") {
+} 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))
+        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)
+        )
     }
-}else if (opt$iwNorm == "QE5") {
+} else if (opt$iwNorm == "QE5") {
     iwNorm <- TRUE
     iwNormFun <- msPurity::iwNormQE.5()
 }
@@ -53,27 +57,27 @@
 
 if (is.null(opt$minOffset) || is.null(opt$maxOffset)) {
     offsets <- NA
-}else{
+} else {
     offsets <- as.numeric(c(opt$minOffset, opt$maxOffset))
 }
 
 
 if (is.null(opt$mostIntense)) {
     mostIntense <- FALSE
-}else{
+} else {
     mostIntense <- TRUE
 }
 
 if (is.null(opt$nearest)) {
     nearest <- FALSE
-}else{
+} else {
     nearest <- TRUE
 }
 
 if (is.null(opt$plotP)) {
     plotP <- FALSE
     plotdir <- NULL
-}else{
+} else {
     plotP <- TRUE
     plotdir <- opt$out_dir
 }
@@ -81,32 +85,34 @@
 
 if (is.null(opt$isotope_matrix)) {
     im <- NULL
-}else{
+} 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)) {
     isotopes <- FALSE
-}else{
+} else {
     isotopes <- TRUE
 }
 
 pa <- msPurity::purityA(filepaths,
-                        cores = opt$cores,
-                        mostIntense = mostIntense,
-                        nearest = nearest,
-                        offsets = offsets,
-                        plotP = plotP,
-                        plotdir = plotdir,
-                        interpol = "linear",
-                        iwNorm = iwNorm,
-                        iwNormFun = iwNormFun,
-                        ilim = opt$ilim,
-                        mzRback = "pwiz",
-                        isotopes = isotopes,
-                        im = im,
-                        ppmInterp = opt$ppmInterp)
+    cores = opt$cores,
+    mostIntense = mostIntense,
+    nearest = nearest,
+    offsets = offsets,
+    plotP = plotP,
+    plotdir = plotdir,
+    interpol = "linear",
+    iwNorm = iwNorm,
+    iwNormFun = iwNormFun,
+    ilim = opt$ilim,
+    mzRback = "pwiz",
+    isotopes = isotopes,
+    im = im,
+    ppmInterp = opt$ppmInterp
+)
 
 
 if (!is.null(opt$galaxy_names)) {