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,68 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
|
3
|
+
describe PubliSci::Metadata::DSL do
|
4
|
+
include PubliSci::Metadata::DSL
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
PubliSci::Prov.registry.clear
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can generate basic metadata as n3" do
|
11
|
+
dataset 'bacon'
|
12
|
+
title 'Bacon Data'
|
13
|
+
description 'a dataset about bacon'
|
14
|
+
creator 'Will'
|
15
|
+
topic 'Delicious Bacon'
|
16
|
+
str = generate_n3
|
17
|
+
str[/rdfs:label "(.+)";/,1].should == "Bacon Data"
|
18
|
+
str[/dct:creator "(.+)";/,1].should == "Will"
|
19
|
+
str[/dct:subject "(.+)";/,1].should == "Delicious Bacon"
|
20
|
+
str[/dct:description "(.+)";/,1].should == "a dataset about bacon"
|
21
|
+
str[/dct:issued "(.+)"\^\^xsd:date/,1].should == Time.now.strftime("%Y-%m-%d")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can add additional information about publisher" do
|
25
|
+
dataset 'bacon'
|
26
|
+
p = publisher do
|
27
|
+
label "pub"
|
28
|
+
uri "http://some-organization.com"
|
29
|
+
end
|
30
|
+
|
31
|
+
p.label.should == "pub"
|
32
|
+
generate_n3[%r{dct:publisher <(.+)> .},1].should == "http://some-organization.com"
|
33
|
+
end
|
34
|
+
|
35
|
+
# it "can be created with a block" do
|
36
|
+
# a = agent :ag do
|
37
|
+
# subject "http://things.com/stuff"
|
38
|
+
# name "Mr Person"
|
39
|
+
# end
|
40
|
+
# a.is_a?(Agent).should be true
|
41
|
+
# a.subject.should == "http://things.com/stuff"
|
42
|
+
# a.name.should == "Mr Person"
|
43
|
+
# end
|
44
|
+
|
45
|
+
# it "can be given a type corresponding to a subclass of prov:Agent" do
|
46
|
+
# a = agent :name, type: "software"
|
47
|
+
# a.type.should == :software
|
48
|
+
# a.to_n3["prov:SoftwareAgent"].should_not be nil
|
49
|
+
# end
|
50
|
+
|
51
|
+
# it "can be created using the organization helper" do
|
52
|
+
# a = organization :group
|
53
|
+
# a.type.should == :organization
|
54
|
+
# end
|
55
|
+
|
56
|
+
# it "raises an exception when on_behalf_of does not refer to an agent" do
|
57
|
+
# a = agent :name, on_behalf_of: :other
|
58
|
+
# expect {a.on_behalf_of[0]}.to raise_error
|
59
|
+
# end
|
60
|
+
|
61
|
+
# it "lazy loads other objects, so declaration order doesn't usually matter" do
|
62
|
+
# a = agent :name, on_behalf_of: :other
|
63
|
+
# b = agent :other
|
64
|
+
|
65
|
+
# a.on_behalf_of.should == b
|
66
|
+
# end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
include PubliSci::Prov::DSL
|
3
|
+
# include PubliSci
|
4
|
+
|
5
|
+
describe PubliSci::Prov::Activity do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@evaluator = PubliSci::Prov::DSL::Instance.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can generate activity fields from symbol" do
|
12
|
+
a = activity :name
|
13
|
+
a.is_a?(Prov::Activity).should be true
|
14
|
+
a.subject.should == "http://rqtl.org/ns/activity/name"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can specify fields manually" do
|
18
|
+
a = activity :name, subject: "http://example.org/name"
|
19
|
+
a.subject.should == "http://example.org/name"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "can be created with a block" do
|
23
|
+
e = entity :data
|
24
|
+
a = activity :ag do
|
25
|
+
subject "http://things.com/stuff"
|
26
|
+
generated :data
|
27
|
+
end
|
28
|
+
a.is_a?(Prov::Activity).should be true
|
29
|
+
a.subject.should == "http://things.com/stuff"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "lazy loads other objects" do
|
33
|
+
a = activity :ag do
|
34
|
+
subject "http://things.com/stuff"
|
35
|
+
generated :data
|
36
|
+
end
|
37
|
+
e = entity :data
|
38
|
+
|
39
|
+
a.generated[0].should == e
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises an exception when used does not refer to an entity" do
|
43
|
+
a = activity :name, used: :some_data
|
44
|
+
expect {a.used[0]}.to raise_error
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises an exception when generated does not refer to an entity" do
|
48
|
+
a = activity :name, generated: :other_data
|
49
|
+
expect {a.generated[0]}.to raise_error
|
50
|
+
end
|
51
|
+
|
52
|
+
it "lazy loads generated relationships" do
|
53
|
+
a = activity :act, generated: :data
|
54
|
+
e = entity :data
|
55
|
+
|
56
|
+
a.generated[0].should == e
|
57
|
+
end
|
58
|
+
|
59
|
+
it "lazy loads used relationships" do
|
60
|
+
a = activity :act, generated: :data, used: :other_data
|
61
|
+
e = entity :data
|
62
|
+
f = entity :other_data
|
63
|
+
|
64
|
+
a.used[0].should == f
|
65
|
+
end
|
66
|
+
|
67
|
+
# it "lazy loads other objects, so declaration order doesn't usually matter" do
|
68
|
+
# a = activity :name, on_behalf_of: :other
|
69
|
+
# b = activity :other
|
70
|
+
|
71
|
+
# a.on_behalf_of.should == b
|
72
|
+
# end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
include PubliSci::Prov::DSL
|
3
|
+
|
4
|
+
describe PubliSci::Prov::Agent do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@evaluator = PubliSci::Prov::DSL::Instance.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can generate agent fields from symbol" do
|
11
|
+
a = agent :name
|
12
|
+
a.is_a?(Prov::Agent).should be true
|
13
|
+
a.subject.should == "http://rqtl.org/ns/agent/name"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can specify fields manually" do
|
17
|
+
a = agent :name, subject: "http://example.org/name"
|
18
|
+
a.subject.should == "http://example.org/name"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can be created with a block" do
|
22
|
+
a = agent :ag do
|
23
|
+
subject "http://things.com/stuff"
|
24
|
+
name "Mr Person"
|
25
|
+
end
|
26
|
+
a.is_a?(Prov::Agent).should be true
|
27
|
+
a.subject.should == "http://things.com/stuff"
|
28
|
+
a.name.should == "Mr Person"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "can be given a type corresponding to a subclass of prov:Agent" do
|
32
|
+
a = agent :name, type: "software"
|
33
|
+
a.type.should == :software
|
34
|
+
a.to_n3["prov:SoftwareAgent"].should_not be nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can be created using the organization helper" do
|
38
|
+
a = organization :group
|
39
|
+
a.type.should == :organization
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises an exception when on_behalf_of does not refer to an agent" do
|
43
|
+
a = agent :name, on_behalf_of: :other
|
44
|
+
expect {a.on_behalf_of[0]}.to raise_error
|
45
|
+
end
|
46
|
+
|
47
|
+
it "lazy loads other objects, so declaration order doesn't usually matter" do
|
48
|
+
a = agent :name, on_behalf_of: :other
|
49
|
+
b = agent :other
|
50
|
+
|
51
|
+
a.on_behalf_of.should == b
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
include PubliSci::Prov::DSL
|
3
|
+
|
4
|
+
describe PubliSci::Prov::Association do
|
5
|
+
before(:each) do
|
6
|
+
@ev = PubliSci::Prov::DSL::Instance.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can create simple associations" do
|
10
|
+
e = @ev.entity :name
|
11
|
+
f = @ev.agent :other
|
12
|
+
g = @ev.activity :do_things, generated: :name, associated_with: :other
|
13
|
+
g.associated_with[0].should == f
|
14
|
+
@ev.generate_n3["prov:wasAssociatedWith"].size.should > 0
|
15
|
+
end
|
16
|
+
|
17
|
+
it "creates qualified associations when a block is passed" do
|
18
|
+
e = @ev.entity :name
|
19
|
+
f = @ev.agent :other
|
20
|
+
p = @ev.plan :the_plan
|
21
|
+
g = @ev.activity :do_things do
|
22
|
+
generated :name
|
23
|
+
associated_with do
|
24
|
+
agent :other
|
25
|
+
plan :the_plan
|
26
|
+
end
|
27
|
+
end
|
28
|
+
g.associated_with.first.agent.should == f
|
29
|
+
@ev.generate_n3["prov:wasAssociatedWith"].size.should > 0
|
30
|
+
@ev.generate_n3["prov:qualifiedAssociation"].size.should > 0
|
31
|
+
end
|
32
|
+
|
33
|
+
# it "raises an exception when derivation does not refer to an entity" do
|
34
|
+
# e = entity :name, derived_from: :dataset
|
35
|
+
# expect {e.derived_from[0]}.to raise_error
|
36
|
+
# end
|
37
|
+
|
38
|
+
# it "raises an exception when attribution does not refer to an agent" do
|
39
|
+
# e = entity :name, attributed_to: :person
|
40
|
+
# expect {e.attributed_to[0]}.to raise_error
|
41
|
+
# end
|
42
|
+
|
43
|
+
# it "raises an exception when generated_by does not refer to an activity" do
|
44
|
+
# e = entity :name, generated_by: :act
|
45
|
+
# expect {e.generated_by[0]}.to raise_error
|
46
|
+
# end
|
47
|
+
|
48
|
+
# it "lazy loads other objects, so declaration order doesn't usually matter" do
|
49
|
+
# e = entity :name, derived_from: :other
|
50
|
+
# f = entity :other
|
51
|
+
|
52
|
+
|
53
|
+
# e.derived_from[0].should == f
|
54
|
+
# end
|
55
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
include PubliSci::Prov::DSL
|
3
|
+
include PubliSci
|
4
|
+
|
5
|
+
describe PubliSci::Prov::Configuration do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@evaluator = PubliSci::Prov::DSL::Instance.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can set basic config methods" do
|
12
|
+
configure do |cfg|
|
13
|
+
cfg.output :to_repository
|
14
|
+
end
|
15
|
+
settings.output.should == :to_repository
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can configure different repository types", no_travis: true do
|
19
|
+
configure do |cfg|
|
20
|
+
cfg.repository :fourstore
|
21
|
+
end
|
22
|
+
a = activity :name
|
23
|
+
a.is_a?(Prov::Activity).should be true
|
24
|
+
r=to_repository
|
25
|
+
a.subject.should == "http://rqtl.org/ns/activity/name"
|
26
|
+
r.is_a?(RDF::FourStore::Repository).should be true
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
include PubliSci::Prov::DSL
|
3
|
+
|
4
|
+
describe PubliSci::Prov::Derivation do
|
5
|
+
before(:each) do
|
6
|
+
@ev = PubliSci::Prov::DSL::Instance.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can create simple derivations" do
|
10
|
+
e = @ev.entity :name
|
11
|
+
f = @ev.entity :other, derived_from: :name
|
12
|
+
# g = @ev.activity :do_things, generated: :name, associated_with: :other
|
13
|
+
f.derived_from[0].should == e
|
14
|
+
@ev.generate_n3
|
15
|
+
@ev.generate_n3["prov:wasDerivedFrom"].size.should > 0
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates qualified derivations when a block is passed" do
|
19
|
+
e = @ev.entity :name
|
20
|
+
f = @ev.entity :other do
|
21
|
+
derived_from :name do
|
22
|
+
had_activity :do_things
|
23
|
+
end
|
24
|
+
end
|
25
|
+
g = @ev.activity :do_things do
|
26
|
+
generated :other
|
27
|
+
end
|
28
|
+
f.derived_from.first.had_activity.should == g
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
include PubliSci::Prov::DSL
|
3
|
+
|
4
|
+
describe PubliSci::Prov::Entity do
|
5
|
+
before(:each) do
|
6
|
+
@evaluator = PubliSci::Prov::DSL::Instance.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can generate entity fields from symbol" do
|
10
|
+
e = entity :name
|
11
|
+
e.is_a?(Prov::Entity).should be true
|
12
|
+
e.subject.should == "http://rqtl.org/ns/entity/name"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can specify fields manually" do
|
16
|
+
e = entity :name, subject: "http://example.org/name"
|
17
|
+
e.subject.should == "http://example.org/name"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can be created with a block" do
|
21
|
+
e = entity :ent do
|
22
|
+
subject "http://things.com/stuff"
|
23
|
+
source "/somefile.txt"
|
24
|
+
end
|
25
|
+
e.is_a?(Prov::Entity).should be true
|
26
|
+
e.subject.should == "http://things.com/stuff"
|
27
|
+
e.source[0].should == "/somefile.txt"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises an exception when derivation does not refer to an entity" do
|
31
|
+
e = entity :name, derived_from: :dataset
|
32
|
+
expect {e.derived_from[0]}.to raise_error
|
33
|
+
end
|
34
|
+
|
35
|
+
it "raises an exception when attribution does not refer to an agent" do
|
36
|
+
e = entity :name, attributed_to: :person
|
37
|
+
expect {e.attributed_to[0]}.to raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "raises an exception when generated_by does not refer to an activity" do
|
41
|
+
e = entity :name, generated_by: :act
|
42
|
+
expect {e.generated_by[0]}.to raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it "lazy loads other objects, so declaration order doesn't usually matter" do
|
46
|
+
e = entity :name, derived_from: :other
|
47
|
+
f = entity :other
|
48
|
+
|
49
|
+
|
50
|
+
e.derived_from[0].should == f
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require_relative '../../lib/bio-publisci.rb'
|
2
|
+
include PubliSci::Prov::DSL
|
3
|
+
|
4
|
+
describe PubliSci::Prov::Role do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@evaluator = PubliSci::Prov::DSL::Instance.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "creates a role in a used block" do
|
11
|
+
ent1 = @ev.entity :some_data
|
12
|
+
ent2 = @ev.entity :other_data
|
13
|
+
ag = @ev.agent :some_guy
|
14
|
+
act = @ev.activity :do_things do
|
15
|
+
generated :some_data
|
16
|
+
associated_with :some_guy
|
17
|
+
used do
|
18
|
+
entity :other_data
|
19
|
+
role :plagirized
|
20
|
+
end
|
21
|
+
end
|
22
|
+
act.used[0].role.to_n3["a prov:Role"].size.should > 0
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can have a comment attached" do
|
26
|
+
ent1 = @ev.entity :some_data
|
27
|
+
ent2 = @ev.entity :other_data
|
28
|
+
ag = @ev.agent :some_guy
|
29
|
+
act = @ev.activity :do_things do
|
30
|
+
generated :some_data
|
31
|
+
associated_with :some_guy
|
32
|
+
used do
|
33
|
+
entity :other_data
|
34
|
+
role :plagirized do
|
35
|
+
comment "I stole all of this data"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
act.used[0].role.to_n3["rdfs:comment"].size.should > 0
|
40
|
+
end
|
41
|
+
|
42
|
+
# it "can be created with a block" do
|
43
|
+
# e = entity :data
|
44
|
+
# a = activity :ag do
|
45
|
+
# subject "http://things.com/stuff"
|
46
|
+
# generated :data
|
47
|
+
# end
|
48
|
+
# a.is_a?(Activity).should be true
|
49
|
+
# a.subject.should == "http://things.com/stuff"
|
50
|
+
# end
|
51
|
+
|
52
|
+
# it "lazy loads other objects" do
|
53
|
+
# a = activity :ag do
|
54
|
+
# subject "http://things.com/stuff"
|
55
|
+
# generated :data
|
56
|
+
# end
|
57
|
+
# e = entity :data
|
58
|
+
|
59
|
+
# a.generated[0].should == e
|
60
|
+
# end
|
61
|
+
|
62
|
+
# it "raises an exception when used does not refer to an entity" do
|
63
|
+
# a = activity :name, used: :some_data
|
64
|
+
# expect {a.used[0]}.to raise_error
|
65
|
+
# end
|
66
|
+
|
67
|
+
# it "raises an exception when generated does not refer to an entity" do
|
68
|
+
# a = activity :name, generated: :other_data
|
69
|
+
# expect {a.generated[0]}.to raise_error
|
70
|
+
# end
|
71
|
+
|
72
|
+
# it "lazy loads generated relationships" do
|
73
|
+
# a = activity :act, generated: :data
|
74
|
+
# e = entity :data
|
75
|
+
|
76
|
+
# a.generated[0].should == e
|
77
|
+
# end
|
78
|
+
|
79
|
+
# it "lazy loads used relationships" do
|
80
|
+
# a = activity :act, generated: :data, used: :other_data
|
81
|
+
# e = entity :data
|
82
|
+
# f = entity :other_data
|
83
|
+
|
84
|
+
# a.used[0].should == f
|
85
|
+
# end
|
86
|
+
|
87
|
+
# it "lazy loads other objects, so declaration order doesn't usually matter" do
|
88
|
+
# a = activity :name, on_behalf_of: :other
|
89
|
+
# b = activity :other
|
90
|
+
|
91
|
+
# a.on_behalf_of.should == b
|
92
|
+
# end
|
93
|
+
|
94
|
+
end
|