mannie-taverna-scufl 0.6.0

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/LICENCE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README ADDED
@@ -0,0 +1,133 @@
1
+ = Taverna[http://taverna.sourceforge.net] 1 Interaction Gem
2
+
3
+ Authors:: Stian Soiland, David Withers, Emmanuel Tagarira
4
+ Version:: 0.6.0
5
+ Contact:: taverna-hackers@lists.sourceforge.net
6
+ URL:: http://taverna.sourceforge.net/
7
+ Licence:: LGPL 3 (See LICENCE or http://www.gnu.org/licenses/lgpl.html)
8
+ Copyright:: (c)2006-2008 University of Manchester, UK
9
+
10
+
11
+
12
+ == Synopsis
13
+
14
+ This is a Ruby library to support the interaction with Taverna[http://taverna.sourceforge.net] version 1 workflows (Scufls). This relies on the functionality provided by a graph visualization package called GraphViz[http://www.graphviz.org/Download.php].
15
+
16
+
17
+
18
+ == Installation
19
+ To install the gems required by the Taverna 1 gem library, type into your command prompt:
20
+ [sudo] gem install libxml-ruby
21
+ [sudo] gem install rdoc
22
+ [sudo] gem install darkfish-rdoc
23
+
24
+ When you have the required gems on your system, you may install this gem using the following commands:
25
+ gem sources -a http://gems.github.com
26
+ [sudo] gem install mannie-taverna-scufl
27
+
28
+
29
+
30
+ == Usage
31
+
32
+ To be able to generate at least a Scufl model using the gem, you can use the code following code:
33
+ require "scufl/model.rb"
34
+ require "scufl/parser.rb"
35
+
36
+ foo = File.new("path/to/workflow/file", "r")
37
+ bar = Scufl::Parser.new.parse(foo)
38
+
39
+ Alternatively:
40
+ foo = File.new("path/to/workflow/file", "r").read
41
+ bar = Scufl::Parser.new.parse(foo)
42
+
43
+ You will then be able to use your Scufl model to retrieve information about the workflow by invoking the different methods and attributes.
44
+ bar.INVOKED
45
+ ... where INVOKED is the method or attribute required.
46
+
47
+ You can also interact with remote workflows.
48
+ require "open-uri"
49
+
50
+ foo = Uri.parse("xxxx://uri_to_workflow").read
51
+ bar = Scufl::Parser.new.parse(foo)
52
+
53
+ To be enable you to draw images of the Scufl, you need to include:
54
+ require "scufl/dot.rb"
55
+
56
+ To be able to use any functionality included in "scufl/dot.rb", you need to have GraphViz[http://www.graphviz.org/Download.php] installed on your system. Once this package has been installed, you may use the gem to draw an image showing the structure of the Scufl as follows.
57
+ out_file = File.new("path/to/file/you/want/the/dot/script/to/be/written", "w+")
58
+ Scufl::Dot.new.write_dot(out_file, bar)
59
+ `dot -Tpng -o"path/to/the/output/image" #{out_file.path}`
60
+ The last line draws a PNG image using +out_file+. To learn more about dot, try typing into your command prompt:
61
+ % man dot
62
+ or
63
+ % dot -h
64
+
65
+
66
+
67
+ == Taverna Remote Execution Service Client
68
+
69
+ The library also includes support for submitting Taverna[http://taverna.sourceforge.net] workflows to the Taverna
70
+ Remote Execution service[2]. This requires the Remote Execution service that
71
+ has already been installed and configured, and with a client username and
72
+ password already registered by the administrator of the service. We
73
+ recommend first testing the service using the Remote Execution service
74
+ from the Taverna workbench[3].
75
+
76
+
77
+
78
+ == Usage
79
+
80
+ Here's the simplest usecase. Given a Taverna workflow in "workflow.xml" (that produces
81
+ a value at the port "myOutput") and a Taverna Remote Execution service [2] running
82
+ at http://localhost:8080/tavernaservice/v1/ you can try:
83
+
84
+ SERVICE = "http://localhost:8080/tavernaservice/v1/"
85
+ workflow = IO.read("workflow.xml")
86
+ require 'rubygems'
87
+ require 'enactor/client'
88
+ enactor = Enactor::Client(SERVICE, "johndoe", "s3cret")
89
+ results = enactor.execute_sync(workflow)
90
+ print results["myOutput"]
91
+
92
+
93
+ Note that the call to execute_sync() will block until the workflow has been executed
94
+ on the server. If you want to do this asynchronously, try:
95
+
96
+ workflow_url = enactor.upload_workflow(workflow)
97
+ job_url = enactor.submit_job(workflow_url)
98
+ sleep 1 while not enactor.finished?(job_url)
99
+ if enactor.get_job_status(job_url) == Enactor::Status.COMPLETE
100
+ results = enactor.get_job_outputs(job_url)
101
+ print results["myOutput"]
102
+ end
103
+
104
+
105
+ You can also supply inputs as a hash:
106
+
107
+ inputs = {}
108
+ inputs['gene'] = ["MY_GENE", "HIS_GENE"]
109
+ inputs['database'] = "kegg"
110
+ results = enactor.execute_sync(workflow, inputs)
111
+
112
+ or
113
+
114
+ inputs_url = enactor.upload_data(inputs)
115
+ job_url = enactor.submitJob(workflow_url, inputsURL)
116
+
117
+
118
+ See the rdoc documentation of Enactor::Client for more information, try:
119
+
120
+ help Enactor::Client
121
+
122
+ Included are also lower level modules Baclava for parsing
123
+ and creating Baclava data documents, and Scufl for extracting basic
124
+ information about a workflow, such as which input and output ports it defines.
125
+
126
+
127
+
128
+ == References
129
+
130
+ [1] http://taverna.sourceforge.net
131
+ [2] http://www.mygrid.org.uk/usermanual1.7/remote_execution_server.html
132
+ [3] http://www.mygrid.org.uk/usermanual1.7/remote_execution.html
133
+
@@ -0,0 +1,61 @@
1
+ require "rexml/document"
2
+ require "document/data"
3
+
4
+ module Baclava
5
+
6
+ class Reader
7
+
8
+ #Reads a baclava document amd returns a hash of Document::Data objects
9
+ def self.read(xml)
10
+ if xml.kind_of?(REXML::Document)
11
+ document = xml
12
+ else
13
+ document = REXML::Document.new(xml)
14
+ end
15
+ root = document.root
16
+ raise "'#{root.name}' doesn't appear to be a data thing!" if root.name != "dataThingMap"
17
+
18
+ create_data_map(root)
19
+ end
20
+
21
+ def self.create_data_map(element)
22
+ data_map = {}
23
+
24
+ element.each_element('b:dataThing') { |datathing|
25
+ key = datathing.attribute('key').value
26
+ data = Document::Data.new
27
+ data_map[key] = data
28
+ datathing.each_element('b:myGridDataDocument') { |dataDocument|
29
+ dataDocument.each_element('s:metadata') { |metadata| data.annotation = get_metadata(metadata) }
30
+ dataDocument.each_element('b:partialOrder') { |partialOrder| data.value = get_list(partialOrder) }
31
+ dataDocument.each_element('b:dataElement') { |dataElement| data.value = get_element(dataElement) }
32
+ }
33
+ }
34
+
35
+ data_map
36
+ end
37
+
38
+ def self.get_list(element)
39
+ list = []
40
+ element.each_element('b:itemList') { |itemList|
41
+ itemList.each_element('b:dataElement') { |dataElement| list << get_element(dataElement) }
42
+ itemList.each_element('b:partialOrder') { |partialOrder| list << get_list(partialOrder) }
43
+ }
44
+ list
45
+ end
46
+
47
+ def self.get_metadata(element)
48
+ list = []
49
+ element.each_element('s:mimeTypes') { |mimeTypes|
50
+ mimeTypes.each_element('s:mimeType') { |mimeType| list << mimeType.text }
51
+ }
52
+ list
53
+ end
54
+
55
+ def self.get_element(element)
56
+ element.each_element('b:dataElementData') { |data| return Base64.decode64(data.text) }
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,82 @@
1
+ require 'base64'
2
+ require 'rubygems'
3
+ require 'builder'
4
+
5
+ module Baclava # :nodoc:
6
+
7
+ class Writer
8
+
9
+ def self.write_doc(data_map)
10
+ REXML::Document.new(write(data_map))
11
+ end
12
+
13
+ def self.write(data_map)
14
+ xml = Builder::XmlMarkup.new :indent => 2
15
+ xml.instruct!
16
+ xml.b :dataThingMap, 'xmlns:b' => 'http://org.embl.ebi.escience/baclava/0.1alpha' do
17
+ for key in data_map.keys do
18
+ data = data_map[key]
19
+ xml.b :dataThing, 'key' => key do
20
+ xml.b :myGridDataDocument, 'lsid' => '', 'syntactictype' => '' do
21
+ #write_metadata xml, data.annotation
22
+ write_data xml, data.value
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ #def self.write_metadata(xml, metadata)
30
+ # xml.s :metadata, 'xmlns:s' => 'http://org.embl.ebi.escience/xscufl/0.1alpha' do
31
+ # xml.s :mimeTypes do
32
+ # for mimetype in metadata do
33
+ # xml.s :mimetype, mimetype
34
+ # end
35
+ # end
36
+ # end
37
+ #end
38
+
39
+ def self.write_data(xml, data, index = nil)
40
+ if data.is_a? Array
41
+ write_list xml, data, index
42
+ else
43
+ if index
44
+ xml.b :dataElement, 'lsid' => '', 'index' => index do
45
+ xml.b :dataElementData, Base64.encode64(data)
46
+ end
47
+ else
48
+ xml.b :dataElement, 'lsid' => '' do
49
+ xml.b :dataElementData, Base64.encode64(data)
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ def self.write_list(xml, list, index)
57
+ if index
58
+ xml.b :partialOrder, 'lsid' => '', 'type' => 'list', 'index' => index do
59
+ write_item_list xml, list
60
+ end
61
+ else
62
+ xml.b :partialOrder, 'lsid' => '', 'type' => 'list' do
63
+ write_item_list xml, list
64
+ end
65
+ end
66
+ end
67
+
68
+ def self.write_item_list(xml, list)
69
+ xml.b :relationList
70
+ for i in 0..list.length - 1 do
71
+ xml.b :relation, 'parent' => i, 'child' => i + 1
72
+ end
73
+ xml.b :itemList do
74
+ for i in 0..list.length - 1 do
75
+ write_data xml, list[i], i
76
+ end
77
+ end
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,24 @@
1
+ module Document # :nodoc:
2
+
3
+ #Input or output data
4
+ #
5
+ #value - the data value or a (possibly nested) list of data values
6
+ class Data
7
+ attr_accessor :value, :annotation
8
+
9
+ def initialize(value=nil, annotation=nil)
10
+ @value = value
11
+ @annotation = annotation
12
+ end
13
+
14
+ def eql?(other)
15
+ @value.eql?(other.value) and @annotation.eql?(other.annotation)
16
+ end
17
+
18
+ def ==(other)
19
+ @value == other.value and @annotation == other.annotation
20
+ end
21
+
22
+ end
23
+
24
+ end