bel 0.4.0.beta.7 → 0.4.0.beta.8

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: d0b4945512529e67124a858ba03f03b18c617ee5
4
- data.tar.gz: a57e2e8142d0ed1ef080e4ff206aaf76e69243b4
3
+ metadata.gz: e22bc8ddb611afaba61076e5e2ac66dc89ff9a59
4
+ data.tar.gz: 54c075abe536cd62000858f19e88cdaad4b1ab79
5
5
  SHA512:
6
- metadata.gz: 860f4fa04e20ae6614701eb4714e6cf525781e23cffe1da36307894d62fa26916b5b8d78795b1d90d973c8aa57cd80c792c943d3305e14e9c29b23f8fc2db29c
7
- data.tar.gz: 7c68969a47cb4d4a21642c6cc3bfbe825373cf7dab2cf087d410972fb07e5c569a13b88b574e62ffb5d0c921ab6ea2783494bde813cd58c01b04aa4cbaf025d1
6
+ metadata.gz: e994fee183fbcedbcec2b6728a9095299eb506e3ec0d8e9a2935b589eaff302498c3318fe5ffd25919490b80803db1d5cf4b9ede339099cb6630efc96d2e27ab
7
+ data.tar.gz: d6573b1c9965ee341f154a03f11c1a50f9392db3d5264c984d6e976435090e6c4f70c8e186e85e46228676791fe46514e6c5610a2e45c22df1b42739f33e02c9
@@ -194,9 +194,11 @@ module BEL
194
194
  namespace = BEL::Namespace::NAMESPACE_LATEST[prefix_token.value.to_sym]
195
195
  if namespace
196
196
  scheme_uri = namespace[1]
197
- return search.search_namespace(
198
- URI(scheme_uri),
197
+ return search.search(
199
198
  "#{active_token.value}*",
199
+ :namespace_concept,
200
+ URI(scheme_uri),
201
+ nil,
200
202
  :start => 0,
201
203
  :size => 10
202
204
  ).
@@ -207,7 +209,10 @@ module BEL
207
209
  end
208
210
  else
209
211
  return search.search(
210
- active_token.value,
212
+ "#{active_token.value}*",
213
+ :namespace_concept,
214
+ nil,
215
+ nil,
211
216
  :start => 0,
212
217
  :size => 10
213
218
  ).
@@ -27,7 +27,7 @@ module BEL::JSON
27
27
  end
28
28
 
29
29
  def write(data, output_io, options = {})
30
- json = MultiJson.dump(json_object)
30
+ json = MultiJson.dump(data)
31
31
  if output_io
32
32
  # write json and return IO
33
33
  output_io.write json
@@ -1,8 +1,6 @@
1
1
  # Load RDF library dependencies
2
2
  require 'rdf'
3
3
  require 'rdf/mongo'
4
- require 'addressable/uri'
5
- require 'uuid'
6
4
 
7
5
  module BEL::RdfRepository::Plugins
8
6
 
@@ -1,8 +1,6 @@
1
1
  # Load RDF library dependencies
2
2
  require 'rdf'
3
3
  require 'rdf/mongo'
4
- require 'addressable/uri'
5
- require 'uuid'
6
4
 
7
5
  module BEL::RdfRepository::Plugins
8
6
 
@@ -9,19 +9,20 @@ module BEL::Translator::Plugins
9
9
  # uri prefixes
10
10
  BELR = ::RDF::Vocabulary.new('http://www.openbel.org/bel/')
11
11
  BELV = ::RDF::Vocabulary.new('http://www.openbel.org/vocabulary/')
12
+ BELE = ::RDF::Vocabulary.new('http://www.openbel.org/evidence/')
12
13
  PUBMED = ::RDF::Vocabulary.new('http://bio2rdf.org/pubmed:')
13
14
  RDF = ::RDF
14
15
  RDFS = ::RDF::RDFS
15
16
 
16
17
  # annotations
17
- Anatomy = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/anatomy/')
18
- Cell = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/cell/')
19
- CellLine = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/cell-line/')
20
- CellStructure = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/cell-structure/')
21
- Disease = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/disease/')
22
- MeSHAnatomy = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/mesh-anatomy/')
23
- MeSHDisease = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/mesh-diseases/')
24
- Species = ::RDF::Vocabulary.new('http://www.openbel.org/bel/annotation/species-taxonomy-id/')
18
+ Anatomy = 'http://www.openbel.org/bel/annotation/anatomy/'
19
+ Cell = 'http://www.openbel.org/bel/annotation/cell/'
20
+ CellLine = 'http://www.openbel.org/bel/annotation/cell-line/'
21
+ CellStructure = 'http://www.openbel.org/bel/annotation/cell-structure/'
22
+ Disease = 'http://www.openbel.org/bel/annotation/disease/'
23
+ MeSHAnatomy = 'http://www.openbel.org/bel/annotation/mesh-anatomy/'
24
+ MeSHDisease = 'http://www.openbel.org/bel/annotation/mesh-diseases/'
25
+ Species = 'http://www.openbel.org/bel/annotation/species-taxonomy-id/'
25
26
 
26
27
  # maps outer function to bel/vocabulary class
27
28
  FUNCTION_TYPE = {
@@ -1,3 +1,5 @@
1
+ require_relative 'uuid'
2
+
1
3
  module BEL::Translator::Plugins
2
4
 
3
5
  module Rdf
@@ -155,8 +157,8 @@ module BEL::Translator::Plugins
155
157
  @arguments.find_all{ |x|
156
158
  x.is_a? ::BEL::Model::Parameter and x.ns != nil
157
159
  }.each do |param|
158
- concept_uri = param.ns.to_rdf_vocabulary[param.value.to_s]
159
- statements << [uri, BEL::RDF::BELV.hasConcept, BEL::RDF::RDF::URI(Addressable::URI.encode(concept_uri))]
160
+ 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))]
160
162
  end
161
163
 
162
164
  # BEL::RDF::BELV.hasChild]
@@ -254,10 +256,10 @@ module BEL::Translator::Plugins
254
256
  statements << [uri, ::RDF::RDFS.label, to_s.force_encoding('UTF-8')]
255
257
 
256
258
  # evidence
257
- evidence_bnode = BEL::RDF::RDF::Node.uuid
258
- statements << [evidence_bnode, BEL::RDF::RDF.type, BEL::RDF::BELV.Evidence]
259
- statements << [uri, BEL::RDF::BELV.hasEvidence, evidence_bnode]
260
- statements << [evidence_bnode, BEL::RDF::BELV.hasStatement, uri]
259
+ 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]
261
263
 
262
264
  # citation
263
265
  citation = @annotations.delete('Citation')
@@ -266,9 +268,9 @@ module BEL::Translator::Plugins
266
268
  if citation and value[0] == 'PubMed'
267
269
  pid = value[2]
268
270
  statements << [
269
- evidence_bnode,
271
+ evidence,
270
272
  BEL::RDF::BELV.hasCitation,
271
- BEL::RDF::RDF::URI(BEL::RDF::PUBMED[pid])
273
+ BEL::RDF::PUBMED[pid]
272
274
  ]
273
275
  end
274
276
  end
@@ -277,7 +279,7 @@ module BEL::Translator::Plugins
277
279
  evidence_text = @annotations.delete('Evidence')
278
280
  if evidence_text
279
281
  value = evidence_text.value.gsub('"', '').force_encoding('UTF-8')
280
- statements << [evidence_bnode, BEL::RDF::BELV.hasEvidenceText, value]
282
+ statements << [evidence, BEL::RDF::BELV.hasEvidenceText, value]
281
283
  end
282
284
 
283
285
  # annotations
@@ -287,8 +289,8 @@ module BEL::Translator::Plugins
287
289
  if BEL::RDF::const_defined? name
288
290
  annotation_scheme = BEL::RDF::const_get name
289
291
  [anno.value].flatten.map{|x| x.gsub('"', '')}.each do |val|
290
- value_uri = BEL::RDF::RDF::URI(Addressable::URI.encode(annotation_scheme[val.to_s]))
291
- statements << [evidence_bnode, BEL::RDF::BELV.hasAnnotation, value_uri]
292
+ value_uri = BEL::RDF::RDF::URI(URI.encode(annotation_scheme + val.to_s))
293
+ statements << [evidence, BEL::RDF::BELV.hasAnnotation, value_uri]
292
294
  end
293
295
  end
294
296
  end
@@ -1,13 +1,6 @@
1
- # Load RDF library dependencies
2
- begin
3
- require 'rdf'
4
- require 'addressable/uri'
5
- require 'uuid'
6
- rescue LoadError => e
7
- # Raise LoadError if the requirements were not met.
8
- raise
9
- end
1
+ require 'rdf'
10
2
 
3
+ require_relative 'uuid'
11
4
  require_relative 'bel_schema'
12
5
  require_relative 'monkey_patch'
13
6
  require_relative 'reader'
@@ -26,8 +19,8 @@ module BEL::Translator::Plugins
26
19
  end
27
20
 
28
21
  def write(objects, writer = StringIO.new, options = {})
29
- format = options[:format] || :ntriples
30
- rdf_writer = Writer::RDFYielder.new(writer, format)
22
+ # format = options[:format] || :ntriples
23
+ rdf_writer = Writer::RDFYielder.new(writer, :nquads)
31
24
 
32
25
  objects.each do |evidence|
33
26
  rdf_writer << evidence
@@ -0,0 +1,21 @@
1
+ module BEL::Translator::Plugins
2
+
3
+ module Rdf
4
+
5
+ unless self.methods.include?(:generate_uuid)
6
+
7
+ # Dynamically defines an efficient UUID method for the current ruby.
8
+ if RUBY_ENGINE =~ /^jruby/i
9
+ java_import 'java.util.UUID'
10
+ define_singleton_method(:generate_uuid) do
11
+ Java::JavaUtil::UUID.random_uuid.to_s
12
+ end
13
+ else
14
+ require 'uuid'
15
+ define_singleton_method(:generate_uuid) do
16
+ UUID.generate
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,5 @@
1
+ require_relative 'uuid'
2
+
1
3
  module BEL::Translator::Plugins
2
4
 
3
5
  module Rdf::Writer
@@ -5,15 +7,18 @@ module BEL::Translator::Plugins
5
7
  class RDFYielder
6
8
  attr_reader :writer
7
9
 
10
+ Rdf = ::BEL::Translator::Plugins::Rdf
11
+
8
12
  def initialize(io, format)
9
13
  rdf_writer = find_writer(format)
10
14
  @writer = rdf_writer.new(io, { :stream => true })
11
15
  end
12
16
 
13
17
  def <<(evidence)
18
+ graph = RDF::URI("http://www.openbel.org/evidence-graphs/#{Rdf.generate_uuid}")
14
19
  triples = evidence.bel_statement.to_rdf[1]
15
20
  triples.each do |triple|
16
- @writer.write_statement(::RDF::Statement(*triple))
21
+ @writer.write_statement(::RDF::Statement(*triple, :graph_name => graph))
17
22
  end
18
23
  end
19
24
 
@@ -26,18 +31,18 @@ module BEL::Translator::Plugins
26
31
  def find_writer(format)
27
32
  case format.to_s.to_sym
28
33
  when :nquads
29
- BEL::RDF::RDF::NQuads::Writer
34
+ RDF::NQuads::Writer
30
35
  when :turtle
31
36
  begin
32
37
  require 'rdf/turtle'
33
- BEL::RDF::RDF::Turtle::Writer
38
+ RDF::Turtle::Writer
34
39
  rescue LoadError
35
40
  $stderr.puts """Turtle format not supported.
36
41
  Install the 'rdf-turtle' gem."""
37
42
  raise
38
43
  end
39
44
  when :ntriples
40
- Rdf::BEL::RDF::RDF::NTriples::Writer
45
+ RDF::NTriples::Writer
41
46
  end
42
47
  end
43
48
  end
@@ -14,10 +14,20 @@ module BEL::Translator::Plugins
14
14
  end
15
15
 
16
16
  def write(objects, writer = StringIO.new, options = {})
17
- XBELYielder.new(objects).each { |xml_data|
18
- writer << xml_data
19
- writer.flush
20
- }
17
+ if block_given?
18
+ XBELYielder.new(objects).each { |xml_data|
19
+ yield xml_data
20
+ }
21
+ else
22
+ if writer
23
+ XBELYielder.new(objects).each { |xml_data|
24
+ writer << xml_data
25
+ writer.flush
26
+ }
27
+ else
28
+ XBELYielder.new(objects)
29
+ end
30
+ end
21
31
  end
22
32
  end
23
33
  end
@@ -1,3 +1,3 @@
1
1
  module BEL
2
- VERSION = '0.4.0.beta.7'
2
+ VERSION = '0.4.0.beta.8'
3
3
  end
metadata CHANGED
@@ -1,34 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.beta.7
4
+ version: 0.4.0.beta.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Bargnesi
8
8
  - Natalie Catlett
9
9
  - Nick Bargnesi
10
10
  - William Hayes
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-03 00:00:00.000000000 Z
14
+ date: 2015-12-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: ffi
18
17
  requirement: !ruby/object:Gem::Requirement
19
18
  requirements:
20
19
  - - '='
21
20
  - !ruby/object:Gem::Version
22
21
  version: 1.9.8
23
- type: :runtime
22
+ name: ffi
24
23
  prerelease: false
24
+ type: :runtime
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.9.8
30
- description: " The BEL gem allows the reading, writing, and processing of BEL (Biological
31
- Expression Language) with a natural DSL. "
30
+ description: " The BEL gem allows the reading, writing, and processing of BEL (Biological\
31
+ \ Expression Language) with a natural DSL. "
32
32
  email:
33
33
  - abargnesi@selventa.com
34
34
  - ncatlett@selventa.com
@@ -152,6 +152,7 @@ files:
152
152
  - lib/bel/translator/plugins/rdf/monkey_patch.rb
153
153
  - lib/bel/translator/plugins/rdf/reader.rb
154
154
  - lib/bel/translator/plugins/rdf/translator.rb
155
+ - lib/bel/translator/plugins/rdf/uuid.rb
155
156
  - lib/bel/translator/plugins/rdf/writer.rb
156
157
  - lib/bel/translator/plugins/xbel.rb
157
158
  - lib/bel/translator/plugins/xbel/evidence_handler.rb
@@ -166,7 +167,7 @@ homepage: https://github.com/OpenBEL/bel.rb
166
167
  licenses:
167
168
  - Apache-2.0
168
169
  metadata: {}
169
- post_install_message:
170
+ post_install_message:
170
171
  rdoc_options:
171
172
  - "--title"
172
173
  - BEL Ruby Documentation
@@ -200,10 +201,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
201
  - !ruby/object:Gem::Version
201
202
  version: 1.3.1
202
203
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.4.5.1
205
- signing_key:
204
+ rubyforge_project:
205
+ rubygems_version: 2.4.8
206
+ signing_key:
206
207
  specification_version: 4
207
208
  summary: Process BEL with ruby.
208
209
  test_files: []
209
- has_rdoc:
210
+ has_rdoc: