Create a gist now

Instantly share code, notes, and snippets.

@wstrinz /dsl_in.rb Secret
Last active Dec 20, 2015

What would you like to do?
# Made up example to show generation and customization features
# Set subject manually (prevents automatic generation)
agent :R, subject: "http://r-project.org"
agent :publisci, type: "software"
# Define plan, load step list from file if available
plan :R_steps, steps: "spec/resource/example.Rhistory"
organization :sciruby, subject: "http://sciruby.com"
# The DSL is built on top Ruby, so you can assign variables if you need to
# or do any other ruby thing you might like.
#
# The vocabulary(url) method is short for RDF::Vocabulary.new(url)
foaf = vocabulary "http://xmlns.com/foaf/0.1/"
agent :Will do
type "person"
name "Will Strinz"
on_behalf_of :sciruby
# Custom predicates can be added using the has(predicate, object) method.
has foaf.mailbox, "wstrinz@gmail.com"
# Predicates must but either a vocabulary object or a valid RDF resource,
# but objects can be a resource or a literal.
#
# RDF.rb is used to assign the right type to each object (resource or literal)
has "http://xmlns.com/foaf/0.1/homepage", "http://gsocsemantic.wordpress.com/"
end
data :field_work
data :original do
# Derivations and attributions can be generated automatically
# if their corresponding methods are called with a symbol
attributed_to :R
# derived_from will add a prov:wasDerivedFrom predicate to this entity
# with the subject for the entity represented by :field_work
# as its object.
derived_from :field_work
end
data :triplified_example do
attributed_to :Will
# Derivations can be qualified by passing a block.
# This will add a prov:qualifiedDerivation relation
# to the resource for :triplified_example.
# (see http://www.w3.org/TR/prov-o/#Derivation)
#
# A new Derivation resource and object will also be
# created with the information in the block.
derived_from do
entity :original
activity :triplify
end
end
activity :triplify do
generated :triplified_example
associated_with :publisci
used :original
end
activity :use_R do
generated :original
# Qualified associations for activities can also be created using blocks
associated_with do
agent :R
plan :R_steps
end
associated_with :Will
end
generate_n3 true
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
entity:field_work a prov:Entity ;
rdfs:label "field_work" .
entity:original a prov:Entity ;
prov:wasAttributedTo <http://r-project.org> ;
prov:wasDerivedFrom entity:field_work ;
rdfs:label "original" .
entity:triplified_example a prov:Entity ;
prov:wasAttributedTo agent:Will ;
prov:wasDerivedFrom entity:original ;
prov:qualifiedDerivation derivation:7at05g ;
rdfs:label "triplified_example" .
<http://r-project.org> a prov:Agent ;
rdfs:label "R" .
agent:publisci a prov:Agent, prov:SoftwareAgent ;
rdfs:label "publisci" .
<http://sciruby.com> a prov:Agent, prov:Organization ;
rdfs:label "sciruby" .
agent:Will a prov:Agent, prov:Person ;
foaf:givenName "Will Strinz" ;
prov:actedOnBehalfOf <sciruby> ;
<http://xmlns.com/foaf/0.1/mailbox> "wstrinz@gmail.com" ;
<http://xmlns.com/foaf/0.1/> <http://gsocsemantic.wordpress.com/> ;
rdfs:label "Will" .
activity:triplify a prov:Activity ;
prov:generated entity:triplified_example ;
prov:used entity:original;
prov:wasAssociatedWith agent:publisci ;
rdfs:label "triplify" .
activity:use_R a prov:Activity ;
prov:generated entity:original ;
prov:wasAssociatedWith <http://r-project.org> ;
prov:qualifiedAssociation assoc:7b2arr ;
prov:wasAssociatedWith agent:Will ;
rdfs:label "use_R" .
plan:R_steps a prov:Plan, prov:Entity ;
rdfs:comment ("library(qtl)" "data(listeria)" "mr = scanone(listeria,method='mr')") ;
rdfs:label "R_steps" .
assoc:7b2arr a prov:Association ;
prov:agent <http://r-project.org> ;
prov:hadPlan plan:R_steps .
derivation:7at05g a prov:Derivation ;
prov:entity entity:original ;
prov:hadActivity activity:triplify .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment