bel_parser 1.0.0.alpha.12 → 1.0.0.alpha.13
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/.gemspec +1 -1
- data/VERSION +1 -1
- data/bin/bel2_validator +35 -8
- data/lib/bel_parser/expression/validator.rb +3 -2
- data/lib/bel_parser/language/apply_namespace_encoding.rb +96 -0
- data/lib/bel_parser/language/base_specification.rb +82 -0
- data/lib/bel_parser/language/expression_validator.rb +6 -2
- data/lib/bel_parser/language/relationship.rb +1 -1
- data/lib/bel_parser/language/semantics/signature_mapping.rb +26 -32
- data/lib/bel_parser/language/semantics_ast.rb +285 -149
- data/lib/bel_parser/language/semantics_ast_warnings.rb +180 -0
- data/lib/bel_parser/language/semantics_result.rb +11 -2
- data/lib/bel_parser/language/semantics_type_warning.rb +22 -0
- data/lib/bel_parser/language/semantics_warning.rb +8 -0
- data/lib/bel_parser/language/specification.rb +38 -55
- data/lib/bel_parser/language/syntax/undefined_namespace_value.rb +43 -0
- data/lib/bel_parser/language/syntax_error.rb +8 -0
- data/lib/bel_parser/language/syntax_result.rb +8 -0
- data/lib/bel_parser/language/syntax_warning.rb +9 -4
- data/lib/bel_parser/language/version1_0/functions/abundance.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/biological_process.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/complex_abundance.rb +6 -7
- data/lib/bel_parser/language/version1_0/functions/fusion.rb +39 -60
- data/lib/bel_parser/language/version1_0/functions/gene_abundance.rb +9 -12
- data/lib/bel_parser/language/version1_0/functions/list.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/micro_rna_abundance.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/pathology.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/protein_abundance.rb +16 -30
- data/lib/bel_parser/language/version1_0/functions/protein_modification.rb +15 -27
- data/lib/bel_parser/language/version1_0/functions/rna_abundance.rb +8 -11
- data/lib/bel_parser/language/version1_0/functions/substitution.rb +6 -12
- data/lib/bel_parser/language/version1_0/functions/translocation.rb +9 -12
- data/lib/bel_parser/language/version1_0/functions/truncation.rb +2 -4
- data/lib/bel_parser/language/version1_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version1_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0.rb +6 -87
- data/lib/bel_parser/language/version2_0/functions/abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/biological_process.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/complex_abundance.rb +9 -12
- data/lib/bel_parser/language/version2_0/functions/fragment.rb +4 -9
- data/lib/bel_parser/language/version2_0/functions/from_location.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/fusion.rb +39 -66
- data/lib/bel_parser/language/version2_0/functions/gene_abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/list.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/location.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/micro_rna_abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/molecular_activity.rb +6 -5
- data/lib/bel_parser/language/version2_0/functions/pathology.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/protein_abundance.rb +21 -30
- data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +11 -17
- data/lib/bel_parser/language/version2_0/functions/rna_abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/to_location.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/variant.rb +1 -4
- data/lib/bel_parser/language/version2_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/activity.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version2_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/location.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_modification.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0.rb +6 -60
- data/lib/bel_parser/language.rb +3 -4
- data/lib/bel_parser/parsers/ast/node.rb +14 -2
- data/lib/bel_parser/{language/quoting.rb → quoting.rb} +0 -56
- data/lib/bel_parser/resource/concept.rb +56 -0
- data/lib/bel_parser/resource/concept_scheme.rb +35 -0
- data/lib/bel_parser/resource/dataset.rb +34 -0
- data/lib/bel_parser/resource/eager_reader.rb +75 -0
- data/lib/bel_parser/resource/eager_sparql_reader.rb +51 -0
- data/lib/bel_parser/resource/http_cache.rb +71 -0
- data/lib/bel_parser/resource/jena_tdb_reader.rb +246 -0
- data/lib/bel_parser/resource/lru_cache.rb +111 -0
- data/lib/bel_parser/resource/lru_reader.rb +38 -0
- data/lib/bel_parser/resource/reader.rb +18 -0
- data/lib/bel_parser/resource/resource_file_reader.rb +134 -0
- data/lib/bel_parser/resource/sparql_reader.rb +178 -0
- data/lib/bel_parser/resource/value.rb +31 -0
- metadata +42 -4
- data/lib/bel_parser/language/version1_0/syntax/function.rb +0 -28
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
require 'bel_parser/parsers/ast/node'
|
|
2
|
+
require_relative 'semantics_warning'
|
|
3
|
+
|
|
4
|
+
module BELParser
|
|
5
|
+
module Language
|
|
6
|
+
module Semantics
|
|
7
|
+
class SemanticsNilNodeWarning < SemanticsWarning
|
|
8
|
+
attr_reader :expected_type
|
|
9
|
+
|
|
10
|
+
def initialize(expression_node, spec, expected)
|
|
11
|
+
super(expression_node, spec)
|
|
12
|
+
@expected_type = expected.ast_type
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_s
|
|
16
|
+
%(Missing the #{@expected_type} type.)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class SemanticsNotNilNodeWarning < SemanticsWarning
|
|
21
|
+
attr_reader :actual_type
|
|
22
|
+
|
|
23
|
+
def initialize(expression_node, spec)
|
|
24
|
+
super(expression_node, spec)
|
|
25
|
+
@actual_type = expression_node.type
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_s
|
|
29
|
+
%(Expected nothing, but saw #{actual_type} type.)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class SemanticsTypeWarning < SemanticsWarning
|
|
34
|
+
attr_reader :expected_type, :actual_type
|
|
35
|
+
|
|
36
|
+
def initialize(expression_node, spec, expected, actual)
|
|
37
|
+
super(expression_node, spec)
|
|
38
|
+
@expected_type = expected.ast_type
|
|
39
|
+
@actual_type = actual.type
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def to_s
|
|
43
|
+
%(Expected #{expected_type} type, but saw #{actual_type} type.)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class SemanticsArgumentLengthWarning < SemanticsWarning
|
|
48
|
+
attr_reader :expected_type, :actual_type
|
|
49
|
+
|
|
50
|
+
def initialize(expression_node, spec, expected, actual)
|
|
51
|
+
super(expression_node, spec)
|
|
52
|
+
@expected_length = expected.arguments.length
|
|
53
|
+
@actual_length = actual.arguments.length
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def to_s
|
|
57
|
+
%(Expected #@expected_length arguments, but saw #@actual_length arguments.)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class SemanticsMissingNamespaceWarning < SemanticsWarning
|
|
62
|
+
def initialize(expression_node, spec)
|
|
63
|
+
super(expression_node, spec)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def to_s
|
|
67
|
+
prefix = @expression_node.identifier.string_literal
|
|
68
|
+
%(Missing namespace for prefix "#{prefix}".)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class SemanticsInvalidNamespaceWarning < SemanticsWarning
|
|
73
|
+
def initialize(expression_node, spec, expected_namespaces)
|
|
74
|
+
super(expression_node, spec)
|
|
75
|
+
@expected_namespaces = expected_namespaces
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def to_s
|
|
79
|
+
namespace =
|
|
80
|
+
@expression_node.namespace &&
|
|
81
|
+
@expression_node.namespace.identifier
|
|
82
|
+
%(Invalid namespace "#{namespace}". Was expecting one of: #{@expected_namespaces.join(', ')})
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class SemanticsMissingEncodingWarning < SemanticsWarning
|
|
87
|
+
def initialize(expression_node, spec)
|
|
88
|
+
super(expression_node, spec)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def to_s
|
|
92
|
+
value = @expression_node.children[0].string_literal
|
|
93
|
+
%(Missing encoding for value "#{value}".)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class SemanticsInvalidEncodingWarning < SemanticsWarning
|
|
98
|
+
def initialize(expression_node, spec, expected_encodings)
|
|
99
|
+
super(expression_node, spec)
|
|
100
|
+
@expected_encodings = expected_encodings
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def to_s
|
|
104
|
+
encoding = @expression_node.encoding
|
|
105
|
+
%(Encoding of "#{encoding}" does not match expected: #{@expected_encodings.join(', ')})
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class SemanticsInvalidFunctionWarning < SemanticsWarning
|
|
110
|
+
def initialize(expression_node, spec, expected_functions)
|
|
111
|
+
super(expression_node, spec)
|
|
112
|
+
@expected_functions = expected_functions
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def to_s
|
|
116
|
+
function = @expression_node.string_literal
|
|
117
|
+
%(Function of "#{function}" does not match expected: #{@expected_functions.join(', ')})
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
class SemanticsInvalidReturnTypeWarning < SemanticsWarning
|
|
122
|
+
def initialize(expression_node, spec, expected_return_types)
|
|
123
|
+
super(expression_node, spec)
|
|
124
|
+
@expected_return_types = expected_return_types
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def to_s
|
|
128
|
+
function = @expression_node.string_literal
|
|
129
|
+
%(Function of "#{function}" does not match return types: #{@expected_return_types.join(', ')})
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
class SemanticsInvalidProteinModificationWarning < SemanticsWarning
|
|
134
|
+
def initialize(expression_node, spec, expected_protein_modifications)
|
|
135
|
+
super(expression_node, spec)
|
|
136
|
+
@expected_protein_modifications = expected_protein_modifications
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def to_s
|
|
140
|
+
pmod = @expression_node.children[0].string_literal
|
|
141
|
+
%(Protein modification of "#{pmod}" does not match allowed protein modifications: #{@expected_protein_modifications.join(', ')})
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
class SemanticsInvalidAminoAcidWarning < SemanticsWarning
|
|
146
|
+
def initialize(expression_node, spec, expected_amino_acids)
|
|
147
|
+
super(expression_node, spec)
|
|
148
|
+
@expected_amino_acids = expected_amino_acids
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def to_s
|
|
152
|
+
amino_acid = @expression_node.children[0].string_literal
|
|
153
|
+
%(Amino acid of "#{amino_acid}" does not match allowed amino acids: #{@expected_amino_acids.join(', ')})
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
class SemanticsInvalidAminoAcidRangeWarning < SemanticsWarning
|
|
158
|
+
def initialize(expression_node, spec)
|
|
159
|
+
super(expression_node, spec)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def to_s
|
|
163
|
+
amino_acid_range = @expression_node.children[0].string_literal
|
|
164
|
+
%(Invalid amino acid range "#{amino_acid_range}".)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
class SemanticsInvalidSequencePositionWarning < SemanticsWarning
|
|
169
|
+
def initialize(expression_node, spec)
|
|
170
|
+
super(expression_node, spec)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def to_s
|
|
174
|
+
pos = @expression_node.children[0].string_literal
|
|
175
|
+
%(Sequence position of "#{pos}" is not a positive number.)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
module BELParser
|
|
2
2
|
module Language
|
|
3
3
|
module Semantics
|
|
4
|
-
# SemanticsResult represents the
|
|
4
|
+
# SemanticsResult represents the successful outcome of applying a
|
|
5
|
+
# {SemanticsFunction}.
|
|
5
6
|
class SemanticsResult
|
|
6
7
|
attr_reader :expression_node, :specification
|
|
7
8
|
|
|
@@ -10,9 +11,17 @@ module BELParser
|
|
|
10
11
|
@specification = specification
|
|
11
12
|
end
|
|
12
13
|
|
|
14
|
+
def success?
|
|
15
|
+
true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def failure?
|
|
19
|
+
false
|
|
20
|
+
end
|
|
21
|
+
|
|
13
22
|
# @abstract Subclass and override {#msg} to provide the message.
|
|
14
23
|
def msg
|
|
15
|
-
|
|
24
|
+
"Successful semantic validation of #{@expression_node.type}."
|
|
16
25
|
end
|
|
17
26
|
|
|
18
27
|
def to_s
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'bel_parser/parsers/ast/node'
|
|
2
|
+
require_relative 'semantics_warning'
|
|
3
|
+
|
|
4
|
+
module BELParser
|
|
5
|
+
module Language
|
|
6
|
+
module Semantics
|
|
7
|
+
class SemanticsTypeWarning < SemanticsWarning
|
|
8
|
+
attr_reader :expected_type, :actual_type
|
|
9
|
+
|
|
10
|
+
def initialize(expression_node, expected_type, actual_type, spec)
|
|
11
|
+
super(expression_node, spec)
|
|
12
|
+
@expected_type = expected_type
|
|
13
|
+
@actual_type = actual_type
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_s
|
|
17
|
+
%(Expected #{expected_type} type, but saw #{actual_type} type.)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -5,6 +5,10 @@ module BELParser
|
|
|
5
5
|
module Specification
|
|
6
6
|
EMPTY_ARRAY = [].freeze
|
|
7
7
|
|
|
8
|
+
def version
|
|
9
|
+
@version
|
|
10
|
+
end
|
|
11
|
+
|
|
8
12
|
def function(short_or_long_form)
|
|
9
13
|
@indexed_functions[short_or_long_form]
|
|
10
14
|
end
|
|
@@ -17,6 +21,10 @@ module BELParser
|
|
|
17
21
|
@indexed_return_types[return_type]
|
|
18
22
|
end
|
|
19
23
|
|
|
24
|
+
def value_encoding(value_encoding)
|
|
25
|
+
@indexed_value_encodings[value_encoding]
|
|
26
|
+
end
|
|
27
|
+
|
|
20
28
|
def functions(*short_or_long_form)
|
|
21
29
|
if short_or_long_form.empty?
|
|
22
30
|
@functions.freeze
|
|
@@ -33,6 +41,18 @@ module BELParser
|
|
|
33
41
|
end
|
|
34
42
|
end
|
|
35
43
|
|
|
44
|
+
attr_reader :causal_relationships
|
|
45
|
+
attr_reader :correlative_relationships
|
|
46
|
+
attr_reader :decreasing_relationships
|
|
47
|
+
attr_reader :deprecated_relationships
|
|
48
|
+
attr_reader :direct_relationships
|
|
49
|
+
attr_reader :directed_relationships
|
|
50
|
+
attr_reader :genomic_relationships
|
|
51
|
+
attr_reader :increasing_relationships
|
|
52
|
+
attr_reader :indirect_relationships
|
|
53
|
+
attr_reader :listable_relationships
|
|
54
|
+
attr_reader :self_relationships
|
|
55
|
+
|
|
36
56
|
def return_types(*return_types)
|
|
37
57
|
if return_types.empty?
|
|
38
58
|
@return_types.freeze
|
|
@@ -41,54 +61,6 @@ module BELParser
|
|
|
41
61
|
end
|
|
42
62
|
end
|
|
43
63
|
|
|
44
|
-
def syntax
|
|
45
|
-
@syntax
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def causal_relationships
|
|
49
|
-
@causal_relationships || EMPTY_ARRAY
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def correlative_relationships
|
|
53
|
-
@correlative_relationships || EMPTY_ARRAY
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def decreasing_relationships
|
|
57
|
-
@decreasing_relationships || EMPTY_ARRAY
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def deprecated_relationships
|
|
61
|
-
@deprecated_relationships || EMPTY_ARRAY
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def direct_relationships
|
|
65
|
-
@direct_relationships || EMPTY_ARRAY
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def directed_relationships
|
|
69
|
-
@directed_relationships || EMPTY_ARRAY
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def genomic_relationships
|
|
73
|
-
@genomic_relationships || EMPTY_ARRAY
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def increasing_relationships
|
|
77
|
-
@increasing_relationships || EMPTY_ARRAY
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def indirect_relationships
|
|
81
|
-
@indirect_relationships || EMPTY_ARRAY
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def listable_relationships
|
|
85
|
-
@listable_relationships || EMPTY_ARRAY
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def self_relationships
|
|
89
|
-
@self_relationships || EMPTY_ARRAY
|
|
90
|
-
end
|
|
91
|
-
|
|
92
64
|
# @param [Array<#long,#short>] language_objects to be indexed by
|
|
93
65
|
# +long+ and +short+ method return
|
|
94
66
|
def index_long_short(language_objects)
|
|
@@ -116,19 +88,30 @@ module BELParser
|
|
|
116
88
|
rel.methods(false).grep(/(.*?)\?/) do |method_name|
|
|
117
89
|
if rel.method(method_name).call
|
|
118
90
|
category = method_name.to_s.delete('?')
|
|
119
|
-
|
|
120
|
-
unless instance_variable_defined? category_ivar
|
|
121
|
-
instance_variable_set(category_ivar, [])
|
|
122
|
-
end
|
|
123
|
-
instance_variable_get(category_ivar) << rel
|
|
91
|
+
add_relationship_to_category(rel, category)
|
|
124
92
|
end
|
|
125
93
|
end
|
|
126
94
|
end
|
|
95
|
+
|
|
96
|
+
freeze_categories
|
|
97
|
+
nil
|
|
127
98
|
end
|
|
128
99
|
protected :assign_relationship_categories
|
|
129
100
|
|
|
130
|
-
def
|
|
131
|
-
|
|
101
|
+
def add_relationship_to_category(relationship, category)
|
|
102
|
+
category_ivar = "@#{category}_relationships".to_sym
|
|
103
|
+
unless instance_variable_defined? category_ivar
|
|
104
|
+
instance_variable_set(category_ivar, [])
|
|
105
|
+
end
|
|
106
|
+
instance_variable_get(category_ivar) << relationship
|
|
107
|
+
end
|
|
108
|
+
private :add_relationship_to_category
|
|
109
|
+
|
|
110
|
+
def freeze_categories
|
|
111
|
+
instance_variables.each do |ivar|
|
|
112
|
+
next unless ivar.to_s =~ /@[a-zA-Z0-9]+_relationships/
|
|
113
|
+
instance_variable_set(ivar, instance_variable_get(ivar).freeze)
|
|
114
|
+
end
|
|
132
115
|
end
|
|
133
116
|
end
|
|
134
117
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'bel_parser/parsers/ast/node'
|
|
2
|
+
|
|
3
|
+
module BELParser
|
|
4
|
+
module Language
|
|
5
|
+
module Syntax
|
|
6
|
+
# Undefined namespace value finds values that are missing from their
|
|
7
|
+
# purported namespaces.
|
|
8
|
+
class UndefinedNamespaceValue
|
|
9
|
+
include SyntaxFunction
|
|
10
|
+
|
|
11
|
+
private_class_method :new
|
|
12
|
+
|
|
13
|
+
def self.map(value_node, spec, namespaces)
|
|
14
|
+
return nil unless value_node.is_a?(BELParser::Parsers::AST::Value)
|
|
15
|
+
return nil unless value_node.namespace
|
|
16
|
+
|
|
17
|
+
unless value_node.namespace_value
|
|
18
|
+
value = value_node.children[0].string_literal
|
|
19
|
+
UndefinedNamespaceValueWarning.new(value_node, spec, value)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# UndefinedNamespaceValueWarning indicates a value is missing from a
|
|
25
|
+
# namespace.
|
|
26
|
+
class UndefinedNamespaceValueWarning < SyntaxWarning
|
|
27
|
+
# Gets the undefined value.
|
|
28
|
+
attr_reader :undefined_value
|
|
29
|
+
|
|
30
|
+
def initialize(prefix_node, spec, undefined_value)
|
|
31
|
+
super(prefix_node, spec)
|
|
32
|
+
@undefined_value = undefined_value
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def msg
|
|
36
|
+
<<-MSG.gsub(/ {10}/, '')
|
|
37
|
+
Undefined namespace value "#{undefined_value}".
|
|
38
|
+
MSG
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -10,6 +10,14 @@ module BELParser
|
|
|
10
10
|
@specification = specification
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
def success?
|
|
14
|
+
true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def failure?
|
|
18
|
+
false
|
|
19
|
+
end
|
|
20
|
+
|
|
13
21
|
# @abstract Subclass and override {#msg} to provide the message.
|
|
14
22
|
def msg
|
|
15
23
|
raise NotImplementedError, "#{__method__} is not implemented."
|
|
@@ -6,11 +6,16 @@ module BELParser
|
|
|
6
6
|
# SyntaxWarning defines a {SyntaxResult} that should be regarded as an
|
|
7
7
|
# warning with the expression.
|
|
8
8
|
class SyntaxWarning < SyntaxResult
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def initialize(expression_node, specification, target_node)
|
|
9
|
+
def initialize(expression_node, specification)
|
|
12
10
|
super(expression_node, specification)
|
|
13
|
-
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def success?
|
|
14
|
+
false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def failure?
|
|
18
|
+
true
|
|
14
19
|
end
|
|
15
20
|
|
|
16
21
|
def to_s
|
|
@@ -14,6 +14,7 @@ module BELParser
|
|
|
14
14
|
SHORT = :a
|
|
15
15
|
LONG = :abundance
|
|
16
16
|
RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::Abundance
|
|
17
|
+
A_ENC = Version1_0::ValueEncodings::Abundance
|
|
17
18
|
DESCRIPTION = 'Denotes the abundance of an entity'.freeze
|
|
18
19
|
|
|
19
20
|
def self.short
|
|
@@ -51,13 +52,11 @@ module BELParser
|
|
|
51
52
|
argument(
|
|
52
53
|
parameter(
|
|
53
54
|
prefix(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
namespace_of(:*))),
|
|
55
|
+
has_namespace,
|
|
56
|
+
namespace_of(:*)),
|
|
57
57
|
value(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
encoding_of(:Abundance))))))
|
|
58
|
+
has_encoding,
|
|
59
|
+
encoding_of(A_ENC)))))
|
|
61
60
|
end
|
|
62
61
|
private_constant :AST
|
|
63
62
|
|
|
@@ -14,6 +14,7 @@ module BELParser
|
|
|
14
14
|
SHORT = :bp
|
|
15
15
|
LONG = :biologicalProcess
|
|
16
16
|
RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::BiologicalProcess
|
|
17
|
+
B_ENC = Version1_0::ValueEncodings::BiologicalProcess
|
|
17
18
|
DESCRIPTION = 'Denotes a process or population of events'.freeze
|
|
18
19
|
|
|
19
20
|
def self.short
|
|
@@ -51,13 +52,11 @@ module BELParser
|
|
|
51
52
|
argument(
|
|
52
53
|
parameter(
|
|
53
54
|
prefix(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
namespace_of(:*))),
|
|
55
|
+
has_namespace,
|
|
56
|
+
namespace_of(:*)),
|
|
57
57
|
value(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
encoding_of(:BiologicalProcess))))))
|
|
58
|
+
has_encoding,
|
|
59
|
+
encoding_of(B_ENC)))))
|
|
61
60
|
end
|
|
62
61
|
private_constant :AST
|
|
63
62
|
|
|
@@ -14,6 +14,7 @@ module BELParser
|
|
|
14
14
|
SHORT = :complex
|
|
15
15
|
LONG = :complexAbundance
|
|
16
16
|
RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::ComplexAbundance
|
|
17
|
+
C_ENC = Version1_0::ValueEncodings::ComplexAbundance
|
|
17
18
|
DESCRIPTION = 'Denotes the abundance of a molecular
|
|
18
19
|
omplex'.freeze
|
|
19
20
|
|
|
@@ -52,17 +53,15 @@ module BELParser
|
|
|
52
53
|
argument(
|
|
53
54
|
parameter(
|
|
54
55
|
prefix(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
namespace_of(:*))),
|
|
56
|
+
has_namespace,
|
|
57
|
+
namespace_of(:*)),
|
|
58
58
|
value(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
encoding_of(:Abundance))))))
|
|
59
|
+
has_encoding,
|
|
60
|
+
encoding_of(C_ENC)))))
|
|
62
61
|
end
|
|
63
62
|
private_constant :AST
|
|
64
63
|
|
|
65
|
-
STRING_FORM = 'complexAbundance(E:
|
|
64
|
+
STRING_FORM = 'complexAbundance(E:complexAbundance)complexAbundance'.freeze
|
|
66
65
|
private_constant :STRING_FORM
|
|
67
66
|
|
|
68
67
|
def self.semantic_ast
|