bel_parser 1.0.0.alpha.22 → 1.0.0.alpha.23

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: 2e418c5b2fae45c7d2d04f8d6f6192fff2f1f1d4
4
- data.tar.gz: 42a84936274b3cdd6eccdb2918b2b5ad37f49551
3
+ metadata.gz: fa3d8ae03619ff00bac48169269500514342d56d
4
+ data.tar.gz: 515fa48e8004ac0e1fea45811b08438ef90f7e16
5
5
  SHA512:
6
- metadata.gz: 356b39aebd42b4298a29d2a4e7ec1521855a5def19f6c1baa8b5769c81a14866f3bab2f7c28450171682b41bb841f47b11c3cd6a98c05ff52749dff53bc294b4
7
- data.tar.gz: f9f900d99b8ba8f5adfd72d5a08747a2b3771bee8a475fa0e2408712ac5ae1cc9470eb49d40837687bc83b6ca4b8e2ea31a4b2174ee627dc5fdb69ce18458d26
6
+ metadata.gz: e5f3318420faa49120fcb6e7b0d3ee890a4f6adffe82bd5ea8bf75f2179c614660e20fbb3dd9bfea5b067344d2aeab458816a342d2a56f0cc38411b572b1a161
7
+ data.tar.gz: c5007a2e4d8f74a606102133ad17aecda204ea8cc8a959213d6fdf83a993f82e9a11539e3a5b69fed79c3aec33f8241671c6d64026caeaebe9f56c69fac77d65
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-05-02}
14
+ spec.date = %q{2016-05-03}
15
15
  spec.email = %q{abargnesi@selventa.com}
16
16
  spec.files = [
17
17
  Dir.glob('lib/**/*.{rb,rl}'),
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.22
1
+ 1.0.0.alpha.23
@@ -1,13 +1,13 @@
1
- require_relative 'evidence_serialization.rb'
1
+ require_relative 'nanopub_serialization.rb'
2
2
 
3
- # BEL Script evidence serialization that groups evidence by citation scoped to
3
+ # BEL Script nanopub serialization that groups nanopub by citation scoped to
4
4
  # individual statement groups (i.e. BEL Script's +SET STATEMENT_GROUP+ and
5
5
  # +UNSET STATEMENT_GROUP+).
6
6
  #
7
- # @example Citation serialization for a group of evidence
7
+ # @example Citation serialization for a group of nanopub
8
8
  # SET STATEMENT_GROUP = 12857727
9
9
  # SET Citation = {"PubMed", "Journal...", "12857727", "2003-08-11", "", ""}
10
- # SET Evidence = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
10
+ # SET Support = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
11
11
  # SET CellLine = "MCF 10A"
12
12
  # SET TextLocation = Abstract
13
13
  # complex(p(HGNC:USF1),g(HGNC:IGF2R))
@@ -18,41 +18,41 @@ require_relative 'evidence_serialization.rb'
18
18
  #
19
19
  # tscript(p(HGNC:USF1)) causesNoChange r(HGNC:IGF2R)
20
20
  #
21
- # SET Evidence = "c-Myc was present on the CDK4 promoter to the ..."
21
+ # SET Support = "c-Myc was present on the CDK4 promoter to the ..."
22
22
  # complex(p(HGNC:MYC),g(HGNC:CDK4))
23
23
  # UNSET STATEMENT_GROUP
24
24
  module BEL::Translator::Plugins::BelScript::BelCitationSerialization
25
- include BEL::Translator::Plugins::BelScript::EvidenceSerialization
25
+ include BEL::Translator::Plugins::BelScript::NanopubSerialization
26
26
 
27
- # Serialize the {BEL::Model::Evidence evidence} to a BEL Script string.
27
+ # Serialize the {BEL::Nanopub::Nanopub nanopub} to a BEL Script string.
28
28
  #
29
29
  # Includes +SET AnnotationName+ and +UNSET AnnotationName+ where needed in
30
30
  # order to remove duplicating annotations.
31
31
  #
32
- # @param [BEL::Model::Evidence] evidence the evidence to serialize
32
+ # @param [BEL::Nanopub::Nanopub] nanopub the nanopub to serialize
33
33
  # @return [String] the BEL Script string
34
- def to_bel(evidence)
34
+ def to_bel(nanopub)
35
35
  bel = ''
36
36
 
37
- citation = citation_value(evidence)
38
- summary_text = summary_text_value(evidence)
39
- annotations = annotation_values(evidence)
37
+ citation = citation_value(nanopub)
38
+ summary_text = summary_text_value(nanopub)
39
+ annotations = annotation_values(nanopub)
40
40
 
41
41
  current_annotations = {}.merge(annotations)
42
42
  current_annotations[:Citation] = citation if citation
43
- current_annotations[:Evidence] = summary_text if summary_text
43
+ current_annotations[:Support] = summary_text if summary_text
44
44
 
45
- if !evidence.citation.id || evidence.citation.id.empty?
45
+ if !nanopub.citation.id || nanopub.citation.id.empty?
46
46
  citation_id = quote('')
47
47
  else
48
- citation_id = quote_if_needed(evidence.citation.id)
48
+ citation_id = quote_if_needed(nanopub.citation.id)
49
49
  end
50
50
 
51
51
  # Reset cumulative annotations if new citation.
52
52
  if cumulative_citation == nil
53
53
  bel << %Q{SET STATEMENT_GROUP = #{citation_id}\n}
54
54
  cumulative_annotations.clear
55
- elsif evidence.citation != cumulative_citation
55
+ elsif nanopub.citation != cumulative_citation
56
56
  bel << %Q{UNSET STATEMENT_GROUP\n}
57
57
  bel << "\n\n"
58
58
  bel << %Q{SET STATEMENT_GROUP = #{citation_id}\n}
@@ -60,22 +60,22 @@ module BEL::Translator::Plugins::BelScript::BelCitationSerialization
60
60
  end
61
61
 
62
62
  # Hang on to the last citation.
63
- self.cumulative_citation = evidence.citation
63
+ self.cumulative_citation = nanopub.citation
64
64
 
65
- # UNSET unused annotations from previous evidence.
65
+ # UNSET unused annotations from previous nanopub.
66
66
  (cumulative_annotations.keys - current_annotations.keys).each do |unset_key|
67
67
  bel << "UNSET #{unset_key}\n"
68
68
  cumulative_annotations.delete(unset_key)
69
69
  end
70
70
 
71
- # Remove annotation if key/value was SET by a previous evidence.
71
+ # Remove annotation if key/value was SET by a previous nanopub.
72
72
  Hash[
73
73
  cumulative_annotations.to_a & current_annotations.to_a
74
74
  ].each do |same_k, _|
75
75
  current_annotations.delete(same_k)
76
76
  end
77
77
 
78
- # Retain the current evidence's annotation in cumulative set.
78
+ # Retain the current nanopub's annotation in cumulative set.
79
79
  cumulative_annotations.merge!(current_annotations)
80
80
 
81
81
  # SET Citation
@@ -84,10 +84,10 @@ module BEL::Translator::Plugins::BelScript::BelCitationSerialization
84
84
  bel << "SET Citation = {#{citation}}\n"
85
85
  end
86
86
 
87
- # SET Evidence
88
- summary_text = current_annotations.delete(:Evidence)
87
+ # SET Support
88
+ summary_text = current_annotations.delete(:Support)
89
89
  if summary_text
90
- bel << %Q{SET Evidence = "#{summary_text}"\n}
90
+ bel << %Q{SET Support = "#{summary_text}"\n}
91
91
  end
92
92
 
93
93
  # SET new or modified annotations
@@ -96,9 +96,9 @@ module BEL::Translator::Plugins::BelScript::BelCitationSerialization
96
96
  end
97
97
 
98
98
  # Assert BEL statement
99
- bel << "#{evidence.bel_statement}\n"
99
+ bel << "#{nanopub.bel_statement}\n"
100
100
 
101
- # Separate evidence by new line.
101
+ # Separate nanopub by new line.
102
102
  bel << "\n"
103
103
 
104
104
  bel
@@ -106,12 +106,12 @@ module BEL::Translator::Plugins::BelScript::BelCitationSerialization
106
106
 
107
107
  private
108
108
 
109
- # The cumulative citation that is active for the current evidence. This is
109
+ # The cumulative citation that is active for the current nanopub. This is
110
110
  # tracked in order to decide when to begin a new statement group.
111
111
  attr_accessor :cumulative_citation
112
112
 
113
113
  # Returns the cumulative +Hash+ of annotations. This *state* is used to keep
114
- # track of the active, scoped annotations as evidence is serialized.
114
+ # track of the active, scoped annotations as nanopub is serialized.
115
115
  def cumulative_annotations
116
116
  @cumulative_annotations ||= {}
117
117
  end
@@ -1,69 +1,69 @@
1
- require_relative 'evidence_serialization'
1
+ require_relative 'nanopub_serialization'
2
2
 
3
- # BEL Script evidence serialization that writes each evidence with their full
3
+ # BEL Script nanopub serialization that writes each nanopub with their full
4
4
  # set of annotations (i.e. includes all `SET` and necessary `UNSET` records).
5
5
  # This style is more readable because it groups all set annotations near the
6
6
  # BEL statement.
7
7
  #
8
- # @example Discrete serialization for a group of evidence
8
+ # @example Discrete serialization for a group of nanopub
9
9
  # SET Citation = {"PubMed", "Journal...", "12857727", "2003-08-11", "", ""}
10
- # SET Evidence = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
10
+ # SET Support = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
11
11
  # SET CellLine = "MCF 10A"
12
12
  # SET TextLocation = Abstract
13
13
  # complex(p(HGNC:USF1),g(HGNC:IGF2R))
14
14
  #
15
15
  # SET Citation = {"PubMed", "Journal...", "12857727", "2003-08-11", "", ""}
16
- # SET Evidence = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
16
+ # SET Support = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
17
17
  # SET CellLine = "MCF 10A"
18
18
  # SET TextLocation = Abstract
19
19
  # complex(p(HGNC:USF2),g(HGNC:IGF2R))
20
20
  #
21
21
  # SET Citation = {"PubMed", "Journal...", "12857727", "2003-08-11", "", ""}
22
- # SET Evidence = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
22
+ # SET Support = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
23
23
  # SET CellLine = "MCF 10A"
24
24
  # SET TextLocation = Abstract
25
25
  # tscript(p(HGNC:USF2)) directlyIncreases r(HGNC:IGF2R)
26
26
  #
27
27
  # SET Citation = {"PubMed", "Journal...", "12857727", "2003-08-11", "", ""}
28
- # SET Evidence = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
28
+ # SET Support = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
29
29
  # SET CellLine = "MCF 10A"
30
30
  # SET TextLocation = Abstract
31
31
  # tscript(p(HGNC:USF1)) causesNoChange r(HGNC:IGF2R)
32
32
  #
33
33
  # SET Citation = {"PubMed", "Journal...", "12857727", "2003-08-11", "", ""}
34
- # SET Evidence = "c-Myc was present on the CDK4 promoter to the ..."
34
+ # SET Support = "c-Myc was present on the CDK4 promoter to the ..."
35
35
  # SET CellLine = "MCF 10A"
36
36
  # SET TextLocation = Abstract
37
37
  # complex(p(HGNC:MYC),g(HGNC:CDK4))
38
38
  #
39
39
  # UNSET CellLine
40
40
  module BEL::Translator::Plugins::BelScript::BelDiscreteSerialization
41
- include BEL::Translator::Plugins::BelScript::EvidenceSerialization
41
+ include BEL::Translator::Plugins::BelScript::NanopubSerialization
42
42
 
43
- # Serialize the {BEL::Model::Evidence evidence} to a BEL Script string.
43
+ # Serialize the {BEL::Nanopub::Nanopub nanopub} to a BEL Script string.
44
44
  # Includes all necessary +SET AnnotationName+ and +UNSET AnnotationName+
45
45
  # records around the BEL statement.
46
46
  #
47
- # @param [BEL::Model::Evidence] evidence the evidence to serialize
47
+ # @param [BEL::Nanopub::Nanopub] nanopub the nanopub to serialize
48
48
  # @return [String] the BEL Script string
49
- def to_bel(evidence)
49
+ def to_bel(nanopub)
50
50
  bel = ''
51
51
 
52
- citation = citation_value(evidence)
53
- summary_text = summary_text_value(evidence)
54
- annotations = annotation_values(evidence)
52
+ citation = citation_value(nanopub)
53
+ summary_text = summary_text_value(nanopub)
54
+ annotations = annotation_values(nanopub)
55
55
 
56
56
  current_annotations = {}.merge(annotations)
57
57
  current_annotations[:Citation] = citation if citation
58
- current_annotations[:Evidence] = summary_text if summary_text
58
+ current_annotations[:Support] = summary_text if summary_text
59
59
 
60
- # UNSET unused annotations from previous evidence.
60
+ # UNSET unused annotations from previous nanopub.
61
61
  (cumulative_annotations.keys - current_annotations.keys).each do |unset_key|
62
62
  bel << "UNSET #{unset_key}\n"
63
63
  cumulative_annotations.delete(unset_key)
64
64
  end
65
65
 
66
- # Retain the current evidence's annotation in cumulative set.
66
+ # Retain the current nanopub's annotation in cumulative set.
67
67
  cumulative_annotations.merge!(current_annotations)
68
68
 
69
69
  # SET Citation
@@ -72,10 +72,10 @@ module BEL::Translator::Plugins::BelScript::BelDiscreteSerialization
72
72
  bel << "SET Citation = {#{citation}}\n"
73
73
  end
74
74
 
75
- # SET Evidence
76
- summary_text = current_annotations.delete(:Evidence)
75
+ # SET Support
76
+ summary_text = current_annotations.delete(:Support)
77
77
  if summary_text
78
- bel << %Q{SET Evidence = "#{summary_text}"\n}
78
+ bel << %Q{SET Support = "#{summary_text}"\n}
79
79
  end
80
80
 
81
81
  # SET new or modified annotations
@@ -84,9 +84,9 @@ module BEL::Translator::Plugins::BelScript::BelDiscreteSerialization
84
84
  end
85
85
 
86
86
  # Assert BEL statement
87
- bel << "#{evidence.bel_statement}\n"
87
+ bel << "#{nanopub.bel_statement}\n"
88
88
 
89
- # Separate evidence by new line.
89
+ # Separate nanopub by new line.
90
90
  bel << "\n"
91
91
 
92
92
  bel
@@ -95,14 +95,14 @@ module BEL::Translator::Plugins::BelScript::BelDiscreteSerialization
95
95
  private
96
96
 
97
97
  # Returns the cumulative +Hash+ of annotations. This *state* is used to keep
98
- # track of the active, scoped annotations as evidence is serialized.
98
+ # track of the active, scoped annotations as nanopub is serialized.
99
99
  def cumulative_annotations
100
100
  @cumulative_annotations ||= {}
101
101
  end
102
102
 
103
103
  # Return BEL Script syntax that completes the BEL Script document.
104
104
  # The empty string is returned since no ending syntax is necessary when
105
- # serializing each evidence discretely.
105
+ # serializing each nanopub discretely.
106
106
  def epilogue
107
107
  ""
108
108
  end
@@ -1,12 +1,12 @@
1
- require_relative 'evidence_serialization.rb'
1
+ require_relative 'nanopub_serialization.rb'
2
2
 
3
- # BEL Script evidence serialization that writes evidence sequentially while
3
+ # BEL Script nanopub serialization that writes nanopubs sequentially while
4
4
  # including only the necessary unsetting of annotations (i.e. BEL Script's
5
5
  # +UNSET AnnotationName+ syntax).
6
6
  #
7
- # @example Top-down serialization for a group of evidence
7
+ # @example Top-down serialization for a group of nanopubs
8
8
  # SET Citation = {"PubMed", "Journal...", "12857727", "2003-08-11", "", ""}
9
- # SET Evidence = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
9
+ # SET Support = "USF1 and USF2 bound the IGF2R promoter in vitro, ..."
10
10
  # SET CellLine = "MCF 10A"
11
11
  # SET TextLocation = Abstract
12
12
  # complex(p(HGNC:USF1),g(HGNC:IGF2R))
@@ -17,44 +17,44 @@ require_relative 'evidence_serialization.rb'
17
17
  #
18
18
  # tscript(p(HGNC:USF1)) causesNoChange r(HGNC:IGF2R)
19
19
  #
20
- # SET Evidence = "c-Myc was present on the CDK4 promoter to the ..."
20
+ # SET Support = "c-Myc was present on the CDK4 promoter to the ..."
21
21
  # complex(p(HGNC:MYC),g(HGNC:CDK4))
22
22
  #
23
23
  # UNSET CellLine
24
24
  module BEL::Translator::Plugins::BelScript::BelTopDownSerialization
25
- include BEL::Translator::Plugins::BelScript::EvidenceSerialization
25
+ include BEL::Translator::Plugins::BelScript::NanopubSerialization
26
26
 
27
- # Serialize the {BEL::Model::Evidence evidence} to a BEL Script string.
27
+ # Serialize the {BEL::Nanopub::Nanopub nanopub} to a BEL Script string.
28
28
  # Includes all necessary +SET AnnotationName+ and +UNSET AnnotationName+
29
29
  # records within the scope of a citation's statement group.
30
30
  #
31
- # @param [BEL::Model::Evidence] evidence the evidence to serialize
31
+ # @param [BEL::Nanopub::Nanopub] nanopub the nanopub to serialize
32
32
  # @return [String] the BEL Script string
33
- def to_bel(evidence)
33
+ def to_bel(nanopub)
34
34
  bel = ''
35
35
 
36
- citation = citation_value(evidence)
37
- summary_text = summary_text_value(evidence)
38
- annotations = annotation_values(evidence)
36
+ citation = citation_value(nanopub)
37
+ summary_text = summary_text_value(nanopub)
38
+ annotations = annotation_values(nanopub)
39
39
 
40
40
  current_annotations = {}.merge(annotations)
41
41
  current_annotations[:Citation] = citation if citation
42
- current_annotations[:Evidence] = summary_text if summary_text
42
+ current_annotations[:Support] = summary_text if summary_text
43
43
 
44
- # UNSET unused annotations from previous evidence.
44
+ # UNSET unused annotations from previous nanopub.
45
45
  (cumulative_annotations.keys - current_annotations.keys).each do |unset_key|
46
46
  bel << "UNSET #{unset_key}\n"
47
47
  cumulative_annotations.delete(unset_key)
48
48
  end
49
49
 
50
- # Remove annotation if key/value was SET by a previous evidence.
50
+ # Remove annotation if key/value was SET by a previous nanopub.
51
51
  Hash[
52
52
  cumulative_annotations.to_a & current_annotations.to_a
53
53
  ].each do |same_k, _|
54
54
  current_annotations.delete(same_k)
55
55
  end
56
56
 
57
- # Retain the current evidence's annotation in cumulative set.
57
+ # Retain the current nanopub's annotation in cumulative set.
58
58
  cumulative_annotations.merge!(current_annotations)
59
59
 
60
60
  # SET Citation
@@ -63,10 +63,10 @@ module BEL::Translator::Plugins::BelScript::BelTopDownSerialization
63
63
  bel << "SET Citation = {#{citation}}\n"
64
64
  end
65
65
 
66
- # SET Evidence
67
- summary_text = current_annotations.delete(:Evidence)
66
+ # SET Support
67
+ summary_text = current_annotations.delete(:Support)
68
68
  if summary_text
69
- bel << %Q{SET Evidence = "#{summary_text}"\n}
69
+ bel << %Q{SET Support = "#{summary_text}"\n}
70
70
  end
71
71
 
72
72
  # SET new or modified annotations
@@ -75,9 +75,9 @@ module BEL::Translator::Plugins::BelScript::BelTopDownSerialization
75
75
  end
76
76
 
77
77
  # Assert BEL statement
78
- bel << "#{evidence.bel_statement}\n"
78
+ bel << "#{nanopub.bel_statement}\n"
79
79
 
80
- # Separate evidence by new line.
80
+ # Separate nanopub by new line.
81
81
  bel << "\n"
82
82
 
83
83
  bel
@@ -86,7 +86,7 @@ module BEL::Translator::Plugins::BelScript::BelTopDownSerialization
86
86
  private
87
87
 
88
88
  # Returns the cumulative +Hash+ of annotations. This *state* is used to keep
89
- # track of the active, scoped annotations as evidence is serialized.
89
+ # track of the active, scoped annotations as nanopub is serialized.
90
90
  def cumulative_annotations
91
91
  @cumulative_annotations ||= {}
92
92
  end
@@ -1,19 +1,19 @@
1
1
  require 'bel/quoting'
2
2
 
3
- # Serializing of common {BEL::Model::Evidence evidence} components to BEL
3
+ # Serializing of common {BEL::Nanopub::Nanopub nanopub} components to BEL
4
4
  # Script syntax.
5
5
  #
6
6
  # @abstract
7
- module BEL::Translator::Plugins::BelScript::EvidenceSerialization
7
+ module BEL::Translator::Plugins::BelScript::NanopubSerialization
8
8
  include BEL::Quoting
9
9
 
10
- # Serialize the {BEL::Model::Evidence evidence} to a BEL Script string.
10
+ # Serialize the {BEL::Nanopub::Nanopub nanopub} to a BEL Script string.
11
11
  #
12
- # @param [BEL::Model::Evidence] evidence the evidence to serialize
12
+ # @param [BEL::Nanopub::Nanopub] nanopub the nanopub to serialize
13
13
  # @return [String] the BEL Script string
14
14
  # @abstract Include and override {#to_bel} to implement serialization
15
- # {BEL::Model::Evidence evidence} to BEL Script
16
- def to_bel(evidence)
15
+ # {BEL::Nanopub::Nanopub nanopub} to BEL Script
16
+ def to_bel(nanopub)
17
17
  end
18
18
 
19
19
  # Return BEL Script syntax that completes the BEL Script document.
@@ -25,8 +25,8 @@ module BEL::Translator::Plugins::BelScript::EvidenceSerialization
25
25
 
26
26
  protected
27
27
 
28
- def citation_value(evidence)
29
- citation = evidence.citation
28
+ def citation_value(nanopub)
29
+ citation = nanopub.citation
30
30
 
31
31
  return nil unless citation && citation.valid?
32
32
 
@@ -42,8 +42,8 @@ module BEL::Translator::Plugins::BelScript::EvidenceSerialization
42
42
  values.join(', ')
43
43
  end
44
44
 
45
- def summary_text_value(evidence)
46
- summary_text = evidence.summary_text
45
+ def summary_text_value(nanopub)
46
+ summary_text = nanopub.summary_text
47
47
 
48
48
  return nil unless summary_text && summary_text.value
49
49
 
@@ -53,8 +53,8 @@ module BEL::Translator::Plugins::BelScript::EvidenceSerialization
53
53
  value
54
54
  end
55
55
 
56
- def annotation_values(evidence)
57
- experiment_context = evidence.experiment_context
56
+ def annotation_values(nanopub)
57
+ experiment_context = nanopub.experiment_context
58
58
 
59
59
  return {} unless experiment_context
60
60
 
@@ -1,6 +1,6 @@
1
1
  require 'bel_parser'
2
2
  require 'bel_parser/resource/resource_url_reader'
3
- require 'bel/evidence_model'
3
+ require 'bel/nanopub'
4
4
 
5
5
  module BEL::Translator::Plugins
6
6
  module BelScript
@@ -28,7 +28,7 @@ module BEL::Translator::Plugins
28
28
  true,
29
29
  false
30
30
  ).each do |(num, line, ast_node, nanopub_hash)|
31
- yield ::BEL::Model::Evidence.create(nanopub_hash)
31
+ yield ::BEL::Nanopub::Nanopub.create(nanopub_hash)
32
32
  end
33
33
  else
34
34
  enum_for(:each)
@@ -9,16 +9,16 @@ module BEL::Translator::Plugins
9
9
 
10
10
  class Writer
11
11
 
12
- # Create a {Writer} object that serializes {BEL::Model::Evidence} to
12
+ # Create a {Writer} object that serializes {BEL::Nanopub::Nanopub} to
13
13
  # BEL Script.
14
14
  #
15
- # @param [Enumerator<BEL::Model::Evidence>] data evidence data iterated
15
+ # @param [Enumerator<BEL::Nanopub::Nanopub>] data nanopubs iterated
16
16
  # using +each+
17
17
  # @option options [Boolean] :write_header +true+ to write the BEL Script
18
18
  # document header; +false+ to not write the BEL Script document
19
19
  # header
20
20
  # @option options [Symbol,Module] :serialization the serialization
21
- # technique to use for evidence; a +Module+ type will be used as
21
+ # technique to use for nanopub; a +Module+ type will be used as
22
22
  # is; a +Symbol+ type will be mapped as
23
23
  # +:discrete+ => {BelDiscreteSerialization},
24
24
  # +:topdown+ => {BelTopDownSerialization},
@@ -61,27 +61,27 @@ module BEL::Translator::Plugins
61
61
  if block_given?
62
62
  combiner =
63
63
  if @streaming
64
- BEL::Model::StreamingEvidenceCombiner.new(@data)
64
+ BEL::Nanopub::StreamingNanopubCombiner.new(@data)
65
65
  elsif @annotation_reference_map && @namespace_reference_map
66
- BEL::Model::MapReferencesCombiner.new(
66
+ BEL::Nanopub::MapReferencesCombiner.new(
67
67
  @data,
68
- BEL::Model::HashMapReferences.new(
68
+ BEL::Nanopub::HashMapReferences.new(
69
69
  @annotation_reference_map,
70
70
  @namespace_reference_map
71
71
  )
72
72
  )
73
73
  else
74
- BEL::Model::BufferingEvidenceCombiner.new(@data)
74
+ BEL::Nanopub::BufferingNanopubCombiner.new(@data)
75
75
  end
76
76
 
77
77
  header_flag = true
78
- combiner.each { |evidence|
78
+ combiner.each { |nanopub|
79
79
 
80
- # serialize evidence
81
- bel = to_bel(evidence)
80
+ # serialize nanopub
81
+ bel = to_bel(nanopub)
82
82
 
83
83
  if @write_header && header_flag
84
- yield document_header(evidence.metadata.document_header)
84
+ yield document_header(nanopub.metadata.document_header)
85
85
  yield namespaces(combiner.namespace_references)
86
86
  yield annotations(combiner.annotation_references)
87
87
 
@@ -5,7 +5,7 @@ module BEL::Translator::Plugins
5
5
  module BelScript
6
6
  ID = :bel_script
7
7
  NAME = 'BEL Script Translator'
8
- DESCRIPTION = 'A translator that can read/write evidence to BEL Script.'
8
+ DESCRIPTION = 'A translator that reads/writes BEL nanopubs to BEL Script.'
9
9
  MEDIA_TYPES = %i(application/bel)
10
10
  EXTENSIONS = %i(bel)
11
11
 
@@ -1,14 +1,16 @@
1
1
  module BELParser
2
2
  module Script
3
3
  module Keyword
4
- BEL_VERSION_STRING = 'BELVersion'.freeze
5
- BEL_VERSION_REGEX = /\A#{BEL_VERSION_STRING}\Z/i
4
+ BEL_VERSION_STRING = 'BELVersion'.freeze
5
+ BEL_VERSION_REGEX = /\A#{BEL_VERSION_STRING}\Z/i
6
6
 
7
- CITATION = 'Citation'.freeze
8
- CITATION_REGEX = /\A#{CITATION}\Z/i
7
+ CITATION = 'Citation'.freeze
8
+ CITATION_REGEX = /\A#{CITATION}\Z/i
9
9
 
10
- SUPPORT = 'Support'.freeze
11
- SUPPORT_REGEX = /\A#{SUPPORT}\Z/i
10
+ SUPPORT = 'Support'.freeze
11
+ SUPPORT_REGEX = /\A#{SUPPORT}\Z/i
12
+
13
+ IMPLICIT_ANNOTATIONS = ['Citation', 'Support', 'STATEMENT_GROUP']
12
14
 
13
15
  def is_bel_version?(string)
14
16
  string =~ BEL_VERSION_REGEX
@@ -21,6 +23,10 @@ module BELParser
21
23
  def is_support?(string)
22
24
  string =~ SUPPORT_REGEX
23
25
  end
26
+
27
+ def is_implicit_annotation?(string)
28
+ IMPLICIT_ANNOTATIONS.any? { |annotation| string == annotation }
29
+ end
24
30
  end
25
31
  end
26
32
  end
@@ -4,15 +4,16 @@ require 'bel_parser/language/syntax_error'
4
4
  require 'bel_parser/quoting'
5
5
  require 'bel_parser/parsers/ast/node'
6
6
  require 'concurrent/hash'
7
+ require_relative '../keywords'
7
8
 
8
9
  module BELParser
9
10
  module Script
10
11
  module Syntax
11
12
  class UndefinedAnnotation
12
13
  extend BELParser::Language::Syntax::SyntaxFunction
14
+ extend BELParser::Script::Keyword
13
15
 
14
16
  TARGET_NODE = BELParser::Parsers::AST::Set
15
- IMPLICIT_KEYWORDS = ['Citation', 'Evidence', 'STATEMENT_GROUP']
16
17
 
17
18
  def self.map(ast_node, script_context)
18
19
  return nil unless ast_node.is_a?(TARGET_NODE)
@@ -20,7 +21,7 @@ module BELParser
20
21
  annotation_definitions =
21
22
  script_context[:annotation_definitions] ||= Concurrent::Hash.new
22
23
 
23
- return nil if IMPLICIT_KEYWORDS.include?(name_string)
24
+ return nil if is_implicit_annotation?(name_string)
24
25
  return nil if annotation_definitions.key?(name_string)
25
26
  UndefinedAnnotationError.new(
26
27
  ast_node,
@@ -4,6 +4,7 @@ require 'bel_parser/language/syntax_warning'
4
4
  require 'bel_parser/quoting'
5
5
  require 'bel_parser/parsers/ast/node'
6
6
  require 'concurrent/hash'
7
+ require_relative '../keywords'
7
8
 
8
9
  module BELParser
9
10
  module Script
@@ -11,17 +12,17 @@ module BELParser
11
12
  class UndefinedAnnotationValue
12
13
  extend BELParser::Language::Syntax::SyntaxFunction
13
14
  extend BELParser::Quoting
15
+ extend BELParser::Script::Keyword
14
16
 
15
17
  TARGET_NODE = BELParser::Parsers::AST::Set
16
18
  LIST_NODE = BELParser::Parsers::AST::List
17
- IMPLICIT_KEYWORDS = ['Citation', 'Evidence', 'STATEMENT_GROUP']
18
19
 
19
20
  def self.map(ast_node, script_context)
20
21
  return nil unless ast_node.is_a?(TARGET_NODE)
21
22
  name, value = ast_node.children
22
23
  name_string = ast_node.name.identifier.string_literal
23
24
 
24
- return nil if IMPLICIT_KEYWORDS.include?(name_string)
25
+ return nil if is_implicit_annotation?(name_string)
25
26
  dataset = annotation(name_string, script_context)
26
27
  return nil unless dataset
27
28
 
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.22
4
+ version: 1.0.0.alpha.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Bargnesi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-02 00:00:00.000000000 Z
12
+ date: 2016-05-03 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
@@ -30,7 +30,7 @@ files:
30
30
  - lib/bel/translator/plugins/bel_script/bel_citation_serialization.rb
31
31
  - lib/bel/translator/plugins/bel_script/bel_discrete_serialization.rb
32
32
  - lib/bel/translator/plugins/bel_script/bel_top_down_serialization.rb
33
- - lib/bel/translator/plugins/bel_script/evidence_serialization.rb
33
+ - lib/bel/translator/plugins/bel_script/nanopub_serialization.rb
34
34
  - lib/bel/translator/plugins/bel_script/reader.rb
35
35
  - lib/bel/translator/plugins/bel_script/translator.rb
36
36
  - lib/bel/translator/plugins/bel_script/writer.rb