bio-publisci 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Rakefile +1 -1
- data/examples/prov_dsl.prov +2 -1
- 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/metadata_steps.rb +2 -4
- data/features/orm_steps.rb +4 -4
- data/features/reader_steps.rb +1 -1
- data/features/store_steps.rb +1 -1
- data/features/writer.feature +1 -1
- data/features/writer_steps.rb +1 -1
- data/lib/bio-publisci.rb +10 -2
- data/lib/bio-publisci/analyzer.rb +4 -4
- data/lib/bio-publisci/{spira.rb → datacube_model.rb} +4 -5
- data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +12 -12
- data/lib/bio-publisci/dataset/ORM/observation.rb +1 -1
- data/lib/bio-publisci/dataset/configuration.rb +31 -0
- data/lib/bio-publisci/dataset/data_cube.rb +28 -17
- data/lib/bio-publisci/dataset/dataset.rb +11 -0
- data/lib/bio-publisci/dataset/dataset_for.rb +19 -9
- data/lib/bio-publisci/dataset/interactive.rb +1 -1
- data/lib/bio-publisci/dsl/config.rb +34 -0
- data/lib/bio-publisci/dsl/dataset_dsl.rb +91 -0
- data/lib/bio-publisci/dsl/dsl.rb +69 -0
- data/lib/bio-publisci/dsl/metadata_dsl.rb +85 -0
- data/lib/bio-publisci/{metadata/prov/dsl.rb → dsl/prov_dsl.rb} +30 -6
- data/lib/bio-publisci/metadata/generator.rb +323 -0
- data/lib/bio-publisci/metadata/metadata.rb +3 -314
- data/lib/bio-publisci/metadata/prov/activity.rb +3 -1
- data/lib/bio-publisci/metadata/prov/agent.rb +1 -1
- data/lib/bio-publisci/metadata/prov/association.rb +2 -2
- data/lib/bio-publisci/metadata/prov/config.rb +34 -0
- data/lib/bio-publisci/metadata/prov/derivation.rb +7 -2
- data/lib/bio-publisci/metadata/prov/element.rb +2 -2
- data/lib/bio-publisci/metadata/prov/entity.rb +1 -22
- data/lib/bio-publisci/metadata/prov/model/prov_models.rb +8 -9
- data/lib/bio-publisci/metadata/prov/plan.rb +1 -1
- data/lib/bio-publisci/metadata/prov/prov.rb +23 -21
- data/lib/bio-publisci/metadata/prov/role.rb +1 -1
- data/lib/bio-publisci/metadata/prov/usage.rb +1 -1
- data/lib/bio-publisci/metadata/publisher.rb +25 -0
- data/lib/bio-publisci/mixins/dereferencable.rb +1 -1
- data/lib/bio-publisci/mixins/registry.rb +27 -0
- data/lib/bio-publisci/output.rb +1 -1
- data/lib/bio-publisci/parser.rb +1 -1
- data/lib/bio-publisci/query/query_helper.rb +14 -14
- data/lib/bio-publisci/r_client.rb +5 -5
- data/lib/bio-publisci/readers/arff.rb +5 -5
- data/lib/bio-publisci/readers/csv.rb +3 -3
- data/lib/bio-publisci/readers/dataframe.rb +3 -3
- data/lib/bio-publisci/readers/r_cross.rb +4 -4
- data/lib/bio-publisci/readers/r_matrix.rb +3 -3
- data/lib/bio-publisci/store.rb +3 -3
- data/lib/bio-publisci/writers/arff.rb +6 -6
- data/lib/bio-publisci/writers/dataframe.rb +5 -5
- data/scripts/islet_mlratio.rb +1 -1
- data/scripts/scan_islet.rb +1 -1
- data/scripts/update_reference.rb +2 -2
- data/spec/ORM/data_cube_orm_spec.rb +2 -2
- data/spec/ORM/prov_model_spec.rb +19 -0
- data/spec/analyzer_spec.rb +7 -7
- data/spec/data_cube_spec.rb +13 -13
- data/spec/dataset_for_spec.rb +11 -4
- data/spec/dsl_spec.rb +90 -0
- data/spec/generators/csv_spec.rb +4 -4
- data/spec/generators/dataframe_spec.rb +6 -6
- data/spec/generators/r_cross_spec.rb +2 -2
- data/spec/generators/r_matrix_spec.rb +2 -2
- data/spec/metadata/metadata_dsl_spec.rb +68 -0
- data/spec/prov/activity_spec.rb +4 -4
- data/spec/prov/agent_spec.rb +3 -4
- data/spec/prov/association_spec.rb +1 -2
- data/spec/prov/config_spec.rb +28 -0
- data/spec/prov/derivation_spec.rb +30 -0
- data/spec/prov/entity_spec.rb +3 -4
- data/spec/prov/role_spec.rb +1 -2
- data/spec/prov/usage_spec.rb +1 -2
- data/spec/r_builder_spec.rb +3 -3
- data/spec/turtle/bacon +20 -4
- data/spec/turtle/reference +20 -4
- metadata +37 -4
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'rdf/4store'
|
2
2
|
|
3
|
-
begin
|
4
|
-
require 'spira'
|
3
|
+
# begin
|
4
|
+
# require 'spira'
|
5
5
|
|
6
6
|
module PubliSci
|
7
|
-
|
7
|
+
class Prov
|
8
8
|
module Model
|
9
9
|
PROV ||= RDF::Vocabulary.new(RDF::URI.new('http://www.w3.org/ns/prov#'))
|
10
10
|
|
@@ -51,19 +51,18 @@ module PubliSci
|
|
51
51
|
has_many :qualifiedAssociation, predicate: PROV.qualifiedAssociation
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
54
|
class Association < Spira::Base
|
56
55
|
type PROV.Association
|
57
56
|
property :label, predicate: RDF::RDFS.label
|
58
57
|
property :agent, predicate: PROV.agent
|
59
|
-
property :hadPlan, predicate: PROV.
|
58
|
+
property :hadPlan, predicate: PROV.hadPlan
|
60
59
|
end
|
61
60
|
|
62
61
|
class Derivation < Spira::Base
|
63
62
|
type PROV.Derivation
|
64
63
|
property :label, predicate: RDF::RDFS.label
|
65
64
|
property :agent, predicate: PROV.agent
|
66
|
-
property :hadPlan, predicate: PROV.
|
65
|
+
property :hadPlan, predicate: PROV.hadPlan
|
67
66
|
end
|
68
67
|
|
69
68
|
class Plan < Spira::Base
|
@@ -74,6 +73,6 @@ module PubliSci
|
|
74
73
|
end
|
75
74
|
end
|
76
75
|
end
|
77
|
-
rescue LoadError
|
78
|
-
|
79
|
-
end
|
76
|
+
# rescue LoadError
|
77
|
+
# puts "spira not installed, ORM unavailable"
|
78
|
+
# end
|
@@ -1,39 +1,41 @@
|
|
1
1
|
module PubliSci
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class Prov
|
3
|
+
extend PubliSci::Registry
|
4
|
+
|
5
|
+
def self.configuration
|
6
|
+
@config ||= Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.symbol_for(object)
|
6
10
|
if object.is_a? Agent
|
7
|
-
|
11
|
+
:agents
|
8
12
|
elsif object.is_a? Entity
|
9
|
-
|
13
|
+
:entities
|
10
14
|
elsif object.is_a? Activity
|
11
|
-
|
15
|
+
:activities
|
12
16
|
elsif object.is_a? Association
|
13
|
-
|
17
|
+
:associations
|
14
18
|
elsif object.is_a? Plan
|
15
|
-
|
16
|
-
else
|
17
|
-
sub = object.class.to_s.split('::').last.downcase.to_sym
|
18
|
-
# raise "UnknownElement: unkown object type for #{object}"
|
19
|
-
end
|
20
|
-
if name
|
21
|
-
(registry[sub] ||= {})[name] = object
|
19
|
+
:plans
|
22
20
|
else
|
23
|
-
|
21
|
+
false
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
|
-
def self.registry
|
28
|
-
@registry ||= {}
|
29
|
-
end
|
30
25
|
|
31
26
|
def self.run(string)
|
27
|
+
sing =DSL::Instance.new
|
32
28
|
if File.exists? string
|
33
|
-
|
29
|
+
sing.instance_eval(IO.read(string),string)
|
34
30
|
else
|
35
|
-
|
31
|
+
sing.instance_eval(string)
|
36
32
|
end
|
33
|
+
sing.output
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.reset_settings
|
37
|
+
Configuration.defaults.map{|k,v| configuration.send("#{k}=",v)}
|
38
|
+
@base_url=nil
|
37
39
|
end
|
38
40
|
|
39
41
|
def self.agents
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module PubliSci
|
2
|
+
class Metadata
|
3
|
+
class Publisher
|
4
|
+
|
5
|
+
def uri(uri=nil)
|
6
|
+
if uri
|
7
|
+
@uri = uri
|
8
|
+
else
|
9
|
+
@uri
|
10
|
+
end
|
11
|
+
end
|
12
|
+
alias_method :url, :uri
|
13
|
+
|
14
|
+
def label(label=nil)
|
15
|
+
if label
|
16
|
+
@label = label
|
17
|
+
else
|
18
|
+
@label
|
19
|
+
end
|
20
|
+
end
|
21
|
+
alias_method :name, :label
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module PubliSci
|
2
|
+
module Registry
|
3
|
+
def register(name,object)
|
4
|
+
# puts "register #{name} #{object} #{associations.size}"
|
5
|
+
name = name.to_sym if name
|
6
|
+
if symbol_for(object)
|
7
|
+
sub = symbol_for(object)
|
8
|
+
else
|
9
|
+
sub = object.class.to_s.split('::').last.downcase.to_sym
|
10
|
+
end
|
11
|
+
if name
|
12
|
+
(registry[sub] ||= {})[name] = object
|
13
|
+
else
|
14
|
+
(registry[sub] ||= []) << object
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def registry
|
19
|
+
@registry ||= {}
|
20
|
+
end
|
21
|
+
|
22
|
+
#should be overridden
|
23
|
+
def symbol_for(object)
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/bio-publisci/output.rb
CHANGED
data/lib/bio-publisci/parser.rb
CHANGED
@@ -16,7 +16,7 @@ module RDF
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
module
|
19
|
+
module PubliSci
|
20
20
|
#.gsub(/^\s+/,'')
|
21
21
|
module Query
|
22
22
|
def vocabulary
|
@@ -30,19 +30,19 @@ module R2RDF
|
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
|
34
34
|
|
35
35
|
# def execute_internal(query,repo)
|
36
36
|
# SPARQL.execute(query,repo)
|
37
37
|
# end
|
38
38
|
|
39
39
|
def execute(string,store,type=:fourstore)
|
40
|
-
if type == :graph || store.is_a?(RDF::Graph) || store.is_a?(RDF::Repository)
|
40
|
+
if type == :graph || store.is_a?(RDF::Graph) || store.is_a?(RDF::Repository)
|
41
41
|
sparql = SPARQL::Client.new(store)
|
42
|
-
elsif store.is_a?
|
43
|
-
sparql = SPARQL::Client.new(store.url+"/sparql/")
|
42
|
+
elsif store.is_a? PubliSci::Store
|
43
|
+
sparql = SPARQL::Client.new(store.url+"/sparql/")
|
44
44
|
elsif type == :fourstore
|
45
|
-
sparql = SPARQL::Client.new(store+"/sparql/")
|
45
|
+
sparql = SPARQL::Client.new(store+"/sparql/")
|
46
46
|
end
|
47
47
|
sparql.query(string)
|
48
48
|
end
|
@@ -62,13 +62,13 @@ module R2RDF
|
|
62
62
|
|
63
63
|
# def prefixes
|
64
64
|
# <<-EOF
|
65
|
-
# PREFIX ns: <http://www.rqtl.org/ns/#>
|
66
|
-
# PREFIX qb: <http://purl.org/linked-data/cube#>
|
67
|
-
# PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
68
|
-
# PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
69
|
-
# PREFIX prop: <http://www.rqtl.org/dc/properties/>
|
65
|
+
# PREFIX ns: <http://www.rqtl.org/ns/#>
|
66
|
+
# PREFIX qb: <http://purl.org/linked-data/cube#>
|
67
|
+
# PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
68
|
+
# PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
69
|
+
# PREFIX prop: <http://www.rqtl.org/dc/properties/>
|
70
70
|
# PREFIX cs: <http://www.rqtl.org/dc/cs/>
|
71
|
-
# PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
71
|
+
# PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
72
72
|
|
73
73
|
# EOF
|
74
74
|
# end
|
@@ -109,6 +109,6 @@ SELECT DISTINCT ?label WHERE {
|
|
109
109
|
end
|
110
110
|
|
111
111
|
class QueryHelper
|
112
|
-
include
|
113
|
-
end
|
112
|
+
include PubliSci::Query
|
113
|
+
end
|
114
114
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module PubliSci
|
2
2
|
module Rconnect
|
3
|
-
|
3
|
+
|
4
4
|
def connect(address=nil)
|
5
5
|
if address
|
6
6
|
Rserve::Connection.new(address)
|
@@ -22,12 +22,12 @@ module R2RDF
|
|
22
22
|
connection.eval("ls()")
|
23
23
|
end
|
24
24
|
|
25
|
-
end
|
25
|
+
end
|
26
26
|
|
27
27
|
class Client
|
28
|
-
include
|
28
|
+
include PubliSci::Rconnect
|
29
29
|
attr :R
|
30
|
-
|
30
|
+
|
31
31
|
def initialize(auto=true, loc=Dir.home)
|
32
32
|
@R = connect
|
33
33
|
@loc = loc
|
@@ -1,15 +1,15 @@
|
|
1
|
-
module
|
1
|
+
module PubliSci
|
2
2
|
module Reader
|
3
3
|
class ARFF
|
4
|
-
include
|
4
|
+
include PubliSci::Dataset::DataCube
|
5
5
|
def generate_n3(arff, options={})
|
6
|
-
arff = IO.read(arff) if File.exist? arff
|
6
|
+
arff = IO.read(arff) if File.exist? arff
|
7
7
|
options[:no_labels] = true # unless options[:no_labels] == nil
|
8
8
|
@options = options
|
9
9
|
comps = components(arff)
|
10
10
|
obs = data(arff, comps.keys)
|
11
11
|
repl = generate(comps.reject{|c| comps[c][:codes]}.keys, comps.select{|c| comps[c][:codes]}.keys, comps.select{|c| comps[c][:codes]}.keys, obs, (1..obs.first[1].size).to_a, relation(arff), options)
|
12
|
-
|
12
|
+
|
13
13
|
end
|
14
14
|
|
15
15
|
def relation(arff)
|
@@ -52,7 +52,7 @@ module R2RDF
|
|
52
52
|
# [@options[:row_label]]
|
53
53
|
# else
|
54
54
|
# ["refRow"]
|
55
|
-
# end
|
55
|
+
# end
|
56
56
|
# end
|
57
57
|
|
58
58
|
# def measures
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module PubliSci
|
2
2
|
module Reader
|
3
3
|
class CSV
|
4
|
-
include
|
5
|
-
include
|
4
|
+
include PubliSci::Dataset::DataCube
|
5
|
+
include PubliSci::Interactive
|
6
6
|
|
7
7
|
def automatic(file=nil,dataset_name=nil,options={},interactive=true)
|
8
8
|
#to do
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module PubliSci
|
2
2
|
module Reader
|
3
3
|
class RCross
|
4
|
-
include
|
5
|
-
include
|
4
|
+
include PubliSci::Dataset::DataCube
|
5
|
+
include PubliSci::Reader::Output
|
6
6
|
|
7
7
|
def generate_n3(client, var, outfile_base, options={})
|
8
8
|
meas = measures(client,var,options)
|
@@ -42,7 +42,7 @@ module R2RDF
|
|
42
42
|
str = prefixes(var,options)
|
43
43
|
str << data_structure_definition(meas,dim,codes,var,options)
|
44
44
|
str << dataset(var,options)
|
45
|
-
component_specifications(meas, dim, var, options).map{ |c| str << c }
|
45
|
+
component_specifications(meas, dim, codes, var, options).map{ |c| str << c }
|
46
46
|
measure_properties(meas,var,options).map{|m| str << m}
|
47
47
|
|
48
48
|
str
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module
|
1
|
+
module PubliSci
|
2
2
|
module Reader
|
3
3
|
class RMatrix
|
4
|
-
include
|
4
|
+
include PubliSci::Dataset::DataCube
|
5
5
|
|
6
6
|
#NOTE; this is pretty much hard coded for Karl's application right now, and doesn't
|
7
7
|
# do any dimension or code generation. Since its a set of LOD scores indexed by dimension
|
@@ -76,7 +76,7 @@ module R2RDF
|
|
76
76
|
str = prefixes(var, options)
|
77
77
|
str << data_structure_definition(meas,[],codes,outvar,options)
|
78
78
|
str << dataset(outvar,options)
|
79
|
-
component_specifications(meas, dim, var, options).map{ |c| str << c }
|
79
|
+
component_specifications(meas, dim, codes, var, options).map{ |c| str << c }
|
80
80
|
measure_properties(meas,var,options).map{|m| str << m}
|
81
81
|
|
82
82
|
str
|
data/lib/bio-publisci/store.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module
|
1
|
+
module PubliSci
|
2
2
|
# handles connection and messaging to/from the triple store
|
3
3
|
class Store
|
4
|
-
include
|
4
|
+
include PubliSci::Query
|
5
5
|
|
6
6
|
def defaults
|
7
7
|
{
|
@@ -27,7 +27,7 @@ module R2RDF
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def add_all(dir, graph, pattern=nil)
|
30
|
-
pattern = /.+\.ttl/ if pattern == :turtle || pattern == :ttl
|
30
|
+
pattern = /.+\.ttl/ if pattern == :turtle || pattern == :ttl
|
31
31
|
|
32
32
|
files = Dir.entries(dir) - %w(. ..)
|
33
33
|
files = files.grep(pattern) if pattern.is_a? Regexp
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module PubliSci
|
2
2
|
module Writer
|
3
3
|
class ARFF
|
4
|
-
include
|
5
|
-
include
|
6
|
-
include
|
4
|
+
include PubliSci::Query
|
5
|
+
include PubliSci::Parser
|
6
|
+
include PubliSci::Analyzer
|
7
7
|
|
8
8
|
def build_arff(relation, attributes, data, source)
|
9
9
|
str = <<-EOS
|
@@ -11,7 +11,7 @@ module R2RDF
|
|
11
11
|
%
|
12
12
|
% 2. Sources:
|
13
13
|
% (a) Generated from RDF source #{source}
|
14
|
-
%
|
14
|
+
%
|
15
15
|
@RELATION #{relation}
|
16
16
|
|
17
17
|
EOS
|
@@ -30,7 +30,7 @@ EOS
|
|
30
30
|
puts "loading #{turtle_file}" if verbose
|
31
31
|
repo = RDF::Repository.load(turtle_file)
|
32
32
|
puts "loaded #{repo.size} statements into temporary repo" if verbose
|
33
|
-
|
33
|
+
|
34
34
|
dims = execute_from_file("dimensions.rq",repo,:graph).to_h.map{|d| [d[:dimension].to_s, d[:label].to_s]}
|
35
35
|
meas = execute_from_file("measures.rq",repo,:graph).to_h.map{|m| [m[:measure].to_s, m[:label].to_s]}
|
36
36
|
relation = execute_from_file("dataset.rq",repo,:graph).to_h.first[:label].to_s
|