bel_parser 1.0.0.alpha.1 → 1.0.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.gemspec +1 -1
  3. data/VERSION +1 -1
  4. data/bin/bel2_termcheck +2 -2
  5. data/lib/bel_parser/expression/term_semantics.rb +2 -2
  6. data/lib/bel_parser/language/expression_validator.rb +42 -0
  7. data/lib/bel_parser/language/function.rb +8 -0
  8. data/lib/bel_parser/language/relationship.rb +57 -0
  9. data/lib/bel_parser/language/{semantic_ast.rb → semantics/semantic_ast.rb} +5 -27
  10. data/lib/bel_parser/language/semantics/semantic_match.rb +28 -0
  11. data/lib/bel_parser/language/semantics.rb +2 -0
  12. data/lib/bel_parser/language/specification.rb +34 -10
  13. data/lib/bel_parser/language/syntax.rb +0 -0
  14. data/lib/bel_parser/language/{version1 → version1_0}/functions/abundance.rb +4 -4
  15. data/lib/bel_parser/language/{version1 → version1_0}/functions/biological_process.rb +4 -4
  16. data/lib/bel_parser/language/{version1 → version1_0}/functions/catalytic_activity.rb +6 -6
  17. data/lib/bel_parser/language/{version1 → version1_0}/functions/cell_secretion.rb +5 -5
  18. data/lib/bel_parser/language/{version1 → version1_0}/functions/cell_surface_expression.rb +5 -5
  19. data/lib/bel_parser/language/{version1 → version1_0}/functions/chaperone_activity.rb +6 -6
  20. data/lib/bel_parser/language/{version1 → version1_0}/functions/complex_abundance.rb +5 -5
  21. data/lib/bel_parser/language/{version1 → version1_0}/functions/composite_abundance.rb +5 -5
  22. data/lib/bel_parser/language/{version1 → version1_0}/functions/degradation.rb +5 -5
  23. data/lib/bel_parser/language/{version1 → version1_0}/functions/fusion.rb +4 -4
  24. data/lib/bel_parser/language/{version1 → version1_0}/functions/gene_abundance.rb +5 -5
  25. data/lib/bel_parser/language/{version1 → version1_0}/functions/gtp_bound_activity.rb +6 -6
  26. data/lib/bel_parser/language/{version1 → version1_0}/functions/kinase_activity.rb +6 -6
  27. data/lib/bel_parser/language/{version1 → version1_0}/functions/list.rb +5 -5
  28. data/lib/bel_parser/language/{version1 → version1_0}/functions/micro_rna_abundance.rb +4 -4
  29. data/lib/bel_parser/language/{version1 → version1_0}/functions/molecular_activity.rb +5 -5
  30. data/lib/bel_parser/language/{version2 → version1_0}/functions/pathology.rb +4 -4
  31. data/lib/bel_parser/language/{version1 → version1_0}/functions/peptidase_activity.rb +6 -6
  32. data/lib/bel_parser/language/{version1 → version1_0}/functions/phosphatase_activity.rb +6 -6
  33. data/lib/bel_parser/language/{version2 → version1_0}/functions/products.rb +5 -5
  34. data/lib/bel_parser/language/{version1 → version1_0}/functions/protein_abundance.rb +8 -8
  35. data/lib/bel_parser/language/{version1 → version1_0}/functions/protein_modification.rb +4 -4
  36. data/lib/bel_parser/language/{version2 → version1_0}/functions/reactants.rb +5 -5
  37. data/lib/bel_parser/language/{version1 → version1_0}/functions/reaction.rb +6 -6
  38. data/lib/bel_parser/language/{version1 → version1_0}/functions/ribosylation_activity.rb +6 -6
  39. data/lib/bel_parser/language/{version1 → version1_0}/functions/rna_abundance.rb +5 -5
  40. data/lib/bel_parser/language/{version1 → version1_0}/functions/substitution.rb +4 -4
  41. data/lib/bel_parser/language/{version1 → version1_0}/functions/transcriptional_activity.rb +6 -6
  42. data/lib/bel_parser/language/{version1 → version1_0}/functions/translocation.rb +5 -5
  43. data/lib/bel_parser/language/{version1 → version1_0}/functions/transport_activity.rb +6 -6
  44. data/lib/bel_parser/language/{version1 → version1_0}/functions/truncation.rb +4 -4
  45. data/lib/bel_parser/language/version1_0/relationships/acts_in.rb +31 -0
  46. data/lib/bel_parser/language/version1_0/relationships/analogous.rb +31 -0
  47. data/lib/bel_parser/language/version1_0/relationships/association.rb +31 -0
  48. data/lib/bel_parser/language/version1_0/relationships/biomarker_for.rb +31 -0
  49. data/lib/bel_parser/language/version1_0/relationships/causes_no_change.rb +31 -0
  50. data/lib/bel_parser/language/version1_0/relationships/decreases.rb +31 -0
  51. data/lib/bel_parser/language/version1_0/relationships/directly_decreases.rb +31 -0
  52. data/lib/bel_parser/language/version1_0/relationships/directly_increases.rb +31 -0
  53. data/lib/bel_parser/language/version1_0/relationships/has_component.rb +31 -0
  54. data/lib/bel_parser/language/version1_0/relationships/has_components.rb +31 -0
  55. data/lib/bel_parser/language/version1_0/relationships/has_member.rb +31 -0
  56. data/lib/bel_parser/language/version1_0/relationships/has_members.rb +31 -0
  57. data/lib/bel_parser/language/version1_0/relationships/has_modification.rb +31 -0
  58. data/lib/bel_parser/language/version1_0/relationships/has_product.rb +31 -0
  59. data/lib/bel_parser/language/version1_0/relationships/has_variant.rb +31 -0
  60. data/lib/bel_parser/language/version1_0/relationships/includes.rb +31 -0
  61. data/lib/bel_parser/language/version1_0/relationships/increases.rb +31 -0
  62. data/lib/bel_parser/language/version1_0/relationships/is_a.rb +31 -0
  63. data/lib/bel_parser/language/version1_0/relationships/negative_correlation.rb +31 -0
  64. data/lib/bel_parser/language/version1_0/relationships/orthologous.rb +31 -0
  65. data/lib/bel_parser/language/version1_0/relationships/positive_correlation.rb +31 -0
  66. data/lib/bel_parser/language/version1_0/relationships/prognostic_biomarker_for.rb +31 -0
  67. data/lib/bel_parser/language/version1_0/relationships/rate_limiting_step_of.rb +31 -0
  68. data/lib/bel_parser/language/version1_0/relationships/reactant_in.rb +31 -0
  69. data/lib/bel_parser/language/version1_0/relationships/sub_process_of.rb +31 -0
  70. data/lib/bel_parser/language/version1_0/relationships/transcribed_to.rb +31 -0
  71. data/lib/bel_parser/language/version1_0/relationships/translated_to.rb +31 -0
  72. data/lib/bel_parser/language/version1_0/relationships/translocates.rb +31 -0
  73. data/lib/bel_parser/language/{version2 → version1_0}/return_types/abundance.rb +1 -1
  74. data/lib/bel_parser/language/{version1 → version1_0}/return_types/any.rb +1 -1
  75. data/lib/bel_parser/language/{version1 → version1_0}/return_types/biological_process.rb +1 -1
  76. data/lib/bel_parser/language/{version1 → version1_0}/return_types/catalytic_activity.rb +1 -1
  77. data/lib/bel_parser/language/{version1 → version1_0}/return_types/chaperone_activity.rb +1 -1
  78. data/lib/bel_parser/language/{version2 → version1_0}/return_types/complex_abundance.rb +1 -1
  79. data/lib/bel_parser/language/{version1 → version1_0}/return_types/fusion.rb +1 -1
  80. data/lib/bel_parser/language/{version2 → version1_0}/return_types/gene_abundance.rb +1 -1
  81. data/lib/bel_parser/language/{version1 → version1_0}/return_types/gtp_bound_activity.rb +1 -1
  82. data/lib/bel_parser/language/{version1 → version1_0}/return_types/kinase_activity.rb +1 -1
  83. data/lib/bel_parser/language/{version1 → version1_0}/return_types/list.rb +1 -1
  84. data/lib/bel_parser/language/{version1 → version1_0}/return_types/micro_rna_abundance.rb +1 -1
  85. data/lib/bel_parser/language/{version1 → version1_0}/return_types/molecular_activity.rb +1 -1
  86. data/lib/bel_parser/language/{version1 → version1_0}/return_types/pathology.rb +1 -1
  87. data/lib/bel_parser/language/{version1 → version1_0}/return_types/peptidase_activity.rb +1 -1
  88. data/lib/bel_parser/language/{version1 → version1_0}/return_types/phosphatase_activity.rb +1 -1
  89. data/lib/bel_parser/language/{version2 → version1_0}/return_types/products.rb +1 -1
  90. data/lib/bel_parser/language/{version2 → version1_0}/return_types/protein_abundance.rb +1 -1
  91. data/lib/bel_parser/language/{version1 → version1_0}/return_types/protein_modification.rb +1 -1
  92. data/lib/bel_parser/language/{version2 → version1_0}/return_types/reactants.rb +1 -1
  93. data/lib/bel_parser/language/{version1 → version1_0}/return_types/ribosylation_activity.rb +1 -1
  94. data/lib/bel_parser/language/{version1 → version1_0}/return_types/rna_abundance.rb +1 -1
  95. data/lib/bel_parser/language/{version1 → version1_0}/return_types/substitution.rb +1 -1
  96. data/lib/bel_parser/language/{version1 → version1_0}/return_types/transcriptional_activity.rb +1 -1
  97. data/lib/bel_parser/language/{version1 → version1_0}/return_types/transport_activity.rb +1 -1
  98. data/lib/bel_parser/language/{version1 → version1_0}/return_types/truncation.rb +1 -1
  99. data/lib/bel_parser/language/version1_0/syntax/function.rb +29 -0
  100. data/lib/bel_parser/language/version1_0.rb +89 -0
  101. data/lib/bel_parser/language/{version2 → version2_0}/functions/abundance.rb +6 -6
  102. data/lib/bel_parser/language/{version2 → version2_0}/functions/activity.rb +7 -7
  103. data/lib/bel_parser/language/{version2 → version2_0}/functions/biological_process.rb +4 -4
  104. data/lib/bel_parser/language/{version2 → version2_0}/functions/cell_secretion.rb +5 -5
  105. data/lib/bel_parser/language/{version2 → version2_0}/functions/cell_surface_expression.rb +5 -5
  106. data/lib/bel_parser/language/{version2 → version2_0}/functions/complex_abundance.rb +8 -8
  107. data/lib/bel_parser/language/{version2 → version2_0}/functions/composite_abundance.rb +5 -5
  108. data/lib/bel_parser/language/{version2 → version2_0}/functions/degradation.rb +5 -5
  109. data/lib/bel_parser/language/{version2 → version2_0}/functions/fragment.rb +4 -4
  110. data/lib/bel_parser/language/{version2 → version2_0}/functions/from_location.rb +4 -4
  111. data/lib/bel_parser/language/{version2 → version2_0}/functions/fusion.rb +4 -4
  112. data/lib/bel_parser/language/{version2 → version2_0}/functions/gene_abundance.rb +7 -7
  113. data/lib/bel_parser/language/{version2 → version2_0}/functions/list.rb +5 -5
  114. data/lib/bel_parser/language/{version2 → version2_0}/functions/location.rb +4 -4
  115. data/lib/bel_parser/language/{version2 → version2_0}/functions/micro_rna_abundance.rb +6 -6
  116. data/lib/bel_parser/language/{version2 → version2_0}/functions/molecular_activity.rb +4 -4
  117. data/lib/bel_parser/language/{version1 → version2_0}/functions/pathology.rb +4 -4
  118. data/lib/bel_parser/language/{version1 → version2_0}/functions/products.rb +5 -5
  119. data/lib/bel_parser/language/{version2 → version2_0}/functions/protein_abundance.rb +9 -9
  120. data/lib/bel_parser/language/{version2 → version2_0}/functions/protein_modification.rb +7 -7
  121. data/lib/bel_parser/language/{version1 → version2_0}/functions/reactants.rb +5 -5
  122. data/lib/bel_parser/language/{version2 → version2_0}/functions/reaction.rb +6 -6
  123. data/lib/bel_parser/language/{version2 → version2_0}/functions/rna_abundance.rb +11 -11
  124. data/lib/bel_parser/language/{version2 → version2_0}/functions/to_location.rb +4 -4
  125. data/lib/bel_parser/language/{version2 → version2_0}/functions/translocation.rb +8 -8
  126. data/lib/bel_parser/language/{version2 → version2_0}/functions/variant.rb +4 -4
  127. data/lib/bel_parser/language/version2_0/relationships/acts_in.rb +31 -0
  128. data/lib/bel_parser/language/version2_0/relationships/analogous.rb +35 -0
  129. data/lib/bel_parser/language/version2_0/relationships/association.rb +31 -0
  130. data/lib/bel_parser/language/version2_0/relationships/biomarker_for.rb +35 -0
  131. data/lib/bel_parser/language/version2_0/relationships/causes_no_change.rb +31 -0
  132. data/lib/bel_parser/language/version2_0/relationships/decreases.rb +31 -0
  133. data/lib/bel_parser/language/version2_0/relationships/directly_decreases.rb +31 -0
  134. data/lib/bel_parser/language/version2_0/relationships/directly_increases.rb +31 -0
  135. data/lib/bel_parser/language/version2_0/relationships/has_component.rb +31 -0
  136. data/lib/bel_parser/language/version2_0/relationships/has_components.rb +31 -0
  137. data/lib/bel_parser/language/version2_0/relationships/has_member.rb +31 -0
  138. data/lib/bel_parser/language/version2_0/relationships/has_members.rb +31 -0
  139. data/lib/bel_parser/language/version2_0/relationships/has_modification.rb +31 -0
  140. data/lib/bel_parser/language/version2_0/relationships/has_product.rb +31 -0
  141. data/lib/bel_parser/language/version2_0/relationships/has_variant.rb +31 -0
  142. data/lib/bel_parser/language/version2_0/relationships/includes.rb +31 -0
  143. data/lib/bel_parser/language/version2_0/relationships/increases.rb +31 -0
  144. data/lib/bel_parser/language/version2_0/relationships/is_a.rb +31 -0
  145. data/lib/bel_parser/language/version2_0/relationships/negative_correlation.rb +31 -0
  146. data/lib/bel_parser/language/version2_0/relationships/orthologous.rb +31 -0
  147. data/lib/bel_parser/language/version2_0/relationships/positive_correlation.rb +31 -0
  148. data/lib/bel_parser/language/version2_0/relationships/prognostic_biomarker_for.rb +35 -0
  149. data/lib/bel_parser/language/version2_0/relationships/rate_limiting_step_of.rb +31 -0
  150. data/lib/bel_parser/language/version2_0/relationships/reactant_in.rb +31 -0
  151. data/lib/bel_parser/language/version2_0/relationships/regulates.rb +31 -0
  152. data/lib/bel_parser/language/version2_0/relationships/sub_process_of.rb +31 -0
  153. data/lib/bel_parser/language/version2_0/relationships/transcribed_to.rb +31 -0
  154. data/lib/bel_parser/language/version2_0/relationships/translated_to.rb +31 -0
  155. data/lib/bel_parser/language/version2_0/relationships/translocates.rb +31 -0
  156. data/lib/bel_parser/language/{version1 → version2_0}/return_types/abundance.rb +1 -1
  157. data/lib/bel_parser/language/{version2 → version2_0}/return_types/activity.rb +1 -1
  158. data/lib/bel_parser/language/{version2 → version2_0}/return_types/any.rb +1 -1
  159. data/lib/bel_parser/language/{version2 → version2_0}/return_types/biological_process.rb +1 -1
  160. data/lib/bel_parser/language/{version1 → version2_0}/return_types/complex_abundance.rb +1 -1
  161. data/lib/bel_parser/language/{version2 → version2_0}/return_types/fragment.rb +1 -1
  162. data/lib/bel_parser/language/{version2 → version2_0}/return_types/from_location.rb +1 -1
  163. data/lib/bel_parser/language/{version2 → version2_0}/return_types/fusion.rb +1 -1
  164. data/lib/bel_parser/language/{version1 → version2_0}/return_types/gene_abundance.rb +1 -1
  165. data/lib/bel_parser/language/{version2 → version2_0}/return_types/list.rb +1 -1
  166. data/lib/bel_parser/language/{version2 → version2_0}/return_types/location.rb +1 -1
  167. data/lib/bel_parser/language/{version2 → version2_0}/return_types/micro_rna_abundance.rb +1 -1
  168. data/lib/bel_parser/language/{version2 → version2_0}/return_types/molecular_activity.rb +1 -1
  169. data/lib/bel_parser/language/{version2 → version2_0}/return_types/pathology.rb +1 -1
  170. data/lib/bel_parser/language/{version1 → version2_0}/return_types/products.rb +1 -1
  171. data/lib/bel_parser/language/{version1 → version2_0}/return_types/protein_abundance.rb +1 -1
  172. data/lib/bel_parser/language/{version2 → version2_0}/return_types/protein_modification.rb +1 -1
  173. data/lib/bel_parser/language/{version1 → version2_0}/return_types/reactants.rb +1 -1
  174. data/lib/bel_parser/language/{version2 → version2_0}/return_types/rna_abundance.rb +1 -1
  175. data/lib/bel_parser/language/{version2 → version2_0}/return_types/to_location.rb +1 -1
  176. data/lib/bel_parser/language/{version2 → version2_0}/return_types/variant.rb +1 -1
  177. data/lib/bel_parser/language/version2_0.rb +73 -0
  178. data/lib/bel_parser/language.rb +90 -2
  179. data/lib/bel_parser/parsers/ast/node.rb +11 -1
  180. metadata +172 -111
  181. data/lib/bel_parser/language/syntax/expression/incomplete_node.rb +0 -14
  182. data/lib/bel_parser/language/syntax/expression/invalid_term_function.rb +0 -22
  183. data/lib/bel_parser/language/version1.rb +0 -50
  184. data/lib/bel_parser/language/version2.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fda715b53e000aa7ea548ec0431879d74daac35d
4
- data.tar.gz: 303d2234ea34a28ee8b2aba781ff56793930b538
3
+ metadata.gz: 90ab686251113e217ed255a26b59b00aa9b6a947
4
+ data.tar.gz: 87f55444534d215b579b4aec8d657cf38479ae1b
5
5
  SHA512:
6
- metadata.gz: 9b4c279634441ef4ade6533780ce72be49e66ec94b43366eb576a95dc08eca2faf34b6c66b71b91d716f5c361ba88e2034ac846c0dcfa4a40527a2104c0249f6
7
- data.tar.gz: 5805beb91805a090d87e4130b7dd248ab1b589ad7c770759e688884642523257f266756da326fd525cb94f5daea09879ed5a77be41fabe32c445e1cbce84e18e
6
+ metadata.gz: 959bbb33f76a1888cabec4bc7bef6a00c130a45aeeac7a175e550403e2b14a78c9f75d147208e500a4aa400d5562e08d42a7733a6f53db38b688d0ba0c85a4e4
7
+ data.tar.gz: 4c43a80f6ad4263753a5e49d76e6bbb57237a32cb61cb6af3dc8349a417ca2d049df3b18af9f1fddfedc3ff89b5e4bc2f7661b39a751aed790eae0dd596ef4b7
data/.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  'Anthony Bargnesi',
12
12
  'Nick Bargnesi',
13
13
  ]
14
- spec.date = %q{2016-04-05}
14
+ spec.date = %q{2016-04-08}
15
15
  spec.email = %q{abargnesi@selventa.com}
16
16
  spec.files = [
17
17
  Dir.glob('lib/**/*.{rb,rl}'),
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.1
1
+ 1.0.0.alpha.2
data/bin/bel2_termcheck CHANGED
@@ -2,7 +2,7 @@
2
2
  $:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
3
3
 
4
4
  require 'bel_parser'
5
- require 'bel_parser/language/version2'
5
+ require 'bel_parser/language/version2_0'
6
6
  require 'bel_parser/language/semantics/analyzer'
7
7
 
8
8
  module BELParser
@@ -16,7 +16,7 @@ module BELParser
16
16
 
17
17
  def each(io)
18
18
  if block_given?
19
- v2 = BELParser::Language::Version2::Specification.new
19
+ v2 = BELParser::Language::Version2_0::Specification.new
20
20
  filtered_ast = FILTER.each(BELParser::ASTGenerator.new.each(io))
21
21
  filtered_ast.each do |results|
22
22
  term = results.last.first
@@ -1,7 +1,7 @@
1
1
  require_relative '../ast_filter'
2
2
  require_relative '../ast_generator'
3
3
  require_relative '../parsers/expression'
4
- require_relative '../language/version2'
4
+ require_relative '../language/version2_0'
5
5
  require_relative '../language/semantics/analyzer'
6
6
 
7
7
  module BELParser
@@ -15,7 +15,7 @@ module BELParser
15
15
 
16
16
  def each(io)
17
17
  if block_given?
18
- v2 = BELParser::Language::Version2::Specification.new
18
+ v2 = BELParser::Language::Version2_0::Specification.new
19
19
  filtered_ast = FILTER.each(BELParser::ASTGenerator.new.each(io))
20
20
  filtered_ast.each do |results|
21
21
  term = results.last.first
@@ -0,0 +1,42 @@
1
+ module BELParser
2
+ module Language
3
+ class ExpressionValidator
4
+ def initialize(spec)
5
+ @spec = spec
6
+ end
7
+
8
+ def validate(expression_ast)
9
+ node_errors = check_syntax(expression_ast)
10
+ if !node_errors.empty?
11
+ node_errors.each do |node_error|
12
+ puts "Syntax error (#{node_error.syntax_errors}) with #{node_error.type}."
13
+ end
14
+ else
15
+ check_semantics(expression_ast)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def check_syntax(ast)
22
+ # Clear syntax checks.
23
+ ast.traverse.each do |node|
24
+ node.syntax_errors.clear
25
+ end
26
+
27
+ # Run syntax checks, sets syntax_errors on nodes.
28
+ @spec.syntax.each do |syntax|
29
+ syntax.match(ast)
30
+ end
31
+
32
+ ast.traverse.select do |node|
33
+ !node.syntax_errors.empty?
34
+ end
35
+ end
36
+
37
+ def check_semantics(ast)
38
+ BELParser::Language::Semantics.check_term(ast, @spec)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -27,6 +27,14 @@ module BELParser
27
27
  raise NotImplementedError, "#{__method__} is not implemented."
28
28
  end
29
29
 
30
+ # Indicates whether this function is deprecated. Override in your
31
+ # function to mark as deprecated.
32
+ #
33
+ # @return [Boolean] false
34
+ def deprecated?
35
+ false
36
+ end
37
+
30
38
  def ===(other)
31
39
  return false if other.nil?
32
40
  short == other || long == other
@@ -0,0 +1,57 @@
1
+ module BELParser
2
+ module Language
3
+ # Relationship allows you to describe the type of BEL Relationship.
4
+ #
5
+ # BEL Relationships represent an interaction between a subject and object
6
+ # in the BEL expression.
7
+ module Relationship
8
+ def short
9
+ raise NotImplementedError, "#{__method__} is not implemented."
10
+ end
11
+
12
+ def long
13
+ raise NotImplementedError, "#{__method__} is not implemented."
14
+ end
15
+
16
+ def description
17
+ raise NotImplementedError, "#{__method__} is not implemented."
18
+ end
19
+
20
+ # Indicates whether this relationship is deprecated. Override in your
21
+ # relationship to mark as deprecated.
22
+ #
23
+ # @return [Boolean] false
24
+ def deprecated?
25
+ false
26
+ end
27
+
28
+ def ===(other)
29
+ return false if other.nil?
30
+ short == other || long == other
31
+ end
32
+
33
+ def to_sym(form = :short)
34
+ value = _form_value(form)
35
+ return nil unless value
36
+ value.to_s
37
+ end
38
+
39
+ def to_s(form = :short)
40
+ value = _form_value(form)
41
+ return nil unless value
42
+ value.to_s
43
+ end
44
+
45
+ private
46
+
47
+ def _form_value(form = :short)
48
+ case form
49
+ when :short
50
+ short
51
+ when :long
52
+ long
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,5 +1,6 @@
1
- require_relative 'quoting'
2
- require_relative '../parsers/ast/node'
1
+ require_relative 'semantic_match'
2
+ require_relative '../quoting'
3
+ require_relative '../../parsers/ast/node'
3
4
 
4
5
  module BELParser
5
6
  module Language
@@ -49,29 +50,6 @@ module BELParser
49
50
  match_results.flatten
50
51
  end
51
52
 
52
- # MatchResult holds the results of an input AST to semantic AST match.
53
- class MatchResult
54
- attr_reader :input_node, :semantic_node
55
-
56
- def initialize(success, input_node, semantic_node)
57
- @success = success
58
- @input_node = input_node
59
- @semantic_node = semantic_node
60
- end
61
-
62
- def success?
63
- @success
64
- end
65
-
66
- def failure?
67
- !@success
68
- end
69
-
70
- def to_s
71
- msg
72
- end
73
- end
74
-
75
53
  # Builder contains methods to build semantic AST nodes.
76
54
  # A convenient {Builder.build} method allows you to use these
77
55
  # methods within a block scope.
@@ -211,11 +189,11 @@ module BELParser
211
189
  end
212
190
 
213
191
  def success(node)
214
- [MatchResult.new(true, node, self)]
192
+ [SemanticMatch.new(true, node, self)]
215
193
  end
216
194
 
217
195
  def failure(node)
218
- [MatchResult.new(false, node, self)]
196
+ [SemanticMatch.new(false, node, self)]
219
197
  end
220
198
  end
221
199
 
@@ -0,0 +1,28 @@
1
+ module BELParser
2
+ module Language
3
+ module Semantics
4
+ # SemanticMatch holds the results of an input AST to semantic AST match.
5
+ class SemanticMatch
6
+ attr_reader :input_node, :semantic_node
7
+
8
+ def initialize(success, input_node, semantic_node)
9
+ @success = success
10
+ @input_node = input_node
11
+ @semantic_node = semantic_node
12
+ end
13
+
14
+ def success?
15
+ @success
16
+ end
17
+
18
+ def failure?
19
+ !@success
20
+ end
21
+
22
+ def to_s
23
+ msg
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'semantics/semantic_ast'
2
+ require_relative 'semantics/analyzer'
@@ -7,43 +7,67 @@ module BELParser
7
7
  @indexed_functions[short_or_long_form]
8
8
  end
9
9
 
10
+ def relationship(short_or_long_form)
11
+ @indexed_relationships[short_or_long_form]
12
+ end
13
+
10
14
  def return_type(return_type)
11
15
  @indexed_return_types[return_type]
12
16
  end
13
17
 
14
18
  def functions(*short_or_long_form)
15
19
  if short_or_long_form.empty?
16
- @functions
20
+ @functions.freeze
17
21
  else
18
22
  @indexed_functions.values_at(*short_or_long_form)
19
23
  end
20
24
  end
21
25
 
26
+ def relationships(*short_or_long_form)
27
+ if short_or_long_form.empty?
28
+ @relationships.freeze
29
+ else
30
+ @indexed_relationships.values_at(*short_or_long_form)
31
+ end
32
+ end
33
+
22
34
  def return_types(*return_types)
23
35
  if return_types.empty?
24
- @return_types
36
+ @return_types.freeze
25
37
  else
26
38
  @indexed_return_types.values_at(*return_types)
27
39
  end
28
40
  end
29
41
 
30
- def index_functions(functions)
42
+ def syntax
43
+ @syntax
44
+ end
45
+
46
+ # @param [Array<#long,#short>] language_objects to be indexed by
47
+ # +long+ and +short+ method return
48
+ def index_long_short(language_objects)
31
49
  Hash[
32
- functions.flat_map do |function|
33
- [[function.short, function], [function.long, function]]
50
+ language_objects.flat_map do |obj|
51
+ [[obj.short, obj], [obj.long, obj]]
34
52
  end
35
53
  ]
36
54
  end
37
- protected :index_functions
55
+ protected :index_long_short
38
56
 
39
- def index_return_types(return_types)
57
+ # @param [Array<#to_sym>] language_objects to be indexed by
58
+ # +to_sym+ method return
59
+ def index_sym(language_objects)
40
60
  Hash[
41
- return_types.map do |return_type|
42
- [return_type.to_sym, return_type]
61
+ language_objects.map do |obj|
62
+ [obj.to_sym, obj]
43
63
  end
44
64
  ]
45
65
  end
46
- protected :index_return_types
66
+ protected :index_sym
67
+
68
+ def version
69
+ @version
70
+ end
47
71
  end
48
72
  end
49
73
  end
File without changes
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # Abundance: Denotes the abundance of an entity
11
11
  class Abundance
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :a
15
15
  LONG = :abundance
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::Abundance
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::Abundance
17
17
  DESCRIPTION = 'Denotes the abundance of an entity'.freeze
18
18
 
19
19
  def self.short
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # BiologicalProcess: Denotes a process or population of events
11
11
  class BiologicalProcess
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :bp
15
15
  LONG = :biologicalProcess
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::BiologicalProcess
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::BiologicalProcess
17
17
  DESCRIPTION = 'Denotes a process or population of events'.freeze
18
18
 
19
19
  def self.short
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # CatalyticActivity: Denotes the frequency or abundance of events where a member acts as an enzymatic catalyst of biochecmial reactions
11
11
  class CatalyticActivity
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :cat
15
15
  LONG = :catalyticActivity
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::CatalyticActivity
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::CatalyticActivity
17
17
  DESCRIPTION = 'Denotes the frequency or abundance of events where a member acts as an enzymatic catalyst of biochecmial reactions'.freeze
18
18
 
19
19
  def self.short
@@ -52,7 +52,7 @@ module BELParser
52
52
  term(
53
53
  function(
54
54
  identifier(
55
- return_type_of(BELParser::Language::Version1::ReturnTypes::ComplexAbundance))))))
55
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::ComplexAbundance))))))
56
56
  end
57
57
  private_constant :AST
58
58
 
@@ -82,7 +82,7 @@ module BELParser
82
82
  term(
83
83
  function(
84
84
  identifier(
85
- return_type_of(BELParser::Language::Version1::ReturnTypes::ProteinAbundance))))))
85
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::ProteinAbundance))))))
86
86
  end
87
87
  private_constant :AST
88
88
 
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # CellSecretion: Denotes the frequency or abundance of events in which members of an abundance move from cells to regions outside of the cells
11
11
  class CellSecretion
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :sec
15
15
  LONG = :cellSecretion
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::Abundance
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::Abundance
17
17
  DESCRIPTION = 'Denotes the frequency or abundance of events in which members of an abundance move from cells to regions outside of the cells'.freeze
18
18
 
19
19
  def self.short
@@ -52,7 +52,7 @@ module BELParser
52
52
  term(
53
53
  function(
54
54
  identifier(
55
- return_type_of(BELParser::Language::Version1::ReturnTypes::Abundance))))))
55
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::Abundance))))))
56
56
  end
57
57
  private_constant :AST
58
58
 
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # CellSurfaceExpression: Denotes the frequency or abundance of events in which members of an abundance move to the surface of cells
11
11
  class CellSurfaceExpression
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :surf
15
15
  LONG = :cellSurfaceExpression
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::Abundance
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::Abundance
17
17
  DESCRIPTION = 'Denotes the frequency or abundance of events in which members of an abundance move to the surface of cells'.freeze
18
18
 
19
19
  def self.short
@@ -52,7 +52,7 @@ module BELParser
52
52
  term(
53
53
  function(
54
54
  identifier(
55
- return_type_of(BELParser::Language::Version1::ReturnTypes::Abundance))))))
55
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::Abundance))))))
56
56
  end
57
57
  private_constant :AST
58
58
 
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # ChaperoneActivity: Denotes the frequency or abundance of events in which a member binds to some substrate and acts as a chaperone for the substrate
11
11
  class ChaperoneActivity
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :chap
15
15
  LONG = :chaperoneActivity
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::ChaperoneActivity
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::ChaperoneActivity
17
17
  DESCRIPTION = 'Denotes the frequency or abundance of events in which a member binds to some substrate and acts as a chaperone for the substrate'.freeze
18
18
 
19
19
  def self.short
@@ -52,7 +52,7 @@ module BELParser
52
52
  term(
53
53
  function(
54
54
  identifier(
55
- return_type_of(BELParser::Language::Version1::ReturnTypes::ComplexAbundance))))))
55
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::ComplexAbundance))))))
56
56
  end
57
57
  private_constant :AST
58
58
 
@@ -82,7 +82,7 @@ module BELParser
82
82
  term(
83
83
  function(
84
84
  identifier(
85
- return_type_of(BELParser::Language::Version1::ReturnTypes::ProteinAbundance))))))
85
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::ProteinAbundance))))))
86
86
  end
87
87
  private_constant :AST
88
88
 
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # ComplexAbundance: Denotes the abundance of a molecular complex
11
11
  class ComplexAbundance
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :complex
15
15
  LONG = :complexAbundance
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::ComplexAbundance
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::ComplexAbundance
17
17
  DESCRIPTION = 'Denotes the abundance of a molecular complex'.freeze
18
18
 
19
19
  def self.short
@@ -87,7 +87,7 @@ module BELParser
87
87
  term(
88
88
  function(
89
89
  identifier(
90
- return_type_of(BELParser::Language::Version1::ReturnTypes::Abundance))))))
90
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::Abundance))))))
91
91
  end
92
92
  private_constant :AST
93
93
 
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # CompositeAbundance: Denotes the frequency or abundance of events in which members are present
11
11
  class CompositeAbundance
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :composite
15
15
  LONG = :compositeAbundance
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::Abundance
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::Abundance
17
17
  DESCRIPTION = 'Denotes the frequency or abundance of events in which members are present'.freeze
18
18
 
19
19
  def self.short
@@ -52,7 +52,7 @@ module BELParser
52
52
  term(
53
53
  function(
54
54
  identifier(
55
- return_type_of(BELParser::Language::Version1::ReturnTypes::Abundance))))))
55
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::Abundance))))))
56
56
  end
57
57
  private_constant :AST
58
58
 
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # Degradation: Denotes the frequency or abundance of events in which a member is degraded in some way such that it is no longer a member
11
11
  class Degradation
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :deg
15
15
  LONG = :degradation
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::Abundance
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::Abundance
17
17
  DESCRIPTION = 'Denotes the frequency or abundance of events in which a member is degraded in some way such that it is no longer a member'.freeze
18
18
 
19
19
  def self.short
@@ -52,7 +52,7 @@ module BELParser
52
52
  term(
53
53
  function(
54
54
  identifier(
55
- return_type_of(BELParser::Language::Version1::ReturnTypes::Abundance))))))
55
+ return_type_of(BELParser::Language::Version1_0::ReturnTypes::Abundance))))))
56
56
  end
57
57
  private_constant :AST
58
58
 
@@ -1,11 +1,11 @@
1
- require_relative '../../version1'
1
+ require_relative '../../version1_0'
2
2
  require_relative '../../function'
3
3
  require_relative '../../signature'
4
- require_relative '../../semantic_ast'
4
+ require_relative '../../semantics'
5
5
 
6
6
  module BELParser
7
7
  module Language
8
- module Version1
8
+ module Version1_0
9
9
  module Functions
10
10
  # Fusion: Specifies the abundance of a protein translated from the fusion of a gene
11
11
  class Fusion
@@ -13,7 +13,7 @@ module BELParser
13
13
 
14
14
  SHORT = :fus
15
15
  LONG = :fusion
16
- RETURN_TYPE = BELParser::Language::Version1::ReturnTypes::Fusion
16
+ RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::Fusion
17
17
  DESCRIPTION = 'Specifies the abundance of a protein translated from the fusion of a gene'.freeze
18
18
 
19
19
  def self.short