bio-publisci 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Rakefile +5 -5
  4. data/bin/bio-publisci +34 -11
  5. data/examples/bio-band_integration.rb +9 -0
  6. data/examples/no_magic.prov +40 -0
  7. data/examples/primer.prov +28 -0
  8. data/examples/prov_dsl.prov +51 -0
  9. data/features/create_generator.feature +5 -9
  10. data/features/integration_steps.rb +8 -8
  11. data/features/metadata.feature +15 -2
  12. data/features/metadata_steps.rb +21 -0
  13. data/features/orm_steps.rb +5 -5
  14. data/features/prov_dsl.feature +14 -0
  15. data/features/prov_dsl_steps.rb +11 -0
  16. data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +234 -236
  17. data/lib/bio-publisci/dataset/ORM/observation.rb +1 -3
  18. data/lib/bio-publisci/dataset/data_cube.rb +30 -26
  19. data/lib/bio-publisci/dataset/dataset_for.rb +14 -8
  20. data/lib/bio-publisci/metadata/metadata.rb +180 -42
  21. data/lib/bio-publisci/metadata/prov/activity.rb +106 -0
  22. data/lib/bio-publisci/metadata/prov/agent.rb +94 -0
  23. data/lib/bio-publisci/metadata/prov/association.rb +73 -0
  24. data/lib/bio-publisci/metadata/prov/derivation.rb +53 -0
  25. data/lib/bio-publisci/metadata/prov/dsl.rb +159 -0
  26. data/lib/bio-publisci/metadata/prov/element.rb +52 -0
  27. data/lib/bio-publisci/metadata/prov/entity.rb +101 -0
  28. data/lib/bio-publisci/metadata/prov/plan.rb +32 -0
  29. data/lib/bio-publisci/metadata/prov/prov.rb +76 -0
  30. data/lib/bio-publisci/mixins/custom_predicate.rb +26 -0
  31. data/lib/bio-publisci/mixins/vocabulary.rb +8 -0
  32. data/lib/bio-publisci/output.rb +27 -0
  33. data/lib/bio-publisci/parser.rb +17 -8
  34. data/lib/bio-publisci/readers/csv.rb +9 -7
  35. data/lib/bio-publisci/readers/dataframe.rb +9 -8
  36. data/lib/bio-publisci/readers/{big_cross.rb → r_cross.rb} +6 -10
  37. data/lib/bio-publisci/readers/r_matrix.rb +37 -13
  38. data/lib/bio-publisci/spira.rb +82 -0
  39. data/lib/bio-publisci/writers/dataframe.rb +65 -65
  40. data/lib/bio-publisci.rb +9 -4
  41. data/spec/ORM/data_cube_orm_spec.rb +3 -3
  42. data/spec/dataset_for_spec.rb +29 -0
  43. data/spec/generators/r_cross_spec.rb +51 -0
  44. data/spec/generators/r_matrix_spec.rb +14 -5
  45. metadata +42 -8
  46. data/lib/bio-publisci/readers/cross.rb +0 -72
@@ -1,17 +1,17 @@
1
1
  module R2RDF
2
2
  module Reader
3
- class BigCross
3
+ class RCross
4
4
  include R2RDF::Dataset::DataCube
5
+ include R2RDF::Reader::Output
5
6
 
6
7
  def generate_n3(client, var, outfile_base, options={})
7
8
  meas = measures(client,var,options)
8
9
  dim = dimensions(client,var,options)
9
10
  codes = codes(client,var,options)
10
-
11
11
 
12
12
  #write structure
13
13
  open(outfile_base+'_structure.ttl','w'){|f| f.write structure(client,var,options)}
14
-
14
+
15
15
  n_individuals = client.eval("length(#{var}$pheno[[1]])").payload.first
16
16
  chromosome_list = (1..19).to_a.map(&:to_s) + ["X"]
17
17
  chromosome_list.map{|chrom|
@@ -19,23 +19,19 @@ module R2RDF
19
19
  entries_per_individual = client.eval("length(#{var}$geno$'#{chrom}'$map)").to_ruby
20
20
 
21
21
  #get genotype data (currently only for chromosome 1)
22
- # => puts "#{var}$geno$'#{chrom}'"
23
22
  geno_chr = client.eval("#{var}$geno$'#{chrom}'")
24
23
 
25
24
  #get number of markers per individual
26
25
 
27
26
  #write observations
28
27
  n_individuals.times{|indi|
29
- #time ||= Time.now
30
28
  obs_data = observation_data(client,var,chrom.to_s,indi,geno_chr,entries_per_individual,options)
31
29
  labels = labels_for(obs_data,chrom.to_s,indi)
32
30
  open(outfile_base+"_#{chrom}.ttl",'a'){|f| observations(meas,dim,codes,obs_data,labels,var,options).map{|obs| f.write obs}}
33
- puts "(#{chrom}) #{indi}/#{n_individuals}" #(#{Time.now - time})
34
- #time = Time.now
31
+ puts "(#{chrom}) #{indi}/#{n_individuals}" unless options[:quiet]
35
32
  }
36
33
  }
37
34
 
38
- #generate(measures, dimensions, codes, observation_data, observation_labels, var, options)
39
35
  end
40
36
 
41
37
  def structure(client,var,options={})
@@ -48,7 +44,7 @@ module R2RDF
48
44
  str << dataset(var,options)
49
45
  component_specifications(meas, dim, var, options).map{ |c| str << c }
50
46
  measure_properties(meas,var,options).map{|m| str << m}
51
-
47
+
52
48
  str
53
49
  end
54
50
 
@@ -68,7 +64,7 @@ module R2RDF
68
64
  end
69
65
 
70
66
  def codes(client, var, options={})
71
- []
67
+ []
72
68
  end
73
69
 
74
70
  def labels_for(data,chr,individual,options={})
@@ -13,11 +13,11 @@ module R2RDF
13
13
  meas = measures(client,var,options)
14
14
  dim = dimensions(client,var,options)
15
15
  codes = codes(client,var,options)
16
-
16
+
17
17
  outvar = sanitize([var]).first
18
-
18
+
19
19
  probes_per_file = options[:probes_per_file] || 100
20
- col_select = "colnames"
20
+ col_select = "colnames"
21
21
  col_select = "names" if options[:type] == :dataframe
22
22
 
23
23
  #write structure
@@ -30,18 +30,42 @@ module R2RDF
30
30
  end
31
31
  markers = rows(client,var,options)
32
32
 
33
+ if options[:print]
34
+ puts prefixes(var,options)
35
+ end
36
+
37
+ if options[:output] == :string
38
+ str = prefixes(var,options)
39
+ end
40
+
33
41
  probes.each_with_index{|probe,i|
34
42
  #write prefixes and erase old file on first run
35
- open(outfile_base+"_#{i/probes_per_file}.ttl",'w'){|f| f.write prefixes(var,options)} if i % probes_per_file == 0
43
+ unless options[:print] || options[:output] == :string
44
+ open(outfile_base+"_#{i/probes_per_file}.ttl",'w'){|f| f.write prefixes(var,options)} if i % probes_per_file == 0
45
+ end
36
46
  i+=1
37
47
  obs_data = observation_data(client,var,i,markers,options)
38
48
  labels = labels_for(client,var,probe)
39
-
49
+
40
50
  # labels = sanitize(labels)
41
51
  # return obs_data
42
- open(outfile_base+"_#{i/probes_per_file}.ttl",'a'){|f| observations(meas,dim,codes,obs_data,labels,outvar,options).map{|obs| f.write obs}}
43
- puts "#{i}/#{probes.size}" unless options[:quiet]
52
+ if options[:print]
53
+ observations(meas,dim,codes,obs_data,labels,outvar,options).each{|obs| puts obs}
54
+ end
55
+
56
+ if options[:output] == :string
57
+ observations(meas,dim,codes,obs_data,labels,outvar,options).each{|obs| str << obs}
58
+ end
59
+
60
+ unless options[:print] || options[:output] == :string
61
+ open(outfile_base+"_#{i/probes_per_file}.ttl",'a'){|f| observations(meas,dim,codes,obs_data,labels,outvar,options).map{|obs| f.write obs}}
62
+ puts "#{i}/#{probes.size}" unless options[:quiet]
63
+ end
44
64
  }
65
+
66
+ if options[:output] == :string
67
+ str
68
+ end
45
69
  end
46
70
 
47
71
  def structure(client,var,outvar,options={})
@@ -54,14 +78,14 @@ module R2RDF
54
78
  str << dataset(outvar,options)
55
79
  component_specifications(meas, dim, var, options).map{ |c| str << c }
56
80
  measure_properties(meas,var,options).map{|m| str << m}
57
-
81
+
58
82
  str
59
83
  end
60
84
 
61
85
  #for now just make everything a measure
62
86
  def measures(client, var, options={})
63
87
  if options[:measures]
64
- options[:measures]
88
+ options[:measures]
65
89
  else
66
90
  ["probe","marker","value"]
67
91
  end
@@ -74,7 +98,7 @@ module R2RDF
74
98
  end
75
99
 
76
100
  def codes(client, var, options={})
77
- []
101
+ []
78
102
  end
79
103
 
80
104
  def labels_for(connection,var,probe_id,options={})
@@ -124,11 +148,11 @@ module R2RDF
124
148
  data["#{col_label}"] = []
125
149
  data["#{row_label}"] = []
126
150
  data["#{val_label}"] = []
127
-
151
+
128
152
  # n_individuals.times{|row_individ|
129
153
  # puts "#{row_individ}/#{n_individuals}"
130
154
 
131
- col_select = "colnames"
155
+ col_select = "colnames"
132
156
  col_select = "names" if options[:type] == :dataframe
133
157
 
134
158
  if options[:type] == :dataframe
@@ -143,7 +167,7 @@ module R2RDF
143
167
  data["#{row_label}"] << row_names[i]
144
168
  data["#{val_label}"] << lod
145
169
  }
146
-
170
+
147
171
  data.map{|k,v| v.flatten!}
148
172
  data
149
173
  end
@@ -0,0 +1,82 @@
1
+ require 'rdf/4store'
2
+ require 'spira'
3
+
4
+ module R2RDF
5
+ module ORM
6
+
7
+ # class Person < Spira::Base
8
+ # configure :base_uri => "http://example.org/example/people"
9
+
10
+ # property :name, :predicate => FOAF.name, :type => String
11
+
12
+ # end
13
+
14
+ # class Observation < Spira::Base
15
+ # type RDF::URI.new('http://purl.org/linked-data/cube#Observation')
16
+ # property :label, predicate: RDFS.label
17
+
18
+ # end
19
+ QB ||= RDF::Vocabulary.new(RDF::URI.new('http://purl.org/linked-data/cube#'))
20
+
21
+ class Component < Spira::Base
22
+ type QB.ComponentSpecification
23
+ property :dimension, predicate: QB.dimension # RDF::URI.new('http://purl.org/linked-data/cube#dimension')
24
+ property :measure, predicate: QB.measure # RDF::URI.new('http://purl.org/linked-data/cube#measure')
25
+ end
26
+
27
+ class DataStructureDefinition < Spira::Base
28
+ type QB.DataStructureDefinition
29
+ has_many :component, predicate: QB.component
30
+ end
31
+
32
+ class DataSet < Spira::Base
33
+ type QB.DataSet
34
+ property :label, predicate: RDFS.label
35
+
36
+ end
37
+
38
+ class Dimension < Spira::Base
39
+ type QB.DimensionProperty
40
+ property :range, predicate: RDFS.range
41
+ property :label, predicate: RDFS.label
42
+ end
43
+
44
+ class Measure < Spira::Base
45
+ type QB.MeasureProperty
46
+ property :label, predicate: RDFS.label
47
+ end
48
+
49
+
50
+ def load_repo(repo)
51
+ raise "Not an RDF::Repository - #{repo}" unless repo.is_a? RDF::Repository
52
+ Spira.add_repository :default, repo
53
+ end
54
+
55
+ def observation
56
+ unless R2RDF::ORM.const_defined?("Observation")
57
+ obs = Class.new(Spira::Base) do
58
+ type RDF::URI.new('http://purl.org/linked-data/cube#Observation')
59
+
60
+ property :structure, predicate: QB.dataSet
61
+
62
+ ((Dimension.each.to_a | Measure.each.to_a) || []).each{|component|
63
+ property strip_uri(component.subject.to_s), predicate: component.subject
64
+ }
65
+ end
66
+ R2RDF::ORM.const_set("Observation",obs)
67
+ end
68
+ Observation
69
+ end
70
+
71
+ def reload_observation
72
+ R2RDF::ORM.send(:remove_const, "Observation")
73
+ observation
74
+ end
75
+
76
+ def strip_uri(uri)
77
+ uri = uri.to_s.dup
78
+ uri[-1] = '' if uri[-1] == '>'
79
+ uri.to_s.split('/').last.split('#').last
80
+ end
81
+ end
82
+ end
@@ -1,81 +1,81 @@
1
1
  module R2RDF
2
- module Writer
3
- module Dataframe
2
+ module Writer
3
+ module Dataframe
4
4
 
5
- def framestring(name,vectors)
6
- framestr = "#{name} = data.frame("
7
- vectors.map{ |k,v| framestr << k + '=' + k +','}
8
- framestr[-1] = ')'
9
- framestr
10
- end
11
-
12
- def get_vectors(variable_name, helper, repo)
13
- column_names = helper.get_ary(helper.execute(helper.property_names(variable_name), repo)).flatten.map{|n| n.gsub(' Component','')}
14
- vectors = {}
15
- column_names.map{|n|
16
- vectors[n] = helper.get_ary(helper.execute(helper.property_values(variable_name,n),repo),'to_f').flatten unless n == "refRow"
17
- }
18
- vectors
19
- end
5
+ def framestring(name,vectors)
6
+ framestr = "#{name} = data.frame("
7
+ vectors.map{ |k,v| framestr << k + '=' + k +','}
8
+ framestr[-1] = ')'
9
+ framestr
10
+ end
20
11
 
21
- def create_dataframe(name, connection, rows, vectors)
22
- connection.assign('rows', rows)
23
- vectors.map{ |k,v|
24
- connection.assign(k,v)
25
- }
26
- connection.eval(framestring(name,vectors))
27
- connection.eval("row.names(#{name}) <- rows")
28
- connection.eval(name)
29
- end
12
+ def get_vectors(variable_name, helper, repo)
13
+ column_names = helper.get_ary(helper.execute(helper.property_names(variable_name), repo)).flatten.map{|n| n.gsub(' Component','')}
14
+ vectors = {}
15
+ column_names.map{|n|
16
+ vectors[n] = helper.get_ary(helper.execute(helper.property_values(variable_name,n),repo),'to_f').flatten unless n == "refRow"
17
+ }
18
+ vectors
19
+ end
30
20
 
31
- def save_workspace(connection, loc)
32
- connection.eval "save.image(#{loc})"
33
- end
21
+ def create_dataframe(name, connection, rows, vectors)
22
+ connection.assign('rows', rows)
23
+ vectors.map{ |k,v|
24
+ connection.assign(k,v)
25
+ }
26
+ connection.eval(framestring(name,vectors))
27
+ connection.eval("row.names(#{name}) <- rows")
28
+ connection.eval(name)
29
+ end
34
30
 
35
- def get_rownames(variable, helper, repo)
36
- rows = helper.get_ary(helper.execute(helper.row_names(variable), repo)).flatten
37
- end
31
+ def save_workspace(connection, loc)
32
+ connection.eval "save.image(#{loc})"
33
+ end
38
34
 
39
- end
35
+ def get_rownames(variable, helper, repo)
36
+ rows = helper.get_ary(helper.execute(helper.row_names(variable), repo)).flatten
37
+ end
40
38
 
41
- class Builder
42
- include R2RDF::Writer::Dataframe
39
+ end
43
40
 
41
+ class Builder
42
+ include R2RDF::Writer::Dataframe
44
43
 
45
- def from_turtle(turtle_file, connection, variable_in=nil, variable_out=nil, verbose=true, save=true)
46
- unless variable_in && variable_out
47
- puts "no variable specified. Simple inference coming soon" if verbose
48
- return
49
- end
50
- puts "loading #{turtle_file}" if verbose
51
- repo = RDF::Repository.load(turtle_file)
52
- puts "loaded #{repo.size} statements into temporary repo" if verbose
53
- # connection = Rserve::Connection.new
54
- query = R2RDF::QueryHelper.new
55
- rows = get_rownames(variable_in, query, repo)
56
- puts "frame has #{rows.size} rows" if verbose
57
44
 
58
- vectors = get_vectors(variable_in, query, repo)
59
- puts "got vectors of size #{vectors.first.last.size}" if verbose && vectors.first
45
+ def from_turtle(turtle_file, connection, variable_in=nil, variable_out=nil, verbose=true, save=true)
46
+ unless variable_in && variable_out
47
+ puts "no variable specified. Simple inference coming soon" if verbose
48
+ return
49
+ end
50
+ puts "loading #{turtle_file}" if verbose
51
+ repo = RDF::Repository.load(turtle_file)
52
+ puts "loaded #{repo.size} statements into temporary repo" if verbose
53
+ # connection = Rserve::Connection.new
54
+ query = R2RDF::QueryHelper.new
55
+ rows = get_rownames(variable_in, query, repo)
56
+ puts "frame has #{rows.size} rows" if verbose
60
57
 
61
- create_dataframe(variable_out, connection, rows, vectors)
62
- save_workspace(connection, connection.eval('getwd()').to_ruby) if save
63
- end
58
+ vectors = get_vectors(variable_in, query, repo)
59
+ puts "got vectors of size #{vectors.first.last.size}" if verbose && vectors.first
64
60
 
65
- def from_store(endpoint_url,connection,variable_in=nil, variable_out=nil, verbose=true, save=true)
66
- unless variable_in && variable_out
67
- puts "no variable specified. Simple inference coming soon" if verbose
68
- return
69
- end
70
- puts "connecting to endpoint at #{endpoint_url}" if verbose
71
- sparql = SPARQL::Client.new(endpoint_url)
72
- # client = R2RDF::Client.new
73
- query = R2RDF::QueryHelper.new
61
+ create_dataframe(variable_out, connection, rows, vectors)
62
+ save_workspace(connection, connection.eval('getwd()').to_ruby) if save
63
+ end
74
64
 
75
- rows = query.get_ary(sparql.query(query.row_names(variable_in))).flatten
65
+ def from_store(endpoint_url,connection,variable_in=nil, variable_out=nil, verbose=true, save=true)
66
+ unless variable_in && variable_out
67
+ puts "no variable specified. Simple inference coming soon" if verbose
68
+ return
69
+ end
70
+ puts "connecting to endpoint at #{endpoint_url}" if verbose
71
+ sparql = SPARQL::Client.new(endpoint_url)
72
+ # client = R2RDF::Client.new
73
+ query = R2RDF::QueryHelper.new
76
74
 
77
- end
75
+ rows = query.get_ary(sparql.query(query.row_names(variable_in))).flatten
78
76
 
79
- end
80
- end
77
+ end
78
+
79
+ end
80
+ end
81
81
  end
data/lib/bio-publisci.rb CHANGED
@@ -8,16 +8,17 @@ require 'sparql'
8
8
  require 'sparql/client'
9
9
  require 'rdf/turtle'
10
10
 
11
- # require 'bio-band'
12
-
13
11
  def load_folder(folder)
14
12
  Dir.foreach(File.dirname(__FILE__) + "/#{folder}") do |file|
15
13
  unless file == "." or file == ".."
16
- load File.dirname(__FILE__) + "/#{folder}/" + file
14
+ f = File.dirname(__FILE__) + "/#{folder}/" + file
15
+ load f unless File.directory?(f)
17
16
  end
18
- end
17
+ end
19
18
  end
20
19
 
20
+ load_folder('bio-publisci/mixins')
21
+
21
22
  load File.dirname(__FILE__) + '/bio-publisci/dataset/interactive.rb'
22
23
  load File.dirname(__FILE__) + '/bio-publisci/query/query_helper.rb'
23
24
  load File.dirname(__FILE__) + '/bio-publisci/parser.rb'
@@ -26,9 +27,13 @@ load File.dirname(__FILE__) + '/bio-publisci/analyzer.rb'
26
27
  load File.dirname(__FILE__) + '/bio-publisci/store.rb'
27
28
  load File.dirname(__FILE__) + '/bio-publisci/dataset/data_cube.rb'
28
29
  load File.dirname(__FILE__) + '/bio-publisci/dataset/dataset_for.rb'
30
+ load File.dirname(__FILE__) + '/bio-publisci/output.rb'
31
+ load File.dirname(__FILE__) + '/bio-publisci/metadata/prov/prov.rb'
32
+ load File.dirname(__FILE__) + '/bio-publisci/metadata/prov/element.rb'
29
33
 
30
34
 
31
35
  load_folder('bio-publisci/metadata')
36
+ load_folder('bio-publisci/metadata/prov')
32
37
  load_folder('bio-publisci/readers')
33
38
  load_folder('bio-publisci/writers')
34
39
  load_folder('bio-publisci/dataset/ORM')
@@ -1,12 +1,12 @@
1
1
  require_relative '../../lib/bio-publisci.rb'
2
2
 
3
- describe R2RDF::Dataset::ORM::DataCube do
3
+ describe R2RDF::ORM::DataCube do
4
4
 
5
5
  it "should load and save a turtle file without loss of information" do
6
6
  ref = IO.read(File.dirname(__FILE__) + '/../turtle/bacon')
7
- cube = R2RDF::Dataset::ORM::DataCube.load(ref, {skip_metadata: true, generator_options: {label_column: 0}})
7
+ cube = R2RDF::ORM::DataCube.load(ref, {skip_metadata: true, generator_options: {label_column: 0}})
8
8
  cube.abbreviate_known(cube.to_n3).should == ref
9
9
  # cube.to_n3.should == ref
10
10
  end
11
-
11
+
12
12
  end
@@ -0,0 +1,29 @@
1
+ require_relative '../lib/bio-publisci.rb'
2
+
3
+ describe R2RDF::Dataset do
4
+ context 'with a csv file' do
5
+ before(:all) do
6
+ @file = File.dirname(__FILE__) + '/csv/bacon.csv'
7
+ end
8
+
9
+ it "should load with no prompts if all details are specified" do
10
+ turtle_string = R2RDF::Dataset.for(@file,{dimensions:["producer"],measures:["pricerange"]},false)
11
+ (turtle_string =~ /qb:Observation/).should_not be nil
12
+ end
13
+
14
+ it "will request user input if not provided" do
15
+ gen = R2RDF::Reader::CSV.new
16
+ gen.stub(:gets).and_return('pricerange,producer')
17
+ gen.stub(:puts)
18
+ turtle_string = gen.automatic(@file,nil,{measures:["chunkiness"]})
19
+ (turtle_string =~ /prop:pricerange/).should_not be nil
20
+ (turtle_string =~ /prop:producer/).should_not be nil
21
+ end
22
+
23
+ it "will try to guess if told not to be interactive" do
24
+ turtle_string = R2RDF::Dataset.for(@file,false)
25
+ (turtle_string =~ /prop:pricerange/).should_not be nil
26
+ (turtle_string =~ /prop:producer/).should_not be nil
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,51 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+
3
+ require 'tempfile'
4
+
5
+ describe R2RDF::Reader::RCross do
6
+
7
+ def create_graph(turtle_string)
8
+ f = Tempfile.new('graph')
9
+ f.write(turtle_string)
10
+ f.close
11
+ graph = RDF::Graph.load(f.path, :format => :ttl)
12
+ f.unlink
13
+ graph
14
+ end
15
+
16
+ context "with reduced listeria cross", no_travis: true do
17
+ before(:all) do
18
+ @r = Rserve::Connection.new
19
+ @generator = R2RDF::Reader::RCross.new
20
+ @r.eval <<-EOF
21
+ library(qtl)
22
+ data(listeria)
23
+
24
+ liscopy = listeria
25
+
26
+ for(i in 1:20)
27
+ liscopy$geno[[i]]$data <- as.matrix(liscopy$geno[[i]]$data[1:2,])
28
+
29
+ liscopy$pheno <- liscopy$phen[1:2,]
30
+ EOF
31
+ end
32
+
33
+ it "generators output to file by default", no_travis: true do
34
+ f=Tempfile.new('cross')
35
+ @generator.generate_n3(@r,'liscopy',f.path,{quiet: true})
36
+ turtle_string = IO.read("#{f.path}_structure.ttl") + IO.read("#{f.path}_1.ttl")
37
+ graph = create_graph(turtle_string)
38
+ graph.size.should > 0
39
+ end
40
+
41
+ it "can generate string output", no_travis: true #do
42
+ # pending
43
+ # f=Tempfile.new('cross')
44
+ # turtle_string = @generator.generate_n3(@connection,'liscopy',f.path,{quiet: false, output: :string})
45
+
46
+ # graph = create_graph(turtle_string)
47
+ # graph.size.should > 0
48
+ # end
49
+ end
50
+
51
+ end
@@ -7,7 +7,7 @@ require_relative '../../lib/bio-publisci.rb'
7
7
  require 'tempfile'
8
8
 
9
9
  describe R2RDF::Reader::RMatrix do
10
-
10
+
11
11
  def create_graph(turtle_string)
12
12
  f = Tempfile.new('graph')
13
13
  f.write(turtle_string)
@@ -17,19 +17,28 @@ describe R2RDF::Reader::RMatrix do
17
17
  graph
18
18
  end
19
19
 
20
- before(:each) do
20
+ before(:each) do
21
21
  @generator = R2RDF::Reader::RMatrix.new
22
- @connection = Rserve::Connection.new
22
+ @connection = Rserve::Connection.new
23
23
  end
24
24
 
25
25
  it "generators a simple output automatically", no_travis: true do
26
26
  f=Tempfile.new('matrix')
27
- @connection.eval "mat = matrix(c(2, 4, 3, 1, 5, 7), nrow=3, ncol=2)"
27
+ @connection.eval "mat = matrix(c(2, 4, 3, 1, 5, 7), nrow=3, ncol=2)"
28
28
  @generator.generate_n3(@connection,'mat',f.path,{quiet: true})
29
29
 
30
30
  turtle_string = IO.read("#{f.path}_structure.ttl") + IO.read("#{f.path}_0.ttl")
31
- graph = create_graph(turtle_string)
31
+ graph = create_graph(turtle_string)
32
32
  graph.size.should > 0
33
33
  end
34
34
 
35
+ it "can generate string output", no_travis: true do
36
+ f=Tempfile.new('matrix')
37
+ @connection.eval "mat = matrix(c(2, 4, 3, 1, 5, 7), nrow=3, ncol=2)"
38
+ turtle_string = @generator.generate_n3(@connection,'mat',f.path,{quiet: true, output: :string})
39
+
40
+ graph = create_graph(turtle_string)
41
+ graph.size.should > 0
42
+ end
43
+
35
44
  end