# HG changeset patch
# User refinery-platform
# Date 1460750030 14400
# Node ID 5b28174e774dba8b5dced917034f79b632f6ca90
Uploaded
diff -r 000000000000 -r 5b28174e774d refinery_test_1-1.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/refinery_test_1-1.xml Fri Apr 15 15:53:50 2016 -0400
@@ -0,0 +1,49 @@
+
+ for testing Galaxy workflow execution from Refinery
+
+
+ refinery_test_tool.py -i $input_file -o $output_file -e $exit_code -p $p_fail -s $sleep_time $stdout $stderr $empty_outfile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**Purpose**
+
+To test Galaxy workflow execution and monitoring from Refinery.
+
+-----
+
+.. class:: infomark
+
+**Inputs and outputs**
+
+This wrapper will accept one text file as input and produce a single output file
+with content from input.
+
+*Note:* You must set the "Probability of failure" parameter to a non-zero value
+for "Write to standard out", "Write to standard error" or "Exit code" to take effect.
+
+
+
diff -r 000000000000 -r 5b28174e774d refinery_test_1-2.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/refinery_test_1-2.xml Fri Apr 15 15:53:50 2016 -0400
@@ -0,0 +1,50 @@
+
+ for testing Galaxy workflow execution from Refinery
+
+
+ refinery_test_tool.py -i $input_file -o $output_file1 $output_file2 -e $exit_code -p $p_fail -s $sleep_time $stdout $stderr $empty_outfile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**Purpose**
+
+To test Galaxy workflow execution and monitoring from Refinery.
+
+-----
+
+.. class:: infomark
+
+**Inputs and outputs**
+
+This wrapper will accept one text file as input and produce two output files
+with content from input.
+
+*Note:* You must set the "Probability of failure" parameter to a non-zero value
+for "Write to standard out", "Write to standard error" or "Exit code" to take effect.
+
+
+
diff -r 000000000000 -r 5b28174e774d refinery_test_2-1.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/refinery_test_2-1.xml Fri Apr 15 15:53:50 2016 -0400
@@ -0,0 +1,50 @@
+
+ for testing Galaxy workflow execution from Refinery
+
+
+ refinery_test_tool.py -i $input_file1 $input_file2 -o $output_file -e $exit_code -p $p_fail -s $sleep_time $stdout $stderr $empty_outfile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**Purpose**
+
+To test Galaxy workflow execution and monitoring from Refinery.
+
+-----
+
+.. class:: infomark
+
+**Inputs and outputs**
+
+This wrapper will accept two text files as input and produce a single output file
+with concatenated content from input files.
+
+*Note:* You must set the "Probability of failure" parameter to a non-zero value
+for "Write to standard out", "Write to standard error" or "Exit code" to take effect.
+
+
+
diff -r 000000000000 -r 5b28174e774d refinery_test_2-2.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/refinery_test_2-2.xml Fri Apr 15 15:53:50 2016 -0400
@@ -0,0 +1,51 @@
+
+ for testing Galaxy workflow execution from Refinery
+
+
+ refinery_test_tool.py -i $input_file1 $input_file2 -o $output_file1 $output_file2 -e $exit_code -p $p_fail -s $sleep_time $stdout $stderr $empty_outfile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**Purpose**
+
+To test Galaxy workflow execution and monitoring from Refinery.
+
+-----
+
+.. class:: infomark
+
+**Inputs and outputs**
+
+This wrapper will accept two text files as input and produce two output files
+with concatenated content from input files.
+
+*Note:* You must set the "Probability of failure" parameter to a non-zero value
+for "Write to standard out", "Write to standard error" or "Exit code" to take effect.
+
+
+
diff -r 000000000000 -r 5b28174e774d refinery_test_2-6.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/refinery_test_2-6.xml Fri Apr 15 15:53:50 2016 -0400
@@ -0,0 +1,55 @@
+
+ for testing Galaxy workflow execution from Refinery
+
+
+ refinery_test_tool.py -i $input_file1 $input_file2 -o $output_file1 $output_file2 $output_file3 $output_file4 $output_file5 $output_file6 -e $exit_code -p $p_fail -s $sleep_time $stdout $stderr $empty_outfile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**Purpose**
+
+To test Galaxy workflow execution and monitoring from Refinery.
+
+-----
+
+.. class:: infomark
+
+**Inputs and outputs**
+
+This wrapper will accept two text files as input and produce six output files
+with concatenated content from input files.
+
+*Note:* You must set the "Probability of failure" parameter to a non-zero value
+for "Write to standard out", "Write to standard error" or "Exit code" to take effect.
+
+
+
diff -r 000000000000 -r 5b28174e774d refinery_test_tool.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/refinery_test_tool.py Fri Apr 15 15:53:50 2016 -0400
@@ -0,0 +1,132 @@
+#!/usr/bin/env python
+
+'''
+Test tool for running Galaxy workflows from Refinery
+
+@author: Ilya Sytchev
+
+Input: one or more text files
+Output: concatenated input file(s) plus annotation
+
+Requires Python v2.7
+
+'''
+
+
+import argparse
+import random
+import sys
+import time
+
+
+def main(args):
+ time.sleep(args.seconds)
+
+ if check_fail(args.p_fail):
+ cleanup(args)
+ quit("Processing failed by request", args)
+
+ input = read_files(args.input_files)
+ try:
+ for out_file in args.output_files:
+ if args.empty_outfile:
+ output = ''
+ else:
+ output = "Output file name: " + out_file.name + "\n\n" + input
+ out_file.write(output)
+ except IOError as e:
+ cleanup(args)
+ parser.error(e)
+ else:
+ cleanup(args)
+
+
+def check_fail(p_fail):
+ '''Determine success/failure state given a probability of failure
+
+ '''
+ random.seed()
+ if random.random() < p_fail:
+ return True
+ else:
+ return False
+
+
+def read_files(file_list):
+ '''Read files from disk into a string
+
+ '''
+ str = ''
+ for in_file in file_list:
+ str += "Input file name: " + in_file.name + "\n\n"
+ str += in_file.read()
+ return str
+
+
+def cleanup(args):
+ '''Close all open file handles
+
+ '''
+ file_list = []
+ if args.input_files:
+ file_list.extend(args.input_files)
+ if args.output_files:
+ file_list.extend(args.output_files)
+ for fh in file_list:
+ try:
+ fh.close()
+ except AttributeError:
+ continue
+
+
+def quit(message, args):
+ '''Exit and optionally write to stdout and/or stderr
+
+ '''
+ if args.stdout:
+ sys.stdout.write(message + '\n')
+ if args.stderr:
+ sys.stderr.write(message + '\n')
+ sys.exit(args.exit_code)
+
+
+if __name__ == '__main__':
+ version = "%(prog)s 0.1"
+ description = "Test tool for running workflows on Galaxy platform from Refinery"
+ parser = argparse.ArgumentParser(description=description, version=version)
+
+ parser.add_argument('-i', '--in-file', dest='input_files', nargs='+',
+ type=file, metavar='INPUT_FILE', required=True,
+ help='name of the input file')
+ parser.add_argument('-o', '--out-file', dest='output_files', nargs='+',
+ type=argparse.FileType('w'), metavar='OUTPUT_FILE',
+ required=True, help='name of the output file')
+ parser.add_argument('-e', '--exit_code', type=int, default=0,
+ help='code to return on exit, default: %(default)s')
+ parser.add_argument('--stdout', action='store_true',
+ help='write a message to stdout')
+ parser.add_argument('--stderr', action='store_true',
+ help='write a message to stderr')
+ parser.add_argument('--empty_outfile', action='store_true',
+ help='produce empty output file(s)')
+ parser.add_argument('-p', '--p-fail', type=float, default=0.0,
+ help='probability of execution failure, default: %(default)s')
+ parser.add_argument('-s', '--sleep', dest='seconds', type=int, default=0,
+ metavar='SECONDS',
+ help='number of seconds to sleep, default: %(default)s')
+
+ # check argument values for errors
+ try:
+ args = parser.parse_args()
+ except IOError as e:
+ parser.error(e)
+
+ if args.exit_code < 0 or args.exit_code > 255:
+ cleanup(args)
+ parser.error("Exit code value must be between 0 and 255")
+
+ if args.p_fail < 0.0 or args.p_fail > 1.0:
+ cleanup(args)
+ parser.error("Probability value must be between 0.0 and 1.0 inclusive")
+
+ main(args)