myexperiment-rest 0.2.6

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.
Files changed (55) hide show
  1. data/CHANGES +9 -0
  2. data/LICENSE +23 -0
  3. data/README +33 -0
  4. data/Rakefile +45 -0
  5. data/bin/get_workflow_data.rb +31 -0
  6. data/doc/classes/MyExperimentREST.html +113 -0
  7. data/doc/classes/MyExperimentREST/IOData.html +169 -0
  8. data/doc/classes/MyExperimentREST/IOData.src/M000003.html +20 -0
  9. data/doc/classes/MyExperimentREST/ReadWorkflow.html +184 -0
  10. data/doc/classes/MyExperimentREST/ReadWorkflow.src/M000002.html +39 -0
  11. data/doc/classes/MyExperimentREST/ReadWorkflow.src/M000005.html +41 -0
  12. data/doc/classes/MyExperimentREST/TavernaIOData.html +167 -0
  13. data/doc/classes/MyExperimentREST/TavernaIOData.src/M000006.html +20 -0
  14. data/doc/classes/MyExperimentREST/TavernaIOData.src/M000007.html +20 -0
  15. data/doc/classes/MyExperimentREST/TavernaWorkflow.html +209 -0
  16. data/doc/classes/MyExperimentREST/TavernaWorkflow.src/M000005.html +23 -0
  17. data/doc/classes/MyExperimentREST/TavernaWorkflow.src/M000006.html +22 -0
  18. data/doc/classes/MyExperimentREST/Workflow.html +172 -0
  19. data/doc/classes/MyExperimentREST/Workflow.src/M000001.html +21 -0
  20. data/doc/classes/MyExperimentREST/Workflows.html +167 -0
  21. data/doc/classes/MyExperimentREST/Workflows.src/M000004.html +41 -0
  22. data/doc/classes/TestReadWorkflow.html +167 -0
  23. data/doc/classes/TestReadWorkflow.src/M000001.html +18 -0
  24. data/doc/classes/TestReadWorkflow.src/M000002.html +24 -0
  25. data/doc/classes/TestReadWorkflow.src/M000003.html +20 -0
  26. data/doc/classes/TestReadWorkflow.src/M000004.html +20 -0
  27. data/doc/created.rid +1 -0
  28. data/doc/files/bin/get_workflow_data_rb.html +116 -0
  29. data/doc/files/lib/myexperiment-rest/my_experiment_rest_rb.html +110 -0
  30. data/doc/files/lib/myexperiment-rest/myexperiment_rest_rb.html +110 -0
  31. data/doc/files/lib/myexperiment-rest_rb.html +108 -0
  32. data/doc/files/test/test_read_workflow_rb.html +122 -0
  33. data/doc/fr_class_index.html +31 -0
  34. data/doc/fr_file_index.html +29 -0
  35. data/doc/fr_method_index.html +32 -0
  36. data/doc/index.html +24 -0
  37. data/doc/rdoc-style.css +208 -0
  38. data/doc/rdoc/classes/MyExperimentREST.html +117 -0
  39. data/doc/rdoc/classes/MyExperimentREST/TavernaIOData.html +178 -0
  40. data/doc/rdoc/classes/MyExperimentREST/TavernaWorkflow.html +223 -0
  41. data/doc/rdoc/classes/MyExperimentREST/Workflows.html +199 -0
  42. data/doc/rdoc/created.rid +1 -0
  43. data/doc/rdoc/files/CHANGES.html +121 -0
  44. data/doc/rdoc/files/LICENSE.html +133 -0
  45. data/doc/rdoc/files/README.html +148 -0
  46. data/doc/rdoc/files/lib/myexperiment-rest/myexperiment_rest_rb.html +110 -0
  47. data/doc/rdoc/files/lib/myexperiment-rest_rb.html +108 -0
  48. data/doc/rdoc/fr_class_index.html +30 -0
  49. data/doc/rdoc/fr_file_index.html +31 -0
  50. data/doc/rdoc/fr_method_index.html +29 -0
  51. data/doc/rdoc/index.html +24 -0
  52. data/doc/rdoc/rdoc-style.css +208 -0
  53. data/lib/myexperiment-rest.rb +5 -0
  54. data/lib/myexperiment-rest/myexperiment_rest.rb +146 -0
  55. metadata +133 -0
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ myexperiment-rest Docs
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>myexperiment-rest Docs</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/README.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
@@ -0,0 +1,5 @@
1
+ require 'myexperiment-rest/myexperiment_rest.rb'
2
+
3
+ module MyExperimentREST
4
+
5
+ end
@@ -0,0 +1,146 @@
1
+ require 'rubygems'
2
+ require 'rest_client'
3
+ require 'libxml'
4
+
5
+ module MyExperimentREST
6
+
7
+ #
8
+ # Connects to myExperiment REST API and creates a _TavernaWorkflow_ object.
9
+ #
10
+ class Workflows
11
+ include LibXML
12
+
13
+ attr_reader(:uri)
14
+
15
+ #def initialize
16
+ #end
17
+
18
+ # Requires the URI of the workflow in the repository as a String.
19
+ def read(uri)
20
+
21
+ workflow_id = ''
22
+ workflow_version = ''
23
+
24
+ # Get workflow id
25
+ uri_id = uri.match(/workflows\/(\d+)/)
26
+ if uri_id != nil
27
+ workflow_id = uri_id[1]
28
+ else
29
+ raise "Could not match workflow id."
30
+ end
31
+
32
+ # Get workflow version if it exists
33
+ uri_version = uri.match(/version=(\d+)/)
34
+ if uri_version != nil
35
+ workflow_version = uri_version[1]
36
+ end
37
+
38
+ # Get workflow resource information -- if version is empty it returns the current version
39
+ response = RestClient.get('http://www.myexperiment.org/workflow.xml', {:params => {'id' => "#{workflow_id}",
40
+ 'version' => "#{workflow_version}",
41
+ 'elements' => 'title,description,content-uri,components'} } )
42
+
43
+ populate_workflow(response)
44
+ end
45
+
46
+
47
+ private
48
+
49
+ # Acquire data from XML response and instantiate a _Taverna_Workflow_ object
50
+ def populate_workflow(response)
51
+ doc = XML::Document.string(response)
52
+ wkf_xml_uri = doc.find_first("/workflow/content-uri").content
53
+ wkf_title = doc.find_first("/workflow/title").content
54
+ wkf_descr = doc.find_first("/workflow/description").content
55
+ wkf_inputs = get_IOData(doc, "source")
56
+ wkf_outputs = get_IOData(doc, "sink")
57
+
58
+ TavernaWorkflow.new(TavernaWorkflow::MY_EXPERIMENT, wkf_xml_uri, wkf_title, wkf_descr, wkf_inputs, wkf_outputs)
59
+
60
+ end
61
+
62
+
63
+ #
64
+ # Populate _Taverna_IOData_ objects for specified type: value +source+'+ is for inputs
65
+ # and +sink+ for outputs
66
+ #
67
+ def get_IOData(doc, type)
68
+ io_data = []
69
+
70
+ # Get all sources or sinks and create appropriate objects
71
+ doc.find("//workflow/components/dataflows/dataflow[@role='top']/#{type}s/#{type}").each do |node|
72
+ name = ''
73
+ descriptions = []
74
+ examples = []
75
+
76
+ node.each_element do |n|
77
+ if n.name.eql? "name"
78
+ name = n.children[0].to_s
79
+ elsif n.name.eql? "descriptions"
80
+ n.each_element do |d|
81
+ descriptions << d.children[0].to_s
82
+ end if n.children?
83
+ elsif n.name.eql? "examples"
84
+ n.each_element do |e|
85
+ examples << e.children[0].to_s
86
+ end if n.children?
87
+ end
88
+ end
89
+
90
+ io_data << TavernaIOData.new(name, descriptions, examples)
91
+ end
92
+
93
+ io_data
94
+ end
95
+
96
+
97
+ end
98
+
99
+
100
+ #
101
+ # Contains all available information about a workflow: _input_type_, _xml_uri_, _title_, _description_,
102
+ # _inputs_ and _outputs_. The _xml_uri_ specifies the XML description on myExperiment and
103
+ # not the XML of the workflow itself. _input_type_ specifies the kind of input. Currently,
104
+ # either "myexperiment" (myExperiment's xml uri) or "t2flow" (filename)
105
+ #
106
+ class TavernaWorkflow
107
+
108
+ # possible input types
109
+ MY_EXPERIMENT = 'myexperiment'
110
+ T2_FLOW = 't2flow'
111
+
112
+ attr_reader(:input_type, :xml_uri, :title, :description, :inputs, :outputs)
113
+
114
+ def initialize(input_type, xml_uri, title, description, inputs, outputs)
115
+ @input_type = input_type
116
+ @xml_uri = xml_uri
117
+ @title = title
118
+ @description = description
119
+ @inputs = inputs
120
+ @outputs = outputs
121
+ end
122
+
123
+ end
124
+
125
+
126
+ #
127
+ # Contains all available information about an input or output: name, descriptions
128
+ # and examples. The last two are lists.
129
+ #--
130
+ # Currently both inputs and outputs contain the same information. If that
131
+ # changes we can subclass this one.
132
+ #
133
+ class TavernaIOData
134
+ attr_reader(:name, :descriptions, :examples)
135
+
136
+ def initialize(name, descriptions, examples)
137
+ @name = name
138
+ @descriptions = descriptions
139
+ @examples = examples
140
+ end
141
+
142
+ end
143
+
144
+
145
+ end
146
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: myexperiment-rest
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 6
10
+ version: 0.2.6
11
+ platform: ruby
12
+ authors:
13
+ - Konstantinos Karasavvas
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-20 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rest-client
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: This is a simple library to access data on myExperiment via its REST API. Currently supports a subset of the workflow information available.
35
+ email: kostas.karasavvas@nbic.nl
36
+ executables:
37
+ - get_workflow_data.rb
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - README
42
+ - LICENSE
43
+ - CHANGES
44
+ files:
45
+ - LICENSE
46
+ - README
47
+ - CHANGES
48
+ - Rakefile
49
+ - bin/get_workflow_data.rb
50
+ - lib/myexperiment-rest.rb
51
+ - lib/myexperiment-rest/myexperiment_rest.rb
52
+ - doc/rdoc-style.css
53
+ - doc/fr_file_index.html
54
+ - doc/classes/TestReadWorkflow.html
55
+ - doc/classes/TestReadWorkflow.src/M000002.html
56
+ - doc/classes/TestReadWorkflow.src/M000001.html
57
+ - doc/classes/TestReadWorkflow.src/M000003.html
58
+ - doc/classes/TestReadWorkflow.src/M000004.html
59
+ - doc/classes/MyExperimentREST.html
60
+ - doc/classes/MyExperimentREST/TavernaWorkflow.src/M000006.html
61
+ - doc/classes/MyExperimentREST/TavernaWorkflow.src/M000005.html
62
+ - doc/classes/MyExperimentREST/ReadWorkflow.src/M000002.html
63
+ - doc/classes/MyExperimentREST/ReadWorkflow.src/M000005.html
64
+ - doc/classes/MyExperimentREST/TavernaIOData.src/M000006.html
65
+ - doc/classes/MyExperimentREST/TavernaIOData.src/M000007.html
66
+ - doc/classes/MyExperimentREST/Workflow.src/M000001.html
67
+ - doc/classes/MyExperimentREST/IOData.src/M000003.html
68
+ - doc/classes/MyExperimentREST/TavernaIOData.html
69
+ - doc/classes/MyExperimentREST/Workflows.html
70
+ - doc/classes/MyExperimentREST/TavernaWorkflow.html
71
+ - doc/classes/MyExperimentREST/Workflow.html
72
+ - doc/classes/MyExperimentREST/ReadWorkflow.html
73
+ - doc/classes/MyExperimentREST/Workflows.src/M000004.html
74
+ - doc/classes/MyExperimentREST/IOData.html
75
+ - doc/fr_class_index.html
76
+ - doc/index.html
77
+ - doc/files/test/test_read_workflow_rb.html
78
+ - doc/files/bin/get_workflow_data_rb.html
79
+ - doc/files/lib/myexperiment-rest/my_experiment_rest_rb.html
80
+ - doc/files/lib/myexperiment-rest/myexperiment_rest_rb.html
81
+ - doc/files/lib/myexperiment-rest_rb.html
82
+ - doc/fr_method_index.html
83
+ - doc/rdoc/rdoc-style.css
84
+ - doc/rdoc/fr_file_index.html
85
+ - doc/rdoc/classes/MyExperimentREST.html
86
+ - doc/rdoc/classes/MyExperimentREST/TavernaIOData.html
87
+ - doc/rdoc/classes/MyExperimentREST/Workflows.html
88
+ - doc/rdoc/classes/MyExperimentREST/TavernaWorkflow.html
89
+ - doc/rdoc/fr_class_index.html
90
+ - doc/rdoc/index.html
91
+ - doc/rdoc/files/LICENSE.html
92
+ - doc/rdoc/files/README.html
93
+ - doc/rdoc/files/lib/myexperiment-rest/myexperiment_rest_rb.html
94
+ - doc/rdoc/files/lib/myexperiment-rest_rb.html
95
+ - doc/rdoc/files/CHANGES.html
96
+ - doc/rdoc/fr_method_index.html
97
+ - doc/rdoc/created.rid
98
+ - doc/created.rid
99
+ homepage:
100
+ licenses: []
101
+
102
+ post_install_message:
103
+ rdoc_options: []
104
+
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ requirements: []
126
+
127
+ rubyforge_project:
128
+ rubygems_version: 1.7.2
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: This is a simple library to access data on myExperiment via its REST API. Currently supports a subset of the workflow information available.
132
+ test_files: []
133
+