bio-publisci 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cb588f4ec6cfa77e1e9011b687ca3e148c6ca6e
4
- data.tar.gz: 6a257692f2317eaea75f0fe306b93e01c1de6a70
3
+ metadata.gz: 017f15f45cc8f40401aebe96aaf5dd886ba602e7
4
+ data.tar.gz: f59abde75019333ff918968a8717f51f419946ee
5
5
  SHA512:
6
- metadata.gz: 163459c5c65c023475a5cb9853c7300d8b5f2a0c4afdf8a98a9f7f7f61ba9103c15e562f01c08a19f7c2d08853ce31447b0710c29e14d9c6f954705f82c26bba
7
- data.tar.gz: 6e07fbb66df785ef3d15820d825823fdcd7ee18fe60cd68f8009f9f92c3204fc8945c3e0ac3bf79663b66d1259036da4f6d2749bac2d34f8870c73c25d850cbc
6
+ metadata.gz: 7c80715a4e5354b330c93591b812f5a6c5105fbf6be2fe3d3028721796246e8a13cd1410af29411ba46d396cb82e494319f7137cd1aa2985e0e5d6cf08ce2422
7
+ data.tar.gz: 96dd7d0f7fb252837524640f21ec6513197366c2455ce3691b8c2a36ba9dd7acfa438eb87cb2b0c3b6560a54fc87e3ab972fd7ae9e5ebec515f74869ac87334c
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.description = %Q{A toolkit for publishing scientific results and datasets using RDF, OWL, and related technologies }
22
22
  gem.email = "wstrinz@gmail.com"
23
23
  gem.authors = ["Will Strinz"]
24
- gem.version = "0.0.4"
24
+ gem.version = "0.0.5"
25
25
 
26
26
  # dependencies defined in Gemfile
27
27
  end
@@ -1,16 +1,29 @@
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
1
11
  agent :publisci, subject: 'http://gsocsemantic.wordpress.com/publisci', type: "software"
2
12
  agent :R, subject: "http://r-project.org"
3
13
  agent :sciruby, subject: "http://sciruby.com", type: "organization"
4
14
 
5
- plan :R_steps, steps: "spec/resource/example.Rhistory"
15
+ plan :R_steps, subject: "http://example.org/plan/R_steps", steps: "spec/resource/example.Rhistory"
6
16
 
7
17
  agent :Will do
18
+ # subject can be called within a block as well
8
19
  subject "http://gsocsemantic.wordpress.com/me"
9
20
  type "person"
10
21
  name "Will Strinz"
11
22
  on_behalf_of "http://sciruby.com"
12
23
  end
13
24
 
25
+ # The wasGeneratedBy relationship is usually created automatically when an activitiy
26
+ # is associated with an entity, but it can be specified manually
14
27
  entity :triplified_example, subject: "http://example.org/dataset/ex", generated_by: :triplify
15
28
 
16
29
  entity :original do
@@ -18,23 +31,28 @@ entity :original do
18
31
  subject "http://example.org/R/ex"
19
32
  source "./example.RData"
20
33
 
21
- set "http://purl.org/dc/terms/title", "original data object"
22
- end
23
-
24
- activity :use_R do
25
- generated :original
26
-
27
- associated_with {
28
- agent :R
29
- }
30
-
31
- associated_with :Will
34
+ # Custom predicates and objects can be used for flexibility and extensibility
35
+ has "http://purl.org/dc/terms/title", "original data object"
32
36
  end
33
37
 
34
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"
35
42
  generated "http://example.org/dataset/ex"
36
43
  associated_with :publisci
37
44
  used :original
38
45
  end
39
46
 
40
- generate_n3
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
@@ -1,28 +1,66 @@
1
- # http://www.w3.org/TR/prov-primer/images/agents.png
1
+ # Provenance generation code for primer example at
2
+ # http://www.w3.org/TR/prov-primer/images/agents.png
2
3
 
3
- organization :chartgen
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
4
13
 
14
+ # Elements can also be defined using a block
15
+ #
16
+ # agent => http://www.w3.org/TR/prov-o/#Agent
5
17
  agent :derek do
18
+
19
+ # name => foaf:name
6
20
  name "Derek"
21
+
22
+ # on_behalf_of => http://www.w3.org/TR/prov-o/#actedOnBehalfOf
7
23
  on_behalf_of :chartgen
8
24
  end
9
25
 
10
- entity :chart1, attributed_to: :derek
11
- entity :composition1
12
- entity :regionList1
13
- entity :dataSet1
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
+
14
32
 
33
+ # An element of the correct type will be looked up for any
34
+ # method whose argument is a symbol
15
35
  activity :illustrate do
36
+
37
+ # generated => http://www.w3.org/TR/prov-o/#generated
16
38
  generated :chart1
39
+
40
+ # associated_with => http://www.w3.org/TR/prov-o/#wasAssociatedWith
17
41
  associated_with :derek
42
+
43
+ # used => http://www.w3.org/TR/prov-o/#used
18
44
  used :composition1
45
+
19
46
  end
20
47
 
21
48
  activity :compose1 do
22
49
  generated :composition1
23
50
  associated_with :derek
24
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
25
55
  used :dataSet1
26
56
  end
27
57
 
28
- generate_n3(true)
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)
@@ -1,10 +1,19 @@
1
- agent :publisci, type: "software"
1
+ # Made up example to show generation and customization features
2
+
3
+ # Set subject manually (prevents automatic generation)
2
4
  agent :R, subject: "http://r-project.org"
3
5
 
6
+ agent :publisci, type: "software"
7
+
8
+ # Define plan, load step list from file if available
4
9
  plan :R_steps, steps: "spec/resource/example.Rhistory"
5
10
 
6
11
  organization :sciruby, subject: "http://sciruby.com"
7
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)
8
17
  foaf = vocabulary "http://xmlns.com/foaf/0.1/"
9
18
 
10
19
  agent :Will do
@@ -12,12 +21,39 @@ agent :Will do
12
21
  name "Will Strinz"
13
22
  on_behalf_of :sciruby
14
23
 
24
+ # Custom predicates can be added using the has(predicate, object) method.
15
25
  has foaf.mailbox, "wstrinz@gmail.com"
16
- has foaf.homepage, "http://gsocsemantic.wordpress.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
17
45
  end
18
46
 
19
47
  data :triplified_example do
20
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.
21
57
  derived_from do
22
58
  entity :original
23
59
  activity :triplify
@@ -30,20 +66,15 @@ activity :triplify do
30
66
  used :original
31
67
  end
32
68
 
33
- data :original do
34
- derived_from :field_work
35
- attributed_to :R
36
- end
37
-
38
- data :field_work
39
69
 
40
70
  activity :use_R do
41
71
  generated :original
42
72
 
43
- associated_with {
73
+ # Qualified associations for activities can also be created using blocks
74
+ associated_with do
44
75
  agent :R
45
76
  plan :R_steps
46
- }
77
+ end
47
78
 
48
79
  associated_with :Will
49
80
  end
@@ -3,8 +3,8 @@ Feature: Receive metadata as user input or extract from data sources
3
3
  To generate clean provenance strings through a friendly interface
4
4
  I want to use a DSL for the PROV ontology
5
5
 
6
- Scenario: Generate without any magic (more open-world)
7
- Given the prov DSL string from file examples/no_magic.prov
6
+ Scenario: Generate based on example for w3.org
7
+ Given the prov DSL string from file examples/primer.prov
8
8
  When I call Prov.run on it
9
9
  Then I should receive a provenance string
10
10
 
@@ -41,16 +41,17 @@ module Prov
41
41
  @organization = organization
42
42
  end
43
43
 
44
- def on_behalf_of(agent=nil)
45
- if agent
46
- if agent.is_a? Symbol
47
- raise "UnknownAgent: #{agent}" unless Prov.agents.has_key?(agent)
48
- agent = Prov.agents[agent]
49
- end
50
- @on_behalf_of = agent
44
+ def on_behalf_of(other_agent=nil)
45
+ if other_agent
46
+ @on_behalf_of = other_agent
47
+ elsif @on_behalf_of.is_a? Symbol
48
+ raise "UnknownAgent: #{@on_behalf_of}" unless Prov.agents.has_key?(@on_behalf_of)
49
+ @on_behalf_of = Prov.agents[@on_behalf_of]
51
50
  else
52
51
  @on_behalf_of
53
52
  end
53
+
54
+ @on_behalf_of
54
55
  end
55
56
  alias_method :worked_for, :on_behalf_of
56
57
 
@@ -109,6 +109,10 @@ module PubliSci
109
109
  end
110
110
  end
111
111
 
112
+ def base_url(url)
113
+ Prov.base_url=url
114
+ end
115
+
112
116
  def generate_n3(abbreviate = false)
113
117
  entities = Prov.entities.values.map(&:to_n3).join
114
118
  agents = Prov.agents.values.map(&:to_n3).join
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-publisci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Strinz