bio-publisci 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.travis.yml +13 -0
- data/Gemfile +24 -0
- data/LICENSE.txt +20 -0
- data/README.md +47 -0
- data/README.rdoc +48 -0
- data/Rakefile +70 -0
- data/bin/bio-publisci +83 -0
- data/features/create_generator.feature +25 -0
- data/features/integration.feature +12 -0
- data/features/integration_steps.rb +10 -0
- data/features/orm.feature +60 -0
- data/features/orm_steps.rb +74 -0
- data/features/reader.feature +25 -0
- data/features/reader_steps.rb +60 -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 +9 -0
- data/features/writer_steps.rb +17 -0
- data/lib/bio-publisci/analyzer.rb +57 -0
- data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +219 -0
- data/lib/bio-publisci/dataset/ORM/observation.rb +20 -0
- data/lib/bio-publisci/dataset/data_cube.rb +308 -0
- data/lib/bio-publisci/dataset/interactive.rb +57 -0
- data/lib/bio-publisci/loader.rb +36 -0
- data/lib/bio-publisci/metadata/metadata.rb +105 -0
- data/lib/bio-publisci/parser.rb +64 -0
- data/lib/bio-publisci/query/query_helper.rb +114 -0
- data/lib/bio-publisci/r_client.rb +54 -0
- data/lib/bio-publisci/readers/arff.rb +87 -0
- data/lib/bio-publisci/readers/big_cross.rb +119 -0
- data/lib/bio-publisci/readers/cross.rb +72 -0
- data/lib/bio-publisci/readers/csv.rb +54 -0
- data/lib/bio-publisci/readers/dataframe.rb +66 -0
- data/lib/bio-publisci/readers/r_matrix.rb +152 -0
- data/lib/bio-publisci/store.rb +56 -0
- data/lib/bio-publisci/writers/arff.rb +66 -0
- data/lib/bio-publisci/writers/dataframe.rb +81 -0
- data/lib/bio-publisci.rb +36 -0
- data/lib/r2rdf.rb +226 -0
- data/lib/template_bak/publisci.rb +3 -0
- data/lib/template_bak.rb +12 -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/queries/codes.rq +13 -0
- data/resources/queries/dataset.rq +7 -0
- data/resources/queries/dimension_ranges.rq +8 -0
- data/resources/queries/dimensions.rq +7 -0
- data/resources/queries/measures.rq +7 -0
- data/resources/queries/observations.rq +12 -0
- data/resources/queries/test.rq +3 -0
- data/resources/weather.numeric.arff +23 -0
- data/spec/analyzer_spec.rb +36 -0
- data/spec/bio-publisci_spec.rb +7 -0
- data/spec/csv/bacon.csv +4 -0
- data/spec/csv/moar_bacon.csv +11 -0
- data/spec/data_cube_spec.rb +166 -0
- data/spec/generators/csv_spec.rb +44 -0
- data/spec/generators/dataframe_spec.rb +44 -0
- data/spec/generators/r_matrix_spec.rb +35 -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/spec_helper.rb +17 -0
- data/spec/turtle/bacon +149 -0
- data/spec/turtle/reference +2066 -0
- metadata +259 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- jruby-19mode # JRuby in 1.9 mode
|
6
|
+
|
7
|
+
# - rbx-19mode
|
8
|
+
# - 1.8.7
|
9
|
+
# - jruby-18mode # JRuby in 1.8 mode
|
10
|
+
# - rbx-18mode
|
11
|
+
#
|
12
|
+
# uncomment this line if your project needs to run something other than `rake`:
|
13
|
+
# script: bundle exec rspec spec
|
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.8.0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "cucumber", ">= 0"
|
12
|
+
gem "jeweler", "~> 1.8.4", :git => "https://github.com/technicalpickles/jeweler.git"
|
13
|
+
gem "bundler", ">= 1.0.21"
|
14
|
+
gem "bio", ">= 1.4.2"
|
15
|
+
gem "rdoc", "~> 3.12"
|
16
|
+
end
|
17
|
+
|
18
|
+
group :production do
|
19
|
+
gem 'rdf'
|
20
|
+
gem 'rdf-4store'
|
21
|
+
gem 'rdf-turtle'
|
22
|
+
gem 'rserve-client'
|
23
|
+
gem 'sparql'
|
24
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 wstrinz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# bio-publisci
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/wstrinz/bioruby-publisci.png)](http://travis-ci.org/wstrinz/bioruby-publisci)
|
4
|
+
|
5
|
+
Full description goes here
|
6
|
+
|
7
|
+
Note: this software is under active development!
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```sh
|
12
|
+
gem install bio-publisci
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'bio-publisci'
|
19
|
+
```
|
20
|
+
|
21
|
+
The API doc is online. For more code examples see the test files in
|
22
|
+
the source tree.
|
23
|
+
|
24
|
+
## Project home page
|
25
|
+
|
26
|
+
Information on the source tree, documentation, examples, issues and
|
27
|
+
how to contribute, see
|
28
|
+
|
29
|
+
http://github.com/wstrinz/bioruby-publisci
|
30
|
+
|
31
|
+
The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
|
32
|
+
|
33
|
+
## Cite
|
34
|
+
|
35
|
+
If you use this software, please cite one of
|
36
|
+
|
37
|
+
* [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
|
38
|
+
* [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
|
39
|
+
|
40
|
+
## Biogems.info
|
41
|
+
|
42
|
+
This Biogem is published at (http://biogems.info/index.html#bio-publisci)
|
43
|
+
|
44
|
+
## Copyright
|
45
|
+
|
46
|
+
Copyright (c) 2013 wstrinz. See LICENSE.txt for further details.
|
47
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= bio-publisci
|
2
|
+
|
3
|
+
{<img
|
4
|
+
src="https://secure.travis-ci.org/wstrinz/bioruby-publisci.png"
|
5
|
+
/>}[http://travis-ci.org/#!/wstrinz/bioruby-publisci]
|
6
|
+
|
7
|
+
Full description goes here
|
8
|
+
|
9
|
+
Note: this software is under active development!
|
10
|
+
|
11
|
+
== Installation
|
12
|
+
|
13
|
+
gem install bio-publisci
|
14
|
+
|
15
|
+
== Usage
|
16
|
+
|
17
|
+
== Developers
|
18
|
+
|
19
|
+
To use the library
|
20
|
+
|
21
|
+
require 'bio-publisci'
|
22
|
+
|
23
|
+
The API doc is online. For more code examples see also the test files in
|
24
|
+
the source tree.
|
25
|
+
|
26
|
+
== Project home page
|
27
|
+
|
28
|
+
Information on the source tree, documentation, issues and how to contribute, see
|
29
|
+
|
30
|
+
http://github.com/wstrinz/bioruby-publisci
|
31
|
+
|
32
|
+
The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
|
33
|
+
|
34
|
+
== Cite
|
35
|
+
|
36
|
+
If you use this software, please cite one of
|
37
|
+
|
38
|
+
* [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
|
39
|
+
* [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
|
40
|
+
|
41
|
+
== Biogems.info
|
42
|
+
|
43
|
+
This Biogem is published at http://biogems.info/index.html#bio-publisci
|
44
|
+
|
45
|
+
== Copyright
|
46
|
+
|
47
|
+
Copyright (c) 2013 wstrinz. See LICENSE.txt for further details.
|
48
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "bio-publisci"
|
18
|
+
gem.homepage = "http://github.com/wstrinz/bioruby-publisci"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Publish science data using semantic web ontologies}
|
21
|
+
gem.description = %Q{A toolkit for publishing scientific results and datasets using RDF and related technologies }
|
22
|
+
gem.email = "wstrinz@gmail.com"
|
23
|
+
gem.authors = ["wstrinz"]
|
24
|
+
gem.version = "0.0.1"
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
require 'cucumber/rake/task'
|
42
|
+
Cucumber::Rake::Task.new(:features)
|
43
|
+
|
44
|
+
# task :default => :spec
|
45
|
+
|
46
|
+
task :default => [] do
|
47
|
+
begin
|
48
|
+
Rake::Task[:spec].invoke
|
49
|
+
rescue
|
50
|
+
end
|
51
|
+
Rake::Task[:features].invoke
|
52
|
+
end
|
53
|
+
|
54
|
+
task :test => [] do
|
55
|
+
begin
|
56
|
+
Rake::Task[:spec].invoke
|
57
|
+
rescue
|
58
|
+
end
|
59
|
+
Rake::Task[:features].invoke
|
60
|
+
end
|
61
|
+
|
62
|
+
require 'rdoc/task'
|
63
|
+
Rake::RDocTask.new do |rdoc|
|
64
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : "0.0.1"
|
65
|
+
|
66
|
+
rdoc.rdoc_dir = 'rdoc'
|
67
|
+
rdoc.title = "bio-publisci #{version}"
|
68
|
+
rdoc.rdoc_files.include('README*')
|
69
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
70
|
+
end
|
data/bin/bio-publisci
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# BioRuby bio-publisci Plugin BioPublisci
|
4
|
+
# Author:: wstrinz
|
5
|
+
# Copyright:: 2013
|
6
|
+
|
7
|
+
USAGE = "Describe bio-publisci"
|
8
|
+
|
9
|
+
gempath = File.dirname(File.dirname(__FILE__))
|
10
|
+
$: << File.join(gempath,'lib')
|
11
|
+
|
12
|
+
VERSION_FILENAME=File.join(gempath,'VERSION')
|
13
|
+
version = File.new(VERSION_FILENAME).read.chomp
|
14
|
+
|
15
|
+
# print banner
|
16
|
+
print "bio-publisci #{version} by wstrinz 2013\n"
|
17
|
+
|
18
|
+
if ARGV.size == 0
|
19
|
+
print USAGE
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'bio-publisci'
|
23
|
+
require 'optparse'
|
24
|
+
|
25
|
+
# Uncomment when using the bio-logger
|
26
|
+
# require 'bio-logger'
|
27
|
+
# Bio::Log::CLI.logger('stderr')
|
28
|
+
# Bio::Log::CLI.trace('info')
|
29
|
+
|
30
|
+
options = {:example_switch=>false,:show_help=>false}
|
31
|
+
opts = OptionParser.new do |o|
|
32
|
+
o.banner = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} the-perfect-gem"
|
33
|
+
|
34
|
+
o.on('--example_parameter [EXAMPLE_PARAMETER]', 'TODO: put a description for the PARAMETER') do |example_parameter|
|
35
|
+
# TODO: your logic here, below an example
|
36
|
+
options[:example_parameter] = 'this is a parameter'
|
37
|
+
end
|
38
|
+
|
39
|
+
o.separator ""
|
40
|
+
o.on("--switch-example", 'TODO: put a description for the SWITCH') do
|
41
|
+
# TODO: your logic here, below an example
|
42
|
+
self[:example_switch] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
# Uncomment the following when using the bio-logger
|
46
|
+
# o.separator ""
|
47
|
+
# o.on("--logger filename",String,"Log to file (default stderr)") do | name |
|
48
|
+
# Bio::Log::CLI.logger(name)
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# o.on("--trace options",String,"Set log level (default INFO, see bio-logger)") do | s |
|
52
|
+
# Bio::Log::CLI.trace(s)
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# o.on("-q", "--quiet", "Run quietly") do |q|
|
56
|
+
# Bio::Log::CLI.trace('error')
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# o.on("-v", "--verbose", "Run verbosely") do |v|
|
60
|
+
# Bio::Log::CLI.trace('info')
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# o.on("--debug", "Show debug messages") do |v|
|
64
|
+
# Bio::Log::CLI.trace('debug')
|
65
|
+
# end
|
66
|
+
|
67
|
+
o.separator ""
|
68
|
+
o.on_tail('-h', '--help', 'display this help and exit') do
|
69
|
+
options[:show_help] = true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
begin
|
74
|
+
opts.parse!(ARGV)
|
75
|
+
|
76
|
+
# Uncomment the following when using the bio-logger
|
77
|
+
# Bio::Log::CLI.configure('bio-publisci')
|
78
|
+
|
79
|
+
# TODO: your code here
|
80
|
+
# use options for your logic
|
81
|
+
rescue OptionParser::InvalidOption => e
|
82
|
+
options[:invalid_argument] = e.message
|
83
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: create generators
|
2
|
+
|
3
|
+
In order to check that objects conform to a common interface
|
4
|
+
I want to be able to call a generate method on various classes
|
5
|
+
|
6
|
+
Scenario: create a Dataframe generator
|
7
|
+
Given a Dataframe generator
|
8
|
+
Then I should be able to call its generate_n3 method
|
9
|
+
|
10
|
+
Scenario: create a CSV generator
|
11
|
+
Given a CSV generator
|
12
|
+
Then I should be able to call its generate_n3 method
|
13
|
+
|
14
|
+
Scenario: create a RMatrix generator
|
15
|
+
Given a RMatrix generator
|
16
|
+
Then I should be able to call its generate_n3 method
|
17
|
+
|
18
|
+
Scenario: create a Cross generator
|
19
|
+
Given a Cross generator
|
20
|
+
Then I should be able to call its generate_n3 method
|
21
|
+
|
22
|
+
Scenario: create a BigCross generator
|
23
|
+
Given a BigCross generator
|
24
|
+
Then I should be able to call its generate_n3 method
|
25
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: Integrate with other GSOC projects
|
2
|
+
|
3
|
+
In order to leverage the data sharing and comprehension power of RDF
|
4
|
+
I want to integrate my code with that of other GSOC students
|
5
|
+
|
6
|
+
Scenario: Integrate with Ruby Mining
|
7
|
+
Given a CSV generator
|
8
|
+
When I provide the reference file spec/csv/moar_bacon.csv and the label "moar_bacon" and the options {dimensions:["producer","pricerange"]}
|
9
|
+
And generate a turtle string from it
|
10
|
+
Given a ARFF writer
|
11
|
+
When I call its from_turtle method on the turtle string
|
12
|
+
Then I should be able to cluster the result and print statistics
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Then(/^I should be able to cluster the result and print statistics$/) do
|
2
|
+
require 'ruby_mining'
|
3
|
+
f=Tempfile.open('arff'); f.write @result; f.close
|
4
|
+
clustering = Weka::Clusterer::SimpleKMeans::Base
|
5
|
+
clustering.set_options "-N 5"
|
6
|
+
clustering.set_data(Core::Parser::parse_ARFF(f.path))
|
7
|
+
f.unlink
|
8
|
+
clustered = clustering.new
|
9
|
+
puts clustered
|
10
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Feature: generate data using ORM
|
2
|
+
|
3
|
+
In order to make the generator simpler and more accessible to ruby users
|
4
|
+
I want to implement an ORM (OTM? OGM?) to assist creation of datacube objects
|
5
|
+
|
6
|
+
Scenario: build data cube and export turtle
|
7
|
+
Given an ORM::DataCube entitled "cats"
|
8
|
+
When I add a "size" dimension
|
9
|
+
And I add a "breed" dimension
|
10
|
+
And I add a "fluffiness" measure
|
11
|
+
And I add the observation {size: "big", breed: "American Shorthair", fluffiness: 100}
|
12
|
+
And I add the observation {size: "huge", breed: "Maine Coon", fluffiness: 9001}
|
13
|
+
And I add the observation {size: "little", breed: "American Shorthair", fluffiness: 15}
|
14
|
+
Then the to_n3 method should return a string
|
15
|
+
|
16
|
+
Scenario: load from turtle string
|
17
|
+
Given a turtle string from file spec/turtle/bacon
|
18
|
+
When I call the ORM::DataCube class method load on it
|
19
|
+
Then I should receive an ORM::DataCube object
|
20
|
+
And the to_n3 method should return a string
|
21
|
+
|
22
|
+
Scenario: load from endpoint
|
23
|
+
Given the URI string "http://localhost:8080"
|
24
|
+
When I call the ORM::DataCube class method load on it
|
25
|
+
Then I should receive an ORM::DataCube object
|
26
|
+
And the to_n3 method should return a string
|
27
|
+
|
28
|
+
Scenario: raise error when unknown components are used
|
29
|
+
Given an ORM::DataCube entitled "animals"
|
30
|
+
When I add a "robustness" dimension
|
31
|
+
And I add a "species" measure
|
32
|
+
And I add the observation {species: "Balaenoptera musculus", robustness: 25}
|
33
|
+
And I add the observation {species: "Hypsibius dujardini", robustness: 9001}
|
34
|
+
Then the to_n3 method should return a string
|
35
|
+
When I add the observation {species: "Deinococcus radiodurans", robustness: 350, chunkiness: 9}
|
36
|
+
Then the to_n3 method should raise error UnknownProperty ["chunkiness"]
|
37
|
+
|
38
|
+
Scenario: raise error when components are missing
|
39
|
+
Given an ORM::DataCube entitled "animals"
|
40
|
+
When I add a "robustness" dimension
|
41
|
+
And I add a "species" measure
|
42
|
+
And I add the observation {species: "Felis catus"}
|
43
|
+
Then the to_n3 method should raise error MissingValues for ["robustness"]
|
44
|
+
|
45
|
+
Scenario: raise error when components are missing
|
46
|
+
Given an ORM::DataCube entitled "animals" with the following options:
|
47
|
+
| key | value |
|
48
|
+
| :validate_each | true |
|
49
|
+
When I add a "robustness" dimension
|
50
|
+
And I add a "species" measure
|
51
|
+
Then adding the observation {species: "Caenorhabditis elegans"} should raise error MissingValues for ["robustness"]
|
52
|
+
|
53
|
+
Scenario: add metadata
|
54
|
+
Given an ORM::DataCube entitled "meta"
|
55
|
+
When I add a "robustness" dimension
|
56
|
+
And I add a "species" measure
|
57
|
+
And I add the observation {species: "Hypsibius dujardini", robustness: 9001}
|
58
|
+
And I call the cubes add_publisher method with the arguments "Moss Piglets Unlimited", "http://mosspiglet.org/"
|
59
|
+
Then the to_n3 method should return a string with a "dct:publisher"
|
60
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative '../lib/bio-publisci.rb'
|
2
|
+
|
3
|
+
Given /^an ORM::DataCube entitled "(.*?)"$/ do |name|
|
4
|
+
@cube = R2RDF::Dataset::ORM::DataCube.new(name: name)
|
5
|
+
end
|
6
|
+
|
7
|
+
Given /^an ORM::DataCube entitled "(.*?)" with the following options:$/ do |name, opts|
|
8
|
+
options_hash = {name: name}
|
9
|
+
opts.hashes.map{|hash|
|
10
|
+
k = hash["key"]
|
11
|
+
k = k[1..-1].to_sym if k[0] == ":"
|
12
|
+
|
13
|
+
v = hash["value"]
|
14
|
+
v = v[1..-1].to_sym if k[0] == ":"
|
15
|
+
|
16
|
+
v = true if v =="true"
|
17
|
+
v = false if v =="false"
|
18
|
+
|
19
|
+
options_hash[k] = v
|
20
|
+
}
|
21
|
+
@cube = R2RDF::Dataset::ORM::DataCube.new(options_hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
Given(/^a turtle string from file (.*)$/) do |file|
|
25
|
+
@string = IO.read(file)
|
26
|
+
end
|
27
|
+
|
28
|
+
Given(/^the URI string "(.*?)"$/) do |uri|
|
29
|
+
@string = uri
|
30
|
+
end
|
31
|
+
|
32
|
+
When(/^I call the ORM::DataCube class method load on it$/) do
|
33
|
+
@cube = R2RDF::Dataset::ORM::DataCube.load(@string)
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^I add a "(.*?)" dimension$/ do |dim|
|
37
|
+
@cube.add_dimension(dim)
|
38
|
+
end
|
39
|
+
|
40
|
+
When /^I add a "(.*?)" measure$/ do |meas|
|
41
|
+
@cube.add_measure(meas)
|
42
|
+
end
|
43
|
+
|
44
|
+
When /^I add the observation (.*)$/ do |obs|
|
45
|
+
data = eval(obs)
|
46
|
+
# obs.split(',').map{|entry| data[entry.chomp.strip.split(':')[0].to_s] = eval(entry.chomp.strip.split(':')[1])}
|
47
|
+
@cube.add_observation(data)
|
48
|
+
end
|
49
|
+
|
50
|
+
When /^adding the observation (.*) should raise error (.*)$/ do |obs,err|
|
51
|
+
data = eval(obs)
|
52
|
+
expect { @cube.add_observation(data) }.to raise_error(err)
|
53
|
+
end
|
54
|
+
|
55
|
+
When /^I call the cubes (.*) method with the arguments (.*)$/ do |method,args|
|
56
|
+
eval("args = #{args}")
|
57
|
+
@cube.send(method.to_sym, *args)
|
58
|
+
end
|
59
|
+
|
60
|
+
Then /^the to_n3 method should return a string$/ do
|
61
|
+
@cube.to_n3.is_a?(String).should be true
|
62
|
+
end
|
63
|
+
|
64
|
+
Then /^the to_n3 method should raise error (.*?)$/ do |err|
|
65
|
+
expect { @cube.to_n3 }.to raise_error(err)
|
66
|
+
end
|
67
|
+
|
68
|
+
Then /^the to_n3 method should return a string with a "(.*?)"$/ do |search|
|
69
|
+
@cube.to_n3[search].should_not be nil
|
70
|
+
end
|
71
|
+
|
72
|
+
Then(/^I should receive an ORM::DataCube object$/) do
|
73
|
+
@cube.is_a?(R2RDF::Dataset::ORM::DataCube).should == true
|
74
|
+
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,60 @@
|
|
1
|
+
require_relative '../lib/bio-publisci.rb'
|
2
|
+
|
3
|
+
Given /^a (.*) generator$/ do |generator|
|
4
|
+
@generator = R2RDF::Reader.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
|
+
end
|
45
|
+
|
46
|
+
Then /^I should have access to a (.*) method$/ do |method|
|
47
|
+
@methods.include?(method).should == true
|
48
|
+
end
|
49
|
+
|
50
|
+
Then /^I should be able to call its (.*) method$/ do |method|
|
51
|
+
@generator.methods.include?(:"#{method}").should == true
|
52
|
+
end
|
53
|
+
|
54
|
+
Then /^the result should contain a "(.*?)"$/ do |search|
|
55
|
+
@turtle_string[search].should_not be nil
|
56
|
+
end
|
57
|
+
|
58
|
+
Then /^the result should contain some "(.*?)"s$/ do |search|
|
59
|
+
@turtle_string[search].size.should > 1
|
60
|
+
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 = R2RDF::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'
|