bel 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/{bel.gemspec → .gemspec} +8 -4
  3. data/README.md +3 -3
  4. data/VERSION +1 -0
  5. data/bin/bel +8 -8
  6. data/bin/bel2rdf.rb +1 -1
  7. data/bin/bel_summarize.rb +4 -4
  8. data/bin/bel_upgrade.rb +6 -6
  9. data/lib/bel.rb +3 -2
  10. data/lib/bel/completion.rb +13 -10
  11. data/lib/bel/completion_rule.rb +29 -21
  12. data/lib/bel/dsl.rb +75 -0
  13. data/lib/bel/gen.rb +2 -2
  14. data/lib/bel/gen/annotation.rb +2 -2
  15. data/lib/bel/gen/citation.rb +6 -6
  16. data/lib/bel/gen/document_header.rb +1 -1
  17. data/lib/bel/gen/{evidence.rb → nanopub.rb} +15 -15
  18. data/lib/bel/gen/parameter.rb +6 -6
  19. data/lib/bel/gen/sample_resources.rb +4 -4
  20. data/lib/bel/gen/statement.rb +1 -1
  21. data/lib/bel/gen/term.rb +1 -1
  22. data/lib/bel/language.rb +0 -20
  23. data/lib/bel/namespace.rb +7 -3
  24. data/lib/bel/nanopub.rb +15 -0
  25. data/lib/bel/{evidence_model/buffering_evidence_combiner.rb → nanopub/buffering_nanopub_combiner.rb} +39 -45
  26. data/lib/bel/{evidence_model → nanopub}/citation.rb +2 -2
  27. data/lib/bel/{evidence_model → nanopub}/experiment_context.rb +7 -1
  28. data/lib/bel/{evidence_model → nanopub}/hash_map_references.rb +1 -1
  29. data/lib/bel/{evidence_model → nanopub}/map_references.rb +1 -1
  30. data/lib/bel/nanopub/map_references_combiner.rb +30 -0
  31. data/lib/bel/nanopub/metadata.rb +102 -0
  32. data/lib/bel/nanopub/nanopub.rb +122 -0
  33. data/lib/bel/{evidence_model → nanopub}/references.rb +50 -38
  34. data/lib/bel/{evidence_model/streaming_evidence_combiner.rb → nanopub/streaming_nanopub_combiner.rb} +8 -8
  35. data/lib/bel/{evidence_model/summary_text.rb → nanopub/support.rb} +8 -2
  36. data/lib/bel/{evidence_model → nanopub}/util.rb +10 -10
  37. data/lib/bel/resource/annotation.rb +15 -24
  38. data/lib/bel/resource/annotation_value.rb +24 -20
  39. data/lib/bel/resource/annotations.rb +12 -11
  40. data/lib/bel/resource/concept.rb +62 -0
  41. data/lib/bel/resource/concept_scheme.rb +49 -0
  42. data/lib/bel/resource/namespace.rb +15 -24
  43. data/lib/bel/resource/namespace_value.rb +26 -23
  44. data/lib/bel/resource/namespaces.rb +11 -11
  45. data/lib/bel/script.rb +367 -367
  46. data/lib/bel/translate.rb +7 -7
  47. data/lib/bel/translator.rb +10 -10
  48. data/lib/bel/translator/plugins/bnj.rb +37 -0
  49. data/lib/bel/translator/plugins/{json_evidence → bnj}/translator.rb +17 -34
  50. data/lib/bel/translator/plugins/jgf.rb +1 -1
  51. data/lib/bel/translator/plugins/jgf/translator.rb +10 -10
  52. data/lib/bel/translator/plugins/jsonld.rb +1 -1
  53. data/lib/bel/translator/plugins/nquads.rb +1 -1
  54. data/lib/bel/translator/plugins/ntriples.rb +1 -1
  55. data/lib/bel/translator/plugins/rdf/bel_schema.rb +134 -126
  56. data/lib/bel/translator/plugins/rdf/graph_translator.rb +6 -6
  57. data/lib/bel/translator/plugins/rdf/monkey_patch.rb +50 -49
  58. data/lib/bel/translator/plugins/rdf/reader.rb +42 -42
  59. data/lib/bel/translator/plugins/rdf/translator.rb +6 -6
  60. data/lib/bel/translator/plugins/rdf/writer.rb +4 -4
  61. data/lib/bel/translator/plugins/rdf2/belv2_0.rb +416 -0
  62. data/lib/bel/translator/plugins/rdf2/converter.rb +13 -0
  63. data/lib/bel/translator/plugins/rdf2/namespace_converter.rb +24 -0
  64. data/lib/bel/translator/plugins/rdf2/nanopub_converter.rb +82 -0
  65. data/lib/bel/translator/plugins/rdf2/parameter_converter.rb +50 -0
  66. data/lib/bel/translator/plugins/rdf2/rdf_converter.rb +13 -0
  67. data/lib/bel/translator/plugins/rdf2/rdf_writer.rb +63 -0
  68. data/lib/bel/translator/plugins/rdf2/reader.rb +172 -0
  69. data/lib/bel/translator/plugins/rdf2/relationship_converter.rb +49 -0
  70. data/lib/bel/translator/plugins/rdf2/statement_converter.rb +65 -0
  71. data/lib/bel/translator/plugins/rdf2/term_converter.rb +262 -0
  72. data/lib/bel/translator/plugins/rdf2/translator.rb +51 -0
  73. data/lib/bel/translator/plugins/rdf2/uuid.rb +20 -0
  74. data/lib/bel/translator/plugins/rdf2/writer.rb +53 -0
  75. data/lib/bel/translator/plugins/rdfa.rb +1 -1
  76. data/lib/bel/translator/plugins/rdfxml.rb +1 -1
  77. data/lib/bel/translator/plugins/rj.rb +1 -1
  78. data/lib/bel/translator/plugins/trig.rb +1 -1
  79. data/lib/bel/translator/plugins/trix.rb +1 -1
  80. data/lib/bel/translator/plugins/turtle.rb +3 -6
  81. data/lib/bel/translator/plugins/xbel.rb +5 -6
  82. data/lib/bel/translator/plugins/xbel/nanopub_handler.rb +625 -0
  83. data/lib/bel/translator/plugins/xbel/{evidence_yielder.rb → nanopub_yielder.rb} +3 -3
  84. data/lib/bel/translator/plugins/xbel/translator.rb +2 -5
  85. data/lib/bel/translator/plugins/xbel/xbel_yielder.rb +135 -74
  86. data/lib/bel/version.rb +31 -1
  87. metadata +81 -33
  88. data/lib/bel/evidence_model.rb +0 -15
  89. data/lib/bel/evidence_model/bel_parameter.rb +0 -56
  90. data/lib/bel/evidence_model/bel_statement.rb +0 -97
  91. data/lib/bel/evidence_model/bel_term.rb +0 -87
  92. data/lib/bel/evidence_model/evidence.rb +0 -127
  93. data/lib/bel/evidence_model/map_references_combiner.rb +0 -30
  94. data/lib/bel/evidence_model/metadata.rb +0 -49
  95. data/lib/bel/parser.rb +0 -39
  96. data/lib/bel/translator/plugins/bel_script.rb +0 -36
  97. data/lib/bel/translator/plugins/bel_script/bel_citation_serialization.rb +0 -125
  98. data/lib/bel/translator/plugins/bel_script/bel_discrete_serialization.rb +0 -109
  99. data/lib/bel/translator/plugins/bel_script/bel_top_down_serialization.rb +0 -100
  100. data/lib/bel/translator/plugins/bel_script/bel_yielder.rb +0 -180
  101. data/lib/bel/translator/plugins/bel_script/evidence_serialization.rb +0 -79
  102. data/lib/bel/translator/plugins/bel_script/evidence_yielder.rb +0 -87
  103. data/lib/bel/translator/plugins/bel_script/translator.rb +0 -35
  104. data/lib/bel/translator/plugins/json_evidence.rb +0 -38
  105. data/lib/bel/translator/plugins/xbel/evidence_handler.rb +0 -495
@@ -24,7 +24,7 @@ module BELRDF
24
24
  end
25
25
 
26
26
  def read(data, options = {})
27
- Reader::BufferedEvidenceYielder.new(data, @format)
27
+ Reader::BufferedNanopubYielder.new(data, @format)
28
28
  end
29
29
 
30
30
  def write(objects, io = StringIO.new, options = {})
@@ -61,10 +61,10 @@ module BELRDF
61
61
  yielder << RDF::Statement.new(*schema_statement)
62
62
  end
63
63
 
64
- # enumerate BEL evidence
65
- objects.each do |evidence|
64
+ # enumerate BEL nanopubs
65
+ objects.each do |nanopub|
66
66
  if void_dataset_uri && !wrote_dataset
67
- void_dataset_triples = evidence.to_void_dataset(void_dataset_uri)
67
+ void_dataset_triples = nanopub.to_void_dataset(void_dataset_uri)
68
68
  if void_dataset_triples && void_dataset_triples.respond_to?(:each)
69
69
  void_dataset_triples.each do |void_triple|
70
70
  yielder << void_triple
@@ -73,7 +73,7 @@ module BELRDF
73
73
  wrote_dataset = true
74
74
  end
75
75
 
76
- evidence_uri, statements = evidence.to_rdf
76
+ nanopub_uri, statements = nanopub.to_rdf
77
77
  statements.each do |statement|
78
78
  yielder << statement
79
79
  end
@@ -82,7 +82,7 @@ module BELRDF
82
82
  yielder << RDF::Statement.new(
83
83
  void_dataset_uri,
84
84
  RDF::DC.hasPart,
85
- evidence_uri
85
+ nanopub_uri
86
86
  )
87
87
  end
88
88
  end
@@ -1,24 +1,25 @@
1
- require 'bel/evidence_model'
1
+ require 'bel/nanopub'
2
+ require_relative 'bel_schema'
2
3
  require_relative 'uuid'
3
4
 
4
5
  module BELRDF
5
6
 
6
- # OpenClass to contribute RDF functionality to BEL Model.
7
+ # OpenClass to contribute RDF functionality to BEL Nanopub objects.
7
8
 
8
9
  class ::BEL::Namespace::NamespaceDefinition
9
10
 
10
11
  def to_uri
11
- @rdf_uri
12
+ rdf_uri
12
13
  end
13
14
 
14
15
  def to_rdf_vocabulary
15
16
  uri = @rdf_uri
16
- uri << '/' unless uri.end_with?('/')
17
+ uri << '/' if uri && !uri.end_with?('/')
17
18
  ::RDF::Vocabulary.new(uri)
18
19
  end
19
20
  end
20
21
 
21
- class ::BEL::Model::Parameter
22
+ class ::BEL::Nanopub::Parameter
22
23
 
23
24
  CONCEPT_ENCODING = {
24
25
  :G => BELRDF::BELV.GeneConcept,
@@ -70,7 +71,7 @@ module BELRDF
70
71
  end
71
72
  end
72
73
 
73
- class ::BEL::Model::Term
74
+ class ::BEL::Nanopub::Term
74
75
 
75
76
  def to_uri
76
77
  tid = to_s.squeeze(')').gsub(/[")\[\]]/, '').gsub(/[(:, ]/, '_')
@@ -82,7 +83,7 @@ module BELRDF
82
83
  fx = @fx.respond_to?(:short_form) ? @fx.short_form : @fx.to_s.to_sym
83
84
  if [:p, :proteinAbundance].include?(fx) &&
84
85
  @arguments.find{ |x|
85
- if x.is_a? ::BEL::Model::Term
86
+ if x.is_a? ::BEL::Nanopub::Term
86
87
  arg_fx = x.fx
87
88
  arg_fx = arg_fx.respond_to?(:short_form) ? arg_fx.short_form : arg_fx.to_s.to_sym
88
89
  [:pmod, :proteinModification].include?(arg_fx)
@@ -96,7 +97,7 @@ module BELRDF
96
97
 
97
98
  if [:p, :proteinAbundance].include?(fx) &&
98
99
  @arguments.find{ |x|
99
- if x.is_a? ::BEL::Model::Term
100
+ if x.is_a? ::BEL::Nanopub::Term
100
101
  arg_fx = x.fx
101
102
  arg_fx = arg_fx.respond_to?(:short_form) ? arg_fx.short_form : arg_fx.to_s.to_sym
102
103
  BELRDF::PROTEIN_VARIANT.include?(arg_fx)
@@ -132,7 +133,7 @@ module BELRDF
132
133
  if [:p, :proteinAbundance].include?(fx)
133
134
  pmod =
134
135
  @arguments.find{ |x|
135
- if x.is_a? ::BEL::Model::Term
136
+ if x.is_a? ::BEL::Nanopub::Term
136
137
  arg_fx = x.fx
137
138
  arg_fx = arg_fx.respond_to?(:short_form) ? arg_fx.short_form : arg_fx.to_s.to_sym
138
139
  [:pmod, :proteinModification].include?(arg_fx)
@@ -150,15 +151,15 @@ module BELRDF
150
151
  statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasModificationPosition, last.to_i, :graph_name => graph_name)
151
152
  end
152
153
  # link root protein abundance as hasChild
153
- root_param = @arguments.find{|x| x.is_a? ::BEL::Model::Parameter}
154
- (root_id, root_statements) = ::BEL::Model::Term.new(:p, [root_param]).to_rdf(graph_name, remap)
154
+ root_param = @arguments.find{|x| x.is_a? ::BEL::Nanopub::Parameter}
155
+ (root_id, root_statements) = ::BEL::Nanopub::Term.new(:p, [root_param]).to_rdf(graph_name, remap)
155
156
  statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasChild, root_id, :graph_name => graph_name)
156
157
  statements.concat(root_statements)
157
158
  return [uri, statements]
158
- elsif @arguments.find{|x| x.is_a? ::BEL::Model::Term and BELRDF::PROTEIN_VARIANT.include? x.fx}
159
+ elsif @arguments.find{|x| x.is_a? ::BEL::Nanopub::Term and BELRDF::PROTEIN_VARIANT.include? x.fx}
159
160
  # link root protein abundance as hasChild
160
- root_param = @arguments.find{|x| x.is_a? ::BEL::Model::Parameter}
161
- (root_id, root_statements) = ::BEL::Model::Term.new(:p, [root_param]).to_rdf(graph_name, remap)
161
+ root_param = @arguments.find{|x| x.is_a? ::BEL::Nanopub::Parameter}
162
+ (root_id, root_statements) = ::BEL::Nanopub::Term.new(:p, [root_param]).to_rdf(graph_name, remap)
162
163
  statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasChild, root_id, :graph_name => graph_name)
163
164
  statements.concat(root_statements)
164
165
  return [uri, statements]
@@ -167,7 +168,7 @@ module BELRDF
167
168
 
168
169
  # BELRDF::BELV.hasConcept
169
170
  @arguments.find_all{ |x|
170
- x.is_a? ::BEL::Model::Parameter and x.ns != nil
171
+ x.is_a? ::BEL::Nanopub::Parameter and x.ns != nil
171
172
  }.each do |param|
172
173
  param_uri, encoding_statements = param.to_rdf(graph_name, remap)
173
174
  statements.concat(encoding_statements)
@@ -175,7 +176,7 @@ module BELRDF
175
176
  end
176
177
 
177
178
  # BELRDF::BELV.hasChild]
178
- @arguments.find_all{|x| x.is_a? ::BEL::Model::Term}.each do |child|
179
+ @arguments.find_all{|x| x.is_a? ::BEL::Nanopub::Term}.each do |child|
179
180
  (child_id, child_statements) = child.to_rdf(graph_name, remap)
180
181
  statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasChild, child_id, :graph_name => graph_name)
181
182
  statements.concat(child_statements)
@@ -185,7 +186,7 @@ module BELRDF
185
186
  end
186
187
  end
187
188
 
188
- class ::BEL::Model::Statement
189
+ class ::BEL::Nanopub::Statement
189
190
 
190
191
  def to_uri
191
192
  case
@@ -267,13 +268,13 @@ module BELRDF
267
268
 
268
269
  # common statement triples
269
270
  statements << ::RDF::Statement.new(uri, BELRDF::RDF.type, BELRDF::BELV.Statement, :graph_name => graph_name)
270
- statements << ::RDF::Statement.new(uri, ::RDF::RDFS.label, to_s.force_encoding('UTF-8'), :graph_name => graph_name)
271
+ statements << ::RDF::Statement.new(uri, BELRDF::RDFS.label, to_s.force_encoding('UTF-8'), :graph_name => graph_name)
271
272
 
272
- # evidence
273
- evidence = BELRDF::BELE[BELRDF.generate_uuid]
274
- statements << ::RDF::Statement.new(evidence, BELRDF::RDF.type, BELRDF::BELV.Evidence, :graph_name => graph_name)
275
- statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasEvidence, evidence, :graph_name => graph_name)
276
- statements << ::RDF::Statement.new(evidence, BELRDF::BELV.hasStatement, uri, :graph_name => graph_name)
273
+ # nanopub
274
+ nanopub = BELRDF::BELE[BELRDF.generate_uuid]
275
+ statements << ::RDF::Statement.new(nanopub, BELRDF::RDF.type, BELRDF::BELV.Nanopub, :graph_name => graph_name)
276
+ statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasNanopub, nanopub, :graph_name => graph_name)
277
+ statements << ::RDF::Statement.new(nanopub, BELRDF::BELV.hasStatement, uri, :graph_name => graph_name)
277
278
 
278
279
  # citation
279
280
  citation = @annotations.delete('Citation')
@@ -281,15 +282,15 @@ module BELRDF
281
282
  value = citation.value.map{|x| x.gsub('"', '')}
282
283
  if citation and value[0] == 'PubMed'
283
284
  pid = value[2]
284
- statements << ::RDF::Statement.new(evidence, BELRDF::BELV.hasCitation, BELRDF::PUBMED[pid], :graph_name => graph_name)
285
+ statements << ::RDF::Statement.new(nanopub, BELRDF::BELV.hasCitation, BELRDF::PUBMED[pid], :graph_name => graph_name)
285
286
  end
286
287
  end
287
288
 
288
- # evidence
289
- evidence_text = @annotations.delete('Evidence')
290
- if evidence_text
291
- value = evidence_text.value.gsub('"', '').force_encoding('UTF-8')
292
- statements << ::RDF::Statement.new(evidence, BELRDF::BELV.hasEvidenceText, value, :graph_name => graph_name)
289
+ # nanopub
290
+ support = @annotations.delete('Support')
291
+ if support
292
+ value = support.value.gsub('"', '').force_encoding('UTF-8')
293
+ statements << ::RDF::Statement.new(nanopub, BELRDF::BELV.hasSupport, value, :graph_name => graph_name)
293
294
  end
294
295
 
295
296
  # annotations
@@ -317,7 +318,7 @@ module BELRDF
317
318
  annotation_scheme = anno_rdf_uri ? anno_rdf_uri : BELRDF::const_get(name)
318
319
  [anno.value].flatten.map{|x| x.gsub('"', '')}.each do |val|
319
320
  value_uri = BELRDF::RDF::URI(URI.encode(annotation_scheme + val.to_s))
320
- statements << ::RDF::Statement.new(evidence, BELRDF::BELV.hasAnnotation, value_uri, :graph_name => graph_name)
321
+ statements << ::RDF::Statement.new(nanopub, BELRDF::BELV.hasAnnotation, value_uri, :graph_name => graph_name)
321
322
  end
322
323
  end
323
324
  end
@@ -336,7 +337,7 @@ module BELRDF
336
337
  end
337
338
  end
338
339
 
339
- class ::BEL::Model::Evidence
340
+ class ::BEL::Nanopub::Nanopub
340
341
 
341
342
  def to_uri
342
343
  BELRDF::BELE[BELRDF.generate_uuid]
@@ -346,15 +347,15 @@ module BELRDF
346
347
  uri = to_uri
347
348
 
348
349
  # parse BEL statement if necessary
349
- unless self.bel_statement.is_a?(::BEL::Model::Statement)
350
+ unless self.bel_statement.is_a?(::BEL::Nanopub::Statement)
350
351
  self.bel_statement = self.class.parse_statement(self)
351
352
  end
352
353
 
353
354
  # convert BEL statement to RDF
354
355
  statement_uri, statements = bel_statement.to_rdf(uri, remap)
355
356
 
356
- statements << ::RDF::Statement.new(uri, BELRDF::RDF.type, BELRDF::BELV.Evidence, :graph_name => uri)
357
- statements << ::RDF::Statement.new(statement_uri, BELRDF::BELV.hasEvidence, uri, :graph_name => uri)
357
+ statements << ::RDF::Statement.new(uri, BELRDF::RDF.type, BELRDF::BELV.Nanopub, :graph_name => uri)
358
+ statements << ::RDF::Statement.new(statement_uri, BELRDF::BELV.hasNanopub, uri, :graph_name => uri)
358
359
  statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasStatement, statement_uri, :graph_name => uri)
359
360
 
360
361
  annotations = bel_statement.annotations
@@ -369,11 +370,11 @@ module BELRDF
369
370
  end
370
371
  end
371
372
 
372
- # evidence
373
- evidence_text = annotations.delete('Evidence')
374
- if evidence_text
375
- value = evidence_text.value.gsub('"', '').force_encoding('UTF-8')
376
- statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasEvidenceText, value, :graph_name => uri)
373
+ # support
374
+ support = annotations.delete('Support')
375
+ if support
376
+ value = support.value.gsub('"', '').force_encoding('UTF-8')
377
+ statements << ::RDF::Statement.new(uri, BELRDF::BELV.hasSupport, value, :graph_name => uri)
377
378
  end
378
379
 
379
380
  # annotations
@@ -397,16 +398,16 @@ module BELRDF
397
398
  return nil if !document_header || !document_header.is_a?(Hash)
398
399
 
399
400
  triples = ::RDF::Repository.new
400
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF.type, ::RDF::VOID.Dataset)
401
+ triples << ::RDF::Statement.new(void_dataset_uri, ::RDF.type, BELRDF::VOID.Dataset)
401
402
 
402
403
  name = version = nil
403
404
  document_header.each do |property, value|
404
405
  case property
405
406
  when /name/i
406
407
  name = value.to_s
407
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.title, name)
408
+ triples << ::RDF::Statement.new(void_dataset_uri, BELRDF::DC.title, name)
408
409
  when /description/i
409
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.description, value.to_s)
410
+ triples << ::RDF::Statement.new(void_dataset_uri, BELRDF::DC.description, value.to_s)
410
411
  when /version/i
411
412
  version = value.to_s
412
413
  when /copyright/i
@@ -423,10 +424,10 @@ module BELRDF
423
424
  when /authors/i
424
425
  if value.respond_to?(:each)
425
426
  value.each do |v|
426
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.creator, v.to_s)
427
+ triples << ::RDF::Statement.new(void_dataset_uri, BELRDF::DC.creator, v.to_s)
427
428
  end
428
429
  else
429
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.creator, value.to_s)
430
+ triples << ::RDF::Statement.new(void_dataset_uri, BELRDF::DC.creator, value.to_s)
430
431
  end
431
432
  when /licenses/i
432
433
  value = value.to_s
@@ -436,17 +437,17 @@ module BELRDF
436
437
  else
437
438
  value
438
439
  end
439
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.license, value)
440
+ triples << ::RDF::Statement.new(void_dataset_uri, BELRDF::DC.license, value)
440
441
  when /contactinfo/i
441
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.publisher, :publisher)
442
- triples << ::RDF::Statement.new(:publisher, ::RDF.type, ::RDF::FOAF.Person)
443
- triples << ::RDF::Statement.new(:publisher, ::RDF::FOAF.mbox, value.to_s)
442
+ triples << ::RDF::Statement.new(void_dataset_uri, BELRDF::DC.publisher, :publisher)
443
+ triples << ::RDF::Statement.new(:publisher, ::RDF.type, BELRDF::FOAF.Person)
444
+ triples << ::RDF::Statement.new(:publisher, BELRDF::FOAF.mbox, value.to_s)
444
445
  end
445
446
  end
446
447
 
447
448
  if name && version
448
449
  identifier = "#{name}/#{version}"
449
- triples << ::RDF::Statement.new(void_dataset_uri, ::RDF::DC.identifier, identifier)
450
+ triples << ::RDF::Statement.new(void_dataset_uri, BELRDF::DC.identifier, identifier)
450
451
  end
451
452
 
452
453
  triples
@@ -1,11 +1,11 @@
1
1
  module BELRDF
2
2
  module Reader
3
3
 
4
- module EvidenceYielder
4
+ module NanopubYielder
5
5
 
6
6
  BELV = BELRDF::BELV
7
7
 
8
- include ::BEL::Model
8
+ include ::BEL::Nanopub
9
9
  include ::BEL::Quoting
10
10
 
11
11
  # Find described resources by +type+ in +graph+.
@@ -36,44 +36,44 @@ module BELRDF
36
36
  }
37
37
  end
38
38
 
39
- # Iterate the {BELV.Evidence} predicated statements, from the
40
- # {::RDF::Graph graph}, and yield those correspdonding {Evidence}
39
+ # Iterate the {BELV.Nanopub} predicated statements, from the
40
+ # {::RDF::Graph graph}, and yield those correspdonding {Nanopub}
41
41
  # objects.
42
42
  #
43
43
  # @param [::RDF::Graph] graph the RDF graph to query
44
- # @yield [evidence_model] yields an {Evidence} object
45
- def evidence_yielder(graph)
46
- resources_of_type(BELV.Evidence, graph).each do |evidence|
44
+ # @yield [::BEL::Nanopub::Nanopub] yields a nanopub object
45
+ def nanopub_yielder(graph)
46
+ resources_of_type(BELV.Nanopub, graph).each do |nanopub|
47
47
 
48
- yield make_evidence(evidence, graph)
48
+ yield make_nanopub(nanopub, graph)
49
49
  end
50
50
  end
51
51
 
52
- # Create an {Evidence} object from RDF statements found in
52
+ # Create an {Nanopub} object from RDF statements found in
53
53
  # the {::RDF::Graph graph}.
54
54
  #
55
- # @param [Hash] evidence a hash of predicate to object
56
- # representing the described evidence
55
+ # @param [Hash] nanopub a hash of predicate to object
56
+ # representing the described nanopub
57
57
  # @param [::RDF::Graph] graph the RDF graph to query
58
- # @return [Evidence] the evidence model
59
- def make_evidence(evidence, graph)
60
- statement = describe(evidence[BELV.hasStatement], graph)
58
+ # @return [Nanopub] the nanopub
59
+ def make_nanopub(nanopub_hash, graph)
60
+ statement = describe(nanopub_hash[BELV.hasStatement], graph)
61
61
 
62
62
  # values
63
63
  bel_statement = statement[::RDF::RDFS.label].value
64
- ev_text = evidence[BELV.hasEvidenceText]
65
- citation = evidence[BELV.hasCitation]
64
+ support_text = nanopub_hash[BELV.hasSupport]
65
+ citation = nanopub_hash[BELV.hasCitation]
66
66
 
67
67
  # model
68
- ev_model = Evidence.new
69
- ev_model.bel_statement = ::BEL::Script.parse(bel_statement)
68
+ nanopub = Nanopub.new
69
+ nanopub.bel_statement = ::BEL::Script.parse(bel_statement)
70
70
  .find { |obj|
71
71
  obj.is_a? Statement
72
72
  }
73
- ev_model.summary_text = SummaryText.new(ev_text.value) if ev_text
73
+ nanopub.support = Support.new(support_text.value) if support_text
74
74
 
75
75
  if citation.respond_to?(:value)
76
- ev_model.citation =
76
+ nanopub.citation =
77
77
  case citation.value
78
78
  when /pubmed:(\d+)$/
79
79
  pubmed_id = $1.to_i
@@ -87,13 +87,13 @@ module BELRDF
87
87
  end
88
88
  end
89
89
 
90
- ev_model
90
+ nanopub
91
91
  end
92
92
  end
93
93
 
94
- class BufferedEvidenceYielder
94
+ class BufferedNanopubYielder
95
95
 
96
- include EvidenceYielder
96
+ include NanopubYielder
97
97
 
98
98
  def initialize(data, format = :ntriples)
99
99
  @data = data
@@ -108,8 +108,8 @@ module BELRDF
108
108
  graph << statement
109
109
  end
110
110
  end
111
- evidence_yielder(graph) do |evidence_model|
112
- yield evidence_model
111
+ nanopub_yielder(graph) do |nanopub|
112
+ yield nanopub
113
113
  end
114
114
  else
115
115
  to_enum(:each)
@@ -117,9 +117,9 @@ module BELRDF
117
117
  end
118
118
  end
119
119
 
120
- class UnbufferedEvidenceYielder
120
+ class UnbufferedNanopubYielder
121
121
 
122
- include EvidenceYielder
122
+ include NanopubYielder
123
123
 
124
124
  def initialize(data, format)
125
125
  @data = data
@@ -128,27 +128,27 @@ module BELRDF
128
128
 
129
129
  def each
130
130
  if block_given?
131
- graph = RDF::Graph.new
132
- evidence_resource = nil
131
+ graph = RDF::Graph.new
132
+ nanopub = nil
133
133
  RDF::Reader.for(@format).new(@data) do |reader|
134
134
  reader.each_statement do |statement|
135
135
  case
136
- when statement.object == BELV.Evidence &&
136
+ when statement.object == BELV.Nanopub &&
137
137
  statement.predicate == RDF.type
138
- evidence_resource = statement.subject
139
- when evidence_resource &&
140
- statement.predicate != BELV.hasEvidence &&
141
- statement.subject != evidence_resource
142
-
143
- # yield current graph as evidence model
144
- yield make_evidence(
145
- describe(evidence_resource, graph),
138
+ nanopub = statement.subject
139
+ when nanopub &&
140
+ statement.predicate != BELV.hasNanopub &&
141
+ statement.subject != nanopub
142
+
143
+ # yield current graph as nanopub
144
+ yield make_nanopub(
145
+ describe(nanopub, graph),
146
146
  graph
147
147
  )
148
148
 
149
149
  # reset parse state
150
150
  graph.clear
151
- evidence_resource = nil
151
+ nanopub = nil
152
152
 
153
153
  # insert this RDF statement
154
154
  graph << statement
@@ -158,9 +158,9 @@ module BELRDF
158
158
  end
159
159
  end
160
160
 
161
- # yield last graph as evidence model
162
- yield make_evidence(
163
- describe(evidence_resource, graph),
161
+ # yield last graph as nanopub
162
+ yield make_nanopub(
163
+ describe(nanopub, graph),
164
164
  graph
165
165
  )
166
166
  else