biointerchange 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -4
  3. data/Gemfile +2 -3
  4. data/README.md +36 -22
  5. data/VERSION +1 -1
  6. data/examples/Felis_catus.gvf.gz +0 -0
  7. data/examples/Felis_catus_incl_consequences.vcf.gz +0 -0
  8. data/generators/rdfxml.rb +1 -1
  9. data/generators/tsv2rubyclass.rb +31 -0
  10. data/lib/biointerchange/core.rb +17 -5
  11. data/lib/biointerchange/genomics/gff3_rdf_ntriples.rb +591 -137
  12. data/lib/biointerchange/genomics/gff3_reader.rb +16 -3
  13. data/lib/biointerchange/genomics/gvf_reader.rb +1 -1
  14. data/lib/biointerchange/genomics/vcf_feature.rb +46 -0
  15. data/lib/biointerchange/genomics/vcf_feature_set.rb +14 -0
  16. data/lib/biointerchange/genomics/vcf_reader.rb +238 -0
  17. data/lib/biointerchange/gfvo.rb +689 -553
  18. data/lib/biointerchange/life_science_registry.rb +3595 -0
  19. data/lib/biointerchange/textmining/text_mining_rdf_ntriples.rb +33 -35
  20. data/lib/biointerchange/writer.rb +11 -16
  21. data/make.sh +4 -0
  22. data/spec/exceptions_spec.rb +1 -7
  23. data/spec/gff3_rdfwriter_spec.rb +2 -16
  24. data/spec/gvf_rdfwriter_spec.rb +2 -19
  25. data/spec/phylogenetics_spec.rb +1 -13
  26. data/spec/text_mining_pdfx_xml_reader_spec.rb +1 -13
  27. data/spec/text_mining_pubannos_json_reader_spec.rb +1 -14
  28. data/spec/text_mining_rdfwriter_spec.rb +8 -19
  29. data/test.sh +4 -0
  30. data/web/about.html +10 -14
  31. data/web/api.html +11 -13
  32. data/web/bootstrap/css/bootstrap-theme.css +347 -0
  33. data/web/bootstrap/css/bootstrap-theme.css.map +1 -0
  34. data/web/bootstrap/css/bootstrap-theme.min.css +7 -0
  35. data/web/bootstrap/css/bootstrap.css +4764 -4603
  36. data/web/bootstrap/css/bootstrap.css.map +1 -0
  37. data/web/bootstrap/css/bootstrap.min.css +6 -8
  38. data/web/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  39. data/web/bootstrap/fonts/glyphicons-halflings-regular.svg +229 -0
  40. data/web/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  41. data/web/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  42. data/web/bootstrap/js/bootstrap.js +1372 -1448
  43. data/web/bootstrap/js/bootstrap.min.js +5 -5
  44. data/web/cli.html +14 -28
  45. data/web/index.html +15 -33
  46. data/web/ontologies.html +1089 -945
  47. data/web/webservices.html +12 -14
  48. metadata +24 -27
  49. data/lib/biointerchange/gff3o.rb +0 -525
  50. data/lib/biointerchange/gvf1o.rb +0 -1354
  51. data/web/bootstrap/css/bootstrap-responsive.css +0 -1040
  52. data/web/bootstrap/css/bootstrap-responsive.min.css +0 -9
  53. data/web/bootstrap/img/glyphicons-halflings-white.png +0 -0
  54. data/web/bootstrap/img/glyphicons-halflings.png +0 -0
@@ -19,8 +19,7 @@ class RDFWriter < BioInterchange::Writer
19
19
  #
20
20
  # +ostream+:: instance of an IO class or derivative that is used for RDF serialization
21
21
  def initialize(ostream)
22
- raise BioInterchange::Exceptions::ImplementationWriterError, 'The output stream is not an instance of IO or its subclasses.' unless ostream.kind_of?(IO) || ostream.kind_of?(StringIO)
23
- @ostream = ostream
22
+ super(ostream)
24
23
  end
25
24
 
26
25
  # Serializes a model as RDF.
@@ -103,7 +102,9 @@ private
103
102
  graph = RDF::Graph.new
104
103
  document_uri = RDF::URI.new(uri_prefix) if uri_prefix
105
104
  document_uri = RDF::URI.new(model.uri) unless document_uri
106
- graph.insert(RDF::Statement.new(document_uri, RDF.type, BioInterchange::SIO.document))
105
+ set_base(document_uri)
106
+ add_prefix('http://semanticscience.org/resource/', 'sio')
107
+ create_triple(document_uri, RDF.type, BioInterchange::SIO.document)
107
108
  model.contents.each { |content|
108
109
  if content.kind_of?(BioInterchange::TextMining::Content)
109
110
  serialize_content(graph, document_uri, content)
@@ -113,7 +114,7 @@ private
113
114
  raise BioInterchange::Exceptions::ImplementationWriterError, "Can only serialize Content and ContentConnection from a Document."
114
115
  end
115
116
  }
116
- RDF::NTriples::Writer.dump(graph, @ostream)
117
+ close
117
118
  end
118
119
 
119
120
 
@@ -124,7 +125,7 @@ private
124
125
  # +content+:: an instance that describes the content
125
126
  def serialize_content(graph, document_uri, content)
126
127
  content_uri = RDF::URI.new(content.uri)
127
- graph.insert(RDF::Statement.new(document_uri, BioInterchange::SIO.has_attribute, content_uri))
128
+ create_triple(document_uri, BioInterchange::SIO.has_attribute, content_uri)
128
129
  serialize_process(graph, document_uri, content_uri, content.process) if content.process
129
130
 
130
131
  sio_url = BioInterchange::SIO.language_entity
@@ -155,11 +156,10 @@ private
155
156
  sio_url = BioInterchange::SIO.character
156
157
  end
157
158
 
158
- graph.insert(RDF::Statement.new(content_uri, RDF.type, sio_url))
159
+ create_triple(content_uri, RDF.type, sio_url)
159
160
 
160
- graph.insert(RDF::Statement.new(content_uri, BioInterchange::SIO.has_attribute, serialize_content_start(graph, document_uri, content_uri, content)))
161
- graph.insert(RDF::Statement.new(content_uri, BioInterchange::SIO.has_attribute, serialize_content_stop(graph, document_uri, content_uri, content)))
162
-
161
+ create_triple(content_uri, BioInterchange::SIO.has_attribute, serialize_content_start(graph, document_uri, content_uri, content))
162
+ create_triple(content_uri, BioInterchange::SIO.has_attribute, serialize_content_stop(graph, document_uri, content_uri, content))
163
163
  end
164
164
 
165
165
  # Serializes a ContentConnection object for a given document URI.
@@ -169,31 +169,29 @@ private
169
169
  # +content+:: an instance that describes the content
170
170
  def serialize_contentconnection(graph, document_uri, contentcon)
171
171
  contentcon_uri = RDF::URI.new(contentcon.uri)
172
- graph.insert(RDF::Statement.new(document_uri, BioInterchange::SIO.has_attribute, contentcon_uri))
172
+ create_triple(document_uri, BioInterchange::SIO.has_attribute, contentcon_uri)
173
173
  serialize_process(graph, document_uri, contentcon_uri, contentcon.process) if contentcon.process
174
174
 
175
-
176
175
  #TODO these sio tags need confirming - there are here as a initial proof of concept
177
176
  #next issue, some of these are relations and some are labels, need to separate out which
178
177
  #I seem to recall that the only relationship types that should be used are "has_attribute" and "RDF::type", in which case these need adjusting for that.
179
178
  #I presume this'd mean making a "has_attribute" link between the content1 and the contentconnection relationship in some way.
180
179
  case contentcon.type
181
180
  when ContentConnection::UNSPECIFIED
182
- graph.insert(RDF::Statement.new(contentcon.content1.uri, BioInterchange::SIO.has_attribute, BioInterchange::SIO.language_entity))
181
+ create_triple(contentcon.content1.uri, BioInterchange::SIO.has_attribute, BioInterchange::SIO.language_entity)
183
182
  when ContentConnection::EQUIVALENCE
184
- graph.insert(RDF::Statement.new(contentcon.content1.uri, BioInterchange::SIO.is_equal_to, contentcon.content2.uri))
183
+ create_triple(contentcon.content1.uri, BioInterchange::SIO.is_equal_to, contentcon.content2.uri)
185
184
  when ContentConnection::SUBCLASS
186
185
  #TODO this class needs more information, the relationship is between a contentcon.content, and 'something'... I've yet to work out what
187
- graph.insert(RDF::Statement.new(contentcon.content2.uri, BioInterchange::SIO.has_attribute, BioInterchange::SIO.in_relation_to))
186
+ create_triple(contentcon.content2.uri, BioInterchange::SIO.has_attribute, BioInterchange::SIO.in_relation_to)
188
187
  when ContentConnection::THEME
189
188
  #TODO there are other more specific options for this that need investigating as options.
190
- graph.insert(RDF::Statement.new(contentcon.content1.uri, BioInterchange::SIO.has_target, contentcon.content2.uri))
189
+ create_triple(contentcon.content1.uri, BioInterchange::SIO.has_target, contentcon.content2.uri)
191
190
  when ContentConnection::SPECULATION
192
- graph.insert(RDF::Statement.new(contentcon.content1.uri, BioInterchange::SIO.has_attribute, BioInterchange::SIO.speculation))
191
+ create_triple(contentcon.content1.uri, BioInterchange::SIO.has_attribute, BioInterchange::SIO.speculation)
193
192
  when ContentConnection::NEGATION
194
- graph.insert(RDF::Statement.new(contentcon.content1.uri, BioInterchange::SIO.denotes, BioInterchange::SIO.negative_regulation))
193
+ create_triple(contentcon.content1.uri, BioInterchange::SIO.denotes, BioInterchange::SIO.negative_regulation)
195
194
  end
196
-
197
195
  end
198
196
 
199
197
  # Serializes a process object for a specific document uri
@@ -201,17 +199,17 @@ private
201
199
  #
202
200
  def serialize_process(graph, document_uri, content_uri, process)
203
201
  process_uri = process_uri(process, :process)
204
- graph.insert(RDF::Statement.new(content_uri, BioInterchange::SIO.is_direct_part_of, process_uri))
202
+ create_triple(content_uri, BioInterchange::SIO.is_direct_part_of, process_uri)
205
203
  # If this is an email address, then create a FOAF representation, otherwise, do something else:
206
204
  if process.type == BioInterchange::TextMining::Process::MANUAL then
207
- graph.insert(RDF::Statement.new(process_uri, RDF.type, RDF::FOAF.Person))
208
- graph.insert(RDF::Statement.new(process_uri, RDF::FOAF.name, RDF::Literal.new(process.name)))
209
- graph.insert(RDF::Statement.new(process_uri, RDF::FOAF.name, RDF::URI.new(process.uri)))
205
+ create_triple(process_uri, RDF.type, RDF::FOAF.Person)
206
+ create_triple(process_uri, RDF::FOAF.name, RDF::Literal.new(process.name))
207
+ create_triple(process_uri, RDF::FOAF.name, RDF::URI.new(process.uri))
210
208
  else
211
- graph.insert(RDF::Statement.new(process_uri, RDF.type, BioInterchange::SIO.process))
212
- graph.insert(RDF::Statement.new(process_uri, BioInterchange::SIO.has_attribute, serialize_process_name(graph, document_uri, content_uri, process_uri, process)))
213
- graph.insert(RDF::Statement.new(process_uri, BioInterchange::SIO.has_attribute, serialize_process_uri(graph, document_uri, content_uri, process_uri, process)))
214
- graph.insert(RDF::Statement.new(process_uri, BioInterchange::SIO.has_attribute, serialize_process_date(graph, document_uri, content_uri, process_uri, process))) if process.date
209
+ create_triple(process_uri, RDF.type, BioInterchange::SIO.process)
210
+ create_triple(process_uri, BioInterchange::SIO.has_attribute, serialize_process_name(graph, document_uri, content_uri, process_uri, process))
211
+ create_triple(process_uri, BioInterchange::SIO.has_attribute, serialize_process_uri(graph, document_uri, content_uri, process_uri, process))
212
+ create_triple(process_uri, BioInterchange::SIO.has_attribute, serialize_process_date(graph, document_uri, content_uri, process_uri, process)) if process.date
215
213
  end
216
214
  end
217
215
 
@@ -220,8 +218,8 @@ private
220
218
  #
221
219
  def serialize_process_name(graph, document_uri, content_uri, process_uri, process)
222
220
  kind_uri = process_uri(process, :name)
223
- graph.insert(RDF::Statement.new(kind_uri, RDF.type, BioInterchange::SIO.name))
224
- graph.insert(RDF::Statement.new(kind_uri, BioInterchange::SIO.has_attribute, RDF::Literal.new("#{process.name}")))
221
+ create_triple(kind_uri, RDF.type, BioInterchange::SIO.name)
222
+ create_triple(kind_uri, BioInterchange::SIO.has_attribute, RDF::Literal.new("#{process.name}"))
225
223
  end
226
224
 
227
225
  #
@@ -229,8 +227,8 @@ private
229
227
  #
230
228
  def serialize_process_uri(graph, document_uri, content_uri, process_uri, process)
231
229
  kind_uri = process_uri(process, :uri)
232
- graph.insert(RDF::Statement.new(kind_uri, RDF.type, BioInterchange::SIO.software_entity))
233
- graph.insert(RDF::Statement.new(kind_uri, BioInterchange::SIO.has_attribute, RDF::URI.new(process.uri)))
230
+ create_triple(kind_uri, RDF.type, BioInterchange::SIO.software_entity)
231
+ create_triple(kind_uri, BioInterchange::SIO.has_attribute, RDF::URI.new(process.uri))
234
232
  end
235
233
 
236
234
  #
@@ -238,7 +236,7 @@ private
238
236
  #
239
237
  def serialize_process_date(graph, document_uri, content_uri, process_uri, process)
240
238
  kind_uri = process_uri(process, :date)
241
- graph.insert(RDF::Statement.new(kind_uri, RDF::DC.date, RDF::Literal.new(Date.parse(process.date))))
239
+ create_triple(kind_uri, RDF::DC.date, RDF::Literal.new(Date.parse(process.date)))
242
240
  end
243
241
 
244
242
  #
@@ -246,8 +244,8 @@ private
246
244
  #
247
245
  def serialize_content_start(graph, document_uri, content_uri, content)
248
246
  kind_uri = content_uri(content, :start)
249
- graph.insert(RDF::Statement.new(kind_uri, RDF::type, BioInterchange::SIO.start_position))
250
- graph.insert(RDF::Statement.new(kind_uri, BioInterchange::SIO.has_attribute, RDF::Literal.new(content.offset)))
247
+ create_triple(kind_uri, RDF::type, BioInterchange::SIO.start_position)
248
+ create_triple(kind_uri, BioInterchange::SIO.has_attribute, RDF::Literal.new(content.offset))
251
249
  end
252
250
 
253
251
  #
@@ -255,8 +253,8 @@ private
255
253
  #
256
254
  def serialize_content_stop(graph, document_uri, content_uri, content)
257
255
  kind_uri = content_uri(content, :stop)
258
- graph.insert(RDF::Statement.new(kind_uri, RDF::type, BioInterchange::SIO.stop_position))
259
- graph.insert(RDF::Statement.new(kind_uri, BioInterchange::SIO.has_attribute, RDF::Literal.new((content.offset+content.length).to_s)))
256
+ create_triple(kind_uri, RDF::type, BioInterchange::SIO.stop_position)
257
+ create_triple(kind_uri, BioInterchange::SIO.has_attribute, RDF::Literal.new((content.offset+content.length).to_s))
260
258
  end
261
259
 
262
260
  end
@@ -12,6 +12,13 @@ class Writer
12
12
  def initialize(ostream)
13
13
  raise BioInterchange::Exceptions::ImplementationWriterError, 'The output stream is not an instance of IO or its subclasses.' unless ostream.kind_of?(IO)
14
14
  @ostream = ostream
15
+ @prefixes = {
16
+ '<http://purl.org/dc/terms/' => 'dc:',
17
+ '<http://www.w3.org/1999/02/22-rdf-syntax-ns#' => 'rdf:',
18
+ '<http://www.w3.org/2000/01/rdf-schema#' => 'rdfs:',
19
+ '<http://www.w3.org/2002/07/owl#' => 'owl:',
20
+ '<http://www.w3.org/2001/XMLSchema#' => 'xsd:'
21
+ }
15
22
  end
16
23
 
17
24
  # Serializes an object model instance.
@@ -43,7 +50,6 @@ class Writer
43
50
  object_representation = "<#{object_uri}>".sub(/\s/, '%20')
44
51
  else
45
52
  if datatype then
46
- # TODO Append type.
47
53
  object_representation = "\"#{object.to_s}\"^^<#{datatype.to_s}>"
48
54
  else
49
55
  object_representation = "\"#{object.to_s}\""
@@ -54,7 +60,7 @@ class Writer
54
60
  if BioInterchange::format == :turtle then
55
61
  serialize_turtle(subject_uri, predicate_uri, object_representation)
56
62
  else
57
- @ostream.puts("#{subject_uri} #{predicate_uri} #{object_representation}")
63
+ @ostream.puts("#{subject_uri} #{predicate_uri} #{object_representation} .")
58
64
  end
59
65
  rescue Errno::EPIPE
60
66
  # Whenever an output pipe disappears, then the user may be happy with what he/she
@@ -62,6 +68,8 @@ class Writer
62
68
  # such as "head".
63
69
  exit 0
64
70
  end
71
+
72
+ subject
65
73
  end
66
74
 
67
75
  # Finishes serializing triples.
@@ -73,13 +81,11 @@ class Writer
73
81
 
74
82
  # Sets the base URI prefix that is output/used when serializing triples in Turtle.
75
83
  def set_base(uri_prefix)
76
- uri_prefix(nil)
77
84
  @prefixes["<#{uri_prefix}"] = '<'
78
85
  end
79
86
 
80
87
  # Adds a URI prefix that should be abbreviated when serializing triples in Turtle.
81
88
  def add_prefix(uri_prefix, abbreviation_prefix)
82
- uri_prefix(nil)
83
89
  @prefixes["<#{uri_prefix}"] = "#{abbreviation_prefix}:"
84
90
  end
85
91
 
@@ -89,21 +95,10 @@ private
89
95
  #
90
96
  # +uri+:: URI that should be shortened
91
97
  def uri_prefix(uri)
92
- @prefixes = {
93
- '<http://biohackathon.org/resource/faldo#' => 'faldo:',
94
- '<http://purl.obolibrary.org/obo/' => 'obo:',
95
- '<http://purl.org/dc/terms/' => 'dc:',
96
- '<http://www.biointerchange.org/gfvo#' => 'gfvo:',
97
- '<http://www.w3.org/1999/02/22-rdf-syntax-ns#' => 'rdf:',
98
- '<http://www.w3.org/2000/01/rdf-schema#' => 'rdfs:',
99
- '<http://www.w3.org/2001/XMLSchema#' => 'xsd:',
100
- '<http://www.w3.org/2002/07/owl#' => 'owl:'
101
- } unless @prefixes
102
-
103
98
  return nil unless uri
104
99
 
105
100
  @prefixes.keys.each { |prefix|
106
- return prefix if uri.start_with?(prefix)
101
+ return prefix if uri.start_with?(prefix) and not "#{prefix}>" == uri
107
102
  }
108
103
  nil
109
104
  end
data/make.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+
3
+ bundle exec rake gemspec ; bundle exec gem build biointerchange.gemspec ; gem install --no-rdoc --no-ri biointerchange
4
+
@@ -2,13 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'rspec'
4
4
 
5
- # Turn off verbose reporting here, since class definitions may be loaded multiple
6
- # times here. That reports that constants have been already been initialized, which
7
- # is true, but they are only "re-initialized" with the very same values.
8
- v, $VERBOSE = $VERBOSE, nil
9
- load 'lib/biointerchange/core.rb'
10
- load 'lib/biointerchange/exceptions.rb'
11
- $VERBOSE = v
5
+ require 'biointerchange'
12
6
 
13
7
  describe BioInterchange::Exceptions do
14
8
  describe 'error and exception creation tests' do
@@ -2,21 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'rspec'
4
4
 
5
- # Turn off verbose reporting here, since class definitions may be loaded multiple
6
- # times here. That reports that constants have been already been initialized, which
7
- # is true, but they are only "re-initialized" with the very same values.
8
- v, $VERBOSE = $VERBOSE, nil
9
- load 'lib/biointerchange/core.rb'
10
- load 'lib/biointerchange/gfvo.rb'
11
- load 'lib/biointerchange/sofa.rb'
12
- load 'lib/biointerchange/reader.rb'
13
- load 'lib/biointerchange/model.rb'
14
- load 'lib/biointerchange/writer.rb'
15
- load 'lib/biointerchange/genomics/gff3_rdf_ntriples.rb'
16
- load 'lib/biointerchange/genomics/gff3_feature_set.rb'
17
- load 'lib/biointerchange/genomics/gff3_feature.rb'
18
- load 'lib/biointerchange/genomics/gff3_feature_sequence.rb'
19
- $VERBOSE = v
5
+ require 'biointerchange'
20
6
 
21
7
  describe BioInterchange::Genomics::RDFWriter do
22
8
  describe 'serialization of GFF3 models' do
@@ -73,7 +59,7 @@ describe BioInterchange::Genomics::RDFWriter do
73
59
  lines.each { |line|
74
60
  feature_no += 1 if line.match(/\sa\s+gfvo:Feature\s+[.,;]$/)
75
61
  }
76
- lines.count.should be == 64
62
+ lines.count.should be == 91
77
63
  feature_no.should be == 3
78
64
  end
79
65
  end
@@ -2,24 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'rspec'
4
4
 
5
- # Turn off verbose reporting here, since class definitions may be loaded multiple
6
- # times here. That reports that constants have been already been initialized, which
7
- # is true, but they are only "re-initialized" with the very same values.
8
- v, $VERBOSE = $VERBOSE, nil
9
- load 'lib/biointerchange/core.rb'
10
- load 'lib/biointerchange/gfvo.rb'
11
- load 'lib/biointerchange/sofa.rb'
12
- load 'lib/biointerchange/reader.rb'
13
- load 'lib/biointerchange/model.rb'
14
- load 'lib/biointerchange/writer.rb'
15
- load 'lib/biointerchange/genomics/gvf_feature_set.rb'
16
- load 'lib/biointerchange/genomics/gvf_feature.rb'
17
- # The GVF implementation extends the GFF3 implementation, so load those classes too:
18
- load 'lib/biointerchange/genomics/gff3_rdf_ntriples.rb'
19
- load 'lib/biointerchange/genomics/gff3_feature_set.rb'
20
- load 'lib/biointerchange/genomics/gff3_feature.rb'
21
- load 'lib/biointerchange/genomics/gff3_feature_sequence.rb'
22
- $VERBOSE = v
5
+ require 'biointerchange'
23
6
 
24
7
  describe BioInterchange::Genomics::RDFWriter do
25
8
  describe 'serialization of GVF models' do
@@ -73,7 +56,7 @@ describe BioInterchange::Genomics::RDFWriter do
73
56
  lines.each { |line|
74
57
  feature_no += 1 if line.match(/\sa\s+gfvo:Feature\s+[.,;]$/)
75
58
  }
76
- lines.count.should be == 64
59
+ lines.count.should be == 91
77
60
  feature_no.should be == 3
78
61
  end
79
62
  end
@@ -3,19 +3,7 @@ require 'rubygems'
3
3
  require 'rspec'
4
4
  require 'bio'
5
5
 
6
- # Turn off verbose reporting here, since class definitions may be loaded multiple
7
- # times here. That reports that constants have been already been initialized, which
8
- # is true, but they are only "re-initialized" with the very same values.
9
- v, $VERBOSE = $VERBOSE, nil
10
- load 'lib/biointerchange/core.rb'
11
- load 'lib/biointerchange/cdao.rb'
12
- load 'lib/biointerchange/reader.rb'
13
- load 'lib/biointerchange/model.rb'
14
- load 'lib/biointerchange/writer.rb'
15
- load 'lib/biointerchange/phylogenetics/newick_reader.rb'
16
- load 'lib/biointerchange/phylogenetics/tree_set.rb'
17
- load 'lib/biointerchange/phylogenetics/cdao_rdf_ntriples.rb'
18
- $VERBOSE = v
6
+ require 'biointerchange'
19
7
 
20
8
  describe BioInterchange::Phylogenetics::NewickReader do
21
9
  describe 'deserialization of Newick trees' do
@@ -2,19 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'rspec'
4
4
 
5
- # Turn off verbose reporting here, since class definitions may be loaded multiple
6
- # times here. That reports that constants have been already been initialized, which
7
- # is true, but they are only "re-initialized" with the very same values.
8
- v, $VERBOSE = $VERBOSE, nil
9
- load 'lib/biointerchange/core.rb'
10
- load 'lib/biointerchange/reader.rb'
11
- load 'lib/biointerchange/model.rb'
12
- load 'lib/biointerchange/textmining/text_mining_reader.rb'
13
- load 'lib/biointerchange/textmining/pdfx_xml_reader.rb'
14
- load 'lib/biointerchange/textmining/document.rb'
15
- load 'lib/biointerchange/textmining/content.rb'
16
- load 'lib/biointerchange/textmining/process.rb'
17
- $VERBOSE = v
5
+ require 'biointerchange'
18
6
 
19
7
  describe BioInterchange::TextMining::PDFxXMLReader do
20
8
  describe 'deserialization of pdfx text-mining documents' do
@@ -2,20 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'rspec'
4
4
 
5
- # Turn off verbose reporting here, since class definitions may be loaded multiple
6
- # times here. That reports that constants have been already been initialized, which
7
- # is true, but they are only "re-initialized" with the very same values.
8
- v, $VERBOSE = $VERBOSE, nil
9
- load 'lib/biointerchange/core.rb'
10
- load 'lib/biointerchange/reader.rb'
11
- load 'lib/biointerchange/model.rb'
12
- load 'lib/biointerchange/textmining/text_mining_reader.rb'
13
- load 'lib/biointerchange/textmining/pubannos_json_reader.rb'
14
- load 'lib/biointerchange/textmining/document.rb'
15
- load 'lib/biointerchange/textmining/content.rb'
16
- load 'lib/biointerchange/textmining/content_connection.rb'
17
- load 'lib/biointerchange/textmining/process.rb'
18
- $VERBOSE = v
5
+ require 'biointerchange'
19
6
 
20
7
  describe BioInterchange::TextMining::PubAnnosJSONReader do
21
8
  describe 'deserialization of pubannos json text-mining documents' do
@@ -1,21 +1,9 @@
1
1
 
2
2
  require 'rubygems'
3
3
  require 'rspec'
4
+ require 'tempfile'
4
5
 
5
- # Turn off verbose reporting here, since class definitions may be loaded multiple
6
- # times here. That reports that constants have been already been initialized, which
7
- # is true, but they are only "re-initialized" with the very same values.
8
- v, $VERBOSE = $VERBOSE, nil
9
- load 'lib/biointerchange/core.rb'
10
- load 'lib/biointerchange/sio.rb'
11
- load 'lib/biointerchange/reader.rb'
12
- load 'lib/biointerchange/model.rb'
13
- load 'lib/biointerchange/writer.rb'
14
- load 'lib/biointerchange/textmining/text_mining_rdf_ntriples.rb'
15
- load 'lib/biointerchange/textmining/document.rb'
16
- load 'lib/biointerchange/textmining/content.rb'
17
- load 'lib/biointerchange/textmining/process.rb'
18
- $VERBOSE = v
6
+ require 'biointerchange'
19
7
 
20
8
  describe BioInterchange::TextMining::RDFWriter do
21
9
  describe 'serialization of text-mining documents' do
@@ -23,7 +11,7 @@ describe BioInterchange::TextMining::RDFWriter do
23
11
  istream, ostream = IO.pipe
24
12
  BioInterchange::TextMining::RDFWriter.new(ostream).serialize(BioInterchange::TextMining::Document.new('http://example.org'))
25
13
  ostream.close
26
- istream.read.lines.count.should eq(1)
14
+ istream.read.lines.count.should eq(8)
27
15
  end
28
16
 
29
17
  it 'document with two entities' do
@@ -61,14 +49,15 @@ describe BioInterchange::TextMining::RDFWriter do
61
49
  end
62
50
 
63
51
  it 'full advanced json document' do
64
- ostream = StringIO.new
52
+ ofile = Tempfile.new('full_advanced_json_document.ttl')
65
53
  reader = BioInterchange::TextMining::PubAnnosJSONReader.new("Test", "http://test.com", "2012-12-09", BioInterchange::TextMining::Process::UNSPECIFIED, "0.0")
66
54
 
67
55
  model = reader.deserialize(File.new('examples/pubannotation.2626671.json'))
68
56
 
69
- BioInterchange::TextMining::RDFWriter.new(ostream).serialize(model)
70
- ostream.close_write
71
- ostream.string.lines.count.should > 100
57
+ BioInterchange::TextMining::RDFWriter.new(File.new(ofile, 'w')).serialize(model)
58
+ ofile.close
59
+ IO.readlines(ofile.path).count.should be > 100
60
+ ofile.unlink
72
61
  end
73
62
  end
74
63
  end