diff transformation_wrapper.R @ 0:c7b8e82af08e draft

planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 308ae36af707ede5697d1b8a0c93f8b5b68872cf
author ethevenot
date Tue, 24 Oct 2017 08:59:35 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/transformation_wrapper.R	Tue Oct 24 08:59:35 2017 -0400
@@ -0,0 +1,119 @@
+#!/usr/bin/env Rscript
+
+library(batch) ## parseCommandArgs
+
+# Constants
+argv <- commandArgs(trailingOnly = FALSE)
+script.path <- sub("--file=","",argv[grep("--file=",argv)])
+prog.name <- basename(script.path)
+
+# Print help
+if (length(grep('-h', argv)) >0) {
+	cat("Usage:", prog.name,
+	    "dataMatrix_in myDataMatrixInput.tsv",
+	    "method log2|log10|sqrt",
+	    "dataMatrix_out myDataMatrixOutput.tsv",
+	    "information information.txt",
+		"\n")
+	quit(status = 0)
+}
+
+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("transformation_script.R")
+
+argVc <- unlist(parseCommandArgs(evaluate=FALSE))
+
+
+##------------------------------
+## Initializing
+##------------------------------
+
+## options
+##--------
+
+strAsFacL <- options()[["stringsAsFactors"]]
+options(stringsAsFactors=FALSE)
+
+## constants
+##----------
+
+modNamC <- "Transformation" ## module name
+
+
+## log file
+##---------
+
+sink(argVc[["information"]])
+
+cat("\nStart of the '", modNamC, "' module: ",
+    format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="")
+
+## loading
+##--------
+
+datMN <- t(as.matrix(read.table(argVc[["dataMatrix_in"]],
+                                check.names = FALSE,
+                                header = TRUE,
+                                row.names = 1,
+                                sep = "\t")))
+
+metC <- argVc[["method"]]
+
+
+##------------------------------
+## Computation
+##------------------------------
+
+
+datMN <- transformF(datMN = datMN, ## dataMatrix
+                    metC = metC)  ## transformation method
+
+
+##------------------------------
+## Ending
+##------------------------------
+
+
+## saving
+##-------
+
+datDF <- cbind.data.frame(dataMatrix = colnames(datMN),
+                          as.data.frame(t(datMN)))
+write.table(datDF,
+            file = argVc[["dataMatrix_out"]],
+            quote = FALSE,
+            row.names = FALSE,
+            sep = "\t")
+
+## ending
+##-------
+
+cat("\nEnd of the '", modNamC, "' Galaxy module call: ",
+    format(Sys.time(), "%a %d %b %Y %X"), "\n", sep = "")
+
+cat("\n\n\n============================================================================")
+cat("\nAdditional information about the call:\n")
+cat("\n1) Parameters:\n")
+print(cbind(value = argVc))
+
+cat("\n2) Session Info:\n")
+sessioninfo <- sessionInfo()
+cat(sessioninfo$R.version$version.string,"\n")
+cat("Main packages:\n")
+for (pkg in names(sessioninfo$otherPkgs)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
+cat("Other loaded packages:\n")
+for (pkg in names(sessioninfo$loadedOnly)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
+
+cat("============================================================================\n")
+
+sink()
+
+options(stringsAsFactors = strAsFacL)
+
+
+rm(list = ls())