bio-publisci 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +13 -0
  4. data/Gemfile +24 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.md +47 -0
  7. data/README.rdoc +48 -0
  8. data/Rakefile +70 -0
  9. data/bin/bio-publisci +83 -0
  10. data/features/create_generator.feature +25 -0
  11. data/features/integration.feature +12 -0
  12. data/features/integration_steps.rb +10 -0
  13. data/features/orm.feature +60 -0
  14. data/features/orm_steps.rb +74 -0
  15. data/features/reader.feature +25 -0
  16. data/features/reader_steps.rb +60 -0
  17. data/features/step_definitions/bio-publisci_steps.rb +0 -0
  18. data/features/store.feature +27 -0
  19. data/features/store_steps.rb +42 -0
  20. data/features/support/env.rb +13 -0
  21. data/features/writer.feature +9 -0
  22. data/features/writer_steps.rb +17 -0
  23. data/lib/bio-publisci/analyzer.rb +57 -0
  24. data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +219 -0
  25. data/lib/bio-publisci/dataset/ORM/observation.rb +20 -0
  26. data/lib/bio-publisci/dataset/data_cube.rb +308 -0
  27. data/lib/bio-publisci/dataset/interactive.rb +57 -0
  28. data/lib/bio-publisci/loader.rb +36 -0
  29. data/lib/bio-publisci/metadata/metadata.rb +105 -0
  30. data/lib/bio-publisci/parser.rb +64 -0
  31. data/lib/bio-publisci/query/query_helper.rb +114 -0
  32. data/lib/bio-publisci/r_client.rb +54 -0
  33. data/lib/bio-publisci/readers/arff.rb +87 -0
  34. data/lib/bio-publisci/readers/big_cross.rb +119 -0
  35. data/lib/bio-publisci/readers/cross.rb +72 -0
  36. data/lib/bio-publisci/readers/csv.rb +54 -0
  37. data/lib/bio-publisci/readers/dataframe.rb +66 -0
  38. data/lib/bio-publisci/readers/r_matrix.rb +152 -0
  39. data/lib/bio-publisci/store.rb +56 -0
  40. data/lib/bio-publisci/writers/arff.rb +66 -0
  41. data/lib/bio-publisci/writers/dataframe.rb +81 -0
  42. data/lib/bio-publisci.rb +36 -0
  43. data/lib/r2rdf.rb +226 -0
  44. data/lib/template_bak/publisci.rb +3 -0
  45. data/lib/template_bak.rb +12 -0
  46. data/lib/vocabs/cc.rb +18 -0
  47. data/lib/vocabs/cert.rb +13 -0
  48. data/lib/vocabs/dc.rb +63 -0
  49. data/lib/vocabs/dc11.rb +23 -0
  50. data/lib/vocabs/doap.rb +45 -0
  51. data/lib/vocabs/exif.rb +168 -0
  52. data/lib/vocabs/foaf.rb +69 -0
  53. data/lib/vocabs/geo.rb +13 -0
  54. data/lib/vocabs/http.rb +26 -0
  55. data/lib/vocabs/ma.rb +78 -0
  56. data/lib/vocabs/owl.rb +59 -0
  57. data/lib/vocabs/rdfs.rb +17 -0
  58. data/lib/vocabs/rsa.rb +12 -0
  59. data/lib/vocabs/rss.rb +14 -0
  60. data/lib/vocabs/sioc.rb +93 -0
  61. data/lib/vocabs/skos.rb +36 -0
  62. data/lib/vocabs/wot.rb +21 -0
  63. data/lib/vocabs/xhtml.rb +9 -0
  64. data/lib/vocabs/xsd.rb +58 -0
  65. data/resources/queries/codes.rq +13 -0
  66. data/resources/queries/dataset.rq +7 -0
  67. data/resources/queries/dimension_ranges.rq +8 -0
  68. data/resources/queries/dimensions.rq +7 -0
  69. data/resources/queries/measures.rq +7 -0
  70. data/resources/queries/observations.rq +12 -0
  71. data/resources/queries/test.rq +3 -0
  72. data/resources/weather.numeric.arff +23 -0
  73. data/spec/analyzer_spec.rb +36 -0
  74. data/spec/bio-publisci_spec.rb +7 -0
  75. data/spec/csv/bacon.csv +4 -0
  76. data/spec/csv/moar_bacon.csv +11 -0
  77. data/spec/data_cube_spec.rb +166 -0
  78. data/spec/generators/csv_spec.rb +44 -0
  79. data/spec/generators/dataframe_spec.rb +44 -0
  80. data/spec/generators/r_matrix_spec.rb +35 -0
  81. data/spec/queries/integrity/1.rq +21 -0
  82. data/spec/queries/integrity/11.rq +29 -0
  83. data/spec/queries/integrity/12.rq +37 -0
  84. data/spec/queries/integrity/14.rq +25 -0
  85. data/spec/queries/integrity/19_1.rq +21 -0
  86. data/spec/queries/integrity/19_2.rq +15 -0
  87. data/spec/queries/integrity/2.rq +22 -0
  88. data/spec/queries/integrity/3.rq +19 -0
  89. data/spec/queries/integrity/4.rq +13 -0
  90. data/spec/queries/integrity/5.rq +14 -0
  91. data/spec/r_builder_spec.rb +33 -0
  92. data/spec/spec_helper.rb +17 -0
  93. data/spec/turtle/bacon +149 -0
  94. data/spec/turtle/reference +2066 -0
  95. metadata +259 -0
@@ -0,0 +1,166 @@
1
+ # require_relative '../lib/r2rdf/data_cube.rb'
2
+ # require_relative '../lib/r2rdf/generators/dataframe.rb'
3
+ # require_relative '../lib/r2rdf/r_client.rb'
4
+ # require_relative '../lib/r2rdf/r_builder.rb'
5
+ # require_relative '../lib/r2rdf/generators/csv.rb'
6
+
7
+ require_relative '../lib/bio-publisci.rb'
8
+
9
+
10
+ describe R2RDF::Dataset::DataCube do
11
+
12
+ context "with Plain Old Ruby objects" do
13
+ #define a temporary class to use module methods
14
+ before(:all) do
15
+ class Gen
16
+ include R2RDF::Dataset::DataCube
17
+ end
18
+
19
+ @generator = Gen.new
20
+ @measures = ['chunkiness','deliciousness']
21
+ @dimensions = ['producer', 'pricerange']
22
+ @codes = @dimensions #all dimensions coded for the tests
23
+ @labels = %w(hormel newskies whys)
24
+ @data =
25
+ {
26
+ "producer" => ["hormel","newskies", "whys"],
27
+ "pricerange" => ["low", "medium", "nonexistant"],
28
+ "chunkiness"=> [1, 6, 9001],
29
+ "deliciousness"=> [1, 9, 6]
30
+ }
31
+ end
32
+
33
+ it "should have correct output according to the reference file" do
34
+
35
+ turtle_string = @generator.generate(@measures, @dimensions, @codes, @data, @labels, 'bacon')
36
+ ref = IO.read(File.dirname(__FILE__) + '/turtle/bacon')
37
+ turtle_string.should == ref
38
+ end
39
+
40
+ context "with missing values" do
41
+
42
+ before(:all) do
43
+ @missing_data = Marshal.load(Marshal.dump(@data))
44
+ missingobs = {
45
+ "producer" => "missingbacon",
46
+ "pricerange" => "unknown",
47
+ "chunkiness"=> nil,
48
+ "deliciousness"=> nil,
49
+ }
50
+ missingobs.map{|k,v| @missing_data[k] << v}
51
+ end
52
+
53
+ it "skips observations with missing values by default" do
54
+ turtle_string = @generator.generate(@measures, @dimensions, @codes, @missing_data, @labels + ["missingbacon"], 'bacon')
55
+ turtle_string[/.*obsmissingbacon.*\n/].should be nil
56
+ end
57
+
58
+ it "includes observations with missing values if flag is set" do
59
+ turtle_string = @generator.generate(@measures, @dimensions, @codes, @missing_data, @labels + ["missingbacon"], 'bacon',{encode_nulls: true})
60
+ turtle_string[/.*obsmissingbacon.*\n/].should_not be nil
61
+ end
62
+
63
+ end
64
+
65
+ it 'generates prefixes' do
66
+ prefixes = @generator.prefixes('bacon')
67
+ prefixes.is_a?(String).should == true
68
+ end
69
+
70
+ it 'generates data structure definition' do
71
+ dsd = @generator.data_structure_definition(@measures | @dimensions, "bacon")
72
+ dsd.is_a?(String).should == true
73
+ end
74
+
75
+ it 'generates dataset' do
76
+ dsd = @generator.dataset("bacon")
77
+ dsd.is_a?(String).should == true
78
+ end
79
+
80
+ it 'generates component specifications' do
81
+ components = @generator.component_specifications(@measures , @dimensions, "bacon")
82
+ components.is_a?(Array).should == true
83
+ components.first.is_a?(String).should == true
84
+ end
85
+
86
+ it 'generates dimension properties' do
87
+ dimensions = @generator.dimension_properties(@dimensions,@codes,"bacon")
88
+ dimensions.is_a?(Array).should == true
89
+ dimensions.first.is_a?(String).should == true
90
+ end
91
+
92
+ it 'generates measure properties' do
93
+ measures = @generator.measure_properties(@measures, "bacon")
94
+ measures.is_a?(Array).should == true
95
+ measures.first.is_a?(String).should == true
96
+ end
97
+
98
+ it 'generates observations' do
99
+ #measures, dimensions, codes, var, observation_labels, data, options={}
100
+
101
+ observations = @generator.observations(@measures, @dimensions, @codes, @data, @labels, "bacon")
102
+ observations.is_a?(Array).should == true
103
+ observations.first.is_a?(String).should == true
104
+ end
105
+ end
106
+
107
+ context "under official integrity constraints" do
108
+ before(:all) do
109
+ @graph = RDF::Graph.load(File.dirname(__FILE__) + '/turtle/reference', :format => :ttl)
110
+ @checks = {}
111
+ Dir.foreach(File.dirname(__FILE__) + '/queries/integrity') do |file|
112
+ if file.split('.').last == 'rq'
113
+ @checks[file.split('.').first] = IO.read(File.dirname(__FILE__) + '/queries/integrity/' + file)
114
+ end
115
+ end
116
+ end
117
+
118
+ it 'obeys IC-1, has a unique dataset for each observation' do
119
+ SPARQL.execute(@checks['1'], @graph).first.should be_nil
120
+ end
121
+
122
+ it 'obeys IC-2, has a unique data structure definition of each dataset' do
123
+ SPARQL.execute(@checks['2'], @graph).first.should be_nil
124
+ end
125
+
126
+ it 'obeys IC-3, has a measure property specified for each dataset' do
127
+ SPARQL.execute(@checks['3'], @graph).first.should be_nil
128
+ end
129
+
130
+ it 'obeys IC-4, specifies a range for all dimensions' do
131
+ SPARQL.execute(@checks['4'], @graph).first.should be_nil
132
+ end
133
+
134
+ it 'obeys IC-5, every dimension with range skos:Concept must have a qb:codeList' do
135
+ SPARQL.execute(@checks['5'], @graph).first.should be_nil
136
+ end
137
+
138
+ it 'obeys IC-11, has a value for each dimension in every observation' do
139
+ SPARQL.execute(@checks['11'], @graph).first.should be_nil
140
+ end
141
+
142
+ ## currently locks up. possible bug in SPARQL gem parsing?
143
+ ## works fine as a raw query
144
+ # it 'obeys IC-12, has do duplicate observations' do
145
+ # SPARQL.execute(@checks['12'], @graph).first.should be_nil
146
+ # end
147
+
148
+ it 'obeys IC-14, has a value for each measure in every observation' do
149
+ SPARQL.execute(@checks['14'], @graph).first.should be_nil
150
+ end
151
+
152
+ it 'obeys IC-19, all codes for each codeList are included' do
153
+ SPARQL.execute(@checks['19_1'], @graph).first.should be_nil
154
+ ## second query for IC-19 uses property paths that aren't as easy to
155
+ ## convert to sparql 1.0, so for now I've left it out
156
+ # SPARQL.execute(@checks['19_2'], @graph).first.should be_nil
157
+ end
158
+ end
159
+
160
+
161
+ it "can set dimensions vs measures via hash" do
162
+
163
+ end
164
+
165
+
166
+ end
@@ -0,0 +1,44 @@
1
+ # require_relative '../../lib/r2rdf/data_cube.rb'
2
+ # require_relative '../../lib/r2rdf/generators/csv.rb'
3
+ require_relative '../../lib/bio-publisci.rb'
4
+
5
+ # require 'rdf/turtle'
6
+ require 'tempfile'
7
+
8
+ describe R2RDF::Reader::CSV do
9
+
10
+ def create_graph(turtle_string)
11
+ f = Tempfile.new('graph')
12
+ f.write(turtle_string)
13
+ f.close
14
+ graph = RDF::Graph.load(f.path, :format => :ttl)
15
+ f.unlink
16
+ graph
17
+ end
18
+
19
+ before(:each) do
20
+ @generator = R2RDF::Reader::CSV.new
21
+ end
22
+
23
+ context 'with reference CSV' do
24
+ it "should generate correct output for reference file" do
25
+ turtle_string = @generator.generate_n3(File.dirname(__FILE__) + '/../csv/bacon.csv','bacon',{dimensions:["producer","pricerange"], label_column:0})
26
+ ref = IO.read(File.dirname(__FILE__) + '/../turtle/bacon')
27
+ turtle_string.should == ref
28
+ end
29
+ end
30
+
31
+ it "selects first column as a coded dimension and creates measures from the rest by default" do
32
+ turtle_string = @generator.generate_n3(File.dirname(__FILE__) + '/../csv/bacon.csv','bacon')
33
+ graph = create_graph(turtle_string)
34
+ qb = RDF::Vocabulary.new("http://purl.org/linked-data/cube#")
35
+
36
+ dims = RDF::Query.execute(graph){ pattern [:dataset, qb.dimension, :dimension] }
37
+ dims.size.should == 1
38
+ dims.first[:dimension].to_s.should == "http://www.rqtl.org/dc/properties/producer"
39
+
40
+ measures = RDF::Query.execute(graph){ pattern [:dataset, qb.measure, :measure] }
41
+ measures.map{|s| s[:measure].to_s.split('/').last}.should == ["pricerange", "chunkiness", "deliciousness"]
42
+ end
43
+
44
+ end
@@ -0,0 +1,44 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+
3
+ describe R2RDF::Reader::Dataframe do
4
+
5
+ def create_graph(turtle_string)
6
+ f = Tempfile.new('graph')
7
+ f.write(turtle_string)
8
+ f.close
9
+ graph = RDF::Graph.load(f.path, :format => :ttl)
10
+ f.unlink
11
+ graph
12
+ end
13
+
14
+ context "with r/qtl dataframe" do
15
+ before(:all) do
16
+ @r = Rserve::Connection.new
17
+ @generator = R2RDF::Reader::Dataframe.new
18
+ @r.eval <<-EOF
19
+ library(qtl)
20
+ data(listeria)
21
+ mr = scanone(listeria,method="mr")
22
+ EOF
23
+ @rexp = @r.eval 'mr'
24
+ @turtle = @generator.generate_n3(@rexp,'mr')
25
+ end
26
+
27
+ it "generates rdf from R dataframe" do
28
+ turtle = @generator.generate_n3(@rexp,'mr')
29
+ turtle.is_a?(String).should be true
30
+ end
31
+
32
+ it "creates correct graph according to refrence file" do
33
+ reference = IO.read(File.dirname(__FILE__) + '/../turtle/reference')
34
+ @turtle.should eq reference
35
+ end
36
+
37
+ it "can optionally specify a row label" do
38
+ @turtle = @generator.generate_n3(@rexp,'mr',{row_label:"markers"})
39
+ end
40
+ end
41
+
42
+
43
+
44
+ end
@@ -0,0 +1,35 @@
1
+ # require_relative '../../lib/r2rdf/data_cube.rb'
2
+ # require_relative '../../lib/r2rdf/generators/r_matrix.rb'
3
+ # require 'rdf/turtle'
4
+ # require 'rserve'
5
+ require_relative '../../lib/bio-publisci.rb'
6
+
7
+ require 'tempfile'
8
+
9
+ describe R2RDF::Reader::RMatrix do
10
+
11
+ def create_graph(turtle_string)
12
+ f = Tempfile.new('graph')
13
+ f.write(turtle_string)
14
+ f.close
15
+ graph = RDF::Graph.load(f.path, :format => :ttl)
16
+ f.unlink
17
+ graph
18
+ end
19
+
20
+ before(:each) do
21
+ @generator = R2RDF::Reader::RMatrix.new
22
+ @connection = Rserve::Connection.new
23
+ end
24
+
25
+ it "generators a simple output automatically" do
26
+ f=Tempfile.new('matrix')
27
+ @connection.eval "mat = matrix(c(2, 4, 3, 1, 5, 7), nrow=3, ncol=2)"
28
+ @generator.generate_n3(@connection,'mat',f.path,{quiet: true})
29
+
30
+ turtle_string = IO.read("#{f.path}_structure.ttl") + IO.read("#{f.path}_0.ttl")
31
+ graph = create_graph(turtle_string)
32
+ graph.size.should > 0
33
+ end
34
+
35
+ end
@@ -0,0 +1,21 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-1. Unique DataSet
9
+
10
+ SELECT ?obs {
11
+ {
12
+ # Check observation has a data set
13
+ ?obs a qb:Observation .
14
+ MINUS { ?obs qb:dataSet ?dataset1 . }
15
+ } UNION {
16
+ # Check has just one data set
17
+ ?obs a qb:Observation ;
18
+ qb:dataSet ?dataset1, ?dataset2 .
19
+ FILTER (?dataset1 != ?dataset2)
20
+ }
21
+ }
@@ -0,0 +1,29 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-11. All dimensions required (modified)
9
+
10
+ SELECT * WHERE {
11
+ #also include qb:dimension resources
12
+ {
13
+ ?obs qb:dataSet ?ds .
14
+ ?ds qb:structure ?dsd .
15
+ ?dsd qb:component ?comp .
16
+ ?comp qb:componentProperty ?dim .
17
+ }
18
+ UNION
19
+ {
20
+ ?obs qb:dataSet ?ds .
21
+ ?ds qb:structure ?dsd .
22
+ ?dsd qb:component ?comp .
23
+ ?comp qb:dimension ?dim .
24
+ }
25
+
26
+
27
+ ?dim a qb:DimensionProperty;
28
+ FILTER NOT EXISTS { ?obs ?dim [] }
29
+ }
@@ -0,0 +1,37 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-12. No duplicate observations (modified)
9
+ # No two qb:Observations in the same qb:DataSet may have the same value for all dimensions.
10
+
11
+ SELECT * WHERE {
12
+ FILTER( ?allEqual )
13
+ {
14
+ # For each pair of observations test if all the dimension values are the same
15
+ SELECT (MIN(?equal) AS ?allEqual) WHERE {
16
+ ?obs1 qb:dataSet ?dataset .
17
+ ?obs2 qb:dataSet ?dataset .
18
+ FILTER (?obs1 != ?obs2)
19
+ {
20
+ ?dataset qb:structure ?dsd .
21
+ ?ds qb:component ?comp .
22
+ ?comp qb:componentProperty ?dim.
23
+ }
24
+ UNION
25
+ {
26
+ ?dataset qb:structure ?dsd .
27
+ ?dsd qb:component ?comp .
28
+ ?comp qb:dimension ?dim .
29
+ }
30
+
31
+ ?dim a qb:DimensionProperty .
32
+ ?obs1 ?dim ?value1 .
33
+ ?obs2 ?dim ?value2 .
34
+ BIND( ?value1 = ?value2 AS ?equal)
35
+ } GROUP BY ?obs1 ?obs2
36
+ }
37
+ }
@@ -0,0 +1,25 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-14. All measures present
9
+
10
+ SELECT * WHERE {
11
+ # Observation in a non-measureType cube
12
+ ?obs qb:dataSet ?dset .
13
+ ?dset qb:structure ?dsd .
14
+ FILTER NOT EXISTS {
15
+ ?dsd qb:component ?comp .
16
+ ?comp qb:componentProperty ?prop .
17
+ ?prop qb:measureType [] .
18
+ }
19
+
20
+ # verify every measure is present
21
+ ?dsd qb:component ?comp .
22
+ ?comp qb:componentProperty ?measure .
23
+ ?measure a qb:MeasureProperty;
24
+ FILTER NOT EXISTS { ?obs ?measure [] }
25
+ }
@@ -0,0 +1,21 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ #IC-19_1 Codes from code list
9
+
10
+ SELECT * WHERE {
11
+ ?obs qb:dataSet ?ds .
12
+ ?ds qb:structure ?str .
13
+ ?str qb:component ?prop .
14
+ ?prop qb:componentProperty ?dim .
15
+ ?dim a qb:DimensionProperty ;
16
+ qb:codeList ?list .
17
+ ?list a skos:ConceptScheme .
18
+ ?obs ?dim ?v .
19
+ FILTER NOT EXISTS { ?v a skos:Concept ; skos:inScheme ?list }
20
+ }
21
+
@@ -0,0 +1,15 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ SELECT * WHERE {
9
+ ?obs qb:dataSet/qb:structure/qb:component/qb:componentProperty ?dim .
10
+ ?dim a qb:DimensionProperty ;
11
+ qb:codeList ?list .
12
+ ?list a skos:Collection .
13
+ ?obs ?dim ?v .
14
+ FILTER NOT EXISTS { ?v a skos:Concept . ?list skos:member+ ?v }
15
+ }
@@ -0,0 +1,22 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-2. Unique DSD
9
+
10
+ SELECT * {
11
+ {
12
+ # Check dataset has a dsd
13
+ ?dataset a qb:DataSet .
14
+ FILTER NOT EXISTS { ?dataset qb:structure ?dsd . }
15
+ } UNION {
16
+ # Check has just one dsd
17
+ ?dataset a qb:DataSet ;
18
+ qb:structure ?dsd1, ?dsd2 .
19
+ FILTER (?dsd1 != ?dsd2)
20
+ }
21
+ }
22
+
@@ -0,0 +1,19 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-3. DSD includes measure (modified)
9
+
10
+ SELECT * WHERE {
11
+ ?dsd a qb:DataStructureDefinition ;
12
+
13
+ FILTER NOT EXISTS {
14
+ #original spec missing this definition
15
+ { ?dsd qb:component [qb:measure []] }
16
+ UNION
17
+ { ?dsd qb:component [qb:componentProperty [a qb:MeasureProperty]] }
18
+ }
19
+ }
@@ -0,0 +1,13 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-4. Dimensions have range
9
+
10
+ SELECT * WHERE {
11
+ ?dim a qb:DimensionProperty .
12
+ FILTER NOT EXISTS { ?dim rdfs:range [] }
13
+ }
@@ -0,0 +1,14 @@
1
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+ PREFIX qb: <http://purl.org/linked-data/cube#>
5
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
7
+
8
+ # IC-5. Concept dimensions have code lists
9
+
10
+ SELECT * WHERE {
11
+ ?dim a qb:DimensionProperty ;
12
+ rdfs:range skos:Concept .
13
+ #FILTER NOT EXISTS { ?dim qb:codeList [] }
14
+ }
@@ -0,0 +1,33 @@
1
+ # require_relative '../lib/r2rdf/data_cube.rb'
2
+ # require_relative '../lib/r2rdf/generators/dataframe.rb'
3
+ # require_relative '../lib/r2rdf/r_client.rb'
4
+ # require_relative '../lib/r2rdf/r_builder.rb'
5
+ # require_relative '../lib/r2rdf/query_helper.rb'
6
+ # require_relative '../lib/r2rdf/generators/csv.rb'
7
+ require_relative '../lib/bio-publisci.rb'
8
+
9
+
10
+ describe R2RDF::Writer::Dataframe do
11
+
12
+ context "when using r/qtl dataframe" do
13
+
14
+ before(:all) do
15
+ @r = Rserve::Connection.new
16
+ @r.eval <<-EOF
17
+ library(qtl)
18
+ data(listeria)
19
+ mr = scanone(listeria,method="mr")
20
+ EOF
21
+ @builder = R2RDF::Writer::Builder.new
22
+ end
23
+
24
+ it "produces equivalent dataframe from rdf" do
25
+ #(a) problem is that builder and the @r connection are different b/c of
26
+ #how rserve works
27
+ @builder.from_turtle(File.dirname(__FILE__) +'/turtle/reference', @r, 'mr', 'mo', false, false)
28
+ puts @r.eval('ls()').payload.to_ruby
29
+ @r.eval('identical(mr,mo)').to_ruby.should == true
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end