Mercurial > repos > refinery-platform > refinery_test
changeset 0:5b28174e774d draft
Uploaded
| author | refinery-platform |
|---|---|
| date | Fri, 15 Apr 2016 15:53:50 -0400 |
| parents | |
| children | b87749d7a24c |
| files | refinery_test_1-1.xml refinery_test_1-2.xml refinery_test_2-1.xml refinery_test_2-2.xml refinery_test_2-6.xml refinery_test_tool.py |
| diffstat | 6 files changed, 387 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 @@ +<tool id="refinery_test_1-1" name="Refinery test tool 1-1" version="0.1"> + <description>for testing Galaxy workflow execution from Refinery</description> + + <command interpreter="python"> + refinery_test_tool.py -i $input_file -o $output_file -e $exit_code -p $p_fail -s $sleep_time $stdout $stderr $empty_outfile + </command> + + <inputs> + <param name="input_file" format="txt" type="data" label="Input file"/> + <param name="sleep_time" type="integer" label="Sleep (seconds)" value="0" min="0"/> + <param name="empty_outfile" type="boolean" label="Produce empty output file" truevalue="--empty_outfile" falsevalue=""/> + <param name="p_fail" type="float" label="Probability of failure [0.0, 1.0]" value="0.0" min="0.0" max="1.0"/> + <param name="stdout" type="boolean" label="Write to standard out" truevalue="--stdout" falsevalue=""/> + <param name="stderr" type="boolean" label="Write to standard error" truevalue="--stderr" falsevalue=""/> + <param name="exit_code" type="integer" label="Exit code [0, 255]" value="0" min="0" max="255"/> + </inputs> + + <outputs> + <data format="txt" name="output_file" label="Output file"/> + </outputs> + + <stdio> + <exit_code range="1:" level="fatal" /> + <regex match=".+" source="stdout" level="fatal" description="Tool produced output to standard out" /> + <regex match=".+" source="stderr" level="fatal" description="Tool produced output to standard error" /> + </stdio> + + <help> + +.. 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. + + </help> +</tool>
--- /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 @@ +<tool id="refinery_test_1-2" name="Refinery test tool 1-2" version="0.1"> + <description>for testing Galaxy workflow execution from Refinery</description> + + <command interpreter="python"> + 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 + </command> + + <inputs> + <param name="input_file" format="txt" type="data" label="Input file"/> + <param name="sleep_time" type="integer" label="Sleep (seconds)" value="0" min="0"/> + <param name="empty_outfile" type="boolean" label="Produce empty output files" truevalue="--empty_outfile" falsevalue=""/> + <param name="p_fail" type="float" label="Probability of failure [0.0, 1.0]" value="0.0" min="0.0" max="1.0"/> + <param name="stdout" type="boolean" label="Write to standard out" truevalue="--stdout" falsevalue=""/> + <param name="stderr" type="boolean" label="Write to standard error" truevalue="--stderr" falsevalue=""/> + <param name="exit_code" type="integer" label="Exit code [0, 255]" value="0" min="0" max="255"/> + </inputs> + + <outputs> + <data format="txt" name="output_file1" label="Output file A"/> + <data format="txt" name="output_file2" label="Output file B"/> + </outputs> + + <stdio> + <exit_code range="1:" level="fatal" /> + <regex match=".+" source="stdout" level="fatal" description="Tool produced output to standard out" /> + <regex match=".+" source="stderr" level="fatal" description="Tool produced output to standard error" /> + </stdio> + + <help> + +.. 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. + + </help> +</tool>
--- /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 @@ +<tool id="refinery_test_2-1" name="Refinery test tool 2-1" version="0.1"> + <description>for testing Galaxy workflow execution from Refinery</description> + + <command interpreter="python"> + 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 + </command> + + <inputs> + <param name="input_file1" format="txt" type="data" label="Input file A"/> + <param name="input_file2" format="txt" type="data" label="Input file B"/> + <param name="sleep_time" type="integer" label="Sleep (seconds)" value="0" min="0"/> + <param name="empty_outfile" type="boolean" label="Produce empty output file" truevalue="--empty_outfile" falsevalue=""/> + <param name="p_fail" type="float" label="Probability of failure [0.0, 1.0]" value="0.0" min="0.0" max="1.0"/> + <param name="stdout" type="boolean" label="Write to standard out" truevalue="--stdout" falsevalue=""/> + <param name="stderr" type="boolean" label="Write to standard error" truevalue="--stderr" falsevalue=""/> + <param name="exit_code" type="integer" label="Exit code [0, 255]" value="0" min="0" max="255"/> + </inputs> + + <outputs> + <data format="txt" name="output_file" label="Output file"/> + </outputs> + + <stdio> + <exit_code range="1:" level="fatal" /> + <regex match=".+" source="stdout" level="fatal" description="Tool produced output to standard out" /> + <regex match=".+" source="stderr" level="fatal" description="Tool produced output to standard error" /> + </stdio> + + <help> + +.. 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. + + </help> +</tool>
--- /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 @@ +<tool id="refinery_test_2-2" name="Refinery test tool 2-2" version="0.1"> + <description>for testing Galaxy workflow execution from Refinery</description> + + <command interpreter="python"> + 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 + </command> + + <inputs> + <param name="input_file1" format="txt" type="data" label="Input file A"/> + <param name="input_file2" format="txt" type="data" label="Input file B"/> + <param name="sleep_time" type="integer" label="Sleep (seconds)" value="0" min="0"/> + <param name="empty_outfile" type="boolean" label="Produce empty output files" truevalue="--empty_outfile" falsevalue=""/> + <param name="p_fail" type="float" label="Probability of failure [0.0, 1.0]" value="0.0" min="0.0" max="1.0"/> + <param name="stdout" type="boolean" label="Write to standard out" truevalue="--stdout" falsevalue=""/> + <param name="stderr" type="boolean" label="Write to standard error" truevalue="--stderr" falsevalue=""/> + <param name="exit_code" type="integer" label="Exit code [0, 255]" value="0" min="0" max="255"/> + </inputs> + + <outputs> + <data format="txt" name="output_file1" label="Output file A"/> + <data format="txt" name="output_file2" label="Output file B"/> + </outputs> + + <stdio> + <exit_code range="1:" level="fatal" /> + <regex match=".+" source="stdout" level="fatal" description="Tool produced output to standard out" /> + <regex match=".+" source="stderr" level="fatal" description="Tool produced output to standard error" /> + </stdio> + + <help> + +.. 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. + + </help> +</tool>
--- /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 @@ +<tool id="refinery_test_2-6" name="Refinery test tool 2-6" version="0.1"> + <description>for testing Galaxy workflow execution from Refinery</description> + + <command interpreter="python"> + 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 + </command> + + <inputs> + <param name="input_file1" format="txt" type="data" label="Input file A"/> + <param name="input_file2" format="txt" type="data" label="Input file B"/> + <param name="sleep_time" type="integer" label="Sleep (seconds)" value="0" min="0"/> + <param name="empty_outfile" type="boolean" label="Produce empty output files" truevalue="--empty_outfile" falsevalue=""/> + <param name="p_fail" type="float" label="Probability of failure [0.0, 1.0]" value="0.0" min="0.0" max="1.0"/> + <param name="stdout" type="boolean" label="Write to standard out" truevalue="--stdout" falsevalue=""/> + <param name="stderr" type="boolean" label="Write to standard error" truevalue="--stderr" falsevalue=""/> + <param name="exit_code" type="integer" label="Exit code [0, 255]" value="0" min="0" max="255"/> + </inputs> + + <outputs> + <data format="txt" name="output_file1" label="Output file A"/> + <data format="txt" name="output_file2" label="Output file B"/> + <data format="txt" name="output_file3" label="Output file C"/> + <data format="txt" name="output_file4" label="Output file D"/> + <data format="txt" name="output_file5" label="Output file E"/> + <data format="txt" name="output_file6" label="Output file F"/> + </outputs> + + <stdio> + <exit_code range="1:" level="fatal" /> + <regex match=".+" source="stdout" level="fatal" description="Tool produced output to standard out" /> + <regex match=".+" source="stderr" level="fatal" description="Tool produced output to standard error" /> + </stdio> + + <help> + +.. 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. + + </help> +</tool>
--- /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)
