# HG changeset patch # User christian-h # Date 1389272095 18000 # Node ID be1a1416cf28b7f7b1fe33eb744774bf8817159f Uploaded diff -r 000000000000 -r be1a1416cf28 ToolShedTest/IO_test.R --- /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) diff -r 000000000000 -r be1a1416cf28 ToolShedTest/IO_test.xml --- /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 @@ + + for Galaxy-R IO-Testing + + 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 + + + + + + + + + + +[!!testing!!] +This is just for testing the python/galaxy - R IO-Interface! + +The output is plain text. +[!!testing!!] + + diff -r 000000000000 -r be1a1416cf28 ToolShedTest/IO_test.xml~ --- /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 @@ + + for Galaxy-R IO-Testing + + /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 + + + + + + + + + + +[!!testing!!] +This is just for testing the python/galaxy - R IO-Interface! + +The output is plain text. +[!!testing!!] + + diff -r 000000000000 -r be1a1416cf28 ToolShedTest/discard_stderr_wrapper.sh --- /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 +