diff checkformat_wrapper.R @ 3:80a38d36f946 draft

planemo upload for repository https://github.com/workflow4metabolomics/checkformat.git commit 5cf3f6eb62c1396ade1b068a3dd3cc2e3f827e15
author ethevenot
date Thu, 11 Jan 2018 10:24:56 -0500
parents b6a6b4cc932a
children
line wrap: on
line diff
--- a/checkformat_wrapper.R	Tue Jun 06 11:51:33 2017 -0400
+++ b/checkformat_wrapper.R	Thu Jan 11 10:24:56 2018 -0500
@@ -44,8 +44,8 @@
 
 resLs <- readAndCheckF(argVc["dataMatrix_in"],
                        argVc["sampleMetadata_in"],
-                       argVc["variableMetadata_in"])
-chkL <- resLs[["chkL"]]
+                       argVc["variableMetadata_in"],
+                       as.logical(argVc["makeNameL"]))
 
 
 ##------------------------------
@@ -53,51 +53,77 @@
 ##------------------------------
 
 
-if(chkL) {
+## dataMatrix
+
+datMN <- resLs[["datMN"]]
+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")
 
-    cat("\nTable formats are OK; enjoy your analyses!\n", sep="")
+## sampleMetadata
 
-    cat("\nEnd of the '", modNamC, "' Galaxy module call: ",
-        format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="")
+samDF <- resLs[["samDF"]]
+samDF <- cbind.data.frame(sampleMetadata = rownames(samDF),
+                          samDF)
+write.table(samDF,
+            file = argVc["sampleMetadata_out"],
+            quote = FALSE,
+            row.names = FALSE,
+            sep = "\t")
 
-    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()
-    
-} else {
-    
-    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")
+## variableMetadata
+
+varDF <- resLs[["varDF"]]
+varDF <- cbind.data.frame(variableMetadata = rownames(varDF),
+                          varDF)
+write.table(varDF,
+            file = argVc["variableMetadata_out"],
+            quote = FALSE,
+            row.names = FALSE,
+            sep = "\t")
 
-    sink()
-    stop("Please check the generated 'information' file")
+if(resLs[["chkL"]]) {
+
+    if(resLs[["newL"]]) {
+        
+        cat("\nWarning: The sample and/or variable names or orders from the input tables have been modified\n(see the information file for details); please use the new output tables for your analyses.\n")
+        
+    } else {
+
+        cat("\nThe input tables have a correct format and can be used for your analyses.\n")
+        
+    }
 
 }
+    
+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()
+
+if(!resLs[["chkL"]]) {
+    stop("Please check the generated 'information' file")
+}
+
 
 ## closing
 ##--------