changeset 0:be1a1416cf28 draft

Uploaded
author christian-h
date Thu, 09 Jan 2014 07:54:55 -0500
parents
children 822d596ca826
files ToolShedTest/IO_test.R ToolShedTest/IO_test.xml ToolShedTest/IO_test.xml~ ToolShedTest/discard_stderr_wrapper.sh
diffstat 4 files changed, 108 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ToolShedTest/IO_test.R	Thu Jan 09 07:54:55 2014 -0500
@@ -0,0 +1,33 @@
+# AIM: Test some IO features betweent Python/Galaxy and R
+# 
+# Author: Christian Hundsrucker
+###############################################################################
+#options(echo=FALSE) #non-interactive -> galaxy
+#options(echo=TRUE)
+#I/O
+#args: filename input
+cargs <- commandArgs(trailingOnly = TRUE)
+args.no<-length(cargs)-1 #last argument is output-file
+outputfile<-cargs[args.no+1]
+
+#functions
+mapKV<-function(keyValue){
+	if (length(keyValue)>2){
+		stop("Wrong arguments used!")
+	}
+	if (length(keyValue)==2){
+		value<-keyValue[2]
+		names(value)<-keyValue[1]
+	}else {
+		value<-keyValue[1]
+		names(value)<-""
+	}
+	return(value)
+}
+
+KVargs<-strsplit(cargs[1:args.no],"([ \t])*=([ \t])*",fixed = FALSE, perl = FALSE, useBytes = FALSE)
+keyValues<-unlist(lapply(KVargs,mapKV))
+
+output<-paste(names(keyValues),keyValues,sep=" -- ")
+output<-paste(output,"\n","current dir: ",getwd(),"\n",sep="")
+capture.output(print(output),file=outputfile,append=FALSE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ToolShedTest/IO_test.xml	Thu Jan 09 07:54:55 2014 -0500
@@ -0,0 +1,21 @@
+<tool id="IOTest" name="IO-Test" version="0.0.1">
+  <description>for Galaxy-R IO-Testing</description>
+  <command interpreter="bash">
+	discard_stderr_wrapper.sh R --slave --vanilla -f IO_test.R --args key=$input01 test="" user="$__user_email__" toolPath=$__tool_data_path__ mylocals="${ locals() }" mydir="${ dir() }" myself="${ dir(self) }" mygroup=${ str($__app__.model.UserGroupAssociation.group) } url1=$__app__.config.fluent_host url2=$__app__.config.fluent_port rootPath=$__root_dir__ output01
+  </command>
+  <inputs>
+  	<param name="input01" type="data" format="txt" label="Text File" />
+  </inputs>
+  <outputs>
+       <data name="output01" type="data" format="txt" label="IOreport" />
+  </outputs> 
+
+
+  <help>
+[!!testing!!]
+This is just for testing the python/galaxy - R IO-Interface!
+
+The output is plain text.
+[!!testing!!]
+  </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ToolShedTest/IO_test.xml~	Thu Jan 09 07:54:55 2014 -0500
@@ -0,0 +1,21 @@
+<tool id="IOTest" name="IO-Test" version="0.0.1">
+  <description>for Galaxy-R IO-Testing</description>
+  <command interpreter="bash">
+	/work/galaxy/galaxy_dist/tools/fmi_quasr/discard_stderr_wrapper.sh /work/galaxy/helper/R/R-3.0.1/bin/R --slave --vanilla -f /work/galaxy/galaxy_dist/tools/fmi_quasr/IO_test.R --args key=$input01 test="" user="$__user_email__" toolPath=$__tool_data_path__ mylocals="${ locals() }" mydir="${ dir() }" myself="${ dir(self) }" mygroup=${ str($__app__.model.UserGroupAssociation.group) } url1=$__app__.config.fluent_host url2=$__app__.config.fluent_port rootPath=$__root_dir__ output01
+  </command>
+  <inputs>
+  	<param name="input01" type="data" format="txt" label="Text File" />
+  </inputs>
+  <outputs>
+       <data name="output01" type="data" format="txt" label="IOreport" />
+  </outputs> 
+
+
+  <help>
+[!!testing!!]
+This is just for testing the python/galaxy - R IO-Interface!
+
+The output is plain text.
+[!!testing!!]
+  </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ToolShedTest/discard_stderr_wrapper.sh	Thu Jan 09 07:54:55 2014 -0500
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# STDERR wrapper - discards STDERR if command execution was OK.
+
+#
+# This script executes a given command line,
+# while saving the STDERR in a temporary file.
+#
+# When the command is completed, it checks to see if the exit code was zero.
+# if so - the command is assumed to have succeeded - the STDERR file is discarded.
+# if not - the command is assumed to have failed, and the STDERR file is dumped to the real STDERR
+#
+#
+# Use this wrapper for tools which insist on writing stuff to STDERR even if they succeeded -
+# which throws galaxy off balance.
+#
+#
+# Copyright 2009 (C) by Assaf Gordon
+# This file is distributed under the BSD license.
+
+TMPFILE=$(mktemp) || exit 1
+
+"$@" 2> $TMPFILE
+
+EXITCODE=$?
+# Exitcode != 0 ?
+if [ "$EXITCODE" -ne "0" ]; then
+       cat $TMPFILE >&2
+fi
+rm $TMPFILE
+
+exit $EXITCODE
+