intermine 1.03.00 → 1.04.00
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.
- checksums.yaml +7 -0
- data/lib/intermine/model.rb +23 -0
- data/lib/intermine/version.rb +2 -1
- data/test/test_model.rb +53 -0
- metadata +112 -171
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: 7acd7d68334244919bb203d2924ac0d83383f49e
|
|
4
|
+
data.tar.gz: b7b72e0ed38c01cc710ce038848698ec152c5729
|
|
5
|
+
!binary "U0hBNTEy":
|
|
6
|
+
metadata.gz: 6a6ff85383c7cc8593ed654f3dc5319cf04f115e2fb7884581c7ceac21b9ca189e9e134ef2c2f2f5bd947fa49929fc52847569d535c4e79e671949e8853d2c83
|
|
7
|
+
data.tar.gz: 1fdd048f8a47b4ed646b89f4791fda7e0731069f960207a39ea43ce3d478beeb0e13c45acec19cdd8569a3af7b698cb4ea6eb90bee4d2d7b5e06499d433a073b
|
data/lib/intermine/model.rb
CHANGED
|
@@ -518,12 +518,35 @@ module Metadata
|
|
|
518
518
|
|
|
519
519
|
klass = Module.new
|
|
520
520
|
fd_names = @fields.values.map { |x| x.name }
|
|
521
|
+
fds = @fields.values
|
|
521
522
|
attr_names = @fields.values.select { |x| x.is_a?(AttributeDescriptor)}.map {|x| x.name}
|
|
522
523
|
klass.class_eval do
|
|
523
524
|
include *supers
|
|
524
525
|
attr_reader *attr_names
|
|
525
526
|
end
|
|
526
527
|
|
|
528
|
+
klass.class_eval do
|
|
529
|
+
|
|
530
|
+
define_method(:to_h) do
|
|
531
|
+
ret = Hash.new
|
|
532
|
+
fds.each do |fd|
|
|
533
|
+
if fd.is_a?(AttributeDescriptor)
|
|
534
|
+
ret.store(fd.name, send(fd.name))
|
|
535
|
+
elsif fd.is_a?(CollectionDescriptor)
|
|
536
|
+
ret.store(fd.name, send(fd.name).map {|v| v.to_h})
|
|
537
|
+
else
|
|
538
|
+
ret.store(fd.name, send(fd.name).to_h)
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
ret.store("id", objectId)
|
|
542
|
+
return ret
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
define_method(:to_json) do |*a|
|
|
546
|
+
to_h.to_json(*a)
|
|
547
|
+
end
|
|
548
|
+
end
|
|
549
|
+
|
|
527
550
|
@fields.values.each do |fd|
|
|
528
551
|
if fd.is_a?(CollectionDescriptor)
|
|
529
552
|
klass.class_eval do
|
data/lib/intermine/version.rb
CHANGED
|
@@ -3,6 +3,7 @@ module Intermine
|
|
|
3
3
|
# Webservice Client Version number
|
|
4
4
|
#
|
|
5
5
|
# Changes:
|
|
6
|
+
# 1.04.00 - Added to_h and to_json methods for result objects
|
|
6
7
|
# 1.03.00 - Add support for indexed sequence service
|
|
7
8
|
# 1.02.00 - Allow the lazy fetching to be optional
|
|
8
9
|
# 1.01.01 - Improved lazy reference fetching
|
|
@@ -21,5 +22,5 @@ module Intermine
|
|
|
21
22
|
# 0.98.09 - Major changes to results - now with thorough-going Enumerable support
|
|
22
23
|
# 0.98.08 - Added column summary support
|
|
23
24
|
#
|
|
24
|
-
VERSION = "1.
|
|
25
|
+
VERSION = "1.04.00"
|
|
25
26
|
end
|
data/test/test_model.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + "/test_helper.rb"
|
|
2
2
|
require "intermine/model"
|
|
3
|
+
require "json"
|
|
3
4
|
|
|
4
5
|
require "test/unit"
|
|
5
6
|
|
|
@@ -220,6 +221,58 @@ class TestModel < Test::Unit::TestCase
|
|
|
220
221
|
|
|
221
222
|
end
|
|
222
223
|
|
|
224
|
+
def test_to_h
|
|
225
|
+
|
|
226
|
+
manager = @model.make_new("Manager", {
|
|
227
|
+
"name" => "David Brent",
|
|
228
|
+
"seniority" => 42,
|
|
229
|
+
"age" => 39,
|
|
230
|
+
"fullTime" => true,
|
|
231
|
+
"department" => {
|
|
232
|
+
"name" => "Sales",
|
|
233
|
+
"employees" => [
|
|
234
|
+
{ "name" => "Tom" },
|
|
235
|
+
{ "name" => "Dick" },
|
|
236
|
+
{ "name" => "Harry" }
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
manager_h = manager.to_h
|
|
242
|
+
|
|
243
|
+
assert_equal(manager_h["name"], "David Brent")
|
|
244
|
+
assert_equal(manager_h["age"], 39)
|
|
245
|
+
assert_equal(manager_h["department"]["name"], "Sales")
|
|
246
|
+
assert_equal(manager_h["department"]["employees"][1]["name"], "Dick")
|
|
247
|
+
assert_equal(manager_h["department"]["employees"].size, 3)
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def test_to_json
|
|
251
|
+
|
|
252
|
+
manager = @model.make_new("Manager", {
|
|
253
|
+
"name" => "David Brent",
|
|
254
|
+
"seniority" => 42,
|
|
255
|
+
"age" => 39,
|
|
256
|
+
"fullTime" => true,
|
|
257
|
+
"department" => {
|
|
258
|
+
"name" => "Sales",
|
|
259
|
+
"employees" => [
|
|
260
|
+
{ "name" => "Tom" },
|
|
261
|
+
{ "name" => "Dick" },
|
|
262
|
+
{ "name" => "Harry" }
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
manager_h = JSON[manager.to_h.to_json]
|
|
268
|
+
|
|
269
|
+
assert_equal(manager_h["name"], "David Brent")
|
|
270
|
+
assert_equal(manager_h["age"], 39)
|
|
271
|
+
assert_equal(manager_h["department"]["name"], "Sales")
|
|
272
|
+
assert_equal(manager_h["department"]["employees"][1]["name"], "Dick")
|
|
273
|
+
assert_equal(manager_h["department"]["employees"].size, 3)
|
|
274
|
+
end
|
|
275
|
+
|
|
223
276
|
def test_inheritance
|
|
224
277
|
|
|
225
278
|
manager = @model.make_new("Manager", { "name" => "David Brent" })
|
metadata
CHANGED
|
@@ -1,185 +1,126 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: intermine
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
version: 1.03.00
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.04.00
|
|
6
5
|
platform: ruby
|
|
7
|
-
authors:
|
|
8
|
-
|
|
6
|
+
authors:
|
|
7
|
+
- Alex Kalderimis
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
==
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
== How to use this library:
|
|
63
|
-
|
|
64
|
-
We have tried to construct an interface to this library that
|
|
65
|
-
does not require you to learn an entirely new set of concepts.
|
|
66
|
-
As such, as well as the underlying methods that are common
|
|
67
|
-
to all libraries, there is an additional set of aliases and sugar
|
|
68
|
-
methods that emulate the DSL style of SQL:
|
|
69
|
-
|
|
70
|
-
=== SQL style
|
|
71
|
-
|
|
72
|
-
service = Service.new("www.flymine.org/query")
|
|
73
|
-
service.model.
|
|
74
|
-
table("Gene").
|
|
75
|
-
select("*", "pathways.*").
|
|
76
|
-
where(:symbol => "zen").
|
|
77
|
-
order_by(:symbol).
|
|
78
|
-
outerjoin(:pathways).
|
|
79
|
-
each_row do |r|
|
|
80
|
-
puts r
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
=== Common InterMine interface
|
|
84
|
-
|
|
85
|
-
service = Service.new("www.flymine.org/query")
|
|
86
|
-
query = service.new_query("Gene")
|
|
87
|
-
query.add_views("*", "pathways.*")
|
|
88
|
-
query.add_constraint("symbol", "=", "zen")
|
|
89
|
-
query.add_sort_order(:symbol)
|
|
90
|
-
query.add_join(:pathways)
|
|
91
|
-
query.each_row do |r|
|
|
92
|
-
puts r
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
For more details, see the accompanying documentation and the unit tests
|
|
96
|
-
for interface examples. Further documentation is available at www.intermine.org.
|
|
97
|
-
|
|
98
|
-
== Support
|
|
99
|
-
|
|
100
|
-
Support is available on our development mailing list: dev@intermine.org
|
|
101
|
-
|
|
102
|
-
== License
|
|
103
|
-
|
|
104
|
-
This code is Open Source under the LGPL. Source code for all InterMine code
|
|
105
|
-
can be checked out from svn://subversion.flymine.org/flymine
|
|
106
|
-
|
|
107
|
-
email:
|
|
108
|
-
- dev@intermine.org
|
|
11
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: json
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: "= Webservice Client Library for InterMine Data-Warehouses\n\nThis library
|
|
28
|
+
provides an interface to the InterMine webservices\nAPI. It makes construction and
|
|
29
|
+
execution of queries more \nstraightforward, safe and convenient, and allows for
|
|
30
|
+
results\nto be used directly in Ruby code. As well as traditional row based\naccess,
|
|
31
|
+
the library provides an object-orientated record result\nformat (similar to ActiveRecords),
|
|
32
|
+
and allows for fast, memory \nefficient iteration of result sets.\n\n== Example\n\nGet
|
|
33
|
+
all protein domains associated with a set of genes and print their names:\n\n require
|
|
34
|
+
\"intermine/service\"\n\n Service.new(\"www.flymine.org/query\").\n new_query(\"Pathway\")\n
|
|
35
|
+
\ select(:name).\n where(\"genes.symbol\" => [\"zen\", \"hox\", \"h\",
|
|
36
|
+
\"bib\"]).\n each_row { |row| puts row[:name]}\n\n== Who is this for?\n\nInterMine
|
|
37
|
+
data warehouses are typically constructed to hold\nBiological data, and as this
|
|
38
|
+
library facilitates programmatic\naccess to these data, this install is primarily
|
|
39
|
+
aimed at \nbioinformaticians. In particular, users of the following services\nmay
|
|
40
|
+
find it especially useful:\n * FlyMine (http://www.flymine.org/query)\n * YeastMine
|
|
41
|
+
(http://yeastmine.yeastgenome.org/yeastmine)\n * RatMine (http://ratmine.mcw.edu/ratmine)\n
|
|
42
|
+
* modMine (http://intermine.modencode.org/release-23)\n * metabolicMine (http://www.metabolicmine.org/beta)\n\n==
|
|
43
|
+
How to use this library:\n\nWe have tried to construct an interface to this library
|
|
44
|
+
that\ndoes not require you to learn an entirely new set of concepts. \nAs such,
|
|
45
|
+
as well as the underlying methods that are common\nto all libraries, there is an
|
|
46
|
+
additional set of aliases and sugar\nmethods that emulate the DSL style of SQL:\n\n===
|
|
47
|
+
SQL style\n\n service = Service.new(\"www.flymine.org/query\")\n service.model.\n
|
|
48
|
+
\ table(\"Gene\").\n select(\"*\", \"pathways.*\").\n where(:symbol =>
|
|
49
|
+
\"zen\").\n order_by(:symbol).\n outerjoin(:pathways).\n each_row do
|
|
50
|
+
|r|\n puts r\n end\n\n=== Common InterMine interface\n\n service = Service.new(\"www.flymine.org/query\")\n
|
|
51
|
+
\ query = service.new_query(\"Gene\")\n query.add_views(\"*\", \"pathways.*\")\n
|
|
52
|
+
\ query.add_constraint(\"symbol\", \"=\", \"zen\")\n query.add_sort_order(:symbol)\n
|
|
53
|
+
\ query.add_join(:pathways)\n query.each_row do |r|\n puts r\n end\n\nFor more
|
|
54
|
+
details, see the accompanying documentation and the unit tests\nfor interface examples.
|
|
55
|
+
Further documentation is available at www.intermine.org.\n\n== Support\n\nSupport
|
|
56
|
+
is available on our development mailing list: dev@intermine.org\n\n== License\n\nThis
|
|
57
|
+
code is Open Source under the LGPL. Source code for all InterMine code\ncan be checked
|
|
58
|
+
out from svn://subversion.flymine.org/flymine\n"
|
|
59
|
+
email:
|
|
60
|
+
- dev@intermine.org
|
|
109
61
|
executables: []
|
|
110
|
-
|
|
111
62
|
extensions: []
|
|
112
|
-
|
|
113
63
|
extra_rdoc_files: []
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- contact_header.rdoc
|
|
64
|
+
files:
|
|
65
|
+
- lib/intermine/lists.rb
|
|
66
|
+
- lib/intermine/model.rb
|
|
67
|
+
- lib/intermine/query.rb
|
|
68
|
+
- lib/intermine/results.rb
|
|
69
|
+
- lib/intermine/service.rb
|
|
70
|
+
- lib/intermine/version.rb
|
|
71
|
+
- test/data/lists.json
|
|
72
|
+
- test/data/model.json
|
|
73
|
+
- test/data/resultobjs.json
|
|
74
|
+
- test/data/resultrow.json
|
|
75
|
+
- test/data/resultset.json
|
|
76
|
+
- test/data/testmodel_model.xml
|
|
77
|
+
- test/live_results.rb
|
|
78
|
+
- test/live_summary_test.rb
|
|
79
|
+
- test/live_test.rb
|
|
80
|
+
- test/test.rb
|
|
81
|
+
- test/test_helper.rb
|
|
82
|
+
- test/test_lists.rb
|
|
83
|
+
- test/test_model.rb
|
|
84
|
+
- test/test_query.rb
|
|
85
|
+
- test/test_result_row.rb
|
|
86
|
+
- test/test_results.rb
|
|
87
|
+
- test/test_service.rb
|
|
88
|
+
- test/test_sugar.rb
|
|
89
|
+
- test/unit_tests.rb
|
|
90
|
+
- MANIFEST
|
|
91
|
+
- LICENCE
|
|
92
|
+
- Rakefile
|
|
93
|
+
- README.rdoc
|
|
94
|
+
- Gemfile
|
|
95
|
+
- contact_header.rdoc
|
|
147
96
|
homepage: http://www.intermine.org
|
|
148
|
-
licenses:
|
|
149
|
-
|
|
97
|
+
licenses:
|
|
98
|
+
- LGPL
|
|
99
|
+
metadata: {}
|
|
150
100
|
post_install_message:
|
|
151
|
-
rdoc_options:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
require_paths:
|
|
158
|
-
|
|
159
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
none: false
|
|
170
|
-
requirements:
|
|
171
|
-
- - ">="
|
|
172
|
-
- !ruby/object:Gem::Version
|
|
173
|
-
hash: 2
|
|
174
|
-
segments:
|
|
175
|
-
- 0
|
|
176
|
-
version: "0"
|
|
101
|
+
rdoc_options:
|
|
102
|
+
- "--title"
|
|
103
|
+
- InterMine Webservice Client
|
|
104
|
+
- "--main"
|
|
105
|
+
- README.rdoc
|
|
106
|
+
- "--line-numbers"
|
|
107
|
+
require_paths:
|
|
108
|
+
- lib
|
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0'
|
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
177
119
|
requirements: []
|
|
178
|
-
|
|
179
120
|
rubyforge_project: intermine
|
|
180
|
-
rubygems_version:
|
|
121
|
+
rubygems_version: 2.0.0.preview3.1
|
|
181
122
|
signing_key:
|
|
182
|
-
specification_version:
|
|
123
|
+
specification_version: 4
|
|
183
124
|
summary: Webservice Client Library for InterMine Data-Warehouses
|
|
184
|
-
test_files:
|
|
185
|
-
|
|
125
|
+
test_files:
|
|
126
|
+
- test/unit_tests.rb
|