root/galaxy-taverna/workflow-to-galaxy/test/Expected_BioAID_ProteinDiscovery_rb @ 75

Revision 75, 2.2 KB (checked in by kostas.karasavvas@…, 3 years ago)

added first unit test to test generated files of workflow 74 with expected files

Line 
1#!/usr/bin/env ruby
2
3require 'rubygems'
4require 't2-server'
5require 'open-uri'
6
7   
8# method that flattens the list of list of list ... result of get_output
9def print_flattened_result(out, data_lists)
10  data_lists.each do |l|
11    if l.instance_of? Array
12      print_flattened_result(out, l)
13    else
14      out.puts l
15    end
16  end
17end
18
19
20# method that acquires all the results of the specified output
21def get_outputs(run, refs, outfile, dir)
22  data_lists = run.get_output(dir, refs)
23  print_flattened_result(outfile, data_lists)
24end
25
26
27#
28# Sanitize single and double quotes in str. E.g. galaxy substitutes them to
29# __sq__ and __dq__ respectively. This methods turns them back to their
30# original values before using them
31#
32def sanitize(string)
33  string.gsub(/(__sq__|__dq__|__at__)/) do
34    if $1 == '__sq__'
35      "'"
36    elsif $1 == '__dq__'
37      '\"'
38    else
39      '@'
40    end
41  end
42end
43
44
45# use the uri reference to download the workflow locally
46wkf_file = URI.parse('http://www.myexperiment.org/workflows/74/download/bioaid_proteindiscovery_221429.xml?version=3')
47in_wkf = open(wkf_file)
48wkf = in_wkf.read()
49
50# create run
51begin
52  run = T2Server::Run.create('http://localhost:8980/taverna-server', wkf)
53rescue T2Server::T2ServerError => e
54  exit 1
55end
56
57# get input arguments -- for each input a boolean specifies if it's from history
58# thus, for each me_rest input we have two arguments in the script!
59Query_from_history = ARGV[0].chomp
60Query_tmp = ARGV[1].chomp
61if Query_from_history == "true"
62  run.upload_input_file('Query', Query_tmp)
63else
64  run.set_input('Query', sanitize(Query_tmp))
65end
66maxHits_parameter_from_history = ARGV[2].chomp
67maxHits_parameter_tmp = ARGV[3].chomp
68if maxHits_parameter_from_history == "true"
69  run.upload_input_file('maxHits_parameter', maxHits_parameter_tmp)
70else
71  run.set_input('maxHits_parameter', sanitize(maxHits_parameter_tmp))
72end
73
74# start run and wait until it is finished
75run.start
76run.wait(:progress => true)
77
78# get output arguments and associated them with a file
79output4 = File.open(ARGV[4], "w")
80get_outputs(run, false, output4, 'ValidatedProtein')
81output5 = File.open(ARGV[5], "w")
82get_outputs(run, false, output5, 'UniProtID')
83
84# delete run
85run.delete
Note: See TracBrowser for help on using the browser.