workflow-to-galaxy 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES ADDED
@@ -0,0 +1,6 @@
1
+ = Changes log for the Taverna-Galaxy Gem
2
+
3
+ == Version 0.2.7
4
+
5
+ * A Galaxy tool can now also be created by provided a t2flow file with the --t2flow flag.
6
+
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ == workflow-to-galaxy
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2010 - Netherlands Bioinformatics Centre
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,60 @@
1
+ = workflow-to-galaxy tool generator
2
+
3
+
4
+ Authors:: Konstantinos Karasavvas
5
+ Gem Version:: 0.2.7
6
+ Contact:: mailto:kostas.karasavvas@nbic.nl
7
+ Licence:: MIT (See LICENCE or http://www.opensource.org/licenses/mit-license)
8
+ Copyright:: (c) 2010 Netherlands Bioinformatics Centre, The Netherlands
9
+
10
+
11
+ == Synopsis
12
+
13
+ This script requires a Taverna2 workflow URL as input and generates a Galaxy tool
14
+ (a UI XML definition plus a script) that will enable the execution of this
15
+ workflow through Galaxy. The tool's description is as good as the description
16
+ provided in the workflow itself. Currently, the myExperiment workflow repository
17
+ is used to access workflow information via its REST API but a workflow description
18
+ from a file is also supported.
19
+
20
+ The name is workflow-to-galaxy rather than t2-workflow-to-galaxy because it is
21
+ possible that it will support other workflow management system's in the future.
22
+
23
+
24
+ == Installation
25
+
26
+ [sudo] gem install workflow-to-galaxy
27
+
28
+
29
+ == Usage
30
+
31
+ workflow_to_galaxy [options] <myExperiement-workflow> | <t2flow-file>
32
+
33
+ Generates a Galaxy tool (a UI xml definition plus a script) for the
34
+ specified Taverna2 workflow, where <myExperiment-workflow> is
35
+ the full URL of the workflow in the myExperiment website. Alternatively
36
+ a t2flow file can be passed for workflows not in myExperiment. Available
37
+ options are:
38
+
39
+ -o OUTPUT, --output=OUTPUT The file name(s) of the generated tool. If it is not specified then the workflow's name will be used.
40
+
41
+ -s SERVER, --server=SERVER The taverna server that the script will request execution from. If it is not specified then "http://localhost:8980/taverna-server" will be used.
42
+
43
+ -t, --t2flow The workflow is a t2flow file.
44
+
45
+
46
+ == Example
47
+
48
+ Let's say we want to install the taverna2 workflow http://www.myexperiment.org/workflows/74.html
49
+ from myExperiment repository:
50
+
51
+ <tt>$ workflow_to_galaxy -s http://localhost:8980/taverna-server http://www.myexperiment.org/workflows/74/download/bioaid_proteindiscovery_781733.t2flow?version=5</tt>
52
+
53
+
54
+
55
+ == References
56
+
57
+ Galaxy:: http://galaxy.psu.edu
58
+ Taverna2:: http://www.taverna.org.uk
59
+ myExperiment:: http://www.myexperiment.org
60
+
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ #
2
+ # To change this template, choose Tools | Templates
3
+ # and open the template in the editor.
4
+
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/clean'
9
+ require 'rake/gempackagetask'
10
+ require 'rake/rdoctask'
11
+ require 'rake/testtask'
12
+
13
+ spec = Gem::Specification.new do |s|
14
+ s.name = 'workflow-to-galaxy'
15
+ s.version = '0.2.7'
16
+ s.extra_rdoc_files = ['README', 'LICENSE', 'CHANGES']
17
+ s.summary = 'This script acquires information for a taverna 2 workflow from myExperiment (or from a file) and generates a Galaxy tool (.xml and .rb files).'
18
+ s.description = s.summary
19
+ s.author = 'Kostas Karasavvas'
20
+ s.email = 'kostas.karasavvas@nbic.nl'
21
+ s.executables = ['workflow_to_galaxy.rb']
22
+ s.files = %w(LICENSE README CHANGES Rakefile) + Dir.glob("{bin,lib,doc,spec}/**/*")
23
+ s.require_path = "lib"
24
+ s.bindir = "bin"
25
+ s.add_dependency 'myexperiment-rest', '>= 0.2.6'
26
+ s.add_dependency 'taverna-t2flow', '>= 0.2.0'
27
+ s.add_dependency 't2-server', '>= 0.5.3'
28
+ end
29
+
30
+ Rake::GemPackageTask.new(spec) do |p|
31
+ p.gem_spec = spec
32
+ p.need_tar = true
33
+ p.need_zip = true
34
+ end
35
+
36
+ Rake::RDocTask.new do |rdoc|
37
+ files =['README', 'LICENSE', 'lib/**/*.rb']
38
+ rdoc.rdoc_files.add(files)
39
+ rdoc.main = "README" # page to start on
40
+ rdoc.title = "workflow-to-galaxy Docs"
41
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
42
+ rdoc.options << '--line-numbers'
43
+ end
44
+
45
+ Rake::TestTask.new do |t|
46
+ t.test_files = FileList['test/**/*.rb']
47
+ end
48
+
49
+
50
+ # copies galaxy tool's files to local galaxy installation
51
+ task :copy_to_galaxy do
52
+ cp 'bin/BioAID_ProteinDiscovery.xml', '/home/kostas/local/galaxy-dist/tools/taverna_tools'
53
+ cp 'bin/BioAID_ProteinDiscovery.rb', '/home/kostas/local/galaxy-dist/tools/taverna_tools'
54
+ end
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'optparse'
5
+ require 't2flow/model.rb'
6
+ require 't2flow/parser.rb'
7
+ require 'cgi'
8
+ require 'myexperiment-rest'
9
+ require 'workflow-to-galaxy'
10
+
11
+ include MyExperimentREST
12
+ include Generator
13
+
14
+
15
+ # Populates and returns a _TavernaWorkflow_ object (same as in
16
+ # myexperiment-rest) from a local t2flow file.
17
+ def populate_taverna_workflow_from_t2flow(t2flow)
18
+ t2flow_file = File.new(t2flow, "r")
19
+ parsed_t2flow = T2Flow::Parser.new.parse(t2flow_file)
20
+
21
+ wkf_title = parsed_t2flow.name
22
+ wkf_descr = parsed_t2flow.main.annotations.descriptions[0] # gets only the first
23
+ wkf_sources = []
24
+ parsed_t2flow.main.sources.each do |s|
25
+ wkf_sources << TavernaIOData.new(s.name,
26
+ s.descriptions ? CGI.escapeHTML(s.descriptions.to_s) : [],
27
+ s.example_values ? s.example_values : [])
28
+ end
29
+ wkf_sinks = []
30
+ parsed_t2flow.main.sinks.each do |s|
31
+ wkf_sinks << TavernaIOData.new(s.name,
32
+ s.descriptions ? CGI.escapeHTML(s.descriptions.to_s) : [],
33
+ s.example_values ? s.example_values : [])
34
+ end
35
+
36
+ workflow = TavernaWorkflow.new(TavernaWorkflow::T2_FLOW, t2flow, wkf_title, wkf_descr, wkf_sources, wkf_sinks)
37
+
38
+ end
39
+
40
+
41
+ # Set up and parse arguments
42
+ out_file = ""
43
+ t2_server = ""
44
+ options = {}
45
+ opts = OptionParser.new do |opt|
46
+ opt.banner = "Usage: workflow_to_galaxy [options] <myExperiement-workflow> | <t2flow-file>"
47
+ opt.separator ""
48
+ opt.separator "Generates a Galaxy tool (a UI xml definition plus a script) for the "
49
+ opt.separator "specified Taverna2 workflow, where <myExperiment-workflow> is "
50
+ opt.separator "the full URL of the workflow in the myExperiment website. Alternatively "
51
+ opt.separator "a t2flow file can be passed for workflows not in myExperiment. Available "
52
+ opt.separator "options are:"
53
+
54
+ opt.on("-o OUTPUT", "--output=OUTPUT", "The file name(s) of the generated tool. " +
55
+ "If it is not specified then the workflow's name will be used.") do |val|
56
+ out_file = val if val != nil
57
+ end
58
+
59
+ opt.on("-s SERVER", "--server=SERVER", "The taverna server that the script will request execution from. " +
60
+ "If it is not specified then 'http://localhost:8980/taverna-server' will be used.") do |val|
61
+ t2_server = val if val != nil
62
+ end
63
+
64
+ opt.on("-t", "--t2flow", "The workflow is a t2flow file. ") do
65
+ options[:t2flow] = true
66
+ end
67
+ end
68
+
69
+ opts.parse!
70
+
71
+ # Read and check workflow URL or file
72
+ url = ARGV.shift
73
+ if url == nil
74
+ puts opts
75
+ exit 1
76
+ end
77
+
78
+ # Object to store the workflow object
79
+ wkf_data = nil
80
+
81
+ if options[:t2flow]
82
+ # Parse local t2flow file -- a _Taverna_Workflow_ object is returned
83
+ wkf_data = populate_taverna_workflow_from_t2flow(url)
84
+ else
85
+ # Get workflow data from myexperiment -- a _Taverna_Workflow_ object is returned
86
+ wkf_data = Workflows.new.read(url)
87
+ end
88
+
89
+ # Set output files
90
+ if out_file != ""
91
+ xml_file = "#{out_file}.xml"
92
+ script_file = "#{out_file}.rb"
93
+ else
94
+ xml_file = "#{wkf_data.title}".gsub(/\W/, '') + ".xml"
95
+ script_file = "#{wkf_data.title}".gsub(/\W/, '') + ".rb"
96
+ end
97
+
98
+ # Set taverna server if not specified
99
+ t2_server = "http://localhost:8980/taverna-server" if t2_server == ""
100
+
101
+
102
+
103
+ # Generate Galaxy tool's files
104
+ xml_file_ob = File.open(xml_file, "w")
105
+ generate_xml(wkf_data, xml_file, xml_file_ob)
106
+ xml_file_ob.close
107
+
108
+ script_file_ob = File.open(script_file, "w")
109
+ generate_script(wkf_data, t2_server, script_file_ob)
110
+ script_file_ob.close
@@ -0,0 +1,215 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Generator</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Generator</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/workflow-to-galaxy/generator_rb.html">
59
+ lib/workflow-to-galaxy/generator.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ The <a href="Generator.html">Generator</a> module contains two public
78
+ methods that generate a Galaxy&#8216;s tool XML and script files
79
+ </p>
80
+
81
+ </div>
82
+
83
+
84
+ </div>
85
+
86
+ <div id="method-list">
87
+ <h3 class="section-bar">Methods</h3>
88
+
89
+ <div class="name-list">
90
+ <a href="#M000002">generate_script</a>&nbsp;&nbsp;
91
+ <a href="#M000001">generate_xml</a>&nbsp;&nbsp;
92
+ </div>
93
+ </div>
94
+
95
+ </div>
96
+
97
+
98
+ <!-- if includes -->
99
+
100
+ <div id="section">
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <!-- if method_list -->
110
+ <div id="methods">
111
+ <h3 class="section-bar">Public Instance methods</h3>
112
+
113
+ <div id="method-M000002" class="method-detail">
114
+ <a name="M000002"></a>
115
+
116
+ <div class="method-heading">
117
+ <a href="#M000002" class="method-signature">
118
+ <span class="method-name">Generator.generate_script(my_exp_rest, t2_server, script_file) &rarr; nil<br />
119
+ </span>
120
+ </a>
121
+ </div>
122
+
123
+ <div class="method-description">
124
+ <p>
125
+ Generates the Galaxy tool&#8216;s script file responsible for talking to
126
+ the taverna server
127
+ </p>
128
+ <dl>
129
+ <dt><tt>my_exp_rest</tt></dt><dd>a <em>Workflow</em> object as returned from
130
+ <em>MyExperimentREST.ReadWorkflow.new(url)</em>
131
+
132
+ </dd>
133
+ <dt><tt>t2_server</tt></dt><dd>a string containing the URL of the taverna 2 server
134
+
135
+ </dd>
136
+ <dt><tt>script_out</tt></dt><dd>the file handler to write the generated script code
137
+
138
+ </dd>
139
+ </dl>
140
+ <p><a class="source-toggle" href="#"
141
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
142
+ <div class="method-source-code" id="M000002-source">
143
+ <pre>
144
+ <span class="ruby-comment cmt"># File lib/workflow-to-galaxy/generator.rb, line 490</span>
145
+ 490: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_script</span>(<span class="ruby-identifier">t2_workflow</span>, <span class="ruby-identifier">t2_server</span>, <span class="ruby-identifier">script_out</span>)
146
+ 491: <span class="ruby-identifier">script_preample</span>(<span class="ruby-identifier">script_out</span>)
147
+ 492: <span class="ruby-identifier">script_util_methods</span>(<span class="ruby-identifier">script_out</span>)
148
+ 493: <span class="ruby-identifier">script_create_t2_run</span>(<span class="ruby-identifier">script_out</span>, <span class="ruby-identifier">t2_workflow</span>, <span class="ruby-identifier">t2_server</span>)
149
+ 494: <span class="ruby-identifier">script_init_inputs</span>(<span class="ruby-identifier">script_out</span>, <span class="ruby-identifier">t2_workflow</span>)
150
+ 495: <span class="ruby-identifier">script_start_run</span>(<span class="ruby-identifier">script_out</span>)
151
+ 496: <span class="ruby-identifier">script_get_outputs</span>(<span class="ruby-identifier">script_out</span>, <span class="ruby-identifier">t2_workflow</span>)
152
+ 497: <span class="ruby-identifier">script_finish_run</span>(<span class="ruby-identifier">script_out</span>)
153
+ 498: <span class="ruby-keyword kw">end</span>
154
+ </pre>
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ <div id="method-M000001" class="method-detail">
160
+ <a name="M000001"></a>
161
+
162
+ <div class="method-heading">
163
+ <a href="#M000001" class="method-signature">
164
+ <span class="method-name">Generator.generate_xml(my_exp_rest, xml_file) &rarr; nil<br />
165
+ </span>
166
+ </a>
167
+ </div>
168
+
169
+ <div class="method-description">
170
+ <p>
171
+ Generates the Galaxy tool&#8216;s xml file responsible for the UI.
172
+ </p>
173
+ <dl>
174
+ <dt>+t2_workflow+</dt><dd>a <em>Workflow</em> object as returned from
175
+ <em>MyExperimentREST::Workflows.new.read(url)</em>
176
+
177
+ </dd>
178
+ <dt><tt>xml_file</tt></dt><dd>a string containing the name of the generated XML file
179
+
180
+ </dd>
181
+ <dt><tt>xml_out</tt></dt><dd>the file handler to write the generated XML tags
182
+
183
+ </dd>
184
+ </dl>
185
+ <p><a class="source-toggle" href="#"
186
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
187
+ <div class="method-source-code" id="M000001-source">
188
+ <pre>
189
+ <span class="ruby-comment cmt"># File lib/workflow-to-galaxy/generator.rb, line 471</span>
190
+ 471: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_xml</span>(<span class="ruby-identifier">t2_workflow</span>, <span class="ruby-identifier">xml_file</span>, <span class="ruby-identifier">xml_out</span>)
191
+ 472: <span class="ruby-identifier">tool_begin_tag</span>(<span class="ruby-identifier">xml_out</span>, <span class="ruby-identifier">t2_workflow</span>.<span class="ruby-identifier">title</span>)
192
+ 473: <span class="ruby-identifier">command_tag</span>(<span class="ruby-identifier">xml_out</span>, <span class="ruby-identifier">t2_workflow</span>, <span class="ruby-identifier">xml_file</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'.xml'</span>, <span class="ruby-value str">'.rb'</span>))
193
+ 474: <span class="ruby-identifier">inputs_tag</span>(<span class="ruby-identifier">xml_out</span>, <span class="ruby-identifier">t2_workflow</span>.<span class="ruby-identifier">inputs</span>)
194
+ 475: <span class="ruby-identifier">outputs_tag</span>(<span class="ruby-identifier">xml_out</span>, <span class="ruby-identifier">t2_workflow</span>.<span class="ruby-identifier">outputs</span>)
195
+ 476: <span class="ruby-identifier">help_tag</span>(<span class="ruby-identifier">xml_out</span>, <span class="ruby-identifier">t2_workflow</span>)
196
+ 477: <span class="ruby-identifier">tool_end_tag</span>(<span class="ruby-identifier">xml_out</span>)
197
+ 478: <span class="ruby-keyword kw">end</span>
198
+ </pre>
199
+ </div>
200
+ </div>
201
+ </div>
202
+
203
+
204
+ </div>
205
+
206
+
207
+ </div>
208
+
209
+
210
+ <div id="validator-badges">
211
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
212
+ </div>
213
+
214
+ </body>
215
+ </html>