bel_parser 1.0.0.alpha.60 → 1.0.0.alpha.61

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3ed4d23d9c8ee19ec667828a774abee68c36097
4
- data.tar.gz: b79fa86a07d35578b26c61d9f23087fd67e3635c
3
+ metadata.gz: e93c65c3994ce33b610ab9cc7eb1eec391fd07d3
4
+ data.tar.gz: a4cc2248c47a87cc507f4e11686038155201305b
5
5
  SHA512:
6
- metadata.gz: 0fd133f1504d68cf9402a21d6107a7f3f19a09bcc576c884452b099ead5f35053f1c1d61e43d359a0a8af1bbe228f71996015a37297d5ef97878d2a22038287b
7
- data.tar.gz: 93c9d788f9b3d8aca23152b59e21db36da06bd852332d53fd035d03e526378f43a27c2b3cf7fc075ee93e0d816257779fa7207a0840970855ae0cfc87543c6fd
6
+ metadata.gz: c3176abf79936fb724f84129dddfd0f6ce8fc55a92c0043084f780d49dd13bfe948d7324e803755b4e1e7451ef9885b8521704668127914ba4ccb6bf3c86ba5e
7
+ data.tar.gz: 628c2d055320e1674dd3147a9d301664d86975b0ba398bd14bdf0b4d8637af702e6f3526667ce02723a70f825f4792a51597fe17784e6be4e2bbd02f975b95bd
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.60
1
+ 1.0.0.alpha.61
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(
3
+ File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
4
+
5
+ require 'optparse'
6
+ require 'bel_parser'
7
+
8
+ options = {
9
+ uri_reader: BELParser::Resource.default_uri_reader,
10
+ url_reader: BELParser::Resource.default_url_reader,
11
+ spec: BELParser::Language.specification(
12
+ BELParser::Language.latest_supported_version)
13
+ }
14
+ OptionParser.new do |opts|
15
+ opts.banner = <<-USAGE.gsub(/^ {4}/, '')
16
+ Confirm compatibility with BEL 2.0 expressions.
17
+ USAGE
18
+ end.parse!
19
+
20
+ def syntax_results(results)
21
+ results.select do |res|
22
+ res.is_a? BELParser::Language::Syntax::SyntaxResult
23
+ end
24
+ end
25
+
26
+ def semantics_results(results)
27
+ results.select do |res|
28
+ res.is_a? BELParser::Language::Semantics::SemanticsResult
29
+ end
30
+ end
31
+
32
+ require 'bel_parser/expression/validator'
33
+ require 'bel_parser/resource/resource_url_reader'
34
+
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
+ def validate(expression)
45
+ v2 = BELParser::Language.specification('2.0')
46
+ ns = {
47
+ 'CHEBI' =>
48
+ BELParser::Expression::Model::Namespace.new(
49
+ 'CHEBI',
50
+ 'http://www.openbel.org/bel/namespace/chebi',
51
+ nil),
52
+ 'GOCC' =>
53
+ BELParser::Expression::Model::Namespace.new(
54
+ 'GOCC',
55
+ 'http://www.openbel.org/bel/namespace/go-cellular-component',
56
+ nil),
57
+ 'HGNC' =>
58
+ BELParser::Expression::Model::Namespace.new(
59
+ 'HGNC',
60
+ 'http://www.openbel.org/bel/namespace/hgnc-human-genes',
61
+ nil),
62
+ 'DEFAULT' =>
63
+ BELParser::Expression::Model::Namespace.new(
64
+ 'DEFAULT',
65
+ 'http://www.openbel.org/bel/namespace/default',
66
+ nil)
67
+ }
68
+ uri_reader = BELParser::Resource.default_uri_reader
69
+ url_reader = BELParser::Resource.default_url_reader
70
+
71
+ BELParser::Expression::Validator
72
+ .new(v2, ns, uri_reader, url_reader)
73
+ .each(StringIO.new(expression)) do |(line_number, line, ast, results)|
74
+ puts "#{line_number}: #{line}"
75
+ puts " AST Type: #{ast.type}"
76
+
77
+ puts " Syntax results:"
78
+
79
+ results.syntax_results.each do |res|
80
+ puts " #{res}"
81
+ end
82
+
83
+ puts " Semantics results:"
84
+ results.semantics_results.each do |res|
85
+ if res.is_a?(BELParser::Language::Semantics::SignatureMappingSuccess)
86
+ puts " Matched signature: #{res.signature.string_form}"
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ puts "Protein Variant"
93
+ validate('proteinAbundance(HGNC:PIK3CA, variant("p.Glu545Lys"))')
94
+ validate('p(HGNC:ABCA1, var("p.Arg1851*"))')
95
+ puts
96
+
97
+ puts "Protein Fusion"
98
+ validate('proteinAbundance(fusion(HGNC:BCR, "p.1_426", HGNC:JAK2, "p.812_1132"))')
99
+ puts
100
+
101
+ puts "Protein Cleavage Fragments"
102
+ validate('p(HGNC:AKT1, frag("5_20"))')
103
+ validate('p(HGNC:AKT1, frag("1_?"))')
104
+ validate('p(HGNC:AKT1, frag("?_*"))')
105
+ validate('p(HGNC:AKT1, frag("?"))')
106
+ validate('p(HGNC:AKT1, frag("?", "55kD"))')
107
+ puts
108
+
109
+ puts "Cellular locations"
110
+ validate('a(CHEBI:"calcium(2+)", loc(GOCC:"endoplasmic reticulum"))')
111
+ puts
112
+
113
+ puts "Translocation with cellular location"
114
+ validate('tloc(p(HGNC:EGFR), fromLoc(GOCC:"cell surface"), toLoc(GOCC:endosome))')
115
+ puts
116
+
117
+ puts "Process Modifiers"
118
+ validate('act(p(HGNC:FOXO1), ma(DEFAULT:tscript))')
119
+ validate('activity(proteinAbundance(MGI:Casp3), molecularActivity(DEFAULT:pep))')
120
+ puts
121
+
122
+ puts "Regulates relationship"
123
+ validate('p(HGNC:AKT1) regulates p(HGNC:EGFR)')
@@ -11,7 +11,6 @@ module BEL::Translator::Plugins
11
11
 
12
12
  def initialize(io, options = {})
13
13
  @io = io
14
- require 'pry'; binding.pry
15
14
 
16
15
  options = {
17
16
  :language => '1.0'
@@ -15,6 +15,7 @@ module BELParser
15
15
  return nil unless stmt_node.is_a?(BELParser::Parsers::AST::Statement)
16
16
  return nil if stmt_node.relationship.string_literal.nil?
17
17
  rel = spec.relationship(stmt_node.relationship.string_literal.to_sym)
18
+ return nil unless rel
18
19
  return nil unless rel.listable?
19
20
 
20
21
  list_func = spec.function(:list)
@@ -19,6 +19,7 @@ module BELParser
19
19
  return nil unless list_func
20
20
 
21
21
  rel = spec.relationship(stmt_node.relationship.string_literal.to_sym)
22
+ return nil unless rel
22
23
  return nil unless rel.listable?
23
24
 
24
25
  map_object(stmt_node.object, rel, list_func, spec)
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.60
4
+ version: 1.0.0.alpha.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Bargnesi
@@ -32,6 +32,7 @@ executables:
32
32
  - bel2_debug_ast
33
33
  - bel2_validator
34
34
  - bel_script_reader
35
+ - bel2_compatibility
35
36
  extensions: []
36
37
  extra_rdoc_files: []
37
38
  files:
@@ -40,6 +41,7 @@ files:
40
41
  - LICENSE
41
42
  - README.md
42
43
  - VERSION
44
+ - bin/bel2_compatibility
43
45
  - bin/bel2_debug_ast
44
46
  - bin/bel2_upgrade
45
47
  - bin/bel2_validator