publisci 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.travis.yml +13 -0
- data/Gemfile +36 -0
- data/LICENSE.txt +20 -0
- data/README.md +51 -0
- data/README.rdoc +48 -0
- data/Rakefile +68 -0
- data/bin/bio-publisci +106 -0
- data/bin/bio-publisci-server +50 -0
- data/examples/bio-band_integration.rb +9 -0
- data/examples/no_magic.prov +58 -0
- data/examples/no_magic.rb +58 -0
- data/examples/orm.prov +48 -0
- data/examples/primer-full.prov +120 -0
- data/examples/primer.prov +66 -0
- data/examples/prov_dsl.prov +85 -0
- data/examples/safe_gen.rb +7 -0
- data/examples/visualization/primer.prov +66 -0
- data/examples/visualization/prov_viz.rb +140 -0
- data/examples/visualization/viz.rb +35 -0
- data/features/create_generator.feature +21 -0
- data/features/integration.feature +12 -0
- data/features/integration_steps.rb +10 -0
- data/features/metadata.feature +37 -0
- data/features/metadata_steps.rb +40 -0
- data/features/orm.feature +60 -0
- data/features/orm_steps.rb +74 -0
- data/features/prov_dsl.feature +14 -0
- data/features/prov_dsl_steps.rb +11 -0
- data/features/reader.feature +25 -0
- data/features/reader_steps.rb +61 -0
- data/features/step_definitions/bio-publisci_steps.rb +0 -0
- data/features/store.feature +27 -0
- data/features/store_steps.rb +42 -0
- data/features/support/env.rb +13 -0
- data/features/writer.feature +14 -0
- data/features/writer_steps.rb +24 -0
- data/lib/bio-publisci.rb +64 -0
- data/lib/bio-publisci/analyzer.rb +57 -0
- data/lib/bio-publisci/datacube_model.rb +111 -0
- data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +240 -0
- data/lib/bio-publisci/dataset/ORM/observation.rb +20 -0
- data/lib/bio-publisci/dataset/configuration.rb +31 -0
- data/lib/bio-publisci/dataset/data_cube.rb +418 -0
- data/lib/bio-publisci/dataset/dataset.rb +11 -0
- data/lib/bio-publisci/dataset/dataset_for.rb +186 -0
- data/lib/bio-publisci/dataset/interactive.rb +72 -0
- data/lib/bio-publisci/dsl/config.rb +34 -0
- data/lib/bio-publisci/dsl/dataset_dsl.rb +93 -0
- data/lib/bio-publisci/dsl/dsl.rb +72 -0
- data/lib/bio-publisci/dsl/metadata_dsl.rb +85 -0
- data/lib/bio-publisci/dsl/prov_dsl.rb +143 -0
- data/lib/bio-publisci/metadata/generator.rb +323 -0
- data/lib/bio-publisci/metadata/metadata.rb +5 -0
- data/lib/bio-publisci/metadata/metadata_model.rb +25 -0
- data/lib/bio-publisci/metadata/prov/activity.rb +88 -0
- data/lib/bio-publisci/metadata/prov/agent.rb +100 -0
- data/lib/bio-publisci/metadata/prov/association.rb +107 -0
- data/lib/bio-publisci/metadata/prov/config.rb +34 -0
- data/lib/bio-publisci/metadata/prov/derivation.rb +60 -0
- data/lib/bio-publisci/metadata/prov/element.rb +120 -0
- data/lib/bio-publisci/metadata/prov/entity.rb +64 -0
- data/lib/bio-publisci/metadata/prov/model/prov_models.rb +109 -0
- data/lib/bio-publisci/metadata/prov/plan.rb +32 -0
- data/lib/bio-publisci/metadata/prov/prov.rb +78 -0
- data/lib/bio-publisci/metadata/prov/role.rb +40 -0
- data/lib/bio-publisci/metadata/prov/usage.rb +64 -0
- data/lib/bio-publisci/metadata/publisher.rb +25 -0
- data/lib/bio-publisci/mixins/custom_predicate.rb +38 -0
- data/lib/bio-publisci/mixins/dereferencable.rb +34 -0
- data/lib/bio-publisci/mixins/registry.rb +27 -0
- data/lib/bio-publisci/mixins/vocabulary.rb +8 -0
- data/lib/bio-publisci/output.rb +27 -0
- data/lib/bio-publisci/parser.rb +266 -0
- data/lib/bio-publisci/post_processor.rb +95 -0
- data/lib/bio-publisci/query/query_helper.rb +123 -0
- data/lib/bio-publisci/r_client.rb +54 -0
- data/lib/bio-publisci/readers/arff.rb +49 -0
- data/lib/bio-publisci/readers/base.rb +57 -0
- data/lib/bio-publisci/readers/csv.rb +88 -0
- data/lib/bio-publisci/readers/dataframe.rb +67 -0
- data/lib/bio-publisci/readers/maf.rb +199 -0
- data/lib/bio-publisci/readers/r_cross.rb +112 -0
- data/lib/bio-publisci/readers/r_matrix.rb +176 -0
- data/lib/bio-publisci/store.rb +56 -0
- data/lib/bio-publisci/writers/arff.rb +91 -0
- data/lib/bio-publisci/writers/base.rb +93 -0
- data/lib/bio-publisci/writers/csv.rb +31 -0
- data/lib/bio-publisci/writers/dataframe.rb +81 -0
- data/lib/bio-publisci/writers/json.rb +18 -0
- data/lib/r2rdf.rb +226 -0
- data/lib/template_bak.rb +12 -0
- data/lib/template_bak/publisci.rb +3 -0
- data/lib/vocabs/cc.rb +18 -0
- data/lib/vocabs/cert.rb +13 -0
- data/lib/vocabs/dc.rb +63 -0
- data/lib/vocabs/dc11.rb +23 -0
- data/lib/vocabs/doap.rb +45 -0
- data/lib/vocabs/exif.rb +168 -0
- data/lib/vocabs/foaf.rb +69 -0
- data/lib/vocabs/geo.rb +13 -0
- data/lib/vocabs/http.rb +26 -0
- data/lib/vocabs/ma.rb +78 -0
- data/lib/vocabs/owl.rb +59 -0
- data/lib/vocabs/rdfs.rb +17 -0
- data/lib/vocabs/rsa.rb +12 -0
- data/lib/vocabs/rss.rb +14 -0
- data/lib/vocabs/sioc.rb +93 -0
- data/lib/vocabs/skos.rb +36 -0
- data/lib/vocabs/wot.rb +21 -0
- data/lib/vocabs/xhtml.rb +9 -0
- data/lib/vocabs/xsd.rb +58 -0
- data/resources/maf_example.maf +10 -0
- data/resources/maf_rdf.ttl +1173 -0
- data/resources/primer.ttl +38 -0
- data/resources/queries/code_resources.rq +10 -0
- data/resources/queries/codes.rq +18 -0
- data/resources/queries/dataset.rq +7 -0
- data/resources/queries/dimension_ranges.rq +8 -0
- data/resources/queries/dimensions.rq +12 -0
- data/resources/queries/gene.rq +16 -0
- data/resources/queries/hugo_to_ensembl.rq +7 -0
- data/resources/queries/maf_column.rq +26 -0
- data/resources/queries/measures.rq +12 -0
- data/resources/queries/observation_labels.rq +8 -0
- data/resources/queries/observations.rq +13 -0
- data/resources/queries/patient.rq +11 -0
- data/resources/queries/patient_list.rq +11 -0
- data/resources/queries/patients_with_mutation.rq +18 -0
- data/resources/queries/properties.rq +8 -0
- data/resources/queries/test.rq +3 -0
- data/resources/weather.numeric.arff +28 -0
- data/scripts/get_gene_lengths.rb +50 -0
- data/scripts/islet_mlratio.rb +6 -0
- data/scripts/scan_islet.rb +6 -0
- data/scripts/update_reference.rb +25 -0
- data/server/helpers.rb +215 -0
- data/server/public/src-min-noconflict/LICENSE +24 -0
- data/server/public/src-min-noconflict/ace.js +11 -0
- data/server/public/src-min-noconflict/ext-chromevox.js +1 -0
- data/server/public/src-min-noconflict/ext-elastic_tabstops_lite.js +1 -0
- data/server/public/src-min-noconflict/ext-emmet.js +1 -0
- data/server/public/src-min-noconflict/ext-keybinding_menu.js +1 -0
- data/server/public/src-min-noconflict/ext-language_tools.js +1 -0
- data/server/public/src-min-noconflict/ext-modelist.js +1 -0
- data/server/public/src-min-noconflict/ext-old_ie.js +1 -0
- data/server/public/src-min-noconflict/ext-searchbox.js +1 -0
- data/server/public/src-min-noconflict/ext-settings_menu.js +1 -0
- data/server/public/src-min-noconflict/ext-spellcheck.js +1 -0
- data/server/public/src-min-noconflict/ext-split.js +1 -0
- data/server/public/src-min-noconflict/ext-static_highlight.js +1 -0
- data/server/public/src-min-noconflict/ext-statusbar.js +1 -0
- data/server/public/src-min-noconflict/ext-textarea.js +1 -0
- data/server/public/src-min-noconflict/ext-themelist.js +1 -0
- data/server/public/src-min-noconflict/ext-whitespace.js +1 -0
- data/server/public/src-min-noconflict/keybinding-emacs.js +1 -0
- data/server/public/src-min-noconflict/keybinding-vim.js +1 -0
- data/server/public/src-min-noconflict/mode-ruby.js +1 -0
- data/server/public/src-min-noconflict/snippets/ruby.js +1 -0
- data/server/public/src-min-noconflict/theme-twilight.js +1 -0
- data/server/public/src-min-noconflict/worker-coffee.js +1 -0
- data/server/public/src-min-noconflict/worker-css.js +1 -0
- data/server/public/src-min-noconflict/worker-javascript.js +1 -0
- data/server/public/src-min-noconflict/worker-json.js +1 -0
- data/server/public/src-min-noconflict/worker-lua.js +1 -0
- data/server/public/src-min-noconflict/worker-php.js +1 -0
- data/server/public/src-min-noconflict/worker-xquery.js +1 -0
- data/server/routes.rb +123 -0
- data/server/views/dsl.haml +65 -0
- data/server/views/dump.haml +3 -0
- data/server/views/import.haml +35 -0
- data/server/views/new_repository.haml +25 -0
- data/server/views/query.haml +28 -0
- data/server/views/repository.haml +25 -0
- data/spec/ORM/data_cube_orm_spec.rb +33 -0
- data/spec/ORM/prov_model_spec.rb +72 -0
- data/spec/analyzer_spec.rb +36 -0
- data/spec/bnode_spec.rb +66 -0
- data/spec/csv/bacon.csv +4 -0
- data/spec/csv/moar_bacon.csv +11 -0
- data/spec/data_cube_spec.rb +169 -0
- data/spec/dataset_for_spec.rb +77 -0
- data/spec/dsl_spec.rb +134 -0
- data/spec/generators/csv_spec.rb +44 -0
- data/spec/generators/dataframe_spec.rb +44 -0
- data/spec/generators/maf_spec.rb +40 -0
- data/spec/generators/r_cross_spec.rb +51 -0
- data/spec/generators/r_matrix_spec.rb +44 -0
- data/spec/length_lookup_spec.rb +0 -0
- data/spec/maf_query_spec.rb +343 -0
- data/spec/metadata/metadata_dsl_spec.rb +68 -0
- data/spec/prov/activity_spec.rb +74 -0
- data/spec/prov/agent_spec.rb +54 -0
- data/spec/prov/association_spec.rb +55 -0
- data/spec/prov/config_spec.rb +28 -0
- data/spec/prov/derivation_spec.rb +30 -0
- data/spec/prov/entity_spec.rb +52 -0
- data/spec/prov/role_spec.rb +94 -0
- data/spec/prov/usage_spec.rb +98 -0
- data/spec/queries/integrity/1.rq +21 -0
- data/spec/queries/integrity/11.rq +29 -0
- data/spec/queries/integrity/12.rq +37 -0
- data/spec/queries/integrity/14.rq +25 -0
- data/spec/queries/integrity/19_1.rq +21 -0
- data/spec/queries/integrity/19_2.rq +15 -0
- data/spec/queries/integrity/2.rq +22 -0
- data/spec/queries/integrity/3.rq +19 -0
- data/spec/queries/integrity/4.rq +13 -0
- data/spec/queries/integrity/5.rq +14 -0
- data/spec/r_builder_spec.rb +33 -0
- data/spec/resource/.RData +0 -0
- data/spec/resource/example.Rhistory +3 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/turtle/bacon +147 -0
- data/spec/turtle/reference +2064 -0
- data/spec/turtle/weather +275 -0
- data/spec/writer_spec.rb +75 -0
- metadata +589 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
Given(/^the prov DSL string from file (.+)$/) do |file|
|
2
|
+
@dsl_string = file
|
3
|
+
end
|
4
|
+
|
5
|
+
When(/^I call Prov\.run on it$/) do
|
6
|
+
@turtle_string = PubliSci::Prov.run(@dsl_string)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then(/^I should receive a provenance string$/) do
|
10
|
+
puts @turtle_string
|
11
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: generate RDF
|
2
|
+
|
3
|
+
In order to test the generators
|
4
|
+
I want to be able to create turtle strings from various objects
|
5
|
+
|
6
|
+
Scenario: generate turtle RDF from a Dataframe
|
7
|
+
Given a Dataframe generator
|
8
|
+
When I provide an R dataframe and the label "mr"
|
9
|
+
And generate a turtle string from it
|
10
|
+
Then the result should contain a "qb:dataSet"
|
11
|
+
And the result should contain some "qb:Observation"s
|
12
|
+
|
13
|
+
Scenario: generate turtle RDF from a CSV
|
14
|
+
Given a CSV generator
|
15
|
+
When I provide the reference file spec/csv/bacon.csv and the label "bacon"
|
16
|
+
And generate a turtle string from it
|
17
|
+
Then the result should contain a "qb:dataSet"
|
18
|
+
And the result should contain some "qb:Observation"s
|
19
|
+
|
20
|
+
Scenario: generate turtle RDF from an ARFF file
|
21
|
+
Given a ARFF generator
|
22
|
+
When I provide the file resources/weather.numeric.arff
|
23
|
+
And generate a turtle string from it
|
24
|
+
Then the result should contain a "qb:dataSet"
|
25
|
+
And the result should contain some "qb:Observation"s
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative '../lib/bio-publisci.rb'
|
2
|
+
|
3
|
+
Given /^a (.*) generator$/ do |generator|
|
4
|
+
@generator = PubliSci::Readers.const_get(generator).new
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^I ask for its methods$/ do
|
8
|
+
@methods = @generator.methods
|
9
|
+
end
|
10
|
+
|
11
|
+
When /^I provide an R (.*) and the label "(.*?)"$/ do |type, label|
|
12
|
+
if type == "dataframe"
|
13
|
+
r = Rserve::Connection.new
|
14
|
+
r.eval <<-EOF
|
15
|
+
library(qtl)
|
16
|
+
data(listeria)
|
17
|
+
mr = scanone(listeria,method="mr")
|
18
|
+
EOF
|
19
|
+
rexp = r.eval 'mr'
|
20
|
+
@attr = rexp,label
|
21
|
+
else
|
22
|
+
raise "Unknown object #{type}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^I provide the.* file (.*) and the label "(.*?)"$/ do |file, label|
|
28
|
+
raise "Cant find #{file}" unless File.exist? file
|
29
|
+
@attr = file,label
|
30
|
+
end
|
31
|
+
|
32
|
+
When /^I provide the.* file (.*) and the label "(.*?)" and the options (.*)$/ do |file, label, opts|
|
33
|
+
raise "Cant find #{file}" unless File.exist? file
|
34
|
+
@attr = file,label,eval(opts)
|
35
|
+
end
|
36
|
+
|
37
|
+
When /^I provide the.* file (\S+)$/ do |file|
|
38
|
+
raise "Cant find #{file}" unless File.exist? file
|
39
|
+
@attr = file
|
40
|
+
end
|
41
|
+
|
42
|
+
When /^generate a turtle string from it$/ do
|
43
|
+
@turtle_string = @generator.send :generate_n3, *@attr
|
44
|
+
# open('weather.ttl','w'){|f| f.write @turtle_string}
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^I should have access to a (.*) method$/ do |method|
|
48
|
+
@methods.include?(method).should == true
|
49
|
+
end
|
50
|
+
|
51
|
+
Then /^I should be able to call its (.*) method$/ do |method|
|
52
|
+
@generator.methods.include?(:"#{method}").should == true
|
53
|
+
end
|
54
|
+
|
55
|
+
Then /^the result should contain a "(.*?)"$/ do |search|
|
56
|
+
@turtle_string[search].should_not be nil
|
57
|
+
end
|
58
|
+
|
59
|
+
Then /^the result should contain some "(.*?)"s$/ do |search|
|
60
|
+
@turtle_string[search].size.should > 1
|
61
|
+
end
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: load triples into a store
|
2
|
+
|
3
|
+
In order to query and share data
|
4
|
+
I want to be able load the output into a variety of store
|
5
|
+
|
6
|
+
Scenario: Use an RDF::Graph to store data
|
7
|
+
Given a store of type graph
|
8
|
+
When I call the stores add method with the turtle file spec/turtle/bacon and an RDF::Repository
|
9
|
+
Then I should recieve a non-empty graph
|
10
|
+
|
11
|
+
Scenario: Use 4store to store data
|
12
|
+
Given a store of type fourstore
|
13
|
+
When I call the stores add method with the turtle file spec/turtle/bacon and the graph name "test"
|
14
|
+
Then I should receive an info string
|
15
|
+
|
16
|
+
Scenario: Run queries on store
|
17
|
+
Given a store of type fourstore
|
18
|
+
When I call the query method using the text in file spec/queries/integrity/1.rq
|
19
|
+
Then I should receive 0 results
|
20
|
+
When I call the query method using the text in file resources/queries/test.rq
|
21
|
+
Then I should receive 10 results
|
22
|
+
|
23
|
+
Scenario: Run queries on graph based store
|
24
|
+
Given a store of type graph
|
25
|
+
When I call the stores add method with the turtle file spec/turtle/bacon and an RDF::Repository
|
26
|
+
Then calling the query method using the text in file spec/queries/integrity/1.rq should return 0 results
|
27
|
+
And calling the query method using the text in file resources/queries/test.rq should return 10 results
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative '../lib/bio-publisci.rb'
|
2
|
+
|
3
|
+
Given /a store of type (.*?)$/ do |type|
|
4
|
+
@store = PubliSci::Store.new(type: :"#{type}")
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^I call the stores add method with the turtle file (.*?) and an RDF::(.*?)$/ do |file,graph|
|
8
|
+
graph = RDF.const_get(graph).new #rescue graph
|
9
|
+
@graph = @store.add(file,graph)
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^I call the stores add method with the turtle file (.*?) and the graph name "(.*?)"$/ do |file,graph|
|
13
|
+
@graph = @store.add(file,graph)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
When /^I call the query method using the text in file (.*)$/ do |file|
|
18
|
+
query_string = IO.read(file)
|
19
|
+
@query_result = @store.query(query_string)
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^calling the query method using the text in file (.*) should return (.*) results$/ do |file, num|
|
23
|
+
query_string = IO.read(file)
|
24
|
+
@store.query(query_string) #.size.should == num
|
25
|
+
end
|
26
|
+
|
27
|
+
Then /^I should recieve a non-empty graph$/ do
|
28
|
+
@graph.is_a?(RDF::Repository).should be true
|
29
|
+
@graph.size.should > 0
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^I should receive an info string$/ do
|
33
|
+
@graph.is_a?(String).should be true
|
34
|
+
end
|
35
|
+
|
36
|
+
Then /^I should receive (.*) results$/ do |num|
|
37
|
+
@query_result.size.should == num.to_i
|
38
|
+
end
|
39
|
+
|
40
|
+
# Then /^raise the result$/ do
|
41
|
+
# raise "got @graph"
|
42
|
+
# end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
begin
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
rescue Bundler::BundlerError => e
|
5
|
+
$stderr.puts e.message
|
6
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
7
|
+
exit e.status_code
|
8
|
+
end
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
+
require 'bio-publisci'
|
12
|
+
|
13
|
+
require 'rspec/expectations'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: export to various formats using writers
|
2
|
+
|
3
|
+
In order to use RDF encoded data in other applications
|
4
|
+
I want to export domain objects using an PubliSci::Writers object
|
5
|
+
|
6
|
+
Scenario: write to ARFF format
|
7
|
+
Given a ARFF writer
|
8
|
+
When I call its from_turtle method on the file spec/turtle/bacon
|
9
|
+
Then I should receive a .arff file as a string
|
10
|
+
|
11
|
+
Scenario: write to CSV
|
12
|
+
Given a CSV writer
|
13
|
+
When I call its from_turtle method on the file spec/turtle/bacon
|
14
|
+
Then I should receive a .csv file as a string
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Given(/^a (.*) writer$/) do |type|
|
2
|
+
@writer = PubliSci::Writers.const_get(type).new
|
3
|
+
end
|
4
|
+
|
5
|
+
When(/^I call its from_turtle method on the file (.*)$/) do |file|
|
6
|
+
@result = @writer.from_turtle(file)
|
7
|
+
end
|
8
|
+
|
9
|
+
When(/^I call its from_turtle method on the turtle string$/) do
|
10
|
+
f=Tempfile.open('writerttl'); f.write @turtle_string; f.close
|
11
|
+
@result = @writer.from_turtle(f.path)
|
12
|
+
f.unlink
|
13
|
+
end
|
14
|
+
|
15
|
+
Then(/^I should receive a \.arff file as a string$/) do
|
16
|
+
puts @result
|
17
|
+
@result.is_a?(String).should be true
|
18
|
+
end
|
19
|
+
|
20
|
+
Then(/^I should receive a \.csv file as a string$/) do
|
21
|
+
puts @result
|
22
|
+
@result.is_a?(String).should be true
|
23
|
+
end
|
24
|
+
|
data/lib/bio-publisci.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# This is temporary, just to help w/ development so I don't have to rewrite r2rdf.rb to be
|
2
|
+
# a standard gem base yet. Also load s the files instead of require for easy reloading
|
3
|
+
require 'tempfile'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'csv'
|
6
|
+
|
7
|
+
require 'rdf'
|
8
|
+
require 'sparql'
|
9
|
+
require 'sparql/client'
|
10
|
+
require 'rdf/turtle'
|
11
|
+
require 'rdf/rdfxml'
|
12
|
+
require 'json/ld'
|
13
|
+
|
14
|
+
require 'rserve'
|
15
|
+
require 'rest-client'
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'spira'
|
19
|
+
rescue LoadError
|
20
|
+
puts "can't load spira; orm unavailable"
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_folder(folder)
|
24
|
+
Dir.foreach(File.dirname(__FILE__) + "/#{folder}") do |file|
|
25
|
+
unless file == "." or file == ".."
|
26
|
+
f = File.dirname(__FILE__) + "/#{folder}/" + file
|
27
|
+
load f unless File.directory?(f)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
load_folder('bio-publisci/mixins')
|
33
|
+
|
34
|
+
load File.dirname(__FILE__) + '/bio-publisci/dataset/interactive.rb'
|
35
|
+
load File.dirname(__FILE__) + '/bio-publisci/query/query_helper.rb'
|
36
|
+
load File.dirname(__FILE__) + '/bio-publisci/parser.rb'
|
37
|
+
load File.dirname(__FILE__) + '/bio-publisci/post_processor.rb'
|
38
|
+
load File.dirname(__FILE__) + '/bio-publisci/r_client.rb'
|
39
|
+
load File.dirname(__FILE__) + '/bio-publisci/analyzer.rb'
|
40
|
+
load File.dirname(__FILE__) + '/bio-publisci/store.rb'
|
41
|
+
load File.dirname(__FILE__) + '/bio-publisci/dataset/data_cube.rb'
|
42
|
+
load File.dirname(__FILE__) + '/bio-publisci/dataset/dataset_for.rb'
|
43
|
+
load File.dirname(__FILE__) + '/bio-publisci/dataset/configuration.rb'
|
44
|
+
load File.dirname(__FILE__) + '/bio-publisci/dataset/dataset.rb'
|
45
|
+
load File.dirname(__FILE__) + '/bio-publisci/datacube_model.rb'
|
46
|
+
load File.dirname(__FILE__) + '/bio-publisci/output.rb'
|
47
|
+
load File.dirname(__FILE__) + '/bio-publisci/metadata/prov/element.rb'
|
48
|
+
load File.dirname(__FILE__) + '/bio-publisci/metadata/prov/prov.rb'
|
49
|
+
load File.dirname(__FILE__) + '/bio-publisci/writers/base.rb'
|
50
|
+
load File.dirname(__FILE__) + '/bio-publisci/readers/base.rb'
|
51
|
+
|
52
|
+
|
53
|
+
load_folder('bio-publisci/dsl')
|
54
|
+
load_folder('bio-publisci/metadata')
|
55
|
+
load_folder('bio-publisci/metadata/prov')
|
56
|
+
load_folder('bio-publisci/metadata/prov/model')
|
57
|
+
load_folder('bio-publisci/readers')
|
58
|
+
load_folder('bio-publisci/writers')
|
59
|
+
load_folder('bio-publisci/dataset/ORM')
|
60
|
+
# Dir.foreach(File.dirname(__FILE__) + '/generators') do |file|
|
61
|
+
# unless file == "." or file == ".."
|
62
|
+
# load File.dirname(__FILE__) + '/generators/' + file
|
63
|
+
# end
|
64
|
+
# end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module PubliSci
|
2
|
+
|
3
|
+
#handles analysis of R expression to extract properties and recognize potential
|
4
|
+
#ambiguity
|
5
|
+
module Analyzer
|
6
|
+
def dirty?(data)
|
7
|
+
if data.is_a? Hash
|
8
|
+
data.map{|k,v|
|
9
|
+
return true if dirty?(k) || dirty?(v)
|
10
|
+
}
|
11
|
+
false
|
12
|
+
elsif data.is_a? Array
|
13
|
+
data.map{|datum|
|
14
|
+
return true if dirty?(datum)
|
15
|
+
}
|
16
|
+
else
|
17
|
+
dirty_characters = [".",' ']
|
18
|
+
if data.to_s.scan(/./) & dirty_characters
|
19
|
+
true
|
20
|
+
else
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def recommend_range(data)
|
27
|
+
classes = data.map{|d| d.class}
|
28
|
+
homogenous = classes.uniq.size == 1
|
29
|
+
if homogenous
|
30
|
+
if classes[0] == Fixnum
|
31
|
+
"xsd:int"
|
32
|
+
elsif classes[0] == Float
|
33
|
+
"xsd:double"
|
34
|
+
elsif classes[0] == String
|
35
|
+
recommend_range_strings(data)
|
36
|
+
else
|
37
|
+
:coded
|
38
|
+
end
|
39
|
+
else
|
40
|
+
:coded
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def recommend_range_strings(data)
|
45
|
+
return "xsd:int" if data.all?{|d| Integer(d) rescue nil}
|
46
|
+
return "xsd:int" if data.all?{|d| Float(d) rescue nil}
|
47
|
+
:coded
|
48
|
+
end
|
49
|
+
|
50
|
+
def check_integrity(obs, dimensions, measures)
|
51
|
+
obs.map{|o|
|
52
|
+
raise "MissingValues for #{(dimensions | measures) - o.keys}" unless ((dimensions | measures) - o.keys).empty?
|
53
|
+
raise "UnknownProperty #{o.keys - (dimensions | measures)}" unless (o.keys - (dimensions | measures)).empty?
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'rdf/4store'
|
2
|
+
begin
|
3
|
+
require 'spira'
|
4
|
+
module PubliSci
|
5
|
+
module ORM
|
6
|
+
# class Observation < Spira::Base
|
7
|
+
# type RDF::URI.new('http://purl.org/linked-data/cube#Observation')
|
8
|
+
# property :label, predicate: RDFS.label
|
9
|
+
|
10
|
+
# end
|
11
|
+
QB ||= RDF::Vocabulary.new(RDF::URI.new('http://purl.org/linked-data/cube#'))
|
12
|
+
|
13
|
+
class Component < Spira::Base
|
14
|
+
type QB.ComponentSpecification
|
15
|
+
property :dimension, predicate: QB.dimension # RDF::URI.new('http://purl.org/linked-data/cube#dimension')
|
16
|
+
property :measure, predicate: QB.measure # RDF::URI.new('http://purl.org/linked-data/cube#measure')
|
17
|
+
end
|
18
|
+
|
19
|
+
class DataStructureDefinition < Spira::Base
|
20
|
+
type QB.DataStructureDefinition
|
21
|
+
property :label, predicate: RDFS.label
|
22
|
+
has_many :component, predicate: QB.component
|
23
|
+
end
|
24
|
+
|
25
|
+
class DataSet < Spira::Base
|
26
|
+
type QB.DataSet
|
27
|
+
property :label, predicate: RDFS.label
|
28
|
+
property :structure, predicate: QB.structure
|
29
|
+
end
|
30
|
+
|
31
|
+
class Dimension < Spira::Base
|
32
|
+
type QB.DimensionProperty
|
33
|
+
property :range, predicate: RDFS.range
|
34
|
+
property :label, predicate: RDFS.label
|
35
|
+
end
|
36
|
+
|
37
|
+
class Measure < Spira::Base
|
38
|
+
type QB.MeasureProperty
|
39
|
+
property :label, predicate: RDFS.label
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def load_repo(repo)
|
44
|
+
raise "Not an RDF::Repository - #{repo}" unless repo.is_a? RDF::Repository
|
45
|
+
Spira.add_repository :default, repo
|
46
|
+
end
|
47
|
+
|
48
|
+
# def observation
|
49
|
+
# unless PubliSci::ORM.const_defined?("Observation")
|
50
|
+
# obs = Class.new(Spira::Base) do
|
51
|
+
# type RDF::URI.new('http://purl.org/linked-data/cube#Observation')
|
52
|
+
|
53
|
+
# property :structure, predicate: QB.dataSet
|
54
|
+
|
55
|
+
# ((Dimension.each.to_a | Measure.each.to_a) || []).each{|component|
|
56
|
+
# property strip_uri(component.subject.to_s), predicate: component.subject
|
57
|
+
# }
|
58
|
+
# end
|
59
|
+
# PubliSci::ORM.const_set("Observation",obs)
|
60
|
+
# end
|
61
|
+
# Observation
|
62
|
+
# end
|
63
|
+
|
64
|
+
class Observation < Spira::Base
|
65
|
+
type QB.Observation
|
66
|
+
property :label, predicate: RDFS.label
|
67
|
+
property :dataset, predicate: QB.dataSet
|
68
|
+
|
69
|
+
def load_properties
|
70
|
+
comps = dataset.as(DataSet).structure.as(DataStructureDefinition).component.map{|comp| comp.as(Component)}
|
71
|
+
props = comps.map{|comp| comp.dimension ? comp.dimension.as(Dimension) : comp.measure.as(Measure) }
|
72
|
+
props.each{|prop|
|
73
|
+
ss = strip_uri(prop.subject.to_s)
|
74
|
+
|
75
|
+
self.class.property ss.to_sym, predicate: prop.subject
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
# for testing; DRY up eventually
|
80
|
+
def strip_uri(uri)
|
81
|
+
uri = uri.to_s.dup
|
82
|
+
uri[-1] = '' if uri[-1] == '>'
|
83
|
+
uri.to_s.split('/').last.split('#').last
|
84
|
+
end
|
85
|
+
|
86
|
+
# def method_missing(meth, *args, &block)
|
87
|
+
# if meth.to_s =~ /^find_by_(.+)$/
|
88
|
+
# run_find_by_method($1, *args, &block)
|
89
|
+
# else
|
90
|
+
# super # You *must* call super if you don't handle the
|
91
|
+
# # method, otherwise you'll mess up Ruby's method
|
92
|
+
# # lookup.
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
end
|
96
|
+
|
97
|
+
def reload_observation
|
98
|
+
PubliSci::ORM.send(:remove_const, "Observation")
|
99
|
+
observation
|
100
|
+
end
|
101
|
+
|
102
|
+
def strip_uri(uri)
|
103
|
+
uri = uri.to_s.dup
|
104
|
+
uri[-1] = '' if uri[-1] == '>'
|
105
|
+
uri.to_s.split('/').last.split('#').last
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
rescue LoadError
|
110
|
+
# puts "Skipping ORM load"
|
111
|
+
end
|