bel_parser 1.1.2-java → 1.1.3-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/bin/bel2_validator +5 -1
- data/bin/bel_script_reader +5 -1
- data/lib/bel_parser/language/apply_default_namespace.rb +48 -0
- data/lib/bel_parser/language/expression_validator.rb +13 -6
- data/lib/bel_parser/language/semantics_ast.rb +11 -3
- data/lib/bel_parser/language/version2_0/functions/fragment.rb +64 -0
- data/lib/bel_parser/language/version2_0/functions/from_location.rb +32 -2
- data/lib/bel_parser/language/version2_0/functions/location.rb +35 -2
- data/lib/bel_parser/language/version2_0/functions/molecular_activity.rb +30 -1
- data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +12 -9
- data/lib/bel_parser/language/version2_0/functions/rna_abundance.rb +1 -1
- data/lib/bel_parser/language/version2_0/functions/to_location.rb +33 -2
- data/lib/bel_parser/language/version2_0/value_encodings/location.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbb2c6873145830a18fedf1164da4505ab32c4cd
|
4
|
+
data.tar.gz: 16e51a23649115539f81f6391c4eca8ad3b5d06e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 650f98be712db578f9b0376e606fcefb9ed0e8e9c015cac5d0e2e43d4c8636782c8928aa9b2baba47c6ad1a61b91b58d69ce84d6202ede98d6611af8291d1dbc
|
7
|
+
data.tar.gz: 3f76b83bd32877aef24f380b5aeb0bb62ac08d7aea5fe4255d27dfe9811068395a383a3857d537fb1ef05f660349faf81ace7acd40937127f34fb4982ad618a1
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/bin/bel2_validator
CHANGED
@@ -87,7 +87,11 @@ uri_reader, url_reader = options.values_at(:uri_reader, :url_reader)
|
|
87
87
|
namespaces = Hash[
|
88
88
|
ARGV.map do |ns|
|
89
89
|
keyword, identifier = ns.split('=')
|
90
|
-
|
90
|
+
if identifier.end_with?('.belns')
|
91
|
+
[keyword, BELParser::Expression::Model::Namespace.new(keyword, nil, identifier)]
|
92
|
+
else
|
93
|
+
[keyword, BELParser::Expression::Model::Namespace.new(keyword, identifier, nil)]
|
94
|
+
end
|
91
95
|
end.compact
|
92
96
|
]
|
93
97
|
|
data/bin/bel_script_reader
CHANGED
@@ -81,7 +81,11 @@ url_reader = options[:url_reader]
|
|
81
81
|
namespaces = Hash[
|
82
82
|
ARGV.map do |ns|
|
83
83
|
keyword, identifier = ns.split('=')
|
84
|
-
|
84
|
+
if identifier.end_with?('.belns')
|
85
|
+
[keyword, BELParser::Expression::Model::Namespace.new(keyword, nil, identifier)]
|
86
|
+
else
|
87
|
+
[keyword, BELParser::Expression::Model::Namespace.new(keyword, identifier, nil)]
|
88
|
+
end
|
85
89
|
end.compact
|
86
90
|
]
|
87
91
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'bel_parser/language/term_transformation'
|
2
|
+
|
3
|
+
module BELParser
|
4
|
+
module Language
|
5
|
+
# ApplyDefaultNamespace sets the DEFAULT namespace for values when one is
|
6
|
+
# not provided. Applies to all namespace values within a BEL 2.0 expression.
|
7
|
+
class ApplyDefaultNamespace
|
8
|
+
include BELParser::Language::TermTransformation
|
9
|
+
|
10
|
+
def initialize(language_spec, namespace_hash, uri_reader, url_reader)
|
11
|
+
@language_spec = language_spec
|
12
|
+
@namespace_hash = namespace_hash
|
13
|
+
@uri_reader = uri_reader
|
14
|
+
@url_reader = url_reader
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_term(term_node)
|
18
|
+
term_node.updated([
|
19
|
+
term_node.function,
|
20
|
+
term_node.arguments.map! {|arg| argument(process(arg.child))}
|
21
|
+
].flatten)
|
22
|
+
end
|
23
|
+
|
24
|
+
def on_argument(argument_node)
|
25
|
+
process(argument_node.child)
|
26
|
+
end
|
27
|
+
|
28
|
+
def on_parameter(parameter_node)
|
29
|
+
parameter_node.updated([
|
30
|
+
process(parameter_node.prefix),
|
31
|
+
parameter_node.value
|
32
|
+
].flatten)
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_prefix(prefix_node)
|
36
|
+
# guard: return prefix AST node if namespace already supplied
|
37
|
+
return prefix_node if prefix_node.identifier
|
38
|
+
|
39
|
+
# return "DEFAULT" namespace
|
40
|
+
prefix(
|
41
|
+
identifier(
|
42
|
+
'DEFAULT',
|
43
|
+
:complete => true),
|
44
|
+
:complete => true)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'syntax'
|
2
2
|
require_relative 'semantics'
|
3
|
+
require_relative 'apply_default_namespace'
|
3
4
|
require_relative 'apply_namespace_encoding'
|
4
5
|
|
5
6
|
module BELParser
|
@@ -9,11 +10,13 @@ module BELParser
|
|
9
10
|
# namespaces.
|
10
11
|
class ExpressionValidator
|
11
12
|
def initialize(spec, namespaces, uri_reader, url_reader)
|
12
|
-
@spec
|
13
|
-
@namespaces
|
14
|
-
@syntax_functions
|
15
|
-
@semantics_functions
|
16
|
-
@
|
13
|
+
@spec = spec
|
14
|
+
@namespaces = namespaces || {}
|
15
|
+
@syntax_functions = Syntax.syntax_functions
|
16
|
+
@semantics_functions = Semantics.semantics_functions
|
17
|
+
@default_namespace_transform =
|
18
|
+
ApplyDefaultNamespace.new(@spec, @namespaces, uri_reader, url_reader)
|
19
|
+
@namespace_encoding_transform =
|
17
20
|
ApplyNamespaceEncoding.new(@spec, @namespaces, uri_reader, url_reader)
|
18
21
|
end
|
19
22
|
|
@@ -23,7 +26,11 @@ module BELParser
|
|
23
26
|
# @param [BELParser::Parsers::AST::Node] expression_node to validate
|
24
27
|
# @return [BELParser::Language::Syntax::SyntaxResult] syntax results
|
25
28
|
def validate(expression_node)
|
26
|
-
@
|
29
|
+
if @spec.version >= "2.0"
|
30
|
+
expression_node = @default_namespace_transform.process(expression_node)
|
31
|
+
end
|
32
|
+
|
33
|
+
@namespace_encoding_transform.process(expression_node)
|
27
34
|
|
28
35
|
case expression_node
|
29
36
|
when BELParser::Parsers::AST::SimpleStatement
|
@@ -574,7 +574,7 @@ module BELParser
|
|
574
574
|
unless prefix_node.respond_to?(:namespace) && prefix_node.namespace
|
575
575
|
return invalid_namespace(prefix_node, spec, namespaces)
|
576
576
|
end
|
577
|
-
|
577
|
+
|
578
578
|
if namespaces.any? { |i| i == :* || i == input_namespace }
|
579
579
|
success(prefix_node, spec)
|
580
580
|
else
|
@@ -736,8 +736,16 @@ module BELParser
|
|
736
736
|
end
|
737
737
|
|
738
738
|
def match(value_node, spec)
|
739
|
-
|
740
|
-
|
739
|
+
ident_or_string = value_node.children[0]
|
740
|
+
value =
|
741
|
+
case ident_or_string
|
742
|
+
when BELParser::Parsers::AST::String
|
743
|
+
ident_or_string.string_value
|
744
|
+
else
|
745
|
+
ident_or_string.string_literal
|
746
|
+
end
|
747
|
+
|
748
|
+
case value
|
741
749
|
when START_STOP, UNDETERMINED, UNKNOWN_START_STOP
|
742
750
|
success(value_node, spec)
|
743
751
|
else
|
@@ -70,6 +70,35 @@ module BELParser
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
class FragmentWithAnySignature
|
74
|
+
extend BELParser::Language::Signature
|
75
|
+
|
76
|
+
private_class_method :new
|
77
|
+
|
78
|
+
AST = BELParser::Language::Semantics::Builder.build do
|
79
|
+
term(
|
80
|
+
function(
|
81
|
+
identifier(
|
82
|
+
function_of(Fragment))),
|
83
|
+
argument(
|
84
|
+
parameter(
|
85
|
+
prefix(any),
|
86
|
+
value(any))))
|
87
|
+
end
|
88
|
+
private_constant :AST
|
89
|
+
|
90
|
+
STRING_FORM = 'fragment(E:*)abundance'.freeze
|
91
|
+
private_constant :STRING_FORM
|
92
|
+
|
93
|
+
def self.semantic_ast
|
94
|
+
AST
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.string_form
|
98
|
+
STRING_FORM
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
73
102
|
# FragmentWithRangeDescriptorSignature
|
74
103
|
class FragmentWithRangeDescriptorSignature
|
75
104
|
extend BELParser::Language::Signature
|
@@ -104,6 +133,41 @@ module BELParser
|
|
104
133
|
STRING_FORM
|
105
134
|
end
|
106
135
|
end
|
136
|
+
|
137
|
+
# FragmentWithRangeDescriptorSignature
|
138
|
+
class FragmentWithAnyDescriptorSignature
|
139
|
+
extend BELParser::Language::Signature
|
140
|
+
|
141
|
+
private_class_method :new
|
142
|
+
|
143
|
+
AST = BELParser::Language::Semantics::Builder.build do
|
144
|
+
term(
|
145
|
+
function(
|
146
|
+
identifier(
|
147
|
+
function_of(Fragment))),
|
148
|
+
argument(
|
149
|
+
parameter(
|
150
|
+
prefix(any),
|
151
|
+
value(any))),
|
152
|
+
argument(
|
153
|
+
parameter(
|
154
|
+
prefix(any),
|
155
|
+
value(any))))
|
156
|
+
end
|
157
|
+
private_constant :AST
|
158
|
+
|
159
|
+
STRING_FORM = 'fragment(E:*,E:*)abundance'.freeze
|
160
|
+
private_constant :STRING_FORM
|
161
|
+
|
162
|
+
def self.semantic_ast
|
163
|
+
AST
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.string_form
|
167
|
+
STRING_FORM
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
107
171
|
end
|
108
172
|
|
109
173
|
SIGNATURES = Signatures.constants.map do |const|
|
@@ -15,7 +15,7 @@ module BELParser
|
|
15
15
|
SHORT = :fromLoc
|
16
16
|
LONG = :fromLocation
|
17
17
|
RETURN_TYPE = BELParser::Language::Version2_0::ReturnTypes::FromLocation
|
18
|
-
|
18
|
+
A_ENC = Version2_0::ValueEncodings::Abundance
|
19
19
|
DESCRIPTION = 'Denotes the from cellular location of the
|
20
20
|
abundance.'.freeze
|
21
21
|
|
@@ -58,7 +58,7 @@ module BELParser
|
|
58
58
|
namespace_of(:*)),
|
59
59
|
value(
|
60
60
|
has_encoding,
|
61
|
-
encoding_of(
|
61
|
+
encoding_of(A_ENC)))))
|
62
62
|
end
|
63
63
|
private_constant :AST
|
64
64
|
|
@@ -73,6 +73,36 @@ module BELParser
|
|
73
73
|
STRING_FORM
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
class FromLocationAnySignature
|
78
|
+
extend BELParser::Language::Signature
|
79
|
+
|
80
|
+
private_class_method :new
|
81
|
+
|
82
|
+
AST = BELParser::Language::Semantics::Builder.build do
|
83
|
+
term(
|
84
|
+
function(
|
85
|
+
identifier(
|
86
|
+
function_of(FromLocation))),
|
87
|
+
argument(
|
88
|
+
parameter(
|
89
|
+
prefix(any),
|
90
|
+
value(any))))
|
91
|
+
end
|
92
|
+
private_constant :AST
|
93
|
+
|
94
|
+
STRING_FORM = 'fromLocation(Any)fromLocation'.freeze
|
95
|
+
private_constant :STRING_FORM
|
96
|
+
|
97
|
+
def self.semantic_ast
|
98
|
+
AST
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.string_form
|
102
|
+
STRING_FORM
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
76
106
|
end
|
77
107
|
|
78
108
|
SIGNATURES = Signatures.constants.map do |const|
|
@@ -14,7 +14,7 @@ module BELParser
|
|
14
14
|
SHORT = :loc
|
15
15
|
LONG = :location
|
16
16
|
RETURN_TYPE = BELParser::Language::Version2_0::ReturnTypes::Location
|
17
|
-
|
17
|
+
A_ENC = Version2_0::ValueEncodings::Abundance
|
18
18
|
DESCRIPTION = 'Denotes the cellular location of the abundance.'.freeze
|
19
19
|
|
20
20
|
def self.short
|
@@ -56,7 +56,7 @@ module BELParser
|
|
56
56
|
namespace_of(:*)),
|
57
57
|
value(
|
58
58
|
has_encoding,
|
59
|
-
encoding_of(
|
59
|
+
encoding_of(A_ENC)))))
|
60
60
|
end
|
61
61
|
private_constant :AST
|
62
62
|
|
@@ -71,6 +71,39 @@ module BELParser
|
|
71
71
|
STRING_FORM
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
75
|
+
# LocationSignature
|
76
|
+
class LocationAnySignature
|
77
|
+
extend BELParser::Language::Signature
|
78
|
+
|
79
|
+
private_class_method :new
|
80
|
+
|
81
|
+
AST = BELParser::Language::Semantics::Builder.build do
|
82
|
+
term(
|
83
|
+
function(
|
84
|
+
identifier(
|
85
|
+
function_of(Location))),
|
86
|
+
argument(
|
87
|
+
parameter(
|
88
|
+
prefix(
|
89
|
+
has_namespace,
|
90
|
+
namespace_of(:*)),
|
91
|
+
value(any))))
|
92
|
+
end
|
93
|
+
private_constant :AST
|
94
|
+
|
95
|
+
STRING_FORM = 'location(Any)location'.freeze
|
96
|
+
private_constant :STRING_FORM
|
97
|
+
|
98
|
+
def self.semantic_ast
|
99
|
+
AST
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.string_form
|
103
|
+
STRING_FORM
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
74
107
|
end
|
75
108
|
|
76
109
|
SIGNATURES = Signatures.constants.map do |const|
|
@@ -74,8 +74,37 @@ module BELParser
|
|
74
74
|
STRING_FORM
|
75
75
|
end
|
76
76
|
end
|
77
|
-
end
|
78
77
|
|
78
|
+
# MolecularActivitySignature
|
79
|
+
class MolecularActivityAnySignature
|
80
|
+
extend BELParser::Language::Signature
|
81
|
+
|
82
|
+
private_class_method :new
|
83
|
+
|
84
|
+
AST = BELParser::Language::Semantics::Builder.build do
|
85
|
+
term(
|
86
|
+
function(
|
87
|
+
identifier(
|
88
|
+
function_of(MolecularActivity))),
|
89
|
+
argument(
|
90
|
+
parameter(
|
91
|
+
prefix(any),
|
92
|
+
value(any))))
|
93
|
+
end
|
94
|
+
private_constant :AST
|
95
|
+
|
96
|
+
STRING_FORM = 'molecularActivity(Any)molecularActivity'.freeze
|
97
|
+
private_constant :STRING_FORM
|
98
|
+
|
99
|
+
def self.semantic_ast
|
100
|
+
AST
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.string_form
|
104
|
+
STRING_FORM
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
79
108
|
SIGNATURES = Signatures.constants.map do |const|
|
80
109
|
Signatures.const_get(const)
|
81
110
|
end.freeze
|
@@ -55,9 +55,10 @@ module BELParser
|
|
55
55
|
argument(
|
56
56
|
parameter(
|
57
57
|
prefix(any),
|
58
|
-
value(
|
59
|
-
|
60
|
-
|
58
|
+
value(any))))
|
59
|
+
# value(
|
60
|
+
# has_encoding,
|
61
|
+
# encoding_of(E_ENC)))))
|
61
62
|
end
|
62
63
|
private_constant :AST
|
63
64
|
|
@@ -90,9 +91,10 @@ module BELParser
|
|
90
91
|
argument(
|
91
92
|
parameter(
|
92
93
|
prefix(any),
|
93
|
-
value(
|
94
|
-
|
95
|
-
|
94
|
+
value(any))),
|
95
|
+
# value(
|
96
|
+
# has_encoding,
|
97
|
+
# encoding_of(E_ENC)))),
|
96
98
|
argument(
|
97
99
|
parameter(
|
98
100
|
prefix(any),
|
@@ -130,9 +132,10 @@ module BELParser
|
|
130
132
|
argument(
|
131
133
|
parameter(
|
132
134
|
prefix(any),
|
133
|
-
value(
|
134
|
-
|
135
|
-
|
135
|
+
value(any))),
|
136
|
+
# value(
|
137
|
+
# has_encoding,
|
138
|
+
# encoding_of(E_ENC)))),
|
136
139
|
argument(
|
137
140
|
parameter(
|
138
141
|
prefix(any),
|
@@ -13,7 +13,7 @@ module BELParser
|
|
13
13
|
|
14
14
|
SHORT = :r
|
15
15
|
LONG = :rnaAbundance
|
16
|
-
RETURN_TYPE = BELParser::Language::Version2_0::ReturnTypes::
|
16
|
+
RETURN_TYPE = BELParser::Language::Version2_0::ReturnTypes::RNAAbundance
|
17
17
|
R_ENC = Version2_0::ValueEncodings::RNAAbundance
|
18
18
|
DESCRIPTION = 'Denotes the abundance of a gene'.freeze
|
19
19
|
|
@@ -14,7 +14,7 @@ module BELParser
|
|
14
14
|
SHORT = :toLoc
|
15
15
|
LONG = :toLocation
|
16
16
|
RETURN_TYPE = BELParser::Language::Version2_0::ReturnTypes::ToLocation
|
17
|
-
|
17
|
+
A_ENC = Version2_0::ValueEncodings::Abundance
|
18
18
|
DESCRIPTION = 'Denotes the to cellular location of the
|
19
19
|
abundance.'.freeze
|
20
20
|
|
@@ -57,7 +57,7 @@ module BELParser
|
|
57
57
|
namespace_of(:*)),
|
58
58
|
value(
|
59
59
|
has_encoding,
|
60
|
-
encoding_of(
|
60
|
+
encoding_of(A_ENC)))))
|
61
61
|
end
|
62
62
|
private_constant :AST
|
63
63
|
|
@@ -72,6 +72,37 @@ module BELParser
|
|
72
72
|
STRING_FORM
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
# ToLocationAnySignature
|
77
|
+
class ToLocationAnySignature
|
78
|
+
extend BELParser::Language::Signature
|
79
|
+
|
80
|
+
private_class_method :new
|
81
|
+
|
82
|
+
AST = BELParser::Language::Semantics::Builder.build do
|
83
|
+
term(
|
84
|
+
function(
|
85
|
+
identifier(
|
86
|
+
function_of(ToLocation))),
|
87
|
+
argument(
|
88
|
+
parameter(
|
89
|
+
prefix(any),
|
90
|
+
value(any))))
|
91
|
+
end
|
92
|
+
private_constant :AST
|
93
|
+
|
94
|
+
STRING_FORM = 'toLocation(Any)toLocation'.freeze
|
95
|
+
private_constant :STRING_FORM
|
96
|
+
|
97
|
+
def self.semantic_ast
|
98
|
+
AST
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.string_form
|
102
|
+
STRING_FORM
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
75
106
|
end
|
76
107
|
|
77
108
|
SIGNATURES = Signatures.constants.map do |const|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bel_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Anthony Bargnesi
|
@@ -56,11 +56,11 @@ dependencies:
|
|
56
56
|
description: Implements language versions 1.0 and 2.0.
|
57
57
|
email: abargnesi@selventa.com
|
58
58
|
executables:
|
59
|
+
- bel2_compatibility
|
60
|
+
- bel2_debug_ast
|
59
61
|
- bel2_upgrade
|
60
62
|
- bel2_validator
|
61
63
|
- bel_script_reader
|
62
|
-
- bel2_compatibility
|
63
|
-
- bel2_debug_ast
|
64
64
|
extensions: []
|
65
65
|
extra_rdoc_files: []
|
66
66
|
files:
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/bel_parser/expression/validator.rb
|
99
99
|
- lib/bel_parser/language.rb
|
100
100
|
- lib/bel_parser/language/amino_acid.rb
|
101
|
+
- lib/bel_parser/language/apply_default_namespace.rb
|
101
102
|
- lib/bel_parser/language/apply_namespace_encoding.rb
|
102
103
|
- lib/bel_parser/language/base_specification.rb
|
103
104
|
- lib/bel_parser/language/covalent_protein_modification.rb
|
@@ -443,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
443
444
|
version: '0'
|
444
445
|
requirements: []
|
445
446
|
rubyforge_project:
|
446
|
-
rubygems_version: 2.
|
447
|
+
rubygems_version: 2.4.8
|
447
448
|
signing_key:
|
448
449
|
specification_version: 4
|
449
450
|
summary: Parser for Biolgical Expression Language.
|