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,58 @@
|
|
1
|
+
# Example using as little generation "magic" as possible, for execution
|
2
|
+
# as plain Ruby script.
|
3
|
+
#
|
4
|
+
# Run using "ruby no_magic.prov"
|
5
|
+
|
6
|
+
require 'bio-publisci'
|
7
|
+
include PubliSci::Prov::DSL
|
8
|
+
|
9
|
+
|
10
|
+
# Subject and type for most elements can be set manually
|
11
|
+
agent :publisci, subject: 'http://gsocsemantic.wordpress.com/publisci', type: "software"
|
12
|
+
agent :R, subject: "http://r-project.org"
|
13
|
+
agent :sciruby, subject: "http://sciruby.com", type: "organization"
|
14
|
+
|
15
|
+
plan :R_steps, subject: "http://example.org/plan/R_steps", steps: "spec/resource/example.Rhistory"
|
16
|
+
|
17
|
+
agent :Will do
|
18
|
+
# subject can be called within a block as well
|
19
|
+
subject "http://gsocsemantic.wordpress.com/me"
|
20
|
+
type "person"
|
21
|
+
name "Will Strinz"
|
22
|
+
on_behalf_of "http://sciruby.com"
|
23
|
+
end
|
24
|
+
|
25
|
+
# The wasGeneratedBy relationship is usually created automatically when an activitiy
|
26
|
+
# is associated with an entity, but it can be specified manually
|
27
|
+
entity :triplified_example, subject: "http://example.org/dataset/ex", generated_by: :triplify
|
28
|
+
|
29
|
+
entity :original do
|
30
|
+
generated_by :use_R
|
31
|
+
subject "http://example.org/R/ex"
|
32
|
+
source "./example.RData"
|
33
|
+
|
34
|
+
# Custom predicates and objects can be used for flexibility and extensibility
|
35
|
+
has "http://purl.org/dc/terms/title", "original data object"
|
36
|
+
end
|
37
|
+
|
38
|
+
activity :triplify do
|
39
|
+
# Most methods will take either Symbols or Strings, and correctly handle
|
40
|
+
# resources vs literals
|
41
|
+
subject "http://example.org/activity/triplify"
|
42
|
+
generated "http://example.org/dataset/ex"
|
43
|
+
associated_with :publisci
|
44
|
+
used :original
|
45
|
+
end
|
46
|
+
|
47
|
+
activity :use_R do
|
48
|
+
subject "http://example.org/activity/use_R"
|
49
|
+
generated "http://example.org/R/ex"
|
50
|
+
|
51
|
+
associated_with :R
|
52
|
+
associated_with :Will
|
53
|
+
end
|
54
|
+
|
55
|
+
# Running a prov script using the gem executable will print the result, but
|
56
|
+
# if you use the DSL you'll have to do it manually. You also read out to a file
|
57
|
+
# or other method/object of course (eg "open('out.ttl','w'){|file| file.write generate_n3}")
|
58
|
+
puts generate_n3
|
data/examples/orm.prov
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
agent :R, subject: "http://r-project.org"
|
2
|
+
agent :publisci, type: "software"
|
3
|
+
plan :R_steps, steps: "spec/resource/example.Rhistory"
|
4
|
+
organization :sciruby, subject: "http://sciruby.com"
|
5
|
+
|
6
|
+
foaf = vocabulary "http://xmlns.com/foaf/0.1/"
|
7
|
+
|
8
|
+
agent :Will do
|
9
|
+
type "person"
|
10
|
+
name "Will Strinz"
|
11
|
+
on_behalf_of :sciruby
|
12
|
+
|
13
|
+
has foaf.mailbox, "wstrinz@gmail.com"
|
14
|
+
has "http://xmlns.com/foaf/0.1/", "http://gsocsemantic.wordpress.com/"
|
15
|
+
end
|
16
|
+
|
17
|
+
data :field_work
|
18
|
+
|
19
|
+
data :original do
|
20
|
+
attributed_to :R
|
21
|
+
derived_from :field_work
|
22
|
+
end
|
23
|
+
|
24
|
+
data :triplified_example do
|
25
|
+
attributed_to :Will
|
26
|
+
derived_from do
|
27
|
+
entity :original
|
28
|
+
activity :triplify
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
activity :triplify do
|
33
|
+
generated :triplified_example
|
34
|
+
associated_with :publisci
|
35
|
+
used :original
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
activity :use_R do
|
40
|
+
generated :original
|
41
|
+
associated_with do
|
42
|
+
agent :R
|
43
|
+
plan :R_steps
|
44
|
+
end
|
45
|
+
associated_with :Will
|
46
|
+
end
|
47
|
+
|
48
|
+
to_repository
|
@@ -0,0 +1,120 @@
|
|
1
|
+
###
|
2
|
+
#
|
3
|
+
# Complete PROV-O primer example,
|
4
|
+
# as shown in http://www.w3.org/TR/prov-primer/images/everything.png
|
5
|
+
# (some prefixes are different)
|
6
|
+
#
|
7
|
+
# See Section 3.10 of http://www.w3.org/TR/prov-primer/
|
8
|
+
#
|
9
|
+
|
10
|
+
base_url "http://example.org"
|
11
|
+
|
12
|
+
dct = vocabulary "http://purl.org/dc/terms/"
|
13
|
+
prov = vocabulary "http://www.w3.org/ns/prov#"
|
14
|
+
|
15
|
+
###
|
16
|
+
# Entities
|
17
|
+
###
|
18
|
+
|
19
|
+
entity :dataSet1
|
20
|
+
entity :regionList
|
21
|
+
entity :composition1
|
22
|
+
|
23
|
+
entity :chart1 do
|
24
|
+
attributed_to :derek
|
25
|
+
has prov.generatedAtTime, "2012-03-02T10:30:00"
|
26
|
+
end
|
27
|
+
|
28
|
+
entity :dataSet2 do
|
29
|
+
has prov.wasRevisionOf, :dataSet1
|
30
|
+
end
|
31
|
+
|
32
|
+
entity :chart2 do
|
33
|
+
derived_from :dataSet2
|
34
|
+
has prov.wasRevisionOf, :chart1
|
35
|
+
end
|
36
|
+
|
37
|
+
entity :article do
|
38
|
+
has dct.title, "Crime rises in cities"
|
39
|
+
end
|
40
|
+
|
41
|
+
entity :articleV1 do
|
42
|
+
has prov.specializationOf, :article
|
43
|
+
end
|
44
|
+
|
45
|
+
entity :articleV2 do
|
46
|
+
has prov.specializationOf, :article
|
47
|
+
has prov.alternateOf, :articleV1
|
48
|
+
end
|
49
|
+
|
50
|
+
entity :quoteInBlogEntry20130326 do
|
51
|
+
subject "http://example.com/blog_entry"
|
52
|
+
has prov.wasQuotedFrom, :article
|
53
|
+
end
|
54
|
+
|
55
|
+
###
|
56
|
+
# Agents
|
57
|
+
###
|
58
|
+
|
59
|
+
agent :edith, type: "person"
|
60
|
+
|
61
|
+
organization :chartgen, name: "Chart Generators Inc"
|
62
|
+
|
63
|
+
agent :derek do
|
64
|
+
name "Derek"
|
65
|
+
on_behalf_of :chartgen
|
66
|
+
end
|
67
|
+
|
68
|
+
###
|
69
|
+
# Activities
|
70
|
+
###
|
71
|
+
|
72
|
+
activity :illustrate1 do
|
73
|
+
generated :chart1
|
74
|
+
associated_with :derek
|
75
|
+
used :composition1
|
76
|
+
end
|
77
|
+
|
78
|
+
activity :compose1 do
|
79
|
+
generated :composition1
|
80
|
+
|
81
|
+
associated_with do
|
82
|
+
agent :derek
|
83
|
+
role :analyst
|
84
|
+
end
|
85
|
+
|
86
|
+
used do
|
87
|
+
entity :regionList
|
88
|
+
role :regionsToAggregateBy
|
89
|
+
end
|
90
|
+
|
91
|
+
used do
|
92
|
+
entity :dataSet1
|
93
|
+
role :dataToCompose
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
activity :correct1 do
|
98
|
+
generated :dataSet2
|
99
|
+
used :dataSet1
|
100
|
+
|
101
|
+
associated_with do
|
102
|
+
agent :edith
|
103
|
+
plan :instructions
|
104
|
+
end
|
105
|
+
|
106
|
+
has prov.startedAtTime, "2012-03-31T09:21:00"
|
107
|
+
has prov.endedAtTime, "2012-04-01T15:21:00"
|
108
|
+
end
|
109
|
+
|
110
|
+
activity :compile1 do
|
111
|
+
generated :chart1
|
112
|
+
used :dataSet1
|
113
|
+
end
|
114
|
+
|
115
|
+
activity :compile2 do
|
116
|
+
generated :chart2
|
117
|
+
used :dataSet2
|
118
|
+
end
|
119
|
+
|
120
|
+
generate_n3 true
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Provenance generation code for primer example at
|
2
|
+
# http://www.w3.org/TR/prov-primer/images/agents.png
|
3
|
+
|
4
|
+
# Set the base url
|
5
|
+
base_url "http://example.org"
|
6
|
+
|
7
|
+
# Elements can be created with an options hash
|
8
|
+
entity :chart1, attributed_to: :derek
|
9
|
+
|
10
|
+
# entity => http://www.w3.org/TR/prov-o/#Entity
|
11
|
+
entity :composition1
|
12
|
+
entity :regionList1
|
13
|
+
|
14
|
+
# Elements can also be defined using a block
|
15
|
+
#
|
16
|
+
# agent => http://www.w3.org/TR/prov-o/#Agent
|
17
|
+
agent :derek do
|
18
|
+
|
19
|
+
# name => foaf:name
|
20
|
+
name "Derek"
|
21
|
+
|
22
|
+
# on_behalf_of => http://www.w3.org/TR/prov-o/#actedOnBehalfOf
|
23
|
+
on_behalf_of :chartgen
|
24
|
+
end
|
25
|
+
|
26
|
+
# Some methods are just wrappers with argument generation
|
27
|
+
# "organization" is short for agent :chartgen, type: "organization"
|
28
|
+
#
|
29
|
+
# organization => http://www.w3.org/TR/prov-o/#Organization
|
30
|
+
organization :chartgen
|
31
|
+
|
32
|
+
|
33
|
+
# An element of the correct type will be looked up for any
|
34
|
+
# method whose argument is a symbol
|
35
|
+
activity :illustrate do
|
36
|
+
|
37
|
+
# generated => http://www.w3.org/TR/prov-o/#generated
|
38
|
+
generated :chart1
|
39
|
+
|
40
|
+
# associated_with => http://www.w3.org/TR/prov-o/#wasAssociatedWith
|
41
|
+
associated_with :derek
|
42
|
+
|
43
|
+
# used => http://www.w3.org/TR/prov-o/#used
|
44
|
+
used :composition1
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
activity :compose1 do
|
49
|
+
generated :composition1
|
50
|
+
associated_with :derek
|
51
|
+
used :regionList1
|
52
|
+
|
53
|
+
# Since symbols are lazy loaded (only when looked up by generate_n3)
|
54
|
+
# you can call used here before declaring dataSet1
|
55
|
+
used :dataSet1
|
56
|
+
end
|
57
|
+
|
58
|
+
# data is aliased to entity
|
59
|
+
data :dataSet1
|
60
|
+
|
61
|
+
# Returns the turtle form of each element
|
62
|
+
generate_n3
|
63
|
+
|
64
|
+
# Can return abbreviated form by passing true
|
65
|
+
# (easier to read, some prefixes not yet included so may not work w/ triple stores)
|
66
|
+
# generate_n3(true)
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Made up example to show generation and customization features
|
2
|
+
|
3
|
+
# Set subject manually (prevents automatic generation)
|
4
|
+
agent :R, subject: "http://r-project.org"
|
5
|
+
|
6
|
+
agent :publisci, type: "software"
|
7
|
+
|
8
|
+
# Define plan, load step list from file if available
|
9
|
+
plan :R_steps, steps: "spec/resource/example.Rhistory"
|
10
|
+
|
11
|
+
organization :sciruby, subject: "http://sciruby.com"
|
12
|
+
|
13
|
+
# The DSL is built on top Ruby, so you can assign variables if you need to
|
14
|
+
# or do any other ruby thing you might like.
|
15
|
+
#
|
16
|
+
# The vocabulary(url) method is short for RDF::Vocabulary.new(url)
|
17
|
+
foaf = vocabulary "http://xmlns.com/foaf/0.1/"
|
18
|
+
|
19
|
+
agent :Will do
|
20
|
+
type "person"
|
21
|
+
name "Will Strinz"
|
22
|
+
on_behalf_of :sciruby
|
23
|
+
|
24
|
+
# Custom predicates can be added using the has(predicate, object) method.
|
25
|
+
has foaf.mailbox, "wstrinz@gmail.com"
|
26
|
+
|
27
|
+
# Predicates must but either a vocabulary object or a valid RDF resource,
|
28
|
+
# but objects can be a resource or a literal.
|
29
|
+
#
|
30
|
+
# RDF.rb is used to assign the right type to each object (resource or literal)
|
31
|
+
has "http://xmlns.com/foaf/0.1/", "http://gsocsemantic.wordpress.com/"
|
32
|
+
end
|
33
|
+
|
34
|
+
data :field_work
|
35
|
+
|
36
|
+
data :original do
|
37
|
+
# Derivations and attributions can be generated automatically
|
38
|
+
# if their corresponding methods are called with a symbol
|
39
|
+
attributed_to :R
|
40
|
+
|
41
|
+
# derived_from will add a prov:wasDerivedFrom predicate to this entity
|
42
|
+
# with the subject for the entity represented by :field_work
|
43
|
+
# as its object.
|
44
|
+
derived_from :field_work
|
45
|
+
end
|
46
|
+
|
47
|
+
data :triplified_example do
|
48
|
+
attributed_to :Will
|
49
|
+
|
50
|
+
# Derivations can be qualified by passing a block.
|
51
|
+
# This will add a prov:qualifiedDerivation relation
|
52
|
+
# to the resource for :triplified_example.
|
53
|
+
# (see http://www.w3.org/TR/prov-o/#Derivation)
|
54
|
+
#
|
55
|
+
# A new Derivation resource and object will also be
|
56
|
+
# created with the information in the block.
|
57
|
+
derived_from do
|
58
|
+
entity :original
|
59
|
+
activity :triplify
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
activity :triplify do
|
64
|
+
generated :triplified_example
|
65
|
+
associated_with :publisci
|
66
|
+
used do
|
67
|
+
entity :original
|
68
|
+
role :generation_input, comment: "source data for triplification"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
activity :use_R do
|
73
|
+
generated :original
|
74
|
+
|
75
|
+
# Qualified associations for activities can also be created using blocks
|
76
|
+
associated_with do
|
77
|
+
agent :R
|
78
|
+
plan :R_steps
|
79
|
+
end
|
80
|
+
|
81
|
+
associated_with :Will
|
82
|
+
end
|
83
|
+
|
84
|
+
generate_n3
|
85
|
+
# generate_n3 true
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Provenance generation code for primer example at
|
2
|
+
# http://www.w3.org/TR/prov-primer/images/agents.png
|
3
|
+
|
4
|
+
# Set the base url
|
5
|
+
base_url "http://example.org"
|
6
|
+
|
7
|
+
# Elements can be created with an options hash
|
8
|
+
entity :chart1, attributed_to: :derek
|
9
|
+
|
10
|
+
# entity => http://www.w3.org/TR/prov-o/#Entity
|
11
|
+
entity :composition1
|
12
|
+
entity :regionList1
|
13
|
+
|
14
|
+
# Elements can also be defined using a block
|
15
|
+
#
|
16
|
+
# agent => http://www.w3.org/TR/prov-o/#Agent
|
17
|
+
agent :derek do
|
18
|
+
|
19
|
+
# name => foaf:name
|
20
|
+
name "Derek"
|
21
|
+
|
22
|
+
# on_behalf_of => http://www.w3.org/TR/prov-o/#actedOnBehalfOf
|
23
|
+
on_behalf_of :chartgen
|
24
|
+
end
|
25
|
+
|
26
|
+
# Some methods are just wrappers with argument generation
|
27
|
+
# "organization" is short for agent :chartgen, type: "organization"
|
28
|
+
#
|
29
|
+
# organization => http://www.w3.org/TR/prov-o/#Organization
|
30
|
+
organization :chartgen
|
31
|
+
|
32
|
+
|
33
|
+
# An element of the correct type will be looked up for any
|
34
|
+
# method whose argument is a symbol
|
35
|
+
activity :illustrate do
|
36
|
+
|
37
|
+
# generated => http://www.w3.org/TR/prov-o/#generated
|
38
|
+
generated :chart1
|
39
|
+
|
40
|
+
# associated_with => http://www.w3.org/TR/prov-o/#wasAssociatedWith
|
41
|
+
associated_with :derek
|
42
|
+
|
43
|
+
# used => http://www.w3.org/TR/prov-o/#used
|
44
|
+
used :composition1
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
activity :compose1 do
|
49
|
+
generated :composition1
|
50
|
+
associated_with :derek
|
51
|
+
used :regionList1
|
52
|
+
|
53
|
+
# Since symbols are lazy loaded (only when looked up by generate_n3)
|
54
|
+
# you can call used here before declaring dataSet1
|
55
|
+
used :dataSet1
|
56
|
+
end
|
57
|
+
|
58
|
+
# data is aliased to entity
|
59
|
+
data :dataSet1
|
60
|
+
|
61
|
+
# Returns the turtle form of each element
|
62
|
+
generate_n3
|
63
|
+
|
64
|
+
# Can return abbreviated form by passing true
|
65
|
+
# (easier to read, some prefixes not yet included so may not work w/ triple stores)
|
66
|
+
# generate_n3(true)
|