bel_parser 1.0.0.alpha.14 → 1.0.0.alpha.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gemspec +1 -1
- data/VERSION +1 -1
- data/bin/bel2_validator +1 -1
- data/bin/bel_script_reader +70 -0
- data/lib/bel_parser/expression/validator.rb +15 -4
- data/lib/bel_parser/language/apply_namespace_encoding.rb +4 -5
- data/lib/bel_parser/language/semantics/signature_mapping.rb +2 -1
- data/lib/bel_parser/language/semantics_ast.rb +2 -2
- data/lib/bel_parser/language/version1_0/functions/rna_abundance.rb +1 -1
- data/lib/bel_parser/resource/lru_reader.rb +1 -4
- data/lib/bel_parser/script/syntax/unresolvable_namespace.rb +0 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a99bbde75e5c199ecf2dd8be815f1405e9eb5e4
|
4
|
+
data.tar.gz: c356ebe805e01532cfce41ac8106468cb4f5c385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2106d5573f751b638a5386111ecd43a5278bdb8dcfc2c346f2a7a92b14cee760d53e848ad1f251f7b4430722219309b1c67190e63e6ed05854ee65a6fcbbd57
|
7
|
+
data.tar.gz: 6876b054cf3ddb09c21471dd787608754fcc09aa31842228d25204464e24f7816464f67f2d02ef9b50a9f2b5d6432aaac44668c6af072e765d229213183a0d15
|
data/.gemspec
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.alpha.
|
1
|
+
1.0.0.alpha.15
|
data/bin/bel2_validator
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(
|
3
|
+
File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
4
|
+
|
5
|
+
bel_specification_version, file = ARGV
|
6
|
+
|
7
|
+
unless bel_specification_version
|
8
|
+
program = File.basename($PROGRAM_NAME)
|
9
|
+
$stderr.puts <<-USAGE.gsub(/ {4}/, '')
|
10
|
+
usage: #{program} [BEL specification version]
|
11
|
+
USAGE
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
io =
|
16
|
+
if file
|
17
|
+
File.open(ARGV.first, external_encoding: 'UTF-8')
|
18
|
+
else
|
19
|
+
$stdin
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'bel_parser/language'
|
23
|
+
require 'bel_parser/script/validator'
|
24
|
+
require 'bel_parser/resource/resource_file_reader'
|
25
|
+
|
26
|
+
def select(list, cls)
|
27
|
+
list.select { |item| item.is_a?(cls) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def report(line_number, ast, errors, warnings)
|
31
|
+
log = !errors.empty? || !warnings.empty?
|
32
|
+
if log
|
33
|
+
puts "On line #{line_number} for #{ast.type}"
|
34
|
+
puts " Errors:"
|
35
|
+
errors.each do |err|
|
36
|
+
puts " #{err}"
|
37
|
+
end
|
38
|
+
puts " Warnings:"
|
39
|
+
warnings.each do |warn|
|
40
|
+
puts " #{warn}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
SYN_ERR = BELParser::Language::Syntax::SyntaxError
|
46
|
+
SYN_WARN = BELParser::Language::Syntax::SyntaxWarning
|
47
|
+
SEM_WARN = BELParser::Language::Semantics::SemanticsWarning
|
48
|
+
|
49
|
+
initial_state = {
|
50
|
+
resource_reader: BELParser::Resource::ResourceFileReader.new,
|
51
|
+
specification: BELParser::Language.specification(
|
52
|
+
bel_specification_version
|
53
|
+
)
|
54
|
+
}
|
55
|
+
|
56
|
+
BELParser::Script::Validator
|
57
|
+
.new(initial_state)
|
58
|
+
.each(io) do |(line_number, line, ast, syntax_results, state)|
|
59
|
+
errors = select(syntax_results, SYN_ERR)
|
60
|
+
warnings =
|
61
|
+
select(syntax_results, SYN_WARN) +
|
62
|
+
select(syntax_results, SEM_WARN)
|
63
|
+
|
64
|
+
report(line_number, ast, errors, warnings)
|
65
|
+
|
66
|
+
unless errors.empty?
|
67
|
+
puts "Exiting due to error on line #{line_number}: #{line}"
|
68
|
+
exit 1
|
69
|
+
end
|
70
|
+
end
|
@@ -48,14 +48,25 @@ if __FILE__ == $PROGRAM_NAME
|
|
48
48
|
USAGE
|
49
49
|
exit 1
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
|
+
require 'bel_parser/resource/resource_file_reader'
|
53
|
+
|
54
|
+
resource_reader = BELParser::Resource::ResourceFileReader.new
|
55
|
+
namespaces =
|
56
|
+
Hash[
|
57
|
+
ARGV[1..-1]
|
58
|
+
.map do |ns|
|
59
|
+
prefix, identifier = ns.split('=')
|
60
|
+
[prefix, resource_reader.retrieve_resource(identifier)]
|
61
|
+
end
|
62
|
+
]
|
52
63
|
BELParser::Expression::Validator
|
53
|
-
.new(ARGV.first, namespaces)
|
54
|
-
.each($stdin) do |(line_number, line, ast,
|
64
|
+
.new(ARGV.first, namespaces, resource_reader)
|
65
|
+
.each($stdin) do |(line_number, line, ast, results)|
|
55
66
|
results.select { |res| res.is_a? BELParser::Language::Syntax::SyntaxError }
|
56
67
|
puts "#{line_number}: #{line}"
|
57
68
|
puts " AST Type: #{ast.type}"
|
58
|
-
puts
|
69
|
+
puts results
|
59
70
|
.map { |r| "#{r}\n" }
|
60
71
|
.join
|
61
72
|
.each_line
|
@@ -8,9 +8,9 @@ module BELParser
|
|
8
8
|
include AST::Processor::Mixin
|
9
9
|
include BELParser::Quoting
|
10
10
|
|
11
|
-
def initialize(language_spec,
|
11
|
+
def initialize(language_spec, namespace_hash, resource_reader)
|
12
12
|
@language_spec = language_spec
|
13
|
-
@
|
13
|
+
@namespace_hash = namespace_hash
|
14
14
|
@resource_reader = resource_reader
|
15
15
|
end
|
16
16
|
|
@@ -61,10 +61,9 @@ module BELParser
|
|
61
61
|
return prefix_node unless prefix_node.identifier
|
62
62
|
|
63
63
|
@prefix = prefix_node.identifier.string_literal
|
64
|
-
|
65
|
-
return prefix_node unless
|
64
|
+
dataset = @namespace_hash[@prefix]
|
65
|
+
return prefix_node unless dataset
|
66
66
|
|
67
|
-
dataset = @resource_reader.retrieve_resource(identifier)
|
68
67
|
@resolved_dataset = dataset
|
69
68
|
prefix_node.namespace = dataset
|
70
69
|
|
@@ -22,8 +22,9 @@ module BELParser
|
|
22
22
|
|
23
23
|
function_name = term_node.function.identifier.string_literal
|
24
24
|
function = spec.function(function_name.to_sym)
|
25
|
-
|
25
|
+
return nil unless function
|
26
26
|
|
27
|
+
mapsig = method(:map_signature).to_proc.curry[term_node][spec]
|
27
28
|
function.signatures.map(&mapsig)
|
28
29
|
end
|
29
30
|
|
@@ -717,7 +717,7 @@ module BELParser
|
|
717
717
|
end
|
718
718
|
|
719
719
|
def match(value_node, spec)
|
720
|
-
string_literal_sym = value_node.children[0].to_sym
|
720
|
+
string_literal_sym = value_node.children[0].string_literal.to_sym
|
721
721
|
return success(value_node, spec) if @hashed[:*]
|
722
722
|
|
723
723
|
if @hashed.key?(string_literal_sym)
|
@@ -760,7 +760,7 @@ module BELParser
|
|
760
760
|
end
|
761
761
|
|
762
762
|
def match(value_node, spec)
|
763
|
-
string_literal = unquote(value_node.string_literal)
|
763
|
+
string_literal = unquote(value_node.children[0].string_literal)
|
764
764
|
integer_position =
|
765
765
|
begin
|
766
766
|
Integer(string_literal)
|
@@ -14,7 +14,7 @@ module BELParser
|
|
14
14
|
SHORT = :r
|
15
15
|
LONG = :rnaAbundance
|
16
16
|
RETURN_TYPE = BELParser::Language::Version1_0::ReturnTypes::GeneAbundance
|
17
|
-
R_ENC = Version1_0::
|
17
|
+
R_ENC = Version1_0::ValueEncodings::RNAAbundance
|
18
18
|
DESCRIPTION = 'Denotes the abundance of a gene'.freeze
|
19
19
|
|
20
20
|
def self.short
|
@@ -21,7 +21,6 @@ module BELParser
|
|
21
21
|
keyword, domain = ast_node.children
|
22
22
|
if domain.url?
|
23
23
|
url = unquote(domain.child.string.string_literal)
|
24
|
-
puts resource_reader.retrieve_resource(url)
|
25
24
|
unless resource_reader.retrieve_resource(url)
|
26
25
|
prefix = keyword.identifier.string_literal
|
27
26
|
return UnresolvableNamespaceError.new(ast_node, prefix, url)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bel_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Bargnesi
|
@@ -9,12 +9,13 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Implements language versions 1.0 and 2.0.
|
15
15
|
email: abargnesi@selventa.com
|
16
16
|
executables:
|
17
17
|
- bel2_validator
|
18
|
+
- bel_script_reader
|
18
19
|
extensions: []
|
19
20
|
extra_rdoc_files: []
|
20
21
|
files:
|
@@ -24,6 +25,7 @@ files:
|
|
24
25
|
- README.md
|
25
26
|
- VERSION
|
26
27
|
- bin/bel2_validator
|
28
|
+
- bin/bel_script_reader
|
27
29
|
- lib/bel_parser.rb
|
28
30
|
- lib/bel_parser/ast_filter.rb
|
29
31
|
- lib/bel_parser/ast_generator.rb
|