bio-publisci 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -1
  4. data/Rakefile +4 -6
  5. data/features/integration_steps.rb +1 -1
  6. data/features/metadata.feature +24 -0
  7. data/features/metadata_steps.rb +21 -0
  8. data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +36 -14
  9. data/lib/bio-publisci/dataset/ORM/observation.rb +1 -1
  10. data/lib/bio-publisci/dataset/data_cube.rb +192 -131
  11. data/lib/bio-publisci/dataset/dataset_for.rb +150 -0
  12. data/lib/bio-publisci/dataset/interactive.rb +70 -55
  13. data/lib/bio-publisci/metadata/metadata.rb +81 -8
  14. data/lib/bio-publisci/parser.rb +76 -1
  15. data/lib/bio-publisci/readers/big_cross.rb +118 -117
  16. data/lib/bio-publisci/readers/csv.rb +37 -2
  17. data/lib/bio-publisci/readers/r_matrix.rb +1 -1
  18. data/lib/bio-publisci/store.rb +31 -31
  19. data/lib/bio-publisci/writers/arff.rb +48 -49
  20. data/lib/bio-publisci.rb +3 -0
  21. data/resources/queries/code_resources.rq +10 -0
  22. data/resources/queries/dimension_ranges.rq +3 -3
  23. data/resources/queries/dimensions.rq +3 -3
  24. data/resources/queries/measures.rq +3 -3
  25. data/resources/queries/observation_labels.rq +8 -0
  26. data/resources/queries/properties.rq +8 -0
  27. data/scripts/islet_mlratio.rb +6 -0
  28. data/scripts/scan_islet.rb +6 -0
  29. data/scripts/update_reference.rb +20 -0
  30. data/spec/ORM/data_cube_orm_spec.rb +12 -0
  31. data/spec/data_cube_spec.rb +1 -1
  32. data/spec/generators/dataframe_spec.rb +1 -1
  33. data/spec/generators/r_matrix_spec.rb +1 -1
  34. data/spec/r_builder_spec.rb +6 -6
  35. data/spec/resource/.RData +0 -0
  36. data/spec/resource/example.Rhistory +3 -0
  37. data/spec/turtle/bacon +4 -22
  38. data/spec/turtle/reference +9 -27
  39. metadata +37 -56
  40. data/lib/bio-publisci/loader.rb +0 -36
  41. data/spec/bio-publisci_spec.rb +0 -7
@@ -1,119 +1,120 @@
1
1
  module R2RDF
2
- module Reader
3
- class BigCross
4
- include R2RDF::Dataset::DataCube
5
-
6
- def generate_n3(client, var, outfile_base, options={})
7
- meas = measures(client,var,options)
8
- dim = dimensions(client,var,options)
9
- codes = codes(client,var,options)
10
-
11
-
12
- #write structure
13
- open(outfile_base+'_structure.ttl','w'){|f| f.write structure(client,var,options)}
14
-
15
- n_individuals = client.eval("length(#{var}$pheno[[1]])").payload.first
16
- chromosome_list = (1..19).to_a.map(&:to_s) + ["X"]
17
- chromosome_list.map{|chrom|
18
- open(outfile_base+"_#{chrom}.ttl",'w'){|f| f.write prefixes(var,options)}
19
- entries_per_individual = client.eval("length(#{var}$geno$'#{chrom}'$map)").to_ruby
20
-
21
- #get genotype data (currently only for chromosome 1)
22
- # => puts "#{var}$geno$'#{chrom}'"
23
- geno_chr = client.eval("#{var}$geno$'#{chrom}'")
24
-
25
- #get number of markers per individual
26
-
27
- #write observations
28
- n_individuals.times{|indi|
29
- #time ||= Time.now
30
- obs_data = observation_data(client,var,chrom.to_s,indi,geno_chr,entries_per_individual,options)
31
- labels = labels_for(obs_data,chrom.to_s,indi)
32
- 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
35
- }
36
- }
37
-
38
- #generate(measures, dimensions, codes, observation_data, observation_labels, var, options)
39
- end
40
-
41
- def structure(client,var,options={})
42
- meas = measures(client,var,options)
43
- dim = dimensions(client,var,options)
44
- codes = codes(client,var,options)
45
-
46
- str = prefixes(var,options)
47
- str << data_structure_definition(meas,var,options)
48
- str << dataset(var,options)
49
- component_specifications(meas, dim, var, options).map{ |c| str << c }
50
- measure_properties(meas,var,options).map{|m| str << m}
51
-
52
- str
53
- end
54
-
55
- def measures(client, var, options={})
56
- pheno_names = client.eval("names(#{var}$pheno)").to_ruby
57
- if options[:measures]
58
- (pheno_names & options[:measures]) | ["genotype","markerpos","marker"]
59
- else
60
- pheno_names | ["genotype","markerpos","marker"]
61
- end
62
- # measure_properties(measures,var,options)
63
- end
64
-
65
- def dimensions(client, var, options={})
66
- # dimension_properties([""],var)
67
- []
68
- end
69
-
70
- def codes(client, var, options={})
71
- []
72
- end
73
-
74
- def labels_for(data,chr,individual,options={})
75
- labels=(((data.first.last.size*individual)+1)..(data.first.last.size*(individual+1))).to_a.map(&:to_s)
76
- labels.map{|l| l.insert(0,"#{chr}_")}
77
- labels
78
- end
79
-
80
- def observation_data(client, var, chr, row_individ, geno_chr, entries_per_individual, options={})
81
- data = {}
82
- # geno_chr = client.eval("#{var}$geno$'#{chr}'")
83
- # n_individuals = client.eval("#{var}$pheno[[1]]").to_ruby.size
84
- # entries_per_individual = @rexp.payload["geno"].payload[row_individ].payload["map"].payload.size * @rexp.payload["geno"].payload.names.size
85
- data["chr"] = []
86
- data["genotype"] = []
87
- data["individual"] = []
88
- data["marker"] = []
89
- data["markerpos"] = []
90
- client.eval("names(#{var}$pheno)").to_ruby.map{|name|
91
- data[name] = []
92
- }
93
- # n_individuals.times{|row_individ|
94
- # puts "#{row_individ}/#{n_individuals}"
95
- data["individual"] << (1..entries_per_individual).to_a.fill(row_individ)
96
-
97
- client.eval("names(#{var}$pheno)").to_ruby.map{|name|
98
- data[name] << (1..entries_per_individual).to_a.fill(client.eval("#{var}$pheno").payload[name].to_ruby[row_individ])
99
- }
100
- # @rexp.payload["geno"].payload.names.map { |chr|
101
- num_markers = geno_chr.payload.first.to_ruby.column_size
102
- data["chr"] << (1..num_markers).to_a.fill(chr)
103
- data["genotype"] << geno_chr.payload["data"].to_ruby.row(row_individ).to_a
104
- data["marker"] << client.eval("names(#{var}$geno$'#{chr}'$map)").payload
105
- data["markerpos"] << geno_chr.payload["map"].to_a
106
- # }
107
- # }
108
- data.map{|k,v| v.flatten!}
109
- data
110
- end
111
-
112
- def num_individuals(client, var, options={})
113
- client.eval("#{var}$pheno").payload.first.to_ruby.size
114
- end
115
-
116
-
117
- end
118
- end
2
+ module Reader
3
+ class BigCross
4
+ include R2RDF::Dataset::DataCube
5
+
6
+ def generate_n3(client, var, outfile_base, options={})
7
+ meas = measures(client,var,options)
8
+ dim = dimensions(client,var,options)
9
+ codes = codes(client,var,options)
10
+
11
+
12
+ #write structure
13
+ open(outfile_base+'_structure.ttl','w'){|f| f.write structure(client,var,options)}
14
+
15
+ n_individuals = client.eval("length(#{var}$pheno[[1]])").payload.first
16
+ chromosome_list = (1..19).to_a.map(&:to_s) + ["X"]
17
+ chromosome_list.map{|chrom|
18
+ open(outfile_base+"_#{chrom}.ttl",'w'){|f| f.write prefixes(var,options)}
19
+ entries_per_individual = client.eval("length(#{var}$geno$'#{chrom}'$map)").to_ruby
20
+
21
+ #get genotype data (currently only for chromosome 1)
22
+ # => puts "#{var}$geno$'#{chrom}'"
23
+ geno_chr = client.eval("#{var}$geno$'#{chrom}'")
24
+
25
+ #get number of markers per individual
26
+
27
+ #write observations
28
+ n_individuals.times{|indi|
29
+ #time ||= Time.now
30
+ obs_data = observation_data(client,var,chrom.to_s,indi,geno_chr,entries_per_individual,options)
31
+ labels = labels_for(obs_data,chrom.to_s,indi)
32
+ 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
35
+ }
36
+ }
37
+
38
+ #generate(measures, dimensions, codes, observation_data, observation_labels, var, options)
39
+ end
40
+
41
+ def structure(client,var,options={})
42
+ meas = measures(client,var,options)
43
+ dim = dimensions(client,var,options)
44
+ codes = codes(client,var,options)
45
+
46
+ str = prefixes(var,options)
47
+ str << data_structure_definition(meas,dim,codes,var,options)
48
+ str << dataset(var,options)
49
+ component_specifications(meas, dim, var, options).map{ |c| str << c }
50
+ measure_properties(meas,var,options).map{|m| str << m}
51
+
52
+ str
53
+ end
54
+
55
+ def measures(client, var, options={})
56
+ pheno_names = client.eval("names(#{var}$pheno)").to_ruby
57
+ if options[:measures]
58
+ (pheno_names & options[:measures]) | ["genotype","markerpos","marker"]
59
+ else
60
+ pheno_names | ["genotype","markerpos","marker"]
61
+ end
62
+ # measure_properties(measures,var,options)
63
+ end
64
+
65
+ def dimensions(client, var, options={})
66
+ # dimension_properties([""],var)
67
+ []
68
+ end
69
+
70
+ def codes(client, var, options={})
71
+ []
72
+ end
73
+
74
+ def labels_for(data,chr,individual,options={})
75
+ labels=(((data.first.last.size*individual)+1)..(data.first.last.size*(individual+1))).to_a.map(&:to_s)
76
+ labels.map{|l| l.insert(0,"#{chr}_")}
77
+ labels
78
+ end
79
+
80
+ def observation_data(client, var, chr, row_individ, geno_chr, entries_per_individual, options={})
81
+ data = {}
82
+ # geno_chr = client.eval("#{var}$geno$'#{chr}'")
83
+ # n_individuals = client.eval("#{var}$pheno[[1]]").to_ruby.size
84
+ # entries_per_individual = @rexp.payload["geno"].payload[row_individ].payload["map"].payload.size * @rexp.payload["geno"].payload.names.size
85
+ data["chr"] = []
86
+ data["genotype"] = []
87
+ data["individual"] = []
88
+ data["marker"] = []
89
+ data["markerpos"] = []
90
+ pheno_names = client.eval("names(#{var}$pheno)").to_ruby
91
+ pheno_names.map{|name|
92
+ data[name] = []
93
+ }
94
+ # n_individuals.times{|row_individ|
95
+ # puts "#{row_individ}/#{n_individuals}"
96
+ data["individual"] << (1..entries_per_individual).to_a.fill(row_individ)
97
+
98
+ pheno_names.map{|name|
99
+ data[name] << (1..entries_per_individual).to_a.fill(client.eval("#{var}$pheno$#{name}").to_ruby[row_individ])
100
+ }
101
+ # @rexp.payload["geno"].payload.names.map { |chr|
102
+ num_markers = geno_chr.payload.first.to_ruby.column_size
103
+ data["chr"] << (1..num_markers).to_a.fill(chr)
104
+ data["genotype"] << geno_chr.payload["data"].to_ruby.row(row_individ).to_a
105
+ data["marker"] << client.eval("names(#{var}$geno$'#{chr}'$map)").payload
106
+ data["markerpos"] << geno_chr.payload["map"].to_a
107
+ # }
108
+ # }
109
+ data.map{|k,v| v.flatten!}
110
+ data
111
+ end
112
+
113
+ def num_individuals(client, var, options={})
114
+ client.eval("#{var}$pheno").payload.first.to_ruby.size
115
+ end
116
+
117
+
118
+ end
119
+ end
119
120
  end
@@ -1,7 +1,43 @@
1
1
  module R2RDF
2
2
  module Reader
3
3
  class CSV
4
- include R2RDF::Dataset::DataCube
4
+ include R2RDF::Dataset::DataCube
5
+ include R2RDF::Interactive
6
+
7
+ def automatic(file=nil,dataset_name=nil,options={},interactive=true)
8
+ #to do
9
+ unless file || !interactive
10
+ puts "Input file?"
11
+ file = gets.chomp
12
+ end
13
+
14
+ raise "CSV reader needs an input file" unless file && file.size > 0
15
+
16
+
17
+ unless dataset_name
18
+ if interactive
19
+ dataset_name = interact("Dataset name?","#{File.basename(file).split('.').first}"){|sel| File.basename(file).split('.').first }
20
+ else
21
+ dataset_name = File.basename(file).split('.').first
22
+ end
23
+ end
24
+
25
+
26
+ categories = ::CSV.read(file)[0]
27
+
28
+
29
+ unless options[:dimensions] || !interactive
30
+ options[:dimensions] = Array(interact("Dimensions?",categories[0],categories))
31
+ end
32
+
33
+ unless options[:measures] || !interactive
34
+ meas = categories - ((options[:dimensions] || []) | [categories[0]])
35
+ selection = interact("Measures?",meas,meas){|s| nil}
36
+ options[:measures] = Array(selection) unless options[:measures] == nil
37
+ end
38
+
39
+ generate_n3(file,dataset_name,options)
40
+ end
5
41
 
6
42
  def generate_n3(file, dataset_name, options={})
7
43
  @data = ::CSV.read(file)
@@ -34,7 +70,6 @@ module R2RDF
34
70
  end
35
71
 
36
72
  def observation_data
37
-
38
73
  obs = {}
39
74
  @data[0].map{|label|
40
75
  obs[label] = []
@@ -50,7 +50,7 @@ module R2RDF
50
50
  codes = codes(client,var,options)
51
51
 
52
52
  str = prefixes(var, options)
53
- str << data_structure_definition(meas,outvar,options)
53
+ str << data_structure_definition(meas,[],codes,outvar,options)
54
54
  str << dataset(outvar,options)
55
55
  component_specifications(meas, dim, var, options).map{ |c| str << c }
56
56
  measure_properties(meas,var,options).map{|m| str << m}
@@ -1,56 +1,56 @@
1
1
  module R2RDF
2
2
  # handles connection and messaging to/from the triple store
3
3
  class Store
4
- include R2RDF::Query
4
+ include R2RDF::Query
5
5
 
6
6
  def defaults
7
- {
8
- type: :fourstore,
9
- url: "http://localhost:8080", #TODO port etc should eventually be extracted from URI if given
7
+ {
8
+ type: :fourstore,
9
+ url: "http://localhost:8080", #TODO port etc should eventually be extracted from URI if given
10
10
  replace: false
11
- }
12
- end
11
+ }
12
+ end
13
13
 
14
- def add(file,graph)
15
- if @options[:type] == :graph
16
- throw "please provide an RDF::Repository" unless graph.is_a? RDF::Repository
17
- graph.load(file)
18
- @store = graph
19
- @store
20
- elsif @options[:type] == :fourstore
21
- if @options[:replace]
14
+ def add(file,graph)
15
+ if @options[:type] == :graph
16
+ throw "please provide an RDF::Repository" unless graph.is_a? RDF::Repository
17
+ graph.load(file)
18
+ @store = graph
19
+ @store
20
+ elsif @options[:type] == :fourstore
21
+ if @options[:replace]
22
22
  `curl -T #{file} -H 'Content-Type: application/x-turtle' #{@options[:url]}/data/http%3A%2F%2Frqtl.org%2F#{graph}`
23
23
  else
24
24
  `curl --data-urlencode data@#{file} -d 'graph=http%3A%2F%2Frqtl.org%2F#{graph}' -d 'mime-type=application/x-turtle' #{@options[:url]}/data/`
25
25
  end
26
- end
27
- end
26
+ end
27
+ end
28
28
 
29
- def add_all(dir, graph, pattern=nil)
30
- pattern = /.+\.ttl/ if pattern == :turtle || pattern == :ttl
29
+ def add_all(dir, graph, pattern=nil)
30
+ pattern = /.+\.ttl/ if pattern == :turtle || pattern == :ttl
31
31
 
32
- files = Dir.entries(dir) - %w(. ..)
33
- files = files.grep(pattern) if pattern.is_a? Regexp
34
- nfiles = files.size
35
- n = 0
36
- files.each{|file| puts file + " #{n+=1}/#{nfiles} files"; puts add(file,graph)}
37
- end
32
+ files = Dir.entries(dir) - %w(. ..)
33
+ files = files.grep(pattern) if pattern.is_a? Regexp
34
+ nfiles = files.size
35
+ n = 0
36
+ files.each{|file| puts file + " #{n+=1}/#{nfiles} files"; puts add(file,graph)}
37
+ end
38
38
 
39
39
  def initialize(options={})
40
40
  @options = defaults.merge(options)
41
41
  end
42
42
 
43
43
  def query(string)
44
- # execute(string, )
45
- if @options[:type] == :graph
46
- execute(string, @store, :graph)
47
- elsif @options[:type] == :fourstore
48
- execute(string, @options[:url], :fourstore)
49
- end
44
+ # execute(string, )
45
+ if @options[:type] == :graph
46
+ execute(string, @store, :graph)
47
+ elsif @options[:type] == :fourstore
48
+ execute(string, @options[:url], :fourstore)
49
+ end
50
50
  end
51
51
 
52
52
  def url
53
- @options[:url]
53
+ @options[:url]
54
54
  end
55
55
  end
56
56
  end
@@ -1,12 +1,12 @@
1
1
  module R2RDF
2
- module Writer
3
- class ARFF
4
- include R2RDF::Query
5
- include R2RDF::Parser
6
- include R2RDF::Analyzer
2
+ module Writer
3
+ class ARFF
4
+ include R2RDF::Query
5
+ include R2RDF::Parser
6
+ include R2RDF::Analyzer
7
7
 
8
- def build_arff(relation, attributes, data, source)
9
- str = <<-EOS
8
+ def build_arff(relation, attributes, data, source)
9
+ str = <<-EOS
10
10
  % 1. Title: #{relation.capitalize} Database
11
11
  %
12
12
  % 2. Sources:
@@ -16,51 +16,50 @@ module R2RDF
16
16
 
17
17
  EOS
18
18
 
19
- Hash[attributes.sort].map{|attribute,type|
20
- str << "@ATTRIBUTE #{attribute} #{type}\n"
21
- }
19
+ Hash[attributes.sort].map{|attribute,type|
20
+ str << "@ATTRIBUTE #{attribute} #{type}\n"
21
+ }
22
22
 
23
- str << "\n@DATA\n"
24
- data.map { |d| str << Hash[d[1].sort].values.join(',') + "\n" }
23
+ str << "\n@DATA\n"
24
+ data.map { |d| str << Hash[d[1].sort].values.join(',') + "\n" }
25
25
 
26
- str
27
- end
26
+ str
27
+ end
28
28
 
29
- def from_turtle(turtle_file, verbose=false)
30
- puts "loading #{turtle_file}" if verbose
31
- repo = RDF::Repository.load(turtle_file)
32
- puts "loaded #{repo.size} statements into temporary repo" if verbose
33
-
34
- dims = get_ary(execute_from_file("dimensions.rq",repo,:graph)).flatten
35
- meas = get_ary(execute_from_file("measures.rq",repo,:graph)).flatten
36
- relation = execute_from_file("dataset.rq",repo,:graph).to_h.first[:label].to_s
37
- codes = execute_from_file("codes.rq",repo,:graph).to_h.map{|e| e.values.map(&:to_s)}.inject({}){|h,el|
38
- (h[el.first]||=[]) << el.last; h
39
- }
29
+ def from_turtle(turtle_file, verbose=false)
30
+ puts "loading #{turtle_file}" if verbose
31
+ repo = RDF::Repository.load(turtle_file)
32
+ puts "loaded #{repo.size} statements into temporary repo" if verbose
33
+
34
+ dims = execute_from_file("dimensions.rq",repo,:graph).to_h.map{|d| [d[:dimension].to_s, d[:label].to_s]}
35
+ meas = execute_from_file("measures.rq",repo,:graph).to_h.map{|m| [m[:measure].to_s, m[:label].to_s]}
36
+ relation = execute_from_file("dataset.rq",repo,:graph).to_h.first[:label].to_s
37
+ codes = execute_from_file("codes.rq",repo,:graph).to_h.map{|e| e.values.map(&:to_s)}.inject({}){|h,el|
38
+ (h[el.first]||=[]) << el.last; h
39
+ }
40
40
 
41
- data = observation_hash(execute_from_file("observations.rq",repo,:graph), true)
42
- attributes = {}
43
- (dims | meas).map{|component|
44
- attributes[component] = case recommend_range(data.map{|o| o[1][component]})
45
- when "xsd:int"
46
- "integer"
47
- when "xsd:double"
48
- "real"
49
- when :coded
50
- if dims.include? component
51
- "{#{codes[component].join(',')}}"
52
- else
53
- "string"
54
- end
55
- end
56
- }
41
+ data = observation_hash(execute_from_file("observations.rq",repo,:graph), true)
42
+ attributes = {}
43
+ (dims | meas).map{|component|
44
+ attributes[component[1]] = case recommend_range(data.map{|o| o[1][component[1]]})
45
+ when "xsd:int"
46
+ "integer"
47
+ when "xsd:double"
48
+ "real"
49
+ when :coded
50
+ if dims.include? component
51
+ "{#{codes[component[1]].join(',')}}"
52
+ else
53
+ "string"
54
+ end
55
+ end
56
+ }
57
+ build_arff(relation, attributes, data, turtle_file)
58
+ end
57
59
 
58
- build_arff(relation, attributes, data, turtle_file)
59
- end
60
-
61
- def from_store(endpoint_url,variable_in=nil, variable_out=nil, verbose=false)
62
- raise "not implemented yet"
63
- end
64
- end
65
- end
60
+ def from_store(endpoint_url,variable_in=nil, variable_out=nil, verbose=false)
61
+ raise "not implemented yet"
62
+ end
63
+ end
64
+ end
66
65
  end
data/lib/bio-publisci.rb CHANGED
@@ -8,6 +8,8 @@ require 'sparql'
8
8
  require 'sparql/client'
9
9
  require 'rdf/turtle'
10
10
 
11
+ # require 'bio-band'
12
+
11
13
  def load_folder(folder)
12
14
  Dir.foreach(File.dirname(__FILE__) + "/#{folder}") do |file|
13
15
  unless file == "." or file == ".."
@@ -23,6 +25,7 @@ load File.dirname(__FILE__) + '/bio-publisci/r_client.rb'
23
25
  load File.dirname(__FILE__) + '/bio-publisci/analyzer.rb'
24
26
  load File.dirname(__FILE__) + '/bio-publisci/store.rb'
25
27
  load File.dirname(__FILE__) + '/bio-publisci/dataset/data_cube.rb'
28
+ load File.dirname(__FILE__) + '/bio-publisci/dataset/dataset_for.rb'
26
29
 
27
30
 
28
31
  load_folder('bio-publisci/metadata')
@@ -0,0 +1,10 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+
5
+ SELECT DISTINCT ?dimension ?dimLabel ?codeList ?class WHERE{
6
+ ?dimension a qb:DimensionProperty;
7
+ rdfs:label ?dimLabel;
8
+ qb:codeList ?codeList;
9
+ rdfs:range ?class.
10
+ }
@@ -1,8 +1,8 @@
1
1
  PREFIX qb: <http://purl.org/linked-data/cube#>
2
2
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
3
 
4
- SELECT DISTINCT ?dimension ?range WHERE {
5
- ?dim a qb:DimensionProperty;
6
- rdfs:label ?dimension;
4
+ SELECT DISTINCT ?dimension ?range ?label WHERE {
5
+ ?dimension a qb:DimensionProperty;
6
+ rdfs:label ?label;
7
7
  rdfs:range ?range.
8
8
  }
@@ -1,7 +1,7 @@
1
1
  PREFIX qb: <http://purl.org/linked-data/cube#>
2
2
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
3
 
4
- SELECT DISTINCT ?dimension WHERE{
5
- ?dim a qb:DimensionProperty;
6
- rdfs:label ?dimension.
4
+ SELECT DISTINCT ?dimension ?label WHERE{
5
+ ?dimension a qb:DimensionProperty;
6
+ rdfs:label ?label.
7
7
  }
@@ -1,7 +1,7 @@
1
1
  PREFIX qb: <http://purl.org/linked-data/cube#>
2
2
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
3
 
4
- SELECT DISTINCT ?measure WHERE{
5
- ?meas a qb:MeasureProperty;
6
- rdfs:label ?measure.
4
+ SELECT DISTINCT ?measure ?label WHERE{
5
+ ?measure a qb:MeasureProperty;
6
+ rdfs:label ?label.
7
7
  }
@@ -0,0 +1,8 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX prop: <http://www.rqtl.org/dc/properties/>
4
+
5
+ SELECT DISTINCT ?observation ?label WHERE{
6
+ ?observation a qb:Observation;
7
+ rdfs:label ?label.
8
+ }
@@ -0,0 +1,8 @@
1
+ SELECT DISTINCT ?comp ?label
2
+ WHERE {
3
+ {?comp a qb:MeasureProperty;
4
+ rdfs:label ?label.}
5
+ UNION
6
+ {?comp a qb:DimensionProperty;
7
+ rdfs:label ?label.}
8
+ }LIMIT 5
@@ -0,0 +1,6 @@
1
+ load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
2
+
3
+ gen = R2RDF::Reader::RMatrix.new
4
+ con = Rserve::Connection.new
5
+ con.eval("load('#{ARGV[0] || './.RData'}')")
6
+ gen.generate_n3(con, "islet.mlratio", "pheno", {measures: ["probe","individual","pheno"], no_labels: true})
@@ -0,0 +1,6 @@
1
+ load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
2
+
3
+ gen = R2RDF::Reader::RMatrix.new
4
+ con = Rserve::Connection.new
5
+ con.eval("load('#{ARGV[0] || './.RData'}')")
6
+ gen.generate_n3(con, "scan.islet", "scan", {measures: ["probe","marker","lod"], no_labels: true})
@@ -0,0 +1,20 @@
1
+ puts "Really rewrite reference files? This could mess up the tests... [y/N]"
2
+ exit unless gets.chomp == 'y'
3
+
4
+ puts "overwriting #{File.absolute_path(File.dirname(__FILE__) + '/../spec/turtle/bacon')}"
5
+ load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
6
+
7
+ gen = R2RDF::Reader::CSV.new
8
+ turtle_string = gen.generate_n3(File.dirname(__FILE__) + '/../spec/csv/bacon.csv','bacon',{dimensions:["producer","pricerange"], label_column:0})
9
+ open(File.dirname(__FILE__) + '/../spec/turtle/bacon', 'w'){|f| f.write turtle_string}
10
+
11
+ rcon = Rserve::Connection.new
12
+ gen = R2RDF::Reader::Dataframe.new
13
+ rcon.void_eval <<-EOF
14
+ library(qtl)
15
+ data(listeria)
16
+ mr = scanone(listeria,method="mr")
17
+ EOF
18
+ rexp = rcon.eval 'mr'
19
+ turtle_string = gen.generate_n3(rexp,'mr')
20
+ open(File.dirname(__FILE__) + '/../spec/turtle/reference', 'w'){|f| f.write turtle_string}
@@ -0,0 +1,12 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+
3
+ describe R2RDF::Dataset::ORM::DataCube do
4
+
5
+ it "should load and save a turtle file without loss of information" do
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}})
8
+ cube.abbreviate_known(cube.to_n3).should == ref
9
+ # cube.to_n3.should == ref
10
+ end
11
+
12
+ end
@@ -68,7 +68,7 @@ describe R2RDF::Dataset::DataCube do
68
68
  end
69
69
 
70
70
  it 'generates data structure definition' do
71
- dsd = @generator.data_structure_definition(@measures | @dimensions, "bacon")
71
+ dsd = @generator.data_structure_definition(@measures, @dimensions, @codes, "bacon")
72
72
  dsd.is_a?(String).should == true
73
73
  end
74
74