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: ""
agent :publisci, type: "software"
# Define plan, load step list from file if available
plan :R_steps, steps: "spec/resource/example.Rhistory"
organization :sciruby, subject: ""
# 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
foaf = vocabulary ""
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, ""
# 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 "", ""
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
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
# A new Derivation resource and object will also be
# created with the information in the block.
derived_from do
entity :original
activity :triplify
activity :triplify do
generated :triplified_example
associated_with :publisci
used :original
activity :use_R do
generated :original
# Qualified associations for activities can also be created using blocks
associated_with do
agent :R
plan :R_steps
associated_with :Will
generate_n3 true
@prefix prov: <> .
@prefix rdf: <> .
@prefix rdfs: <> .
@prefix foaf: <> .
entity:field_work a prov:Entity ;
rdfs:label "field_work" .
entity:original a prov:Entity ;
prov:wasAttributedTo <> ;
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" .
<> a prov:Agent ;
rdfs:label "R" .
agent:publisci a prov:Agent, prov:SoftwareAgent ;
rdfs:label "publisci" .
<> a prov:Agent, prov:Organization ;
rdfs:label "sciruby" .
agent:Will a prov:Agent, prov:Person ;
foaf:givenName "Will Strinz" ;
prov:actedOnBehalfOf <sciruby> ;
<> "" ;
<> <> ;
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 <> ;
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 <> ;
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