bel_parser 1.0.8 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gemspec +12 -2
  3. data/VERSION +1 -1
  4. data/bin/bel2_compatibility +12 -9
  5. data/bin/bel2_upgrade +18 -6
  6. data/bin/bel2_validator +6 -3
  7. data/bin/bel_script_reader +1 -0
  8. data/lib/bel_parser/completion.rb +984 -0
  9. data/lib/bel_parser/language/apply_namespace_encoding.rb +14 -3
  10. data/lib/bel_parser/language/expression_validator.rb +1 -2
  11. data/lib/bel_parser/language/function.rb +4 -0
  12. data/lib/bel_parser/language/relationship.rb +4 -0
  13. data/lib/bel_parser/language/semantics/function_deprecation.rb +1 -0
  14. data/lib/bel_parser/language/semantics/list_function_subject.rb +2 -0
  15. data/lib/bel_parser/language/semantics/multiple_subject_object.rb +4 -1
  16. data/lib/bel_parser/language/semantics/nested_statement_without_object.rb +43 -0
  17. data/lib/bel_parser/language/semantics/non_object_list.rb +3 -0
  18. data/lib/bel_parser/language/semantics/relationship_not_listable.rb +2 -0
  19. data/lib/bel_parser/language/semantics/signature_mapping.rb +2 -0
  20. data/lib/bel_parser/language/semantics_ast.rb +0 -7
  21. data/lib/bel_parser/language/syntax/invalid_function.rb +6 -1
  22. data/lib/bel_parser/language/syntax/invalid_relationship.rb +1 -0
  23. data/lib/bel_parser/language/version1_0/relationships/acts_in.rb +9 -9
  24. data/lib/bel_parser/language/version1_0/relationships/analogous.rb +6 -4
  25. data/lib/bel_parser/language/version1_0/relationships/association.rb +8 -7
  26. data/lib/bel_parser/language/version1_0/relationships/biomarker_for.rb +6 -5
  27. data/lib/bel_parser/language/version1_0/relationships/causes_no_change.rb +8 -7
  28. data/lib/bel_parser/language/version1_0/relationships/decreases.rb +13 -12
  29. data/lib/bel_parser/language/version1_0/relationships/directly_decreases.rb +8 -6
  30. data/lib/bel_parser/language/version1_0/relationships/directly_increases.rb +8 -6
  31. data/lib/bel_parser/language/version1_0/relationships/has_component.rb +14 -14
  32. data/lib/bel_parser/language/version1_0/relationships/has_components.rb +12 -11
  33. data/lib/bel_parser/language/version1_0/relationships/has_member.rb +10 -8
  34. data/lib/bel_parser/language/version1_0/relationships/has_members.rb +12 -11
  35. data/lib/bel_parser/language/version1_0/relationships/has_modification.rb +9 -7
  36. data/lib/bel_parser/language/version1_0/relationships/has_product.rb +10 -8
  37. data/lib/bel_parser/language/version1_0/relationships/has_variant.rb +9 -7
  38. data/lib/bel_parser/language/version1_0/relationships/includes.rb +11 -10
  39. data/lib/bel_parser/language/version1_0/relationships/increases.rb +12 -13
  40. data/lib/bel_parser/language/version1_0/relationships/is_a.rb +10 -8
  41. data/lib/bel_parser/language/version1_0/relationships/negative_correlation.rb +9 -7
  42. data/lib/bel_parser/language/version1_0/relationships/orthologous.rb +9 -8
  43. data/lib/bel_parser/language/version1_0/relationships/positive_correlation.rb +8 -5
  44. data/lib/bel_parser/language/version1_0/relationships/prognostic_biomarker_for.rb +8 -6
  45. data/lib/bel_parser/language/version1_0/relationships/rate_limiting_step_of.rb +10 -9
  46. data/lib/bel_parser/language/version1_0/relationships/reactant_in.rb +10 -8
  47. data/lib/bel_parser/language/version1_0/relationships/sub_process_of.rb +13 -12
  48. data/lib/bel_parser/language/version1_0/relationships/transcribed_to.rb +8 -7
  49. data/lib/bel_parser/language/version1_0/relationships/translated_to.rb +9 -7
  50. data/lib/bel_parser/language/version1_0/relationships/translocates.rb +10 -9
  51. data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +1 -2
  52. data/lib/bel_parser/language/version2_0/functions/translocation.rb +1 -2
  53. data/lib/bel_parser/language/version2_0/functions/variant.rb +1 -2
  54. data/lib/bel_parser/language/version2_0/relationships/acts_in.rb +10 -9
  55. data/lib/bel_parser/language/version2_0/relationships/biomarker_for.rb +7 -5
  56. data/lib/bel_parser/language/version2_0/relationships/causes_no_change.rb +9 -7
  57. data/lib/bel_parser/language/version2_0/relationships/decreases.rb +13 -12
  58. data/lib/bel_parser/language/version2_0/relationships/directly_decreases.rb +8 -6
  59. data/lib/bel_parser/language/version2_0/relationships/directly_increases.rb +8 -6
  60. data/lib/bel_parser/language/version2_0/relationships/has_component.rb +15 -14
  61. data/lib/bel_parser/language/version2_0/relationships/has_components.rb +12 -11
  62. data/lib/bel_parser/language/version2_0/relationships/has_member.rb +9 -8
  63. data/lib/bel_parser/language/version2_0/relationships/has_members.rb +12 -11
  64. data/lib/bel_parser/language/version2_0/relationships/has_modification.rb +9 -7
  65. data/lib/bel_parser/language/version2_0/relationships/has_product.rb +10 -8
  66. data/lib/bel_parser/language/version2_0/relationships/has_variant.rb +9 -7
  67. data/lib/bel_parser/language/version2_0/relationships/includes.rb +11 -10
  68. data/lib/bel_parser/language/version2_0/relationships/increases.rb +13 -12
  69. data/lib/bel_parser/language/version2_0/relationships/is_a.rb +10 -8
  70. data/lib/bel_parser/language/version2_0/relationships/negative_correlation.rb +9 -7
  71. data/lib/bel_parser/language/version2_0/relationships/orthologous.rb +10 -8
  72. data/lib/bel_parser/language/version2_0/relationships/positive_correlation.rb +7 -5
  73. data/lib/bel_parser/language/version2_0/relationships/prognostic_biomarker_for.rb +8 -6
  74. data/lib/bel_parser/language/version2_0/relationships/rate_limiting_step_of.rb +10 -9
  75. data/lib/bel_parser/language/version2_0/relationships/reactant_in.rb +10 -8
  76. data/lib/bel_parser/language/version2_0/relationships/regulates.rb +9 -8
  77. data/lib/bel_parser/language/version2_0/relationships/sub_process_of.rb +13 -12
  78. data/lib/bel_parser/language/version2_0/relationships/transcribed_to.rb +8 -7
  79. data/lib/bel_parser/language/version2_0/relationships/translated_to.rb +9 -7
  80. data/lib/bel_parser/language/version2_0/relationships/translocates.rb +10 -9
  81. data/lib/bel_parser/mixin/levenshtein.rb +20 -0
  82. data/lib/bel_parser/parsers/ast/node.rb +49 -2
  83. data/lib/bel_parser/parsers/bel_script/define_annotation.rb +156 -156
  84. data/lib/bel_parser/parsers/bel_script/define_namespace.rb +60 -60
  85. data/lib/bel_parser/parsers/bel_script/set.rb +200 -200
  86. data/lib/bel_parser/parsers/bel_script/set_document.rb +188 -188
  87. data/lib/bel_parser/parsers/bel_script/unset.rb +14 -14
  88. data/lib/bel_parser/parsers/common/common.rl +1 -0
  89. data/lib/bel_parser/parsers/common/function.rb +8 -8
  90. data/lib/bel_parser/parsers/common/function.rl +6 -6
  91. data/lib/bel_parser/parsers/common/identifier.rb +3 -3
  92. data/lib/bel_parser/parsers/common/identifier.rl +4 -4
  93. data/lib/bel_parser/parsers/common/list.rb +78 -78
  94. data/lib/bel_parser/parsers/common/multi_identifier.rb +275 -0
  95. data/lib/bel_parser/parsers/common/multi_identifier.rl +141 -0
  96. data/lib/bel_parser/parsers/common/string.rb +6 -6
  97. data/lib/bel_parser/parsers/common/string.rl +4 -4
  98. data/lib/bel_parser/parsers/common.rb +1 -0
  99. data/lib/bel_parser/parsers/expression/nested_statement.rb +30180 -29055
  100. data/lib/bel_parser/parsers/expression/observed_term.rb +1456 -1099
  101. data/lib/bel_parser/parsers/expression/parameter.rb +192 -111
  102. data/lib/bel_parser/parsers/expression/parameter.rl +6 -3
  103. data/lib/bel_parser/parsers/expression/relationship.rb +43 -19
  104. data/lib/bel_parser/parsers/expression/relationship.rl +1 -0
  105. data/lib/bel_parser/parsers/expression/simple_statement.rb +17805 -17093
  106. data/lib/bel_parser/parsers/expression/statement_autocomplete.rb +1035 -0
  107. data/lib/bel_parser/parsers/expression/statement_autocomplete.rl +736 -0
  108. data/lib/bel_parser/parsers/expression/term.rb +960 -705
  109. data/lib/bel_parser/parsers/serializer.rb +8 -4
  110. data/lib/bel_parser/version.rb +33 -0
  111. data/lib/bel_parser.rb +3 -0
  112. metadata +25 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1799ba1ab5abb0d0e3866657c5fc98ad064fe915
4
- data.tar.gz: 41e23bc6c3ccbf5ab389986ce481e4ae782997d9
3
+ metadata.gz: 918e134aad64f9a085893f1efe594fc7c7bc8176
4
+ data.tar.gz: 58c493d5631689b4230e9055dbe443381abe9e75
5
5
  SHA512:
6
- metadata.gz: 86bd2352f0258d54903dfdec9b6906f6c42046b86fb7723ae9456d8e457afedb32ec9985e9e65aefab5474611d8db06d35d9057321bf318a52ebff03081bc86f
7
- data.tar.gz: 081fd1cc6447a2b4140f1309663d402fb2da58e1adb9a21a0d925ccd2e5a2390d68193fbf0b8ab8978f95f6bd2ad24aa3b30320cffae65a4641e87a06a2ffaf7
6
+ metadata.gz: 747d0dfc27dae01731d43e7d464819d935be23d96a78321a88d6e82947a8a3389745381e1a23343a96494c25d43308807f8af31076e9a09e82598e6ee0ab4924
7
+ data.tar.gz: ff4584aa710cdba505a0ec05c24d731b8c8b058608178432cbd42d108bf054080372f3d1d6ae0e78a49105fed85dd793c27d3235207e9adec5f2da8ac103bd39
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-06-17}
14
+ spec.date = %q{2017-01-13}
15
15
  spec.email = %q{abargnesi@selventa.com}
16
16
  spec.files = [
17
17
  Dir.glob('lib/**/*.{rb,rl}'),
@@ -26,5 +26,15 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ['lib']
27
27
  spec.required_ruby_version = '>= 2.0.0'
28
28
 
29
- spec.add_runtime_dependency 'sparql-client', '~> 2.0.0'
29
+ if RUBY_ENGINE =~ /jruby/
30
+ spec.platform = 'java'
31
+ spec.add_runtime_dependency 'sparql-client', '~> 2.0.0'
32
+ spec.add_runtime_dependency 'dbm-mapdb3', '~> 0.6.0.beta'
33
+ spec.add_runtime_dependency 'levenshtein-jruby', '0.1.0'
34
+ else
35
+ spec.platform = 'ruby'
36
+ spec.add_runtime_dependency 'sparql-client', '~> 2.0.0'
37
+ spec.add_runtime_dependency 'damerau-levenshtein', '1.2.0'
38
+ end
30
39
  end
40
+ # vim: ft=ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.8
1
+ 1.1.1
@@ -15,6 +15,18 @@ OptionParser.new do |opts|
15
15
  opts.banner = <<-USAGE.gsub(/^ {4}/, '')
16
16
  Confirm compatibility with BEL 2.0 expressions.
17
17
  USAGE
18
+
19
+ if RUBY_ENGINE =~ /^jruby/i
20
+ opts.on(
21
+ '-t',
22
+ '--read-jena-tdb DIRECTORY',
23
+ 'Jena TDB directory containing BEL RDF resources.') do |tdb|
24
+
25
+ require 'bel_parser/resource/jena_tdb_reader'
26
+ options[:uri_reader] = BELParser::Resource::JenaTDBReader.new(tdb)
27
+ BELParser::Resource.default_uri_reader = options[:uri_reader]
28
+ end
29
+ end
18
30
  end.parse!
19
31
 
20
32
  def syntax_results(results)
@@ -32,15 +44,6 @@ end
32
44
  require 'bel_parser/expression/validator'
33
45
  require 'bel_parser/resource/resource_url_reader'
34
46
 
35
- uri_reader, url_reader = options.values_at(:uri_reader, :url_reader)
36
-
37
- namespaces = Hash[
38
- ARGV.map do |ns|
39
- keyword, identifier = ns.split('=')
40
- [keyword, BELParser::Expression::Model::Namespace.new(keyword, identifier, nil)]
41
- end.compact
42
- ]
43
-
44
47
  def validate(expression)
45
48
  v2 = BELParser::Language.specification('2.0')
46
49
  ns = {
data/bin/bel2_upgrade CHANGED
@@ -20,6 +20,18 @@ OptionParser.new do |opts|
20
20
  opts.on('-f', '--file FILE', 'BEL script file to read.') do |bel|
21
21
  options[:file] = bel
22
22
  end
23
+
24
+ if RUBY_ENGINE =~ /^jruby/i
25
+ opts.on(
26
+ '-t',
27
+ '--read-jena-tdb DIRECTORY',
28
+ 'Jena TDB directory containing BEL RDF resources.') do |tdb|
29
+
30
+ require 'bel_parser/resource/jena_tdb_reader'
31
+ options[:uri_reader] = BELParser::Resource::JenaTDBReader.new(tdb)
32
+ BELParser::Resource.default_uri_reader = options[:uri_reader]
33
+ end
34
+ end
23
35
  end.parse!
24
36
 
25
37
  file = options[:file]
@@ -49,7 +61,7 @@ puts serialize(
49
61
  value(
50
62
  string('"2.0"'))))
51
63
  BELParser::ASTGenerator.new(io).each do |result|
52
- line_number, line, asts = result
64
+ _, line, asts = result
53
65
 
54
66
  document_property =
55
67
  asts.find { |ast|
@@ -57,17 +69,17 @@ BELParser::ASTGenerator.new(io).each do |result|
57
69
  }
58
70
  next if document_property && document_property.name.identifier.string_literal.downcase == 'belversion'
59
71
 
60
- ast =
72
+ convert_ast =
61
73
  asts.find do |ast|
62
74
  ast && CONVERSION_TYPES.include?(ast.type)
63
75
  end
64
76
 
65
- if ast
66
- ast =
67
- upgrades.reduce(ast) do |ast, upgrade|
77
+ if convert_ast
78
+ puts serialize(
79
+ upgrades.reduce(convert_ast) do |ast, upgrade|
68
80
  upgrade.process(ast)
69
81
  end
70
- puts serialize(ast)
82
+ )
71
83
  else
72
84
  puts line
73
85
  end
data/bin/bel2_validator CHANGED
@@ -62,6 +62,7 @@ OptionParser.new do |opts|
62
62
 
63
63
  require 'bel_parser/resource/jena_tdb_reader'
64
64
  options[:uri_reader] = BELParser::Resource::JenaTDBReader.new(tdb)
65
+ BELParser::Resource.default_uri_reader = options[:uri_reader]
65
66
  end
66
67
  end
67
68
  end.parse!
@@ -104,14 +105,16 @@ BELParser::Expression::Validator
104
105
 
105
106
  puts " Semantics results:"
106
107
  results.semantics_results.each do |res|
107
- if res.is_a?(BELParser::Language::Semantics::SignatureMappingSuccess)
108
+ case res
109
+ when BELParser::Language::Semantics::SignatureMappingSuccess
108
110
  puts " Matched signature: #{res.signature.string_form}"
109
- end
110
- if res.is_a?(BELParser::Language::Semantics::SignatureMappingWarning)
111
+ when BELParser::Language::Semantics::SignatureMappingWarning
111
112
  puts " Failed signature: #{res.signature.string_form}"
112
113
  res.results.select(&:failure?).each do |warning|
113
114
  puts " #{warning}"
114
115
  end
116
+ when BELParser::Language::Semantics::SemanticsWarning
117
+ puts " Warning: #{res}"
115
118
  end
116
119
  end
117
120
  end
@@ -62,6 +62,7 @@ OptionParser.new do |opts|
62
62
 
63
63
  require 'bel_parser/resource/jena_tdb_reader'
64
64
  options[:uri_reader] = BELParser::Resource::JenaTDBReader.new(tdb)
65
+ BELParser::Resource.default_uri_reader = options[:uri_reader]
65
66
  end
66
67
  end
67
68
  end.parse!