bel_parser 1.0.0.alpha.60-java → 1.0.0.alpha.61-java

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: ae28215133d83c8b2a237eaed70fed02cc9cbdd6
4
- data.tar.gz: 10c4e0c2296a1e924456bfb01d431272f42c2445
3
+ metadata.gz: 1a35ee454b07ae1a3be4ebf49805f37cf48ebb7e
4
+ data.tar.gz: 657ea7e596653e46ecfb53484fe05b847b78b0fa
5
5
  SHA512:
6
- metadata.gz: f9392a9d8769f5a469e234de93d524e754f244d9472a21a6636538cb55f04c6d100f944f4225c39ca3cd8c7e795f114fb6194755be5305712e947a488e238254
7
- data.tar.gz: a649282f4e242ec258a573020e50561db4201d49dd6a07ab4c1ee18ab53542781db5ecc2c1a632e7aae3178fa60b0a9e8426875a35712cd2c77e48cb25523c7c
6
+ metadata.gz: 8d7d5f580a2117b778af23486dafc9bc2847c90347e224aa2684ddc9fa365e8088cb689ffe25bfa02e51f4fa2fce8d4ebc2a01357cb86e6a44ae594f158c6590
7
+ data.tar.gz: 1128d47705f8f5a6eb3f1eaee0788a3978dfa23cfe7b16a6a3206dfce448952a89907340424824472bfe33c27c443cdc9f7755be5540735e8ff5019b3f55a616
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: java
6
6
  authors:
7
7
  - Anthony Bargnesi
@@ -46,6 +46,7 @@ executables:
46
46
  - bel2_debug_ast
47
47
  - bel2_validator
48
48
  - bel_script_reader
49
+ - bel2_compatibility
49
50
  extensions: []
50
51
  extra_rdoc_files: []
51
52
  files:
@@ -54,6 +55,7 @@ files:
54
55
  - LICENSE
55
56
  - README.md
56
57
  - VERSION
58
+ - bin/bel2_compatibility
57
59
  - bin/bel2_debug_ast
58
60
  - bin/bel2_upgrade
59
61
  - bin/bel2_validator