publisci 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +36 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +51 -0
  8. data/README.rdoc +48 -0
  9. data/Rakefile +68 -0
  10. data/bin/bio-publisci +106 -0
  11. data/bin/bio-publisci-server +50 -0
  12. data/examples/bio-band_integration.rb +9 -0
  13. data/examples/no_magic.prov +58 -0
  14. data/examples/no_magic.rb +58 -0
  15. data/examples/orm.prov +48 -0
  16. data/examples/primer-full.prov +120 -0
  17. data/examples/primer.prov +66 -0
  18. data/examples/prov_dsl.prov +85 -0
  19. data/examples/safe_gen.rb +7 -0
  20. data/examples/visualization/primer.prov +66 -0
  21. data/examples/visualization/prov_viz.rb +140 -0
  22. data/examples/visualization/viz.rb +35 -0
  23. data/features/create_generator.feature +21 -0
  24. data/features/integration.feature +12 -0
  25. data/features/integration_steps.rb +10 -0
  26. data/features/metadata.feature +37 -0
  27. data/features/metadata_steps.rb +40 -0
  28. data/features/orm.feature +60 -0
  29. data/features/orm_steps.rb +74 -0
  30. data/features/prov_dsl.feature +14 -0
  31. data/features/prov_dsl_steps.rb +11 -0
  32. data/features/reader.feature +25 -0
  33. data/features/reader_steps.rb +61 -0
  34. data/features/step_definitions/bio-publisci_steps.rb +0 -0
  35. data/features/store.feature +27 -0
  36. data/features/store_steps.rb +42 -0
  37. data/features/support/env.rb +13 -0
  38. data/features/writer.feature +14 -0
  39. data/features/writer_steps.rb +24 -0
  40. data/lib/bio-publisci.rb +64 -0
  41. data/lib/bio-publisci/analyzer.rb +57 -0
  42. data/lib/bio-publisci/datacube_model.rb +111 -0
  43. data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +240 -0
  44. data/lib/bio-publisci/dataset/ORM/observation.rb +20 -0
  45. data/lib/bio-publisci/dataset/configuration.rb +31 -0
  46. data/lib/bio-publisci/dataset/data_cube.rb +418 -0
  47. data/lib/bio-publisci/dataset/dataset.rb +11 -0
  48. data/lib/bio-publisci/dataset/dataset_for.rb +186 -0
  49. data/lib/bio-publisci/dataset/interactive.rb +72 -0
  50. data/lib/bio-publisci/dsl/config.rb +34 -0
  51. data/lib/bio-publisci/dsl/dataset_dsl.rb +93 -0
  52. data/lib/bio-publisci/dsl/dsl.rb +72 -0
  53. data/lib/bio-publisci/dsl/metadata_dsl.rb +85 -0
  54. data/lib/bio-publisci/dsl/prov_dsl.rb +143 -0
  55. data/lib/bio-publisci/metadata/generator.rb +323 -0
  56. data/lib/bio-publisci/metadata/metadata.rb +5 -0
  57. data/lib/bio-publisci/metadata/metadata_model.rb +25 -0
  58. data/lib/bio-publisci/metadata/prov/activity.rb +88 -0
  59. data/lib/bio-publisci/metadata/prov/agent.rb +100 -0
  60. data/lib/bio-publisci/metadata/prov/association.rb +107 -0
  61. data/lib/bio-publisci/metadata/prov/config.rb +34 -0
  62. data/lib/bio-publisci/metadata/prov/derivation.rb +60 -0
  63. data/lib/bio-publisci/metadata/prov/element.rb +120 -0
  64. data/lib/bio-publisci/metadata/prov/entity.rb +64 -0
  65. data/lib/bio-publisci/metadata/prov/model/prov_models.rb +109 -0
  66. data/lib/bio-publisci/metadata/prov/plan.rb +32 -0
  67. data/lib/bio-publisci/metadata/prov/prov.rb +78 -0
  68. data/lib/bio-publisci/metadata/prov/role.rb +40 -0
  69. data/lib/bio-publisci/metadata/prov/usage.rb +64 -0
  70. data/lib/bio-publisci/metadata/publisher.rb +25 -0
  71. data/lib/bio-publisci/mixins/custom_predicate.rb +38 -0
  72. data/lib/bio-publisci/mixins/dereferencable.rb +34 -0
  73. data/lib/bio-publisci/mixins/registry.rb +27 -0
  74. data/lib/bio-publisci/mixins/vocabulary.rb +8 -0
  75. data/lib/bio-publisci/output.rb +27 -0
  76. data/lib/bio-publisci/parser.rb +266 -0
  77. data/lib/bio-publisci/post_processor.rb +95 -0
  78. data/lib/bio-publisci/query/query_helper.rb +123 -0
  79. data/lib/bio-publisci/r_client.rb +54 -0
  80. data/lib/bio-publisci/readers/arff.rb +49 -0
  81. data/lib/bio-publisci/readers/base.rb +57 -0
  82. data/lib/bio-publisci/readers/csv.rb +88 -0
  83. data/lib/bio-publisci/readers/dataframe.rb +67 -0
  84. data/lib/bio-publisci/readers/maf.rb +199 -0
  85. data/lib/bio-publisci/readers/r_cross.rb +112 -0
  86. data/lib/bio-publisci/readers/r_matrix.rb +176 -0
  87. data/lib/bio-publisci/store.rb +56 -0
  88. data/lib/bio-publisci/writers/arff.rb +91 -0
  89. data/lib/bio-publisci/writers/base.rb +93 -0
  90. data/lib/bio-publisci/writers/csv.rb +31 -0
  91. data/lib/bio-publisci/writers/dataframe.rb +81 -0
  92. data/lib/bio-publisci/writers/json.rb +18 -0
  93. data/lib/r2rdf.rb +226 -0
  94. data/lib/template_bak.rb +12 -0
  95. data/lib/template_bak/publisci.rb +3 -0
  96. data/lib/vocabs/cc.rb +18 -0
  97. data/lib/vocabs/cert.rb +13 -0
  98. data/lib/vocabs/dc.rb +63 -0
  99. data/lib/vocabs/dc11.rb +23 -0
  100. data/lib/vocabs/doap.rb +45 -0
  101. data/lib/vocabs/exif.rb +168 -0
  102. data/lib/vocabs/foaf.rb +69 -0
  103. data/lib/vocabs/geo.rb +13 -0
  104. data/lib/vocabs/http.rb +26 -0
  105. data/lib/vocabs/ma.rb +78 -0
  106. data/lib/vocabs/owl.rb +59 -0
  107. data/lib/vocabs/rdfs.rb +17 -0
  108. data/lib/vocabs/rsa.rb +12 -0
  109. data/lib/vocabs/rss.rb +14 -0
  110. data/lib/vocabs/sioc.rb +93 -0
  111. data/lib/vocabs/skos.rb +36 -0
  112. data/lib/vocabs/wot.rb +21 -0
  113. data/lib/vocabs/xhtml.rb +9 -0
  114. data/lib/vocabs/xsd.rb +58 -0
  115. data/resources/maf_example.maf +10 -0
  116. data/resources/maf_rdf.ttl +1173 -0
  117. data/resources/primer.ttl +38 -0
  118. data/resources/queries/code_resources.rq +10 -0
  119. data/resources/queries/codes.rq +18 -0
  120. data/resources/queries/dataset.rq +7 -0
  121. data/resources/queries/dimension_ranges.rq +8 -0
  122. data/resources/queries/dimensions.rq +12 -0
  123. data/resources/queries/gene.rq +16 -0
  124. data/resources/queries/hugo_to_ensembl.rq +7 -0
  125. data/resources/queries/maf_column.rq +26 -0
  126. data/resources/queries/measures.rq +12 -0
  127. data/resources/queries/observation_labels.rq +8 -0
  128. data/resources/queries/observations.rq +13 -0
  129. data/resources/queries/patient.rq +11 -0
  130. data/resources/queries/patient_list.rq +11 -0
  131. data/resources/queries/patients_with_mutation.rq +18 -0
  132. data/resources/queries/properties.rq +8 -0
  133. data/resources/queries/test.rq +3 -0
  134. data/resources/weather.numeric.arff +28 -0
  135. data/scripts/get_gene_lengths.rb +50 -0
  136. data/scripts/islet_mlratio.rb +6 -0
  137. data/scripts/scan_islet.rb +6 -0
  138. data/scripts/update_reference.rb +25 -0
  139. data/server/helpers.rb +215 -0
  140. data/server/public/src-min-noconflict/LICENSE +24 -0
  141. data/server/public/src-min-noconflict/ace.js +11 -0
  142. data/server/public/src-min-noconflict/ext-chromevox.js +1 -0
  143. data/server/public/src-min-noconflict/ext-elastic_tabstops_lite.js +1 -0
  144. data/server/public/src-min-noconflict/ext-emmet.js +1 -0
  145. data/server/public/src-min-noconflict/ext-keybinding_menu.js +1 -0
  146. data/server/public/src-min-noconflict/ext-language_tools.js +1 -0
  147. data/server/public/src-min-noconflict/ext-modelist.js +1 -0
  148. data/server/public/src-min-noconflict/ext-old_ie.js +1 -0
  149. data/server/public/src-min-noconflict/ext-searchbox.js +1 -0
  150. data/server/public/src-min-noconflict/ext-settings_menu.js +1 -0
  151. data/server/public/src-min-noconflict/ext-spellcheck.js +1 -0
  152. data/server/public/src-min-noconflict/ext-split.js +1 -0
  153. data/server/public/src-min-noconflict/ext-static_highlight.js +1 -0
  154. data/server/public/src-min-noconflict/ext-statusbar.js +1 -0
  155. data/server/public/src-min-noconflict/ext-textarea.js +1 -0
  156. data/server/public/src-min-noconflict/ext-themelist.js +1 -0
  157. data/server/public/src-min-noconflict/ext-whitespace.js +1 -0
  158. data/server/public/src-min-noconflict/keybinding-emacs.js +1 -0
  159. data/server/public/src-min-noconflict/keybinding-vim.js +1 -0
  160. data/server/public/src-min-noconflict/mode-ruby.js +1 -0
  161. data/server/public/src-min-noconflict/snippets/ruby.js +1 -0
  162. data/server/public/src-min-noconflict/theme-twilight.js +1 -0
  163. data/server/public/src-min-noconflict/worker-coffee.js +1 -0
  164. data/server/public/src-min-noconflict/worker-css.js +1 -0
  165. data/server/public/src-min-noconflict/worker-javascript.js +1 -0
  166. data/server/public/src-min-noconflict/worker-json.js +1 -0
  167. data/server/public/src-min-noconflict/worker-lua.js +1 -0
  168. data/server/public/src-min-noconflict/worker-php.js +1 -0
  169. data/server/public/src-min-noconflict/worker-xquery.js +1 -0
  170. data/server/routes.rb +123 -0
  171. data/server/views/dsl.haml +65 -0
  172. data/server/views/dump.haml +3 -0
  173. data/server/views/import.haml +35 -0
  174. data/server/views/new_repository.haml +25 -0
  175. data/server/views/query.haml +28 -0
  176. data/server/views/repository.haml +25 -0
  177. data/spec/ORM/data_cube_orm_spec.rb +33 -0
  178. data/spec/ORM/prov_model_spec.rb +72 -0
  179. data/spec/analyzer_spec.rb +36 -0
  180. data/spec/bnode_spec.rb +66 -0
  181. data/spec/csv/bacon.csv +4 -0
  182. data/spec/csv/moar_bacon.csv +11 -0
  183. data/spec/data_cube_spec.rb +169 -0
  184. data/spec/dataset_for_spec.rb +77 -0
  185. data/spec/dsl_spec.rb +134 -0
  186. data/spec/generators/csv_spec.rb +44 -0
  187. data/spec/generators/dataframe_spec.rb +44 -0
  188. data/spec/generators/maf_spec.rb +40 -0
  189. data/spec/generators/r_cross_spec.rb +51 -0
  190. data/spec/generators/r_matrix_spec.rb +44 -0
  191. data/spec/length_lookup_spec.rb +0 -0
  192. data/spec/maf_query_spec.rb +343 -0
  193. data/spec/metadata/metadata_dsl_spec.rb +68 -0
  194. data/spec/prov/activity_spec.rb +74 -0
  195. data/spec/prov/agent_spec.rb +54 -0
  196. data/spec/prov/association_spec.rb +55 -0
  197. data/spec/prov/config_spec.rb +28 -0
  198. data/spec/prov/derivation_spec.rb +30 -0
  199. data/spec/prov/entity_spec.rb +52 -0
  200. data/spec/prov/role_spec.rb +94 -0
  201. data/spec/prov/usage_spec.rb +98 -0
  202. data/spec/queries/integrity/1.rq +21 -0
  203. data/spec/queries/integrity/11.rq +29 -0
  204. data/spec/queries/integrity/12.rq +37 -0
  205. data/spec/queries/integrity/14.rq +25 -0
  206. data/spec/queries/integrity/19_1.rq +21 -0
  207. data/spec/queries/integrity/19_2.rq +15 -0
  208. data/spec/queries/integrity/2.rq +22 -0
  209. data/spec/queries/integrity/3.rq +19 -0
  210. data/spec/queries/integrity/4.rq +13 -0
  211. data/spec/queries/integrity/5.rq +14 -0
  212. data/spec/r_builder_spec.rb +33 -0
  213. data/spec/resource/.RData +0 -0
  214. data/spec/resource/example.Rhistory +3 -0
  215. data/spec/spec_helper.rb +17 -0
  216. data/spec/turtle/bacon +147 -0
  217. data/spec/turtle/reference +2064 -0
  218. data/spec/turtle/weather +275 -0
  219. data/spec/writer_spec.rb +75 -0
  220. 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,7 @@
1
+ require 'bio-publisci'
2
+
3
+ str = IO.read(ARGV[0])
4
+ str.untaint
5
+ $SAFE=4
6
+ runner = PubliSci::Prov::DSL::Instance.new
7
+ puts runner.instance_eval(str,ARGV[0])
@@ -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)