bel 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{bel.gemspec → .gemspec} +8 -4
- data/README.md +3 -3
- data/VERSION +1 -0
- data/bin/bel +8 -8
- data/bin/bel2rdf.rb +1 -1
- data/bin/bel_summarize.rb +4 -4
- data/bin/bel_upgrade.rb +6 -6
- data/lib/bel.rb +3 -2
- data/lib/bel/completion.rb +13 -10
- data/lib/bel/completion_rule.rb +29 -21
- data/lib/bel/dsl.rb +75 -0
- data/lib/bel/gen.rb +2 -2
- data/lib/bel/gen/annotation.rb +2 -2
- data/lib/bel/gen/citation.rb +6 -6
- data/lib/bel/gen/document_header.rb +1 -1
- data/lib/bel/gen/{evidence.rb → nanopub.rb} +15 -15
- data/lib/bel/gen/parameter.rb +6 -6
- data/lib/bel/gen/sample_resources.rb +4 -4
- data/lib/bel/gen/statement.rb +1 -1
- data/lib/bel/gen/term.rb +1 -1
- data/lib/bel/language.rb +0 -20
- data/lib/bel/namespace.rb +7 -3
- data/lib/bel/nanopub.rb +15 -0
- data/lib/bel/{evidence_model/buffering_evidence_combiner.rb → nanopub/buffering_nanopub_combiner.rb} +39 -45
- data/lib/bel/{evidence_model → nanopub}/citation.rb +2 -2
- data/lib/bel/{evidence_model → nanopub}/experiment_context.rb +7 -1
- data/lib/bel/{evidence_model → nanopub}/hash_map_references.rb +1 -1
- data/lib/bel/{evidence_model → nanopub}/map_references.rb +1 -1
- data/lib/bel/nanopub/map_references_combiner.rb +30 -0
- data/lib/bel/nanopub/metadata.rb +102 -0
- data/lib/bel/nanopub/nanopub.rb +122 -0
- data/lib/bel/{evidence_model → nanopub}/references.rb +50 -38
- data/lib/bel/{evidence_model/streaming_evidence_combiner.rb → nanopub/streaming_nanopub_combiner.rb} +8 -8
- data/lib/bel/{evidence_model/summary_text.rb → nanopub/support.rb} +8 -2
- data/lib/bel/{evidence_model → nanopub}/util.rb +10 -10
- data/lib/bel/resource/annotation.rb +15 -24
- data/lib/bel/resource/annotation_value.rb +24 -20
- data/lib/bel/resource/annotations.rb +12 -11
- data/lib/bel/resource/concept.rb +62 -0
- data/lib/bel/resource/concept_scheme.rb +49 -0
- data/lib/bel/resource/namespace.rb +15 -24
- data/lib/bel/resource/namespace_value.rb +26 -23
- data/lib/bel/resource/namespaces.rb +11 -11
- data/lib/bel/script.rb +367 -367
- data/lib/bel/translate.rb +7 -7
- data/lib/bel/translator.rb +10 -10
- data/lib/bel/translator/plugins/bnj.rb +37 -0
- data/lib/bel/translator/plugins/{json_evidence → bnj}/translator.rb +17 -34
- data/lib/bel/translator/plugins/jgf.rb +1 -1
- data/lib/bel/translator/plugins/jgf/translator.rb +10 -10
- data/lib/bel/translator/plugins/jsonld.rb +1 -1
- data/lib/bel/translator/plugins/nquads.rb +1 -1
- data/lib/bel/translator/plugins/ntriples.rb +1 -1
- data/lib/bel/translator/plugins/rdf/bel_schema.rb +134 -126
- data/lib/bel/translator/plugins/rdf/graph_translator.rb +6 -6
- data/lib/bel/translator/plugins/rdf/monkey_patch.rb +50 -49
- data/lib/bel/translator/plugins/rdf/reader.rb +42 -42
- data/lib/bel/translator/plugins/rdf/translator.rb +6 -6
- data/lib/bel/translator/plugins/rdf/writer.rb +4 -4
- data/lib/bel/translator/plugins/rdf2/belv2_0.rb +416 -0
- data/lib/bel/translator/plugins/rdf2/converter.rb +13 -0
- data/lib/bel/translator/plugins/rdf2/namespace_converter.rb +24 -0
- data/lib/bel/translator/plugins/rdf2/nanopub_converter.rb +82 -0
- data/lib/bel/translator/plugins/rdf2/parameter_converter.rb +50 -0
- data/lib/bel/translator/plugins/rdf2/rdf_converter.rb +13 -0
- data/lib/bel/translator/plugins/rdf2/rdf_writer.rb +63 -0
- data/lib/bel/translator/plugins/rdf2/reader.rb +172 -0
- data/lib/bel/translator/plugins/rdf2/relationship_converter.rb +49 -0
- data/lib/bel/translator/plugins/rdf2/statement_converter.rb +65 -0
- data/lib/bel/translator/plugins/rdf2/term_converter.rb +262 -0
- data/lib/bel/translator/plugins/rdf2/translator.rb +51 -0
- data/lib/bel/translator/plugins/rdf2/uuid.rb +20 -0
- data/lib/bel/translator/plugins/rdf2/writer.rb +53 -0
- data/lib/bel/translator/plugins/rdfa.rb +1 -1
- data/lib/bel/translator/plugins/rdfxml.rb +1 -1
- data/lib/bel/translator/plugins/rj.rb +1 -1
- data/lib/bel/translator/plugins/trig.rb +1 -1
- data/lib/bel/translator/plugins/trix.rb +1 -1
- data/lib/bel/translator/plugins/turtle.rb +3 -6
- data/lib/bel/translator/plugins/xbel.rb +5 -6
- data/lib/bel/translator/plugins/xbel/nanopub_handler.rb +625 -0
- data/lib/bel/translator/plugins/xbel/{evidence_yielder.rb → nanopub_yielder.rb} +3 -3
- data/lib/bel/translator/plugins/xbel/translator.rb +2 -5
- data/lib/bel/translator/plugins/xbel/xbel_yielder.rb +135 -74
- data/lib/bel/version.rb +31 -1
- metadata +81 -33
- data/lib/bel/evidence_model.rb +0 -15
- data/lib/bel/evidence_model/bel_parameter.rb +0 -56
- data/lib/bel/evidence_model/bel_statement.rb +0 -97
- data/lib/bel/evidence_model/bel_term.rb +0 -87
- data/lib/bel/evidence_model/evidence.rb +0 -127
- data/lib/bel/evidence_model/map_references_combiner.rb +0 -30
- data/lib/bel/evidence_model/metadata.rb +0 -49
- data/lib/bel/parser.rb +0 -39
- data/lib/bel/translator/plugins/bel_script.rb +0 -36
- data/lib/bel/translator/plugins/bel_script/bel_citation_serialization.rb +0 -125
- data/lib/bel/translator/plugins/bel_script/bel_discrete_serialization.rb +0 -109
- data/lib/bel/translator/plugins/bel_script/bel_top_down_serialization.rb +0 -100
- data/lib/bel/translator/plugins/bel_script/bel_yielder.rb +0 -180
- data/lib/bel/translator/plugins/bel_script/evidence_serialization.rb +0 -79
- data/lib/bel/translator/plugins/bel_script/evidence_yielder.rb +0 -87
- data/lib/bel/translator/plugins/bel_script/translator.rb +0 -35
- data/lib/bel/translator/plugins/json_evidence.rb +0 -38
- data/lib/bel/translator/plugins/xbel/evidence_handler.rb +0 -495
data/lib/bel/gen.rb
CHANGED
@@ -3,7 +3,7 @@ require 'bel'
|
|
3
3
|
module BEL
|
4
4
|
|
5
5
|
# The {Gen} module defines submodules that generate random data that
|
6
|
-
# represent parts of
|
6
|
+
# represent parts of a {::BEL::Nanopub nanopub}.
|
7
7
|
module Gen
|
8
8
|
|
9
9
|
# Requires +paths+ treated as a soft dependency to bel.rb.
|
@@ -45,7 +45,7 @@ require_relative 'gen/namespace'
|
|
45
45
|
require_relative 'gen/parameter'
|
46
46
|
require_relative 'gen/term'
|
47
47
|
require_relative 'gen/statement'
|
48
|
-
require_relative 'gen/
|
48
|
+
require_relative 'gen/nanopub'
|
49
49
|
require_relative 'gen/sample_resources'
|
50
50
|
|
51
51
|
# vim: ts=2 sw=2:
|
data/lib/bel/gen/annotation.rb
CHANGED
@@ -5,7 +5,7 @@ module BEL
|
|
5
5
|
module Gen
|
6
6
|
|
7
7
|
# The {Annotation} module defines methods that generate random annotations
|
8
|
-
# to be used in
|
8
|
+
# to be used in a nanopub's {BEL::Nanopub::ExperimentContext}.
|
9
9
|
module Annotation
|
10
10
|
|
11
11
|
# Array of the latest OpenBEL {BEL::Annotation::AnnotationDefinition}.
|
@@ -23,7 +23,7 @@ module BEL
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Returns a random annotation as a hash of +:name+ and +:value+. These
|
26
|
-
# can be added directly to
|
26
|
+
# can be added directly to a nanopub's {BEL::Nanopub::ExperimentContext}.
|
27
27
|
#
|
28
28
|
# @return [Hash] random annotation; hash of +:name+ and +:value+
|
29
29
|
def annotation
|
data/lib/bel/gen/citation.rb
CHANGED
@@ -5,7 +5,7 @@ module BEL
|
|
5
5
|
module Gen
|
6
6
|
|
7
7
|
# The {Citation} module defines methods that generate random citation
|
8
|
-
# fields. See {Citation#citation} to generate a {BEL::
|
8
|
+
# fields. See {Citation#citation} to generate a {BEL::Nanopub::Citation}.
|
9
9
|
module Citation
|
10
10
|
|
11
11
|
# Returns a random citation type.
|
@@ -63,13 +63,13 @@ module BEL
|
|
63
63
|
}
|
64
64
|
end
|
65
65
|
|
66
|
-
# Returns a random {BEL::
|
66
|
+
# Returns a random {BEL::Nanopub::Citation}.
|
67
67
|
#
|
68
68
|
# Note: This method has a good chance to return the last generated
|
69
|
-
# {BEL::
|
70
|
-
#
|
69
|
+
# {BEL::Nanopub::Citation}. This behavior better models curated BEL
|
70
|
+
# nanopubs where many BEL statements have the same citation.
|
71
71
|
#
|
72
|
-
# @return [BEL::
|
72
|
+
# @return [BEL::Nanopub::Citation] a random citation
|
73
73
|
def citation
|
74
74
|
choice =
|
75
75
|
@citation_hash == nil ?
|
@@ -92,7 +92,7 @@ module BEL
|
|
92
92
|
}
|
93
93
|
end
|
94
94
|
|
95
|
-
::BEL::
|
95
|
+
::BEL::Nanopub::Citation.new(@citation_hash)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -5,7 +5,7 @@ module BEL
|
|
5
5
|
module Gen
|
6
6
|
|
7
7
|
# The {DocumentHeader} module defines methods that generate a random
|
8
|
-
# document header for the {BEL::
|
8
|
+
# document header for the {BEL::Nanopub::Nanopub} metadata.
|
9
9
|
module DocumentHeader
|
10
10
|
|
11
11
|
# Returns a randomly chosen document name.
|
@@ -13,11 +13,11 @@ BEL::Gen.soft_require('rantly')
|
|
13
13
|
module BEL
|
14
14
|
module Gen
|
15
15
|
|
16
|
-
# The {
|
17
|
-
# {BEL::
|
18
|
-
module
|
16
|
+
# The {Nanopub} module defines methods that generate random
|
17
|
+
# {BEL::Nanopub::Nanopub nanopubs}.
|
18
|
+
module Nanopub
|
19
19
|
|
20
|
-
# Include other generators needed to create {BEL::
|
20
|
+
# Include other generators needed to create {BEL::Nanopub::Nanopub}.
|
21
21
|
include BEL::Gen::DocumentHeader
|
22
22
|
include BEL::Gen::Annotation
|
23
23
|
include BEL::Gen::Citation
|
@@ -26,21 +26,21 @@ module BEL
|
|
26
26
|
include BEL::Gen::Statement
|
27
27
|
include BEL::Gen::Term
|
28
28
|
|
29
|
-
# Returns a random {BEL::
|
29
|
+
# Returns a random {BEL::Nanopub::Nanopub}.
|
30
30
|
#
|
31
|
-
# @return [BEL::
|
32
|
-
def
|
33
|
-
|
31
|
+
# @return [BEL::Nanopub::Nanopub] a random nanopub
|
32
|
+
def nanopub
|
33
|
+
nanopub = BEL::Nanopub::Nanopub.new
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
nanopub.bel_statement = bel_statement
|
36
|
+
nanopub.citation = citation
|
37
|
+
nanopub.support = BEL::Nanopub::Support.new(
|
38
38
|
Rantly { sized(120) {string(:alpha)} }
|
39
39
|
)
|
40
|
-
|
40
|
+
nanopub.experiment_context = BEL::Nanopub::ExperimentContext.new(
|
41
41
|
(1..5).to_a.sample.times.map { annotation }
|
42
42
|
)
|
43
|
-
|
43
|
+
nanopub.references = BEL::Nanopub::References.new({
|
44
44
|
:namespaces => referenced_namespaces.map { |prefix, ns_def|
|
45
45
|
{
|
46
46
|
:keyword => prefix,
|
@@ -55,11 +55,11 @@ module BEL
|
|
55
55
|
}
|
56
56
|
}
|
57
57
|
})
|
58
|
-
|
58
|
+
nanopub.metadata = BEL::Nanopub::Metadata.new({
|
59
59
|
:document_header => document_header
|
60
60
|
})
|
61
61
|
|
62
|
-
|
62
|
+
nanopub
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/bel/gen/parameter.rb
CHANGED
@@ -6,14 +6,14 @@ module BEL
|
|
6
6
|
module Gen
|
7
7
|
|
8
8
|
# The {Parameter} module defines methods that generate random BEL
|
9
|
-
# {BEL::
|
9
|
+
# {BEL::Nanopub::Parameter parameters}.
|
10
10
|
module Parameter
|
11
11
|
include BEL::Gen::Namespace
|
12
12
|
|
13
13
|
# Returns a BEL parameter from a random namespace. The value will be
|
14
14
|
# a random string and not necessarily part of the namespace.
|
15
15
|
#
|
16
|
-
# @return [BEL::
|
16
|
+
# @return [BEL::Nanopub::Parameter] a randomly generated parameter with
|
17
17
|
# a namespace
|
18
18
|
def bel_parameter_with_namespace
|
19
19
|
ns = namespace
|
@@ -22,7 +22,7 @@ module BEL
|
|
22
22
|
string(/[[:alnum:]]|[[:blank:]]|[[:punct:]]/)
|
23
23
|
}
|
24
24
|
}
|
25
|
-
BEL::
|
25
|
+
BEL::Nanopub::Parameter.new(
|
26
26
|
ns,
|
27
27
|
value,
|
28
28
|
:A
|
@@ -32,7 +32,7 @@ module BEL
|
|
32
32
|
# Returns a BEL parameter without a namespace. The value will be
|
33
33
|
# a random string.
|
34
34
|
#
|
35
|
-
# @return [BEL::
|
35
|
+
# @return [BEL::Nanopub::Parameter] a randomly generated parameter
|
36
36
|
# without a namespace
|
37
37
|
def bel_parameter_without_namespace
|
38
38
|
value = Rantly.value {
|
@@ -40,7 +40,7 @@ module BEL
|
|
40
40
|
string(/[[:alnum:]]|[[:blank:]]|[[:punct:]]/)
|
41
41
|
}
|
42
42
|
}
|
43
|
-
BEL::
|
43
|
+
BEL::Nanopub::Parameter.new(
|
44
44
|
nil,
|
45
45
|
value,
|
46
46
|
:A
|
@@ -54,7 +54,7 @@ module BEL
|
|
54
54
|
#
|
55
55
|
# @see #bel_parameter_with_namespace
|
56
56
|
# @see #bel_parameter_without_namespace
|
57
|
-
# @return [BEL::
|
57
|
+
# @return [BEL::Nanopub::Parameter] a parameter that may or may not have
|
58
58
|
# a namespace
|
59
59
|
def bel_parameter
|
60
60
|
with_namespace = bel_parameter_with_namespace
|
@@ -7,7 +7,7 @@ module BEL
|
|
7
7
|
# The {SampleResources} module defines methods that sample data from actual
|
8
8
|
# resources.
|
9
9
|
#
|
10
|
-
# {BEL::
|
10
|
+
# {BEL::Nanopub::Parameter BEL parameters} are sampled from a
|
11
11
|
# {BEL::Namespace::NamespaceDefinition}.
|
12
12
|
#
|
13
13
|
# Annotations are sampled from a {BEL::Annotation::AnnotationDefinition}.
|
@@ -15,7 +15,7 @@ module BEL
|
|
15
15
|
include BEL::Gen::Annotation
|
16
16
|
|
17
17
|
# Returns a sampled annotation as a hash of +:name+ and +:value+. These
|
18
|
-
# can be added directly to
|
18
|
+
# can be added directly to a nanopubs's {BEL::Nanopub::ExperimentContext}.
|
19
19
|
#
|
20
20
|
# @return [Hash] sampled annotation; hash of +:name+ and +:value+
|
21
21
|
def annotation
|
@@ -35,13 +35,13 @@ module BEL
|
|
35
35
|
|
36
36
|
# Returns a BEL parameter with a value sampled from a random namespace.
|
37
37
|
#
|
38
|
-
# @return [BEL::
|
38
|
+
# @return [BEL::Nanopub::Parameter] a parameter with value sampled from a
|
39
39
|
# random namespace
|
40
40
|
def bel_parameter_with_namespace
|
41
41
|
ns = namespace
|
42
42
|
value = ns.values.keys.sample
|
43
43
|
enc = ns.values[value]
|
44
|
-
BEL::
|
44
|
+
BEL::Nanopub::Parameter.new(
|
45
45
|
ns,
|
46
46
|
value,
|
47
47
|
enc
|
data/lib/bel/gen/statement.rb
CHANGED
data/lib/bel/gen/term.rb
CHANGED
data/lib/bel/language.rb
CHANGED
@@ -615,26 +615,6 @@ module BEL
|
|
615
615
|
:translatedTo => :translatedTo,
|
616
616
|
:translocates => :translocates,
|
617
617
|
}
|
618
|
-
|
619
|
-
def self.include_bel_dsl
|
620
|
-
RELATIONSHIPS.each do |rel, long_form|
|
621
|
-
BEL::Model::Term.send(:define_method, rel) do |another|
|
622
|
-
s = BEL::Model::Statement.new self
|
623
|
-
s.relationship = long_form
|
624
|
-
s.object = another
|
625
|
-
s
|
626
|
-
end
|
627
|
-
end
|
628
|
-
FUNCTIONS.each do |fx, metadata|
|
629
|
-
func = Function.new(metadata)
|
630
|
-
Language.send(:define_method, fx) do |*args|
|
631
|
-
BEL::Model::Term.new(func, *args)
|
632
|
-
end
|
633
|
-
Language.send(:define_method, metadata[:long_form]) do |*args|
|
634
|
-
BEL::Model::Term.new(func, *args)
|
635
|
-
end
|
636
|
-
end
|
637
|
-
end
|
638
618
|
end
|
639
619
|
end
|
640
620
|
# vim: ts=2 sw=2:
|
data/lib/bel/namespace.rb
CHANGED
@@ -250,6 +250,10 @@ module BEL
|
|
250
250
|
@values = nil
|
251
251
|
end
|
252
252
|
|
253
|
+
def rdf_uri
|
254
|
+
@rdf_uri ||= DEFAULT_URI
|
255
|
+
end
|
256
|
+
|
253
257
|
def values
|
254
258
|
unless @values
|
255
259
|
reload(@url)
|
@@ -262,16 +266,16 @@ module BEL
|
|
262
266
|
reload(@url) if not @values
|
263
267
|
sym = value.to_sym
|
264
268
|
encoding = @values[sym] || :''
|
265
|
-
|
269
|
+
Nanopub::Parameter.new(self, sym, encoding)
|
266
270
|
end
|
267
271
|
|
268
272
|
def each &block
|
269
273
|
reload(@url) if not @values
|
270
274
|
@values.each do |val, enc|
|
271
275
|
if block_given?
|
272
|
-
block.call(
|
276
|
+
block.call(Nanopub::Parameter.new(self, val, enc))
|
273
277
|
else
|
274
|
-
yield
|
278
|
+
yield Nanopub::Parameter.new(self, val, enc)
|
275
279
|
end
|
276
280
|
end
|
277
281
|
end
|
data/lib/bel/nanopub.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Expression model (from bel_parser)
|
2
|
+
require 'bel_parser/expression/model'
|
3
|
+
|
4
|
+
# Nanopub model
|
5
|
+
require_relative 'nanopub/nanopub'
|
6
|
+
require_relative 'nanopub/citation'
|
7
|
+
require_relative 'nanopub/support'
|
8
|
+
require_relative 'nanopub/experiment_context'
|
9
|
+
require_relative 'nanopub/metadata'
|
10
|
+
|
11
|
+
# Nanopub utilities
|
12
|
+
require_relative 'nanopub/buffering_nanopub_combiner'
|
13
|
+
require_relative 'nanopub/map_references_combiner'
|
14
|
+
require_relative 'nanopub/streaming_nanopub_combiner'
|
15
|
+
require_relative 'nanopub/util'
|
data/lib/bel/{evidence_model/buffering_evidence_combiner.rb → nanopub/buffering_nanopub_combiner.rb}
RENAMED
@@ -1,13 +1,13 @@
|
|
1
1
|
require_relative 'hash_map_references'
|
2
2
|
|
3
3
|
module BEL
|
4
|
-
module
|
4
|
+
module Nanopub
|
5
5
|
|
6
|
-
#
|
6
|
+
# NanopubReferenceCombiner is responsible for disambiguating nanopubs
|
7
7
|
# with overlapping sets of annotation/namespace references. This can occur
|
8
8
|
# when documents use the same keyword to refer to more than one reference.
|
9
9
|
#
|
10
|
-
# For example,
|
10
|
+
# For example, nanopub A may be annotated with:
|
11
11
|
#
|
12
12
|
# {
|
13
13
|
# :keyword => :Species,
|
@@ -15,7 +15,7 @@ module BEL
|
|
15
15
|
# :domain => 'file:///20131211/annotation/species-taxonomy-id.belanno'
|
16
16
|
# }
|
17
17
|
#
|
18
|
-
# while
|
18
|
+
# while nanopub B may be annotated with:
|
19
19
|
#
|
20
20
|
# {
|
21
21
|
# :keyword => :Species,
|
@@ -28,26 +28,23 @@ module BEL
|
|
28
28
|
#
|
29
29
|
# @abstract Subclass and override {#map_namespace_reference} to implement
|
30
30
|
# mapping of namespaces.
|
31
|
-
class
|
31
|
+
class BufferingNanopubCombiner
|
32
32
|
|
33
33
|
attr_reader :annotation_references, :namespace_references
|
34
34
|
|
35
|
-
def initialize(
|
36
|
-
@
|
35
|
+
def initialize(nanopub_collection)
|
36
|
+
@nanopub_collection = nanopub_collection
|
37
37
|
end
|
38
38
|
|
39
39
|
def each
|
40
40
|
if block_given?
|
41
|
-
|
42
|
-
combine_references(@
|
41
|
+
nanopub_array, map_references =
|
42
|
+
combine_references(@nanopub_collection)
|
43
43
|
@annotation_references = map_references.annotation_references
|
44
44
|
@namespace_references = map_references.namespace_references
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
evidence.bel_statement = BEL::Model::Evidence.parse_statement(evidence)
|
49
|
-
end
|
50
|
-
yield rewrite_evidence!(evidence, map_references)
|
46
|
+
nanopub_array.each do |nanopub|
|
47
|
+
yield rewrite_nanopub!(nanopub, map_references)
|
51
48
|
end
|
52
49
|
else
|
53
50
|
to_enum(:each)
|
@@ -56,33 +53,33 @@ module BEL
|
|
56
53
|
|
57
54
|
protected
|
58
55
|
|
59
|
-
def combine_references(
|
56
|
+
def combine_references(nanopub_collection)
|
60
57
|
annotation_reference_map = {}
|
61
58
|
namespace_reference_map = {}
|
62
59
|
annotations = []
|
63
60
|
namespaces = []
|
64
|
-
|
61
|
+
buffered_nanopub = nanopub_collection.each.map { |nanopub|
|
65
62
|
annotations, remap =
|
66
|
-
BEL::
|
63
|
+
BEL::Nanopub.union_annotation_references(
|
67
64
|
annotations,
|
68
|
-
|
65
|
+
nanopub.references.annotations,
|
69
66
|
'incr'
|
70
67
|
)
|
71
68
|
annotation_reference_map.merge!(remap)
|
72
69
|
|
73
70
|
namespaces, remap =
|
74
|
-
BEL::
|
71
|
+
BEL::Nanopub.union_namespace_references(
|
75
72
|
namespaces,
|
76
|
-
|
73
|
+
nanopub.references.namespaces,
|
77
74
|
'incr'
|
78
75
|
)
|
79
76
|
namespace_reference_map.merge!(remap)
|
80
77
|
|
81
|
-
|
78
|
+
nanopub
|
82
79
|
}.to_a
|
83
80
|
|
84
81
|
[
|
85
|
-
|
82
|
+
buffered_nanopub,
|
86
83
|
HashMapReferences.new(
|
87
84
|
annotation_reference_map,
|
88
85
|
namespace_reference_map
|
@@ -90,26 +87,28 @@ module BEL
|
|
90
87
|
]
|
91
88
|
end
|
92
89
|
|
93
|
-
def
|
90
|
+
def rewrite_nanopub!(nanopub, map_references)
|
94
91
|
rewrite_experiment_context!(
|
95
|
-
|
96
|
-
|
92
|
+
nanopub.experiment_context,
|
93
|
+
nanopub.references.annotations,
|
97
94
|
map_references
|
98
95
|
)
|
99
96
|
|
100
97
|
rewrite_statement!(
|
101
|
-
|
102
|
-
|
98
|
+
nanopub.bel_statement,
|
99
|
+
nanopub.references.namespaces,
|
103
100
|
map_references
|
104
101
|
)
|
105
102
|
|
106
|
-
|
103
|
+
nanopub
|
107
104
|
end
|
108
105
|
|
109
106
|
def rewrite_statement!(statement, namespace_references, map_references)
|
107
|
+
return if statement.nil?
|
108
|
+
|
110
109
|
keyword_to_reference = Hash[
|
111
110
|
namespace_references.map { |reference|
|
112
|
-
[reference
|
111
|
+
[reference.keyword, reference]
|
113
112
|
}
|
114
113
|
]
|
115
114
|
|
@@ -121,9 +120,9 @@ module BEL
|
|
121
120
|
obj = statement.object
|
122
121
|
if obj
|
123
122
|
case obj
|
124
|
-
when ::
|
123
|
+
when ::BELParser::Expression::Model::Statement
|
125
124
|
rewrite_statement!(obj, namespace_references, map_references)
|
126
|
-
when ::
|
125
|
+
when ::BELParser::Expression::Model::Term
|
127
126
|
rewrite_term!(obj, keyword_to_reference, map_references)
|
128
127
|
end
|
129
128
|
end
|
@@ -134,24 +133,19 @@ module BEL
|
|
134
133
|
|
135
134
|
term.arguments.each do |arg|
|
136
135
|
case arg
|
137
|
-
when ::
|
138
|
-
if arg.
|
139
|
-
prefix
|
140
|
-
if arg.ns.respond_to?(:prefix)
|
141
|
-
arg.ns.prefix
|
142
|
-
else
|
143
|
-
arg.ns[:prefix]
|
144
|
-
end
|
136
|
+
when ::BELParser::Expression::Model::Parameter
|
137
|
+
if arg.namespace
|
138
|
+
prefix = arg.namespace.keyword
|
145
139
|
reference = keyword_to_reference[prefix.to_sym]
|
146
140
|
new_reference = map_references.map_namespace_reference(reference)
|
147
141
|
if new_reference
|
148
|
-
arg.
|
149
|
-
|
150
|
-
|
151
|
-
|
142
|
+
arg.namespace =
|
143
|
+
BELParser::Expression::Model::Namespace.new(
|
144
|
+
new_reference[:keyword],
|
145
|
+
new_reference[:uri])
|
152
146
|
end
|
153
147
|
end
|
154
|
-
when ::
|
148
|
+
when ::BELParser::Expression::Model::Term
|
155
149
|
rewrite_term!(arg, keyword_to_reference, map_references)
|
156
150
|
end
|
157
151
|
end
|
@@ -164,7 +158,7 @@ module BEL
|
|
164
158
|
)
|
165
159
|
references = Hash[
|
166
160
|
annotation_references.map { |reference|
|
167
|
-
[reference
|
161
|
+
[reference.keyword, reference]
|
168
162
|
}
|
169
163
|
]
|
170
164
|
experiment_context.values.each do |annotation|
|