bel 0.4.0.beta.11 → 0.4.0.beta.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bel/evidence_model/citation.rb +3 -0
- data/lib/bel/evidence_model/experiment_context.rb +8 -1
- data/lib/bel/evidence_model/metadata.rb +3 -1
- data/lib/bel/translator/plugins/bel_script/bel_yielder.rb +0 -1
- data/lib/bel/translator/plugins/bel_script/translator.rb +15 -4
- data/lib/bel/translator/plugins/json_evidence/translator.rb +32 -16
- data/lib/bel/translator/plugins/xbel/translator.rb +1 -0
- data/lib/bel/translator/plugins/xbel/xbel_yielder.rb +11 -2
- data/lib/bel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1de2e3597f5e9e16484beb22668582c728a31296
|
4
|
+
data.tar.gz: f43c19636c538cf6efc1d69420e1d76183e0608c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75d4efe4137aba17e5ab685282fa998b9e6013a3e7e67ba253651d51b0eb97a81d5ff82a7ef7fa5cd926a3cfd87787fdd0ec8c54d3a67b87789583e92798cb1f
|
7
|
+
data.tar.gz: 3d76283d55261eb0460b1828ba894fafeb344d48d8231d71252b1bcc5502b790e9415a125e00b8ee9b4fe8cfaf3cceb3a92a6aa57e0b055fa42a8af7f4e4e071
|
@@ -52,6 +52,9 @@ module BEL
|
|
52
52
|
if args.length == 1
|
53
53
|
enumerable = args.first
|
54
54
|
if enumerable.respond_to? :each_pair
|
55
|
+
enumerable.keys.each do |key|
|
56
|
+
enumerable[key.to_s.to_sym] = enumerable.delete(key)
|
57
|
+
end
|
55
58
|
(MEMBER_ORDER & enumerable.keys).each do |member|
|
56
59
|
self.send(:"#{member}=", enumerable[member])
|
57
60
|
end
|
@@ -10,7 +10,14 @@ module BEL
|
|
10
10
|
include Enumerable
|
11
11
|
|
12
12
|
def initialize(values = [])
|
13
|
-
@values = values
|
13
|
+
@values = values.map { |item|
|
14
|
+
name = item[:name] || item['name']
|
15
|
+
value = item[:value] || item['value']
|
16
|
+
{
|
17
|
+
:name => name.to_sym,
|
18
|
+
:value => value
|
19
|
+
}
|
20
|
+
}
|
14
21
|
end
|
15
22
|
|
16
23
|
def_delegators :@values, :<<, :[], :"[]=",
|
@@ -14,10 +14,21 @@ module BEL::Translator::Plugins
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def write(objects, writer = StringIO.new, options = {})
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
if block_given?
|
18
|
+
BelYielder.new(objects).each { |bel_part|
|
19
|
+
yield bel_part
|
20
|
+
}
|
21
|
+
else
|
22
|
+
if writer
|
23
|
+
BelYielder.new(objects).each { |bel_part|
|
24
|
+
writer << "#{bel_part}"
|
25
|
+
writer.flush
|
26
|
+
}
|
27
|
+
writer
|
28
|
+
else
|
29
|
+
BelYielder.new(objects)
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
22
33
|
end
|
23
34
|
end
|
@@ -18,26 +18,42 @@ module BEL::Translator::Plugins
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def write(objects, writer = StringIO.new, options = {})
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
json_strings = Enumerator.new { |yielder|
|
22
|
+
yielder << '['
|
23
|
+
begin
|
24
|
+
evidence_enum = objects.each
|
24
25
|
|
25
|
-
|
26
|
-
evidence = evidence_enum.next
|
27
|
-
::BEL::JSON.write(wrap(evidence), writer)
|
28
|
-
|
29
|
-
# each successive evidence starts with a comma
|
30
|
-
while true
|
26
|
+
# write first evidence object
|
31
27
|
evidence = evidence_enum.next
|
32
|
-
|
33
|
-
|
28
|
+
yielder << ::BEL::JSON.write(wrap(evidence), nil)
|
29
|
+
|
30
|
+
# each successive evidence starts with a comma
|
31
|
+
while true
|
32
|
+
evidence = evidence_enum.next
|
33
|
+
yielder << ','
|
34
|
+
yielder << ::BEL::JSON.write(wrap(evidence), nil)
|
35
|
+
end
|
36
|
+
rescue StopIteration
|
37
|
+
# end of evidence hashes
|
34
38
|
end
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
write_array_end(writer)
|
39
|
+
yielder << ']'
|
40
|
+
}
|
39
41
|
|
40
|
-
|
42
|
+
if block_given?
|
43
|
+
json_strings.each do |string|
|
44
|
+
yield string
|
45
|
+
end
|
46
|
+
else
|
47
|
+
if writer
|
48
|
+
json_strings.each do |string|
|
49
|
+
writer << string
|
50
|
+
writer.flush
|
51
|
+
end
|
52
|
+
writer
|
53
|
+
else
|
54
|
+
json_strings
|
55
|
+
end
|
56
|
+
end
|
41
57
|
end
|
42
58
|
|
43
59
|
private
|
@@ -77,12 +77,21 @@ module BEL::Translator::Plugins
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def self.statement(statement, el_statement)
|
80
|
+
if statement.is_a?(String)
|
81
|
+
statement = BEL::Script.parse(statement.to_s).find { |x|
|
82
|
+
x.is_a? BEL::Model::Statement
|
83
|
+
}
|
84
|
+
return el_statement if statement == nil
|
85
|
+
end
|
86
|
+
|
80
87
|
if statement.relationship
|
81
88
|
el_statement.add_attribute 'bel:relationship', statement.relationship
|
82
89
|
end
|
83
90
|
|
84
|
-
|
85
|
-
|
91
|
+
if statement.subject
|
92
|
+
el_subject = self.subject(statement.subject)
|
93
|
+
el_statement.add_element(el_subject)
|
94
|
+
end
|
86
95
|
|
87
96
|
if statement.object
|
88
97
|
el_object = self.object(statement.object)
|
data/lib/bel/version.rb
CHANGED