intermine 1.00.00 → 1.01.00

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -52,7 +52,6 @@ namespace :test do
52
52
  t.libs << "test"
53
53
  t.test_files = FileList['test/unit_tests.rb']
54
54
  t.verbose = true
55
- puts "Running UNIT TESTS"
56
55
  end
57
56
 
58
57
  desc "Run the live integration tests"
@@ -60,7 +59,6 @@ namespace :test do
60
59
  t.libs << "test"
61
60
  t.test_files = FileList['test/live_test.rb'] << FileList['test/live_summary_test.rb'] << FileList['test/live_results.rb']
62
61
  t.verbose = false
63
- puts "Running LIVE INTEGRATION TESTS"
64
62
  end
65
63
 
66
64
  desc "Run all tests"
@@ -312,7 +312,7 @@ module InterMine::Lists
312
312
  @tags = @manager.tags_for(self)
313
313
  end
314
314
 
315
- ENRICHMENT_DEFAULTS = {:correction => "Holm-Bonferroni", :maxp => 0.05}
315
+ ENRICHMENT_DEFAULTS = {:correction => "Holm-Bonferroni", :maxp => 0.05, :format => 'json'}
316
316
 
317
317
  # Retrieve the results of an enrichment calculation
318
318
  #
@@ -211,7 +211,7 @@ module Metadata
211
211
  # organism = gene["organism"]
212
212
  #
213
213
  def [](key)
214
- if @__cd__.has_field?(key):
214
+ if @__cd__.has_field?(key)
215
215
  return self.send(key)
216
216
  end
217
217
  raise IndexError, "No field #{key} found for #{@__cd__.name}"
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'intermine/model'
3
2
  require "intermine/query"
4
3
  require "intermine/lists"
@@ -156,15 +155,22 @@ module InterMine
156
155
  end
157
156
  @root = root
158
157
  @token = token
159
- begin
160
- @version = fetch(@root + VERSION_PATH).to_i
161
- rescue => e
162
- raise ServiceError, "Error fetching version at #{@root + VERSION_PATH}: #{e.message}"
163
- end
164
158
  @model = mock_model
165
159
  @_templates = nil
166
160
  @broken_templates = []
167
161
  @list_manager = InterMine::Lists::ListManager.new(self)
162
+
163
+ root_uri = URI.parse(@root)
164
+ @root_path = root_uri.path
165
+
166
+ @http = Net::HTTP.new(root_uri.host, root_uri.port)
167
+
168
+ v_path = @root + VERSION_PATH
169
+ begin
170
+ @version = fetch(v_path).to_i
171
+ rescue Exception => e
172
+ raise ServiceError, "Error fetching version at #{ v_path }: #{e.message}"
173
+ end
168
174
  end
169
175
 
170
176
  # Return the release string
@@ -223,21 +229,19 @@ module InterMine
223
229
  # Returns all the templates available to query against in the service
224
230
  #
225
231
  def templates
226
- if @_templates.nil?
227
- @_templates = {}
228
- parser = InterMine::PathQuery::Template.parser(model)
229
- template_xml = fetch(@root + TEMPLATES_PATH)
230
- doc = REXML::Document.new(template_xml)
231
- doc.elements.each("template-queries/template") do |t|
232
- begin
233
- temp = parser.parse(t)
234
- @_templates[temp.name] = temp
235
- rescue
236
- @broken_templates.push(t.attribute("name").value)
237
- end
232
+ parsed = {}
233
+ parser = InterMine::PathQuery::Template.parser(model)
234
+ template_xml = fetch(@root + TEMPLATES_PATH)
235
+ doc = REXML::Document.new(template_xml)
236
+ doc.elements.each("template-queries/template") do |t|
237
+ begin
238
+ temp = parser.parse(t)
239
+ parsed[temp.name] = temp
240
+ rescue
241
+ @broken_templates.push(t.attribute("name").value)
238
242
  end
239
243
  end
240
- return @_templates
244
+ return parsed
241
245
  end
242
246
 
243
247
  # Get all the names of the available templates, in
@@ -261,9 +265,19 @@ module InterMine
261
265
 
262
266
  # Retrieves data from a url with a get request.
263
267
  def fetch(url)
264
- uri = URI.parse(url)
265
- qs = params.map { |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&')
266
- return Net::HTTP.get(uri.host, uri.path + (params.empty? ? "" : "?#{qs}"))
268
+ ps = params
269
+ qs = ps.empty? ? '' : '?' + ps.map{ |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&')
270
+ uri = URI.parse(url + qs)
271
+
272
+ req = Net::HTTP::Get.new(uri.path + qs)
273
+ resp = @http.request req
274
+
275
+ return case resp
276
+ when Net::HTTPSuccess
277
+ resp.body
278
+ else
279
+ raise ServiceError, resp.code, resp.body
280
+ end
267
281
  end
268
282
  end
269
283
 
@@ -3,6 +3,8 @@ module Intermine
3
3
  # Webservice Client Version number
4
4
  #
5
5
  # Changes:
6
+ # 1.01.00 - Test compatibility with 1.8.7, 1.9.2, 2.0.0-rc1
7
+ # Numerous bug fixes.
6
8
  # 1.00.00 - Up to make use of new features of the InterMine 1.0 API
7
9
  # * Enrichment queries
8
10
  # * Range constraints
@@ -15,5 +17,6 @@ module Intermine
15
17
  # 0.98.10 - Added status property to lists
16
18
  # 0.98.09 - Major changes to results - now with thorough-going Enumerable support
17
19
  # 0.98.08 - Added column summary support
18
- VERSION = "1.00.00"
20
+ #
21
+ VERSION = "1.01.00"
19
22
  end
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require File.dirname(__FILE__) + "/test_helper.rb"
2
3
 
3
4
  require "test/unit"
@@ -12,7 +13,7 @@ class LiveResultsTest < Test::Unit::TestCase
12
13
  @q = @service.query("Employee").select("*", "department.*").where(:age => {:lt => @max})
13
14
  @empty = @service.query("Employee").where(:name => "some-non-existant-value")
14
15
  @exp_count = 82
15
- @expected_last = "Didier Legu\303\251lec"
16
+ @expected_last = "Didier Leguélec"
16
17
  @expected_last_summary = "Vincent"
17
18
  @expected_last_obj = "Both Quotes '\""
18
19
  @expected_target = 37.02439
@@ -10,9 +10,8 @@ class LiveDemoTest < Test::Unit::TestCase
10
10
  @temp_lists = []
11
11
  end
12
12
 
13
-
14
13
  def teardown
15
- @temp_lists.each do |l|
14
+ (@temp_lists || []).each do |l|
16
15
  begin
17
16
  @service.delete_lists(l)
18
17
  rescue
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require File.dirname(__FILE__) + "/test_helper.rb"
2
4
  require "intermine/query"
3
5
  require "intermine/model"
@@ -38,27 +40,25 @@ class TestQuery < Test::Unit::TestCase
38
40
  "Employee.age",
39
41
  "Employee.department.name"
40
42
  ]
41
- expected = views.to_s
42
-
43
43
 
44
44
  query = InterMine::PathQuery::Query.new(@model)
45
45
  query.add_views("Employee.name", "Employee.age",
46
46
  "Employee.department.name")
47
- assert_equal(query.views.to_s, expected)
47
+ assert_equal(query.views.map{ |x| x.to_s }, views)
48
48
 
49
49
 
50
50
  query = InterMine::PathQuery::Query.new(@model, "Employee")
51
51
  query.add_views("Employee.name", "Employee.age",
52
52
  "Employee.department.name")
53
- assert_equal(query.views.to_s, expected)
53
+ assert_equal(query.views.map{ |x| x.to_s }, views)
54
54
 
55
55
  query = InterMine::PathQuery::Query.new(@model)
56
56
  query.add_views(views)
57
- assert_equal(query.views.to_s, expected)
57
+ assert_equal(query.views.map{ |x| x.to_s }, views)
58
58
 
59
59
  query = InterMine::PathQuery::Query.new(@model, "Employee")
60
60
  query.add_views(views)
61
- assert_equal(query.views.to_s, expected)
61
+ assert_equal(query.views.map{ |x| x.to_s }, views)
62
62
  end
63
63
 
64
64
  def test_bad_viewpath
@@ -83,15 +83,15 @@ class TestQuery < Test::Unit::TestCase
83
83
  "Employee.age",
84
84
  "Employee.department.name"
85
85
  ]
86
- expected = views.to_s
86
+ expected = views
87
87
 
88
88
  query = InterMine::PathQuery::Query.new(@model, "Employee")
89
89
  query.add_views("name", "age", "department.name")
90
- assert_equal(query.views.to_s, expected)
90
+ assert_equal(query.views.map {|x| x.to_s }, expected)
91
91
 
92
92
  query = InterMine::PathQuery::Query.new(@model, "Employee")
93
93
  query.add_views(["name", "age", "department.name"])
94
- assert_equal(query.views.to_s, expected)
94
+ assert_equal(query.views.map {|x| x.to_s }, expected)
95
95
  end
96
96
 
97
97
  def test_bad_unqualified_path
@@ -166,8 +166,8 @@ class TestQuery < Test::Unit::TestCase
166
166
  :sub_class => "Manager"
167
167
  })
168
168
  query.add_views("Department.employees.seniority")
169
- expected = ["Department.employees.seniority"].to_s
170
- assert_equal(query.views.to_s, expected)
169
+ expected = ["Department.employees.seniority"]
170
+ assert_equal(query.views.map {|x| x.to_s }, expected)
171
171
 
172
172
  query = InterMine::PathQuery::Query.new(@model)
173
173
  assert_raise InterMine::Metadata::PathException do
@@ -570,7 +570,7 @@ class TestQuery < Test::Unit::TestCase
570
570
  assert_equal(conA.loopPath.to_s, "Employee.department.company.departments")
571
571
  end
572
572
 
573
- def test_bad_lookup_constraint
573
+ def test_bad_loop_constraint
574
574
  query = InterMine::PathQuery::Query.new(@model, "Employee")
575
575
  assert_raise ArgumentError do
576
576
  query.add_constraint({
@@ -1,11 +1,13 @@
1
1
  require File.dirname(__FILE__) + "/test_helper.rb"
2
+ require "test/unit"
3
+
2
4
  require "intermine/query"
3
5
  require "intermine/model"
4
6
  require "intermine/lists"
5
7
  require "intermine/service"
6
- require "test/unit"
7
8
 
8
- class Service
9
+ # Open Service class and mock the fetch method.
10
+ class InterMine::Service
9
11
  def fetch(x)
10
12
  return 100
11
13
  end
@@ -15,10 +17,10 @@ class TestQuerySugar < Test::Unit::TestCase
15
17
 
16
18
  def initialize(name)
17
19
  super
18
- file = File.new(
19
- File.dirname(__FILE__) + "/data/model.json", "r")
20
- data = file.read
21
- @model = InterMine::Metadata::Model.new(data)
20
+ modelf = File.dirname(__FILE__) + "/data/model.json"
21
+ File.open(modelf, "r") do |f|
22
+ @model = InterMine::Metadata::Model.new f.read
23
+ end
22
24
  @service = InterMine::Service.new("foo", "bar", @model)
23
25
  @model.send(:set_service, @service)
24
26
  @list = InterMine::Lists::List.new({"name" => "test-list"})
metadata CHANGED
@@ -1,126 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: intermine
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.01.00
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.00.00
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Alex Kalderimis
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-10-08 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-03-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: json
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :runtime
33
- version_requirements: *id001
34
- description: |
35
- = Webservice Client Library for InterMine Data-Warehouses
36
-
37
- This library provides an interface to the InterMine webservices
38
- API. It makes construction and execution of queries more
39
- straightforward, safe and convenient, and allows for results
40
- to be used directly in Ruby code. As well as traditional row based
41
- access, the library provides an object-orientated record result
42
- format (similar to ActiveRecords), and allows for fast, memory
43
- efficient iteration of result sets.
44
-
45
- == Example
46
-
47
- Get all protein domains associated with a set of genes and print their names:
48
-
49
- require "intermine/service"
50
-
51
- Service.new("www.flymine.org/query").
52
- new_query("Pathway")
53
- select(:name).
54
- where("genes.symbol" => ["zen", "hox", "h", "bib"]).
55
- each_row { |row| puts row[:name]}
56
-
57
- == Who is this for?
58
-
59
- InterMine data warehouses are typically constructed to hold
60
- Biological data, and as this library facilitates programmatic
61
- access to these data, this install is primarily aimed at
62
- bioinformaticians. In particular, users of the following services
63
- may find it especially useful:
64
- * FlyMine (http://www.flymine.org/query)
65
- * YeastMine (http://yeastmine.yeastgenome.org/yeastmine)
66
- * RatMine (http://ratmine.mcw.edu/ratmine)
67
- * modMine (http://intermine.modencode.org/release-23)
68
- * metabolicMine (http://www.metabolicmine.org/beta)
69
-
70
- == How to use this library:
71
-
72
- We have tried to construct an interface to this library that
73
- does not require you to learn an entirely new set of concepts.
74
- As such, as well as the underlying methods that are common
75
- to all libraries, there is an additional set of aliases and sugar
76
- methods that emulate the DSL style of SQL:
77
-
78
- === SQL style
79
-
80
- service = Service.new("www.flymine.org/query")
81
- service.model.
82
- table("Gene").
83
- select("*", "pathways.*").
84
- where(:symbol => "zen").
85
- order_by(:symbol).
86
- outerjoin(:pathways).
87
- each_row do |r|
88
- puts r
89
- end
90
-
91
- === Common InterMine interface
92
-
93
- service = Service.new("www.flymine.org/query")
94
- query = service.new_query("Gene")
95
- query.add_views("*", "pathways.*")
96
- query.add_constraint("symbol", "=", "zen")
97
- query.add_sort_order(:symbol)
98
- query.add_join(:pathways)
99
- query.each_row do |r|
100
- puts r
101
- end
102
-
103
- For more details, see the accompanying documentation and the unit tests
104
- for interface examples. Further documentation is available at www.intermine.org.
105
-
106
- == Support
107
-
108
- Support is available on our development mailing list: dev@intermine.org
109
-
110
- == License
111
-
112
- This code is Open Source under the LGPL. Source code for all InterMine code
113
- can be checked out from svn://subversion.flymine.org/flymine
114
-
115
- email:
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: ! "= Webservice Client Library for InterMine Data-Warehouses\n\nThis
31
+ library provides an interface to the InterMine webservices\nAPI. It makes construction
32
+ and execution of queries more \nstraightforward, safe and convenient, and allows
33
+ for results\nto be used directly in Ruby code. As well as traditional row based\naccess,
34
+ the library provides an object-orientated record result\nformat (similar to ActiveRecords),
35
+ and allows for fast, memory \nefficient iteration of result sets.\n\n== Example\n\nGet
36
+ all protein domains associated with a set of genes and print their names:\n\n require
37
+ \"intermine/service\"\n\n Service.new(\"www.flymine.org/query\").\n new_query(\"Pathway\")\n
38
+ \ select(:name).\n where(\"genes.symbol\" => [\"zen\", \"hox\", \"h\",
39
+ \"bib\"]).\n each_row { |row| puts row[:name]}\n\n== Who is this for?\n\nInterMine
40
+ data warehouses are typically constructed to hold\nBiological data, and as this
41
+ library facilitates programmatic\naccess to these data, this install is primarily
42
+ aimed at \nbioinformaticians. In particular, users of the following services\nmay
43
+ find it especially useful:\n * FlyMine (http://www.flymine.org/query)\n * YeastMine
44
+ (http://yeastmine.yeastgenome.org/yeastmine)\n * RatMine (http://ratmine.mcw.edu/ratmine)\n
45
+ * modMine (http://intermine.modencode.org/release-23)\n * metabolicMine (http://www.metabolicmine.org/beta)\n\n==
46
+ How to use this library:\n\nWe have tried to construct an interface to this library
47
+ that\ndoes not require you to learn an entirely new set of concepts. \nAs such,
48
+ as well as the underlying methods that are common\nto all libraries, there is an
49
+ additional set of aliases and sugar\nmethods that emulate the DSL style of SQL:\n\n===
50
+ SQL style\n\n service = Service.new(\"www.flymine.org/query\")\n service.model.\n
51
+ \ table(\"Gene\").\n select(\"*\", \"pathways.*\").\n where(:symbol =>
52
+ \"zen\").\n order_by(:symbol).\n outerjoin(:pathways).\n each_row do
53
+ |r|\n puts r\n end\n\n=== Common InterMine interface\n\n service = Service.new(\"www.flymine.org/query\")\n
54
+ \ query = service.new_query(\"Gene\")\n query.add_views(\"*\", \"pathways.*\")\n
55
+ \ query.add_constraint(\"symbol\", \"=\", \"zen\")\n query.add_sort_order(:symbol)\n
56
+ \ query.add_join(:pathways)\n query.each_row do |r|\n puts r\n end\n\nFor more
57
+ details, see the accompanying documentation and the unit tests\nfor interface examples.
58
+ Further documentation is available at www.intermine.org.\n\n== Support\n\nSupport
59
+ is available on our development mailing list: dev@intermine.org\n\n== License\n\nThis
60
+ code is Open Source under the LGPL. Source code for all InterMine code\ncan be checked
61
+ out from svn://subversion.flymine.org/flymine\n"
62
+ email:
116
63
  - dev@intermine.org
117
64
  executables: []
118
-
119
65
  extensions: []
120
-
121
66
  extra_rdoc_files: []
122
-
123
- files:
67
+ files:
124
68
  - lib/intermine/lists.rb
125
69
  - lib/intermine/model.rb
126
70
  - lib/intermine/query.rb
@@ -153,41 +97,40 @@ files:
153
97
  - Gemfile
154
98
  - contact_header.rdoc
155
99
  homepage: http://www.intermine.org
156
- licenses:
100
+ licenses:
157
101
  - LGPL
158
102
  post_install_message:
159
- rdoc_options:
103
+ rdoc_options:
160
104
  - --title
161
105
  - InterMine Webservice Client
162
106
  - --main
163
107
  - README.rdoc
164
108
  - --line-numbers
165
- require_paths:
109
+ require_paths:
166
110
  - lib
167
- required_ruby_version: !ruby/object:Gem::Requirement
111
+ required_ruby_version: !ruby/object:Gem::Requirement
168
112
  none: false
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- hash: 3
173
- segments:
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
174
118
  - 0
175
- version: "0"
176
- required_rubygems_version: !ruby/object:Gem::Requirement
119
+ hash: 150304175
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
121
  none: false
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- hash: 3
182
- segments:
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ segments:
183
127
  - 0
184
- version: "0"
128
+ hash: 150304175
185
129
  requirements: []
186
-
187
130
  rubyforge_project: intermine
188
- rubygems_version: 1.8.15
131
+ rubygems_version: 1.8.25
189
132
  signing_key:
190
133
  specification_version: 3
191
134
  summary: Webservice Client Library for InterMine Data-Warehouses
192
- test_files:
135
+ test_files:
193
136
  - test/unit_tests.rb