bel_parser 1.0.0.alpha.12 → 1.0.0.alpha.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.gemspec +1 -1
  3. data/VERSION +1 -1
  4. data/bin/bel2_validator +35 -8
  5. data/lib/bel_parser/expression/validator.rb +3 -2
  6. data/lib/bel_parser/language/apply_namespace_encoding.rb +96 -0
  7. data/lib/bel_parser/language/base_specification.rb +82 -0
  8. data/lib/bel_parser/language/expression_validator.rb +6 -2
  9. data/lib/bel_parser/language/relationship.rb +1 -1
  10. data/lib/bel_parser/language/semantics/signature_mapping.rb +26 -32
  11. data/lib/bel_parser/language/semantics_ast.rb +285 -149
  12. data/lib/bel_parser/language/semantics_ast_warnings.rb +180 -0
  13. data/lib/bel_parser/language/semantics_result.rb +11 -2
  14. data/lib/bel_parser/language/semantics_type_warning.rb +22 -0
  15. data/lib/bel_parser/language/semantics_warning.rb +8 -0
  16. data/lib/bel_parser/language/specification.rb +38 -55
  17. data/lib/bel_parser/language/syntax/undefined_namespace_value.rb +43 -0
  18. data/lib/bel_parser/language/syntax_error.rb +8 -0
  19. data/lib/bel_parser/language/syntax_result.rb +8 -0
  20. data/lib/bel_parser/language/syntax_warning.rb +9 -4
  21. data/lib/bel_parser/language/version1_0/functions/abundance.rb +5 -6
  22. data/lib/bel_parser/language/version1_0/functions/biological_process.rb +5 -6
  23. data/lib/bel_parser/language/version1_0/functions/complex_abundance.rb +6 -7
  24. data/lib/bel_parser/language/version1_0/functions/fusion.rb +39 -60
  25. data/lib/bel_parser/language/version1_0/functions/gene_abundance.rb +9 -12
  26. data/lib/bel_parser/language/version1_0/functions/list.rb +5 -6
  27. data/lib/bel_parser/language/version1_0/functions/micro_rna_abundance.rb +5 -6
  28. data/lib/bel_parser/language/version1_0/functions/pathology.rb +5 -6
  29. data/lib/bel_parser/language/version1_0/functions/protein_abundance.rb +16 -30
  30. data/lib/bel_parser/language/version1_0/functions/protein_modification.rb +15 -27
  31. data/lib/bel_parser/language/version1_0/functions/rna_abundance.rb +8 -11
  32. data/lib/bel_parser/language/version1_0/functions/substitution.rb +6 -12
  33. data/lib/bel_parser/language/version1_0/functions/translocation.rb +9 -12
  34. data/lib/bel_parser/language/version1_0/functions/truncation.rb +2 -4
  35. data/lib/bel_parser/language/version1_0/value_encodings/abundance.rb +21 -0
  36. data/lib/bel_parser/language/version1_0/value_encodings/any.rb +74 -0
  37. data/lib/bel_parser/language/version1_0/value_encodings/biological_process.rb +21 -0
  38. data/lib/bel_parser/language/version1_0/value_encodings/complex_abundance.rb +21 -0
  39. data/lib/bel_parser/language/version1_0/value_encodings/gene_abundance.rb +21 -0
  40. data/lib/bel_parser/language/version1_0/value_encodings/micro_rna_abundance.rb +21 -0
  41. data/lib/bel_parser/language/version1_0/value_encodings/pathology.rb +21 -0
  42. data/lib/bel_parser/language/version1_0/value_encodings/protein_abundance.rb +21 -0
  43. data/lib/bel_parser/language/version1_0/value_encodings/rna_abundance.rb +21 -0
  44. data/lib/bel_parser/language/version1_0.rb +6 -87
  45. data/lib/bel_parser/language/version2_0/functions/abundance.rb +13 -18
  46. data/lib/bel_parser/language/version2_0/functions/biological_process.rb +5 -6
  47. data/lib/bel_parser/language/version2_0/functions/complex_abundance.rb +9 -12
  48. data/lib/bel_parser/language/version2_0/functions/fragment.rb +4 -9
  49. data/lib/bel_parser/language/version2_0/functions/from_location.rb +5 -6
  50. data/lib/bel_parser/language/version2_0/functions/fusion.rb +39 -66
  51. data/lib/bel_parser/language/version2_0/functions/gene_abundance.rb +13 -18
  52. data/lib/bel_parser/language/version2_0/functions/list.rb +5 -6
  53. data/lib/bel_parser/language/version2_0/functions/location.rb +5 -6
  54. data/lib/bel_parser/language/version2_0/functions/micro_rna_abundance.rb +13 -18
  55. data/lib/bel_parser/language/version2_0/functions/molecular_activity.rb +6 -5
  56. data/lib/bel_parser/language/version2_0/functions/pathology.rb +5 -6
  57. data/lib/bel_parser/language/version2_0/functions/protein_abundance.rb +21 -30
  58. data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +11 -17
  59. data/lib/bel_parser/language/version2_0/functions/rna_abundance.rb +13 -18
  60. data/lib/bel_parser/language/version2_0/functions/to_location.rb +5 -6
  61. data/lib/bel_parser/language/version2_0/functions/variant.rb +1 -4
  62. data/lib/bel_parser/language/version2_0/value_encodings/abundance.rb +21 -0
  63. data/lib/bel_parser/language/version2_0/value_encodings/activity.rb +21 -0
  64. data/lib/bel_parser/language/version2_0/value_encodings/any.rb +74 -0
  65. data/lib/bel_parser/language/version2_0/value_encodings/biological_process.rb +21 -0
  66. data/lib/bel_parser/language/version2_0/value_encodings/complex_abundance.rb +21 -0
  67. data/lib/bel_parser/language/version2_0/value_encodings/gene_abundance.rb +21 -0
  68. data/lib/bel_parser/language/version2_0/value_encodings/location.rb +21 -0
  69. data/lib/bel_parser/language/version2_0/value_encodings/micro_rna_abundance.rb +21 -0
  70. data/lib/bel_parser/language/version2_0/value_encodings/pathology.rb +21 -0
  71. data/lib/bel_parser/language/version2_0/value_encodings/protein_abundance.rb +21 -0
  72. data/lib/bel_parser/language/version2_0/value_encodings/protein_modification.rb +21 -0
  73. data/lib/bel_parser/language/version2_0/value_encodings/rna_abundance.rb +21 -0
  74. data/lib/bel_parser/language/version2_0.rb +6 -60
  75. data/lib/bel_parser/language.rb +3 -4
  76. data/lib/bel_parser/parsers/ast/node.rb +14 -2
  77. data/lib/bel_parser/{language/quoting.rb → quoting.rb} +0 -56
  78. data/lib/bel_parser/resource/concept.rb +56 -0
  79. data/lib/bel_parser/resource/concept_scheme.rb +35 -0
  80. data/lib/bel_parser/resource/dataset.rb +34 -0
  81. data/lib/bel_parser/resource/eager_reader.rb +75 -0
  82. data/lib/bel_parser/resource/eager_sparql_reader.rb +51 -0
  83. data/lib/bel_parser/resource/http_cache.rb +71 -0
  84. data/lib/bel_parser/resource/jena_tdb_reader.rb +246 -0
  85. data/lib/bel_parser/resource/lru_cache.rb +111 -0
  86. data/lib/bel_parser/resource/lru_reader.rb +38 -0
  87. data/lib/bel_parser/resource/reader.rb +18 -0
  88. data/lib/bel_parser/resource/resource_file_reader.rb +134 -0
  89. data/lib/bel_parser/resource/sparql_reader.rb +178 -0
  90. data/lib/bel_parser/resource/value.rb +31 -0
  91. metadata +42 -4
  92. data/lib/bel_parser/language/version1_0/syntax/function.rb +0 -28
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'any'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # Abundance value encoding.
9
+ class Abundance < Any
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != Abundance
15
+ :A
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'any'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # Activity value encoding.
9
+ class Activity < Any
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != Activity
15
+ :T
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,74 @@
1
+ require 'English'
2
+
3
+ module BELParser
4
+ module Language
5
+ module Version2_0
6
+ module ValueEncodings
7
+ # The Any value encoding.
8
+ class Any
9
+ # Return the {Symbol} value.
10
+ #
11
+ # @note This method should be overridden in subclasses.
12
+ def self.to_sym
13
+ raise_not_implemented(__method__) if self != Any
14
+ :*
15
+ end
16
+
17
+ # Returns +true+ if I am a subtype of +other_return_type+; otherwise
18
+ # return +false+.
19
+ #
20
+ # @param [Class] other_return_type to compare to
21
+ # @return [Boolean] +true+ if I am a subtype; +false+ if not
22
+ def self.subtype_of?(other_return_type)
23
+ self <= other_return_type
24
+ end
25
+
26
+ # Retrieve my immediate subtypes.
27
+ #
28
+ # @return [Array<Class>] my immediate subtypes
29
+ def self.subtypes
30
+ (@subtypes ||= []).freeze
31
+ end
32
+
33
+ # Retrieve my transitive subtypes.
34
+ #
35
+ # @return [Array<Class>] my transitive subtypes
36
+ def self.transitive_subtypes
37
+ transitive_subtypes =
38
+ (@subtypes ||= []).flat_map do |subtype|
39
+ [subtype, subtype.subtypes]
40
+ end.flatten
41
+ transitive_subtypes << self
42
+ transitive_subtypes.freeze
43
+ end
44
+
45
+ # Inherited hook overridden to keep track of descendants. This method
46
+ # is inherited by all descendants.
47
+ #
48
+ # @param [Class] cls the subclass that is inheriting me
49
+ # @see .subtypes
50
+ def self.inherited(cls)
51
+ (@subtypes ||= []) << cls
52
+ end
53
+ private_class_method
54
+
55
+ # Raise {NotImplementedError} for +method+. Alters the exception
56
+ # backtrace to exclude this method.
57
+ #
58
+ # @param [#to_s] the method name
59
+ # @raise [NotImplementedError] for +method+
60
+ def self.raise_not_implemented(method)
61
+ msg = "#{name} must implement the #{method} method"
62
+ raise NotImplementedError, msg
63
+ rescue StandardError
64
+ raise(
65
+ $ERROR_INFO.class,
66
+ $ERROR_INFO.message,
67
+ $ERROR_INFO.backtrace[1..-1])
68
+ end
69
+ private_class_method
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'any'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # BiologicalProcess value encoding.
9
+ class BiologicalProcess < Any
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != BiologicalProcess
15
+ :B
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'abundance'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # ComplexAbundance value encoding.
9
+ class ComplexAbundance < Abundance
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != ComplexAbundance
15
+ :C
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'abundance'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # GeneAbundance value encoding.
9
+ class GeneAbundance < Abundance
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != GeneAbundance
15
+ :G
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'any'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # Location value encoding.
9
+ class Location < Any
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != Location
15
+ :L
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'rna_abundance'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # Micro RNA abundance value encoding.
9
+ class MicroRNAAbundance < RNAAbundance
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != MicroRNAAbundance
15
+ :M
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'biological_process'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # Pathology value encoding.
9
+ class Pathology < BiologicalProcess
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != Pathology
15
+ :O
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'abundance'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # ProteinAbundance value encoding.
9
+ class ProteinAbundance < Abundance
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != ProteinAbundance
15
+ :P
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'any'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # ProteinModification value encoding.
9
+ class ProteinModification < Any
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != ProteinModification
15
+ :E
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../version2_0'
2
+ require_relative 'abundance'
3
+
4
+ module BELParser
5
+ module Language
6
+ module Version2_0
7
+ module ValueEncodings
8
+ # RNAAbundance value encoding.
9
+ class RNAAbundance < Abundance
10
+ # Return the {Symbol} value.
11
+ #
12
+ # @note This method should be overridden in subclasses.
13
+ def self.to_sym
14
+ raise_not_implemented(__method__) if self != RNAAbundance
15
+ :R
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,74 +1,20 @@
1
1
  require_relative 'function'
2
2
  require_relative 'specification'
3
+ require_relative 'base_specification'
3
4
 
4
5
  module BELParser
5
6
  module Language
6
7
  module Version2_0
7
- # Version2_0Specification defines the BEL, version 2.0 specification.
8
- class Specification
9
- include BELParser::Language::Specification
8
+ # Version2_0 specification defines the BEL 2.0 specification.
9
+ class Specification < BaseSpecification
10
+ BaseSpecification.load_version_path('version2_0')
11
+
10
12
  def initialize
11
13
  @version = '2.0'.freeze
12
-
13
- # Establish functions
14
- function_classes = Version2_0::Functions.constants.collect do |symbol|
15
- const = Version2_0::Functions.const_get(symbol)
16
- const if
17
- const.respond_to?(:short) &&
18
- const.respond_to?(:long)
19
- end
20
- @functions = function_classes.compact
21
- @indexed_functions = index_long_short(@functions)
22
-
23
- # Collect relationships
24
- rel_classes = Version2_0::Relationships.constants.collect do |symbol|
25
- const = Version2_0::Relationships.const_get(symbol)
26
- const if
27
- const.respond_to?(:short) &&
28
- const.respond_to?(:long)
29
- end
30
- @relationships = rel_classes.compact
31
- @indexed_relationships = index_long_short(@relationships)
32
- assign_relationship_categories(@relationships)
33
-
34
- # Establish return types
35
- ret_classes = Version2_0::ReturnTypes.constants.collect do |symbol|
36
- const = Version2_0::ReturnTypes.const_get(symbol)
37
- const if const.respond_to?(:subtypes)
38
- end
39
- @return_types = ret_classes.compact
40
- @indexed_return_types = index_sym(@return_types)
41
-
14
+ load_language_constants(Version2_0)
42
15
  freeze
43
16
  end
44
17
  end
45
18
  end
46
19
  end
47
20
  end
48
-
49
- # Require all version 2.0 return types
50
- Dir[
51
- File.join(
52
- File.dirname(File.expand_path(__FILE__)),
53
- 'version2_0', 'return_types', '*.rb')
54
- ].each do |path|
55
- require_relative "version2_0/return_types/#{File.basename(path)}"
56
- end
57
-
58
- # Require all version 2.0 functions.
59
- Dir[
60
- File.join(
61
- File.dirname(File.expand_path(__FILE__)),
62
- 'version2_0', 'functions', '*.rb')
63
- ].each do |path|
64
- require_relative "version2_0/functions/#{File.basename(path)}"
65
- end
66
-
67
- # Require all version 1.0 relationships.
68
- Dir[
69
- File.join(
70
- File.dirname(File.expand_path(__FILE__)),
71
- 'version2_0', 'relationships', '*.rb')
72
- ].each do |path|
73
- require_relative "version2_0/relationships/#{File.basename(path)}"
74
- end
@@ -1,5 +1,4 @@
1
1
  require_relative 'language/function'
2
- require_relative 'language/quoting'
3
2
  require_relative 'language/syntax'
4
3
  require_relative 'language/semantics'
5
4
  require_relative 'language/signature'
@@ -68,13 +67,13 @@ module BELParser
68
67
  # supported
69
68
  # @see {.defines?}
70
69
  def self.specification(version)
71
- version_string = version.to_s
72
- unless version_string =~ /^[0-9]+\.[0-9]+/
70
+ version_string = version.to_s
71
+ unless version_string =~ /^[0-9]+\.[0-9]+/
73
72
  raise ArgumentError, 'Version format incorrect; expecting MAJOR.MINOR'
74
73
  end
75
74
 
76
75
  LOCK.synchronize do
77
- version_sym = version_string.to_sym
76
+ version_sym = version_string.to_sym
78
77
  @specs ||= {}
79
78
  @specs[version_sym] ||= create_specification(version_string)
80
79
  @specs[version_sym]
@@ -428,6 +428,9 @@ module BELParser
428
428
  end
429
429
 
430
430
  # AST node representing a parameter.
431
+ #
432
+ # === Special node properties - _namespace_: {#namespace}
433
+ #
431
434
  class Prefix < Node
432
435
  # AST node type
433
436
  @ast_type = :prefix
@@ -445,6 +448,9 @@ module BELParser
445
448
  def identifier
446
449
  children[0]
447
450
  end
451
+
452
+ # Get/Set the namespace property.
453
+ attr_accessor :namespace
448
454
  end
449
455
 
450
456
  # AST node representing a parameter.
@@ -814,8 +820,14 @@ module BELParser
814
820
  super(Value.ast_type, children, properties)
815
821
  end
816
822
 
817
- # Get the value's encoding.
818
- attr_reader :encoding
823
+ # Get/Set the value's encoding.
824
+ attr_accessor :encoding
825
+
826
+ # Get/Set the value's namespace.
827
+ attr_accessor :namespace
828
+
829
+ # Get/Set the value from the purported namespace.
830
+ attr_accessor :namespace_value
819
831
  end
820
832
 
821
833
  # Sexp defines a module that creates {BELParser::Parsers::AST::Node
@@ -173,61 +173,5 @@ module BELParser
173
173
  matcher.match string
174
174
  end
175
175
  end
176
-
177
- ## Deprecated, remove in [0.6.0].
178
-
179
- # @deprecated Use {#quote_if_needed} instead. Will be removed in a
180
- # future release.
181
- def ensure_quotes(identifier)
182
- warn <<-DOC.gsub(/^\s+/, '')
183
- Deprecation Warning
184
- -------------------
185
- The BEL::Quoting::ensure_quotes method is deprecated and
186
- will be removed in a future release.
187
- Call module method BEL::Quoting.quote_if_needed instead.
188
- DOC
189
- quote_if_needed(identifier)
190
- end
191
-
192
- # @deprecated Use {#unquote} instead. Will be removed in a
193
- # future release.
194
- def remove_quotes(identifier)
195
- warn <<-DOC.gsub(/^\s+/, '')
196
- Deprecation Warning
197
- -------------------
198
- The BEL::Quoting::remove_quotes method is deprecated and
199
- will be removed in a future release.
200
- Call module method BEL::Quoting.unquote instead.
201
- DOC
202
- unquote(identifier)
203
- end
204
-
205
- # @deprecated Use {#quote} instead. Will be removed in a
206
- # future release.
207
- def always_quote(identifier)
208
- warn <<-DOC.gsub(/^\s+/, '')
209
- Deprecation Warning
210
- -------------------
211
- The BEL::Quoting::always_quote method is deprecated and
212
- will be removed in a future release.
213
- Call module method BEL::Quoting.quote instead.
214
- DOC
215
- quote(identifier)
216
- end
217
-
218
- # @deprecated Use {#quoted?} or {#unquoted?} instead. Will be removed
219
- # in a future release.
220
- def quotes_required?(identifier)
221
- warn <<-DOC.gsub(/^\s+/, '')
222
- Deprecation Warning
223
- -------------------
224
- The BEL::Quoting::quotes_required? method is deprecated and
225
- will be removed in a future release. Use BEL::Quoting.quoted? and
226
- BEL::Quoting.unquoted?.
227
- DOC
228
- [NonWordMatcher, KeywordMatcher].any? do |m|
229
- m.match identifier.to_s
230
- end
231
- end
232
176
  end
233
177
  end
@@ -0,0 +1,56 @@
1
+ require_relative 'value'
2
+
3
+ module BELParser
4
+ module Resource
5
+ # Concept
6
+ class Concept
7
+ include Value
8
+
9
+ attr_reader :dataset, :uri, :name, :identifier,
10
+ :title, :synonyms, :encodings
11
+
12
+ def initialize(dataset, uri, pref_label, identifier,
13
+ title, alt_labels, types)
14
+
15
+ @dataset = dataset
16
+ @uri = uri
17
+ @name = pref_label.to_s
18
+ @identifier = identifier.to_s
19
+ @title = title.to_s
20
+ @synonyms = alt_labels.to_s.split('|')
21
+ @encodings = convert_encoding_types(types.to_s)
22
+ end
23
+
24
+ private
25
+
26
+ def convert_encoding_types(types)
27
+ types.split('|').map do |type|
28
+ case type
29
+ when /AbundanceConcept$/
30
+ :A
31
+ when /BiologicalProcessConcept$/
32
+ :B
33
+ when /ComplexConcept$/
34
+ :C
35
+ when /GeneConcept$/
36
+ :G
37
+ when /LocationConcept$/
38
+ :L
39
+ when /MicroRNAConcept$/
40
+ :M
41
+ when /MolecularActivityConcept$/
42
+ :T
43
+ when /PathologyConcept$/
44
+ :O
45
+ when /ProteinConcept$/
46
+ :P
47
+ when /ProteinModificationConcept$/
48
+ :E
49
+ when /RNAConcept$/
50
+ :R
51
+ end
52
+ end.compact
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'dataset'
2
+
3
+ module BELParser
4
+ module Resource
5
+ #ConceptScheme
6
+ class ConceptScheme
7
+ include Dataset
8
+
9
+ attr_reader :identifier, :domain, :keyword, :name, :types
10
+
11
+ def initialize(identifier, domain, prefix, name, types)
12
+ @identifier = identifier.to_s
13
+ @domain = domain.to_s
14
+ @keyword = prefix.to_s
15
+ @name = name.to_s
16
+ @types = convert_types(types.to_s)
17
+ end
18
+
19
+ private
20
+
21
+ def convert_types(types)
22
+ types.split('|').map do |type|
23
+ case type
24
+ when /NamespaceConceptScheme$/
25
+ Dataset::NAMESPACE
26
+ when /AnnotationConceptScheme$/
27
+ Dataset::ANNOTATION
28
+ else
29
+ nil
30
+ end
31
+ end.compact
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ module BELParser
2
+ module Resource
3
+ # Dataset
4
+ module Dataset
5
+
6
+ ANNOTATION = :annotation
7
+ NAMESPACE = :namespace
8
+
9
+ def identifier
10
+ raise NotImplementedError, "#{__method__} is not implemented."
11
+ end
12
+
13
+ def keyword
14
+ raise NotImplementedError, "#{__method__} is not implemented."
15
+ end
16
+
17
+ def domain
18
+ raise NotImplementedError, "#{__method__} is not implemented."
19
+ end
20
+
21
+ def annotation_resource?
22
+ types.include?(ANNOTATION)
23
+ end
24
+
25
+ def namespace_resource?
26
+ types.include?(NAMESPACE)
27
+ end
28
+
29
+ def types
30
+ raise NotImplementedError, "#{__method__} is not implemented."
31
+ end
32
+ end
33
+ end
34
+ end