bel 0.4.0.beta.8 → 0.4.0.beta.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e22bc8ddb611afaba61076e5e2ac66dc89ff9a59
4
- data.tar.gz: 54c075abe536cd62000858f19e88cdaad4b1ab79
3
+ metadata.gz: c2439b3403f830ef0c8117b3bd1ed9ef6cd589c4
4
+ data.tar.gz: 9a5279406ef99030abb59b2b4f19960d03b43b18
5
5
  SHA512:
6
- metadata.gz: e994fee183fbcedbcec2b6728a9095299eb506e3ec0d8e9a2935b589eaff302498c3318fe5ffd25919490b80803db1d5cf4b9ede339099cb6630efc96d2e27ab
7
- data.tar.gz: d6573b1c9965ee341f154a03f11c1a50f9392db3d5264c984d6e976435090e6c4f70c8e186e85e46228676791fe46514e6c5610a2e45c22df1b42739f33e02c9
6
+ metadata.gz: 8acf51e5234ecdb58206b761451dda5437097eec73c0200ae165985cffbc5bdf27bf3eef7931dad3bfbb48affdacf75a72fbb4e4e1d24d45ce9a39ee99ea4592
7
+ data.tar.gz: f003e2105ad90a3eae32872b6c58b97a310ea3ec035cd3a82f1af1f2af56c4930c5a0117a1df6d12b0321116222b06c8ceb8572e17c42fb0f48da39aac892d2b
@@ -50,7 +50,7 @@ module BEL
50
50
  raise TranslateError.new(output_format)
51
51
 
52
52
  evidence = in_translator.read(prepared_input)
53
- output = out_translator.write(evidence, writer)
53
+ out_translator.write(evidence, writer, options)
54
54
  writer
55
55
  end
56
56
 
@@ -1,3 +1,4 @@
1
+ require 'bel/evidence_model'
1
2
  require_relative 'uuid'
2
3
 
3
4
  module BEL::Translator::Plugins
@@ -5,6 +6,7 @@ module BEL::Translator::Plugins
5
6
  module Rdf
6
7
 
7
8
  # OpenClass to contribute RDF functionality to BEL Model.
9
+
8
10
  class ::BEL::Namespace::NamespaceDefinition
9
11
 
10
12
  def to_uri
@@ -18,43 +20,38 @@ module BEL::Translator::Plugins
18
20
 
19
21
  class ::BEL::Model::Parameter
20
22
 
23
+ CONCEPT_ENCODING = {
24
+ :G => BEL::RDF::BELV.GeneConcept,
25
+ :R => BEL::RDF::BELV.RNAConcept,
26
+ :P => BEL::RDF::BELV.ProteinConcept,
27
+ :M => BEL::RDF::BELV.MicroRNAConcept,
28
+ :C => BEL::RDF::BELV.ComplexConcept,
29
+ :B => BEL::RDF::BELV.BiologicalProcessConcept,
30
+ :A => BEL::RDF::BELV.AbundanceConcept,
31
+ :O => BEL::RDF::BELV.PathologyConcept,
32
+ }
33
+
21
34
  def to_uri
22
35
  @ns.to_rdf_vocabulary[URI::encode(@value)]
23
36
  end
24
37
 
25
- def to_rdf
38
+ def to_rdf(graph_name = nil)
26
39
  uri = to_uri
27
40
  encodings = ['A'].concat(@enc.to_s.each_char.to_a).uniq
28
41
  if block_given?
29
- encodings.map { |enc| concept_statement(enc, uri) }.each do |stmt|
42
+ encodings.map { |enc| concept_statement(enc, uri, graph_name) }.each do |stmt|
30
43
  yield stmt
31
44
  end
32
45
  else
33
- encodings.map { |enc| concept_statement(enc, uri)}
46
+ encodings.map { |enc| concept_statement(enc, uri, graph_name)}
34
47
  end
35
48
  end
36
49
 
37
50
  private
38
51
 
39
- def concept_statement(encoding_character, uri)
40
- case encoding_character
41
- when 'G'
42
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.GeneConcept)
43
- when 'R'
44
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.RNAConcept)
45
- when 'P'
46
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.ProteinConcept)
47
- when 'M'
48
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.MicroRNAConcept)
49
- when 'C'
50
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.ComplexConcept)
51
- when 'B'
52
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.BiologicalProcessConcept)
53
- when 'A'
54
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.AbundanceConcept)
55
- when 'O'
56
- ::RDF::Statement(uri, ::RDF.type, BEL::RDF::BELV.PathologyConcept)
57
- end
52
+ def concept_statement(encoding_character, uri, graph_name = nil)
53
+ encoding = CONCEPT_ENCODING.fetch(encoding_character.to_sym, BEL::RDF::BELV.AbundanceConcept)
54
+ ::RDF::Statement(uri, ::RDF.type, encoding, :graph_name => graph_name)
58
55
  end
59
56
  end
60
57
 
@@ -100,21 +97,21 @@ module BEL::Translator::Plugins
100
97
  end
101
98
  end
102
99
 
103
- def to_rdf
100
+ def to_rdf(graph_name = nil)
104
101
  uri = to_uri
105
102
  statements = []
106
103
 
107
104
  # rdf:type
108
105
  type = rdf_type
109
- statements << [uri, BEL::RDF::RDF.type, BEL::RDF::BELV.Term]
110
- statements << [uri, BEL::RDF::RDF.type, type]
106
+ statements << ::RDF::Statement.new(uri, BEL::RDF::RDF.type, BEL::RDF::BELV.Term, :graph_name => graph_name)
107
+ statements << ::RDF::Statement.new(uri, BEL::RDF::RDF.type, type, :graph_name => graph_name)
111
108
  fx = @fx.respond_to?(:short_form) ? @fx.short_form : @fx.to_s.to_sym
112
109
  if BEL::RDF::ACTIVITY_TYPE.include? fx
113
- statements << [uri, BEL::RDF::BELV.hasActivityType, BEL::RDF::ACTIVITY_TYPE[fx]]
110
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasActivityType, BEL::RDF::ACTIVITY_TYPE[fx], :graph_name => graph_name)
114
111
  end
115
112
 
116
113
  # rdfs:label
117
- statements << [uri, BEL::RDF::RDFS.label, to_s.force_encoding('UTF-8')]
114
+ statements << ::RDF::Statement.new(uri, BEL::RDF::RDFS.label, to_s.force_encoding('UTF-8'), :graph_name => graph_name)
118
115
 
119
116
  # special proteins (does not recurse into pmod)
120
117
  if [:p, :proteinAbundance].include?(fx)
@@ -132,22 +129,22 @@ module BEL::Translator::Plugins
132
129
  mod_string = pmod.arguments.map(&:to_s).join(',')
133
130
  mod_type = BEL::RDF::MODIFICATION_TYPE.find {|k,v| mod_string.start_with? k}
134
131
  mod_type = (mod_type ? mod_type[1] : BEL::RDF::BELV.Modification)
135
- statements << [uri, BEL::RDF::BELV.hasModificationType, mod_type]
132
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasModificationType, mod_type, :graph_name => graph_name)
136
133
  last = pmod.arguments.last.to_s
137
134
  if last.match(/^\d+$/)
138
- statements << [uri, BEL::RDF::BELV.hasModificationPosition, last.to_i]
135
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasModificationPosition, last.to_i, :graph_name => graph_name)
139
136
  end
140
137
  # link root protein abundance as hasChild
141
138
  root_param = @arguments.find{|x| x.is_a? ::BEL::Model::Parameter}
142
139
  (root_id, root_statements) = ::BEL::Model::Term.new(:p, [root_param]).to_rdf
143
- statements << [uri, BEL::RDF::BELV.hasChild, root_id]
140
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasChild, root_id, :graph_name => graph_name)
144
141
  statements += root_statements
145
142
  return [uri, statements]
146
143
  elsif @arguments.find{|x| x.is_a? ::BEL::Model::Term and BEL::RDF::PROTEIN_VARIANT.include? x.fx}
147
144
  # link root protein abundance as hasChild
148
145
  root_param = @arguments.find{|x| x.is_a? ::BEL::Model::Parameter}
149
146
  (root_id, root_statements) = ::BEL::Model::Term.new(:p, [root_param]).to_rdf
150
- statements << [uri, BEL::RDF::BELV.hasChild, root_id]
147
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasChild, root_id, :graph_name => graph_name)
151
148
  statements += root_statements
152
149
  return [uri, statements]
153
150
  end
@@ -158,17 +155,17 @@ module BEL::Translator::Plugins
158
155
  x.is_a? ::BEL::Model::Parameter and x.ns != nil
159
156
  }.each do |param|
160
157
  concept_uri = param.ns.to_uri + param.value.to_s
161
- statements << [uri, BEL::RDF::BELV.hasConcept, BEL::RDF::RDF::URI(URI.encode(concept_uri))]
158
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasConcept, BEL::RDF::RDF::URI(URI.encode(concept_uri)), :graph_name => graph_name)
162
159
  end
163
160
 
164
161
  # BEL::RDF::BELV.hasChild]
165
162
  @arguments.find_all{|x| x.is_a? ::BEL::Model::Term}.each do |child|
166
163
  (child_id, child_statements) = child.to_rdf
167
- statements << [uri, BEL::RDF::BELV.hasChild, child_id]
164
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasChild, child_id, :graph_name => graph_name)
168
165
  statements += child_statements
169
166
  end
170
167
 
171
- return [uri, statements]
168
+ [uri, statements]
172
169
  end
173
170
  end
174
171
 
@@ -176,9 +173,6 @@ module BEL::Translator::Plugins
176
173
 
177
174
  def to_uri
178
175
  case
179
- when subject_only?
180
- tid = @subject.to_s.squeeze(')').gsub(/[")\[\]]/, '').gsub(/[(:, ]/, '_')
181
- BEL::RDF::BELR[URI::encode(tid)]
182
176
  when simple?
183
177
  sub_id = @subject.to_s.squeeze(')').gsub(/[")\[\]]/, '').gsub(/[(:, ]/, '_')
184
178
  obj_id = @object.to_s.squeeze(')').gsub(/[")\[\]]/, '').gsub(/[(:, ]/, '_')
@@ -206,17 +200,21 @@ module BEL::Translator::Plugins
206
200
  nrel = @object.relationship.to_s
207
201
  end
208
202
  BEL::RDF::BELR[URI::encode("#{sub_id}_#{rel}_#{nsub_id}_#{nrel}_#{nobj_id}")]
203
+ else
204
+ # Interpret as subject only BEL statement.
205
+ tid = @subject.to_s.squeeze(')').gsub(/[")\[\]]/, '').gsub(/[(:, ]/, '_')
206
+ BEL::RDF::BELR[URI::encode(tid)]
209
207
  end
210
208
  end
211
209
 
212
- def to_rdf
213
- uri = to_uri
210
+ def to_rdf(graph_name = nil)
211
+ uri = to_uri
214
212
  statements = []
215
213
 
216
214
  case
217
215
  when subject_only?
218
216
  (sub_uri, sub_statements) = @subject.to_rdf
219
- statements << [uri, BEL::RDF::BELV.hasSubject, sub_uri]
217
+ statements << ::RDF::Statement(uri, BEL::RDF::BELV.hasSubject, sub_uri, :graph_name => graph_name)
220
218
  statements += sub_statements
221
219
  when simple?
222
220
  (sub_uri, sub_statements) = @subject.to_rdf
@@ -226,9 +224,9 @@ module BEL::Translator::Plugins
226
224
  statements += obj_statements
227
225
 
228
226
  rel = BEL::RDF::RELATIONSHIP_TYPE[@relationship.to_s]
229
- statements << [uri, BEL::RDF::BELV.hasSubject, sub_uri]
230
- statements << [uri, BEL::RDF::BELV.hasObject, obj_uri]
231
- statements << [uri, BEL::RDF::BELV.hasRelationship, rel]
227
+ statements << ::RDF::Statement(uri, BEL::RDF::BELV.hasSubject, sub_uri, :graph_name => graph_name)
228
+ statements << ::RDF::Statement(uri, BEL::RDF::BELV.hasObject, obj_uri, :graph_name => graph_name)
229
+ statements << ::RDF::Statement(uri, BEL::RDF::BELV.hasRelationship, rel, :graph_name => graph_name)
232
230
  when nested?
233
231
  (sub_uri, sub_statements) = @subject.to_rdf
234
232
  (nsub_uri, nsub_statements) = @object.subject.to_rdf
@@ -241,25 +239,25 @@ module BEL::Translator::Plugins
241
239
  nuri = BEL::RDF::BELR["#{strip_prefix(nsub_uri)}_#{nrel}_#{strip_prefix(nobj_uri)}"]
242
240
 
243
241
  # inner
244
- statements << [nuri, BEL::RDF::BELV.hasSubject, nsub_uri]
245
- statements << [nuri, BEL::RDF::BELV.hasObject, nobj_uri]
246
- statements << [nuri, BEL::RDF::BELV.hasRelationship, nrel]
242
+ statements << ::RDF::Statement.new(nuri, BEL::RDF::BELV.hasSubject, nsub_uri, :graph_name => graph_name)
243
+ statements << ::RDF::Statement.new(nuri, BEL::RDF::BELV.hasObject, nobj_uri, :graph_name => graph_name)
244
+ statements << ::RDF::Statement.new(nuri, BEL::RDF::BELV.hasRelationship, nrel, :graph_name => graph_name)
247
245
 
248
246
  # outer
249
- statements << [uri, BEL::RDF::BELV.hasSubject, sub_uri]
250
- statements << [uri, BEL::RDF::BELV.hasObject, nuri]
251
- statements << [uri, BEL::RDF::BELV.hasRelationship, rel]
247
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasSubject, sub_uri, :graph_name => graph_name)
248
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasObject, nuri, :graph_name => graph_name)
249
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasRelationship, rel, :graph_name => graph_name)
252
250
  end
253
251
 
254
252
  # common statement triples
255
- statements << [uri, BEL::RDF::RDF.type, BEL::RDF::BELV.Statement]
256
- statements << [uri, ::RDF::RDFS.label, to_s.force_encoding('UTF-8')]
253
+ statements << ::RDF::Statement.new(uri, BEL::RDF::RDF.type, BEL::RDF::BELV.Statement, :graph_name => graph_name)
254
+ statements << ::RDF::Statement.new(uri, ::RDF::RDFS.label, to_s.force_encoding('UTF-8'), :graph_name => graph_name)
257
255
 
258
256
  # evidence
259
257
  evidence = BEL::RDF::BELE[Rdf.generate_uuid]
260
- statements << [evidence, BEL::RDF::RDF.type, BEL::RDF::BELV.Evidence]
261
- statements << [uri, BEL::RDF::BELV.hasEvidence, evidence]
262
- statements << [evidence, BEL::RDF::BELV.hasStatement, uri]
258
+ statements << ::RDF::Statement.new(evidence, BEL::RDF::RDF.type, BEL::RDF::BELV.Evidence, :graph_name => graph_name)
259
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasEvidence, evidence, :graph_name => graph_name)
260
+ statements << ::RDF::Statement.new(evidence, BEL::RDF::BELV.hasStatement, uri, :graph_name => graph_name)
263
261
 
264
262
  # citation
265
263
  citation = @annotations.delete('Citation')
@@ -267,11 +265,7 @@ module BEL::Translator::Plugins
267
265
  value = citation.value.map{|x| x.gsub('"', '')}
268
266
  if citation and value[0] == 'PubMed'
269
267
  pid = value[2]
270
- statements << [
271
- evidence,
272
- BEL::RDF::BELV.hasCitation,
273
- BEL::RDF::PUBMED[pid]
274
- ]
268
+ statements << ::RDF::Statement.new(evidence, BEL::RDF::BELV.hasCitation, BEL::RDF::PUBMED[pid], :graph_name => graph_name)
275
269
  end
276
270
  end
277
271
 
@@ -279,23 +273,23 @@ module BEL::Translator::Plugins
279
273
  evidence_text = @annotations.delete('Evidence')
280
274
  if evidence_text
281
275
  value = evidence_text.value.gsub('"', '').force_encoding('UTF-8')
282
- statements << [evidence, BEL::RDF::BELV.hasEvidenceText, value]
276
+ statements << ::RDF::Statement.new(evidence, BEL::RDF::BELV.hasEvidenceText, value, :graph_name => graph_name)
283
277
  end
284
278
 
285
279
  # annotations
286
- @annotations.each do |name, anno|
280
+ @annotations.each do |_, anno|
287
281
  name = anno.name.gsub('"', '')
288
282
 
289
283
  if BEL::RDF::const_defined? name
290
284
  annotation_scheme = BEL::RDF::const_get name
291
285
  [anno.value].flatten.map{|x| x.gsub('"', '')}.each do |val|
292
286
  value_uri = BEL::RDF::RDF::URI(URI.encode(annotation_scheme + val.to_s))
293
- statements << [evidence, BEL::RDF::BELV.hasAnnotation, value_uri]
287
+ statements << ::RDF::Statement.new(evidence, BEL::RDF::BELV.hasAnnotation, value_uri, :graph_name => graph_name)
294
288
  end
295
289
  end
296
290
  end
297
291
 
298
- return [uri, statements]
292
+ [uri, statements]
299
293
  end
300
294
 
301
295
  private
@@ -308,5 +302,115 @@ module BEL::Translator::Plugins
308
302
  end
309
303
  end
310
304
  end
305
+
306
+ class ::BEL::Model::Evidence
307
+
308
+ def to_uri
309
+ BEL::RDF::BELE[Rdf.generate_uuid]
310
+ end
311
+
312
+ def to_rdf
313
+ uri = to_uri
314
+ statement_uri, statements = bel_statement.to_rdf(uri)
315
+
316
+ statements << ::RDF::Statement.new(uri, BEL::RDF::RDF.type, BEL::RDF::BELV.Evidence, :graph_name => uri)
317
+ statements << ::RDF::Statement.new(statement_uri, BEL::RDF::BELV.hasEvidence, uri, :graph_name => uri)
318
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasStatement, statement_uri, :graph_name => uri)
319
+
320
+ annotations = bel_statement.annotations
321
+
322
+ # citation
323
+ citation = annotations.delete('Citation')
324
+ if citation
325
+ value = citation.value.map{|x| x.gsub('"', '')}
326
+ if citation and value[0] == 'PubMed'
327
+ pid = value[2]
328
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasCitation, BEL::RDF::PUBMED[pid], :graph_name => uri)
329
+ end
330
+ end
331
+
332
+ # evidence
333
+ evidence_text = annotations.delete('Evidence')
334
+ if evidence_text
335
+ value = evidence_text.value.gsub('"', '').force_encoding('UTF-8')
336
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasEvidenceText, value, :graph_name => uri)
337
+ end
338
+
339
+ # annotations
340
+ annotations.each do |_, anno|
341
+ name = anno.name.gsub('"', '')
342
+
343
+ if BEL::RDF::const_defined? name
344
+ annotation_scheme = BEL::RDF::const_get name
345
+ [anno.value].flatten.map{|x| x.gsub('"', '')}.each do |val|
346
+ value_uri = BEL::RDF::RDF::URI(URI.encode(annotation_scheme + val.to_s))
347
+ statements << ::RDF::Statement.new(uri, BEL::RDF::BELV.hasAnnotation, value_uri, :graph_name => uri)
348
+ end
349
+ end
350
+ end
351
+
352
+ [uri, statements]
353
+ end
354
+
355
+ def to_void_dataset(void_dataset_uri)
356
+ document_header = self.metadata[:document_header]
357
+ return nil if !document_header || !document_header.is_a?(Hash)
358
+
359
+ triples = ::RDF::Repository.new
360
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF.type, ::RDF::VOID.Dataset)
361
+
362
+ name = version = nil
363
+ document_header.each do |property, value|
364
+ case property
365
+ when /name/i
366
+ name = value.to_s
367
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.title, name)
368
+ when /description/i
369
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.description, value.to_s)
370
+ when /version/i
371
+ version = value.to_s
372
+ when /copyright/i
373
+ waiver = RDF::Vocabulary.new('http://vocab.org/waiver/terms/').waiver
374
+
375
+ value = value.to_s
376
+ uri = RDF::URI(value)
377
+ value = if uri.valid?
378
+ uri
379
+ else
380
+ value
381
+ end
382
+ triples << ::RDF::Statement.new(void_dataset_uri, waiver, value)
383
+ when /authors/i
384
+ if value.respond_to?(:each)
385
+ value.each do |v|
386
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.creator, v.to_s)
387
+ end
388
+ else
389
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.creator, value.to_s)
390
+ end
391
+ when /licenses/i
392
+ value = value.to_s
393
+ uri = RDF::URI(value)
394
+ value = if uri.valid?
395
+ uri
396
+ else
397
+ value
398
+ end
399
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.license, value)
400
+ when /contactinfo/i
401
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.publisher, :publisher)
402
+ triples << ::RDF::Statement.new(:publisher, ::RDF.type, ::RDF::FOAF.Person)
403
+ triples << ::RDF::Statement.new(:publisher, ::RDF::FOAF.mbox, value.to_s)
404
+ end
405
+ end
406
+
407
+ if name && version
408
+ identifier = "#{name}/#{version}"
409
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.identifier, identifier)
410
+ end
411
+
412
+ triples
413
+ end
414
+ end
311
415
  end
312
416
  end
@@ -20,7 +20,7 @@ module BEL::Translator::Plugins
20
20
 
21
21
  def write(objects, writer = StringIO.new, options = {})
22
22
  # format = options[:format] || :ntriples
23
- rdf_writer = Writer::RDFYielder.new(writer, :nquads)
23
+ rdf_writer = Writer::RDFYielder.new(writer, :nquads, options)
24
24
 
25
25
  objects.each do |evidence|
26
26
  rdf_writer << evidence
@@ -9,17 +9,37 @@ module BEL::Translator::Plugins
9
9
 
10
10
  Rdf = ::BEL::Translator::Plugins::Rdf
11
11
 
12
- def initialize(io, format)
13
- rdf_writer = find_writer(format)
14
- @writer = rdf_writer.new(io, { :stream => true })
12
+ def initialize(io, format, options = {})
13
+ rdf_writer = find_writer(format)
14
+ @writer = rdf_writer.new(io, { :stream => true })
15
+
16
+ if options[:void_dataset_uri]
17
+ void_dataset_uri = options.delete(:void_dataset_uri)
18
+ void_dataset_uri = RDF::URI(void_dataset_uri)
19
+ unless void_dataset_uri.valid?
20
+ raise ArgumentError.new 'void_dataset_uri is not a valid URI'
21
+ end
22
+ @void_dataset_uri = void_dataset_uri
23
+ else
24
+ @void_dataset_uri = nil
25
+ end
26
+ @wrote_dataset = false
15
27
  end
16
28
 
17
29
  def <<(evidence)
18
- graph = RDF::URI("http://www.openbel.org/evidence-graphs/#{Rdf.generate_uuid}")
19
- triples = evidence.bel_statement.to_rdf[1]
20
- triples.each do |triple|
21
- @writer.write_statement(::RDF::Statement(*triple, :graph_name => graph))
30
+ if !@wrote_dataset && @void_dataset_uri
31
+ void_dataset_triples = evidence.to_void_dataset(@void_dataset_uri)
32
+ if void_dataset_triples && void_dataset_triples.respond_to?(:each)
33
+ void_dataset_triples.each do |void_triple|
34
+ @writer.write_statement(void_triple)
35
+ end
36
+ end
37
+ end
38
+ evidence_uri, statements = evidence.to_rdf
39
+ statements.each do |statement|
40
+ @writer.write_statement(statement)
22
41
  end
42
+ @writer.write_statement(RDF::Statement.new(@void_dataset_uri, RDF::DC.hasPart, evidence_uri))
23
43
  end
24
44
 
25
45
  def done
@@ -9,7 +9,7 @@ module BEL::Translator::Plugins
9
9
 
10
10
  include ::BEL::Translator
11
11
 
12
- def read(data)
12
+ def read(data, options = {})
13
13
  EvidenceYielder.new(data)
14
14
  end
15
15
 
@@ -1,3 +1,3 @@
1
1
  module BEL
2
- VERSION = '0.4.0.beta.8'
2
+ VERSION = '0.4.0.beta.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.beta.8
4
+ version: 0.4.0.beta.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Bargnesi
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-09 00:00:00.000000000 Z
14
+ date: 2015-12-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  requirement: !ruby/object:Gem::Requirement
@@ -207,4 +207,3 @@ signing_key:
207
207
  specification_version: 4
208
208
  summary: Process BEL with ruby.
209
209
  test_files: []
210
- has_rdoc: