SBOL Standard‎ > ‎Extensions‎ > ‎SBOL semantic‎ > ‎

Turtle RDF Primer for SBOL

Turtle is a text RDF representation, it’s based on N3. This form of RDF is easier for people to read and write than RDF/XML. This primer provides a guide as to how to write SBOL as RDF in Turtle syntax. This is a complement to SBOL RDF by hand guide which is in development.

Introduction
A Turtle document is a set of RDF triples. Triples take the following form:

<subject> <relationship> <object> .

Each triple is a statement. Statements end with a period.

Each element of the triple is an URI. Except for the <object>, which can be a URI, text like "string" or a number like 134. For example, to say that a DnaComponent has a SequenceAnnotation, we can use the triple:

<http://biofab.org/data#pFAB105> <http://sbols.org/sbol.owl#annotation> <http://biofab.org/data#12b4237374d81643b539f29c5b858699e6fd8322> .

Here, the URI for the BIOFAB pFAB105 DnaComponent is used as an identifier, and the URI for annotation means it has a DNA sequence which is identified by the URI with the following hash as the ID 12b4237374d81643b539f29c5b858699e6fd8322. In SBOL we use use URIs (eg http://sbols.org/sbol.owl#annotation) as identifiers and the terms we specify with SBOL URIs have an agreed to meaning in the SBOL specification. Most of the effort of developing RDF for SBOL is making up URIs that have an agreed-upon meaning like "This URI means has annotation”.  If the dnaComponent also has another annotation in Turtle, we can say:

<http://biofab.org/data#pFAB105> <http://sbols.org/sbol.owl#annotation> <http://biofab.org/data#18f35b38fb8d53b9f694c89a8a6b03865d58c993> .

This is pretty much all you need to know to write Turtle, but there are a lot of "shortcuts" that can make your documents shorter and more readable.

Using prefixes

Using the full URI again and again makes it difficult to read. With Turtle, we can define a namespace prefix so that we don't have to write the same long URI prefixes all the time. A prefix definition looks like this:
@prefix pref: <uri prefix> .

For example, for SBOLelements, we can use a prefix definition like this:
@prefix sbol: <http://sbols.org/sbol.owl#> .

Then we can use the topics described above like this:

@prefix sbol: <http://sbols.org/sbol.owl#> .

<http://biofab.org/data#pFAB105> sbol:annotation <http://biofab.org/data#12b4237374d81643b539f29c5b858699e6fd8322> .

<http://biofab.org/data#pFAB105> sbol:annotation <http://biofab.org/data#18f35b38fb8d53b9f694c89a8a6b03865d58c993> .


We can also define a default namespace prefix, in cases where we use the same namespace prefix over and over. To do this, we use the same format without a substitution string:
@prefix : <uri prefix> .

Often the "main" namespace for a Turtle document is given a default namespace. If we're working on a BIOFAB SBOL document and the http://biofab.org/data# namespace would otherwise be repeated contantly we might want to make it the default one:

@prefix : <http://biofab.org/data#> .
@prefix sbol: <http://sbols.org/sbol.owl#> .

:pFAB105> sbol:annotation :12b4237374d81643b539f29c5b858699e6fd8322 .
:pFAB105> sbol:annotation :18f35b38fb8d53b9f694c89a8a6b03865d58c993 .


Commas
When we make two or more statements with the same subject and relationship, we can make the document shorter and more readable by combining the statements and separating the objects by one or more commas. Our topic example above could be written:

@prefix : <http://biofab.org/data#> .
@prefix sbol: <http://sbols.org/sbol.owl#> .

:pFAB105 sbol:annotation :12b4237374d81643b539f29c5b858699e6fd8322
:18f35b38fb8d53b9f694c89a8a6b03865d58c993 .

Note that the meaning is exactly the same; just the number of characters typed is different.

Semicolons

If you have the same subject in more than one statement, but different relationships, you can combine them and separate the relationship + object parts with a semicolon. For example, if we wanted to say that our DnaComponent's name is “pFAB105”, we'd write:

@prefix : <http://biofab.org/data#> .
@prefix sbol: <http://sbols.org/sbol.owl#> .

<:pFAB105> sbol:name “pFAB105”

We could combine this with our document for the DnaComponent's annotations to make:

@prefix : <http://biofab.org/data#> .
@prefix sbol: <http://sbols.org/sbol.owl#> .

:pFAB105

sbol:name “pFAB105” ;

sbol:annotation :12b4237374d81643b539f29c5b858699e6fd8322,

:18f35b38fb8d53b9f694c89a8a6b03865d58c993 .


Note that there's still a period at the end, eventually. The newline isn't particularly necessary, but it makes the document a little more readable.

Types

There's a special relationship between a thing and a category of things, called type (http://www.w3.org/1999/02/22-rdf-syntax-ns#type). If we want to say that pFAB105 is a DnaComponent, we can write it like this:

@prefix : <http://biofab.org/data#> .
@prefix sbol: <http://sbols.org/sbol.owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

:pFAB105 rdf:type sbol:DnaComponent .

Because this is such a fundamental relationship, Turtle has a special keyword a, to replace the type relationship:

@prefix : <http://biofab.org/data#> .
@prefix sbol: <http://sbols.org/sbol.owl#> .

:pFAB105 a sbol:DnaComponent .

Our SBOL document for pFAB105 becomes:
@prefix : <http://biofab.org/data#> .
@prefix sbol: <http://sbols.org/sbol.owl#> .

:pFAB105

a sbol:DnaComponent ;

sbol:name “pFAB105” ;

sbol:annotation :12b4237374d81643b539f29c5b858699e6fd8322 ,

   :18f35b38fb8d53b9f694c89a8a6b03865d58c993 .


The advantage here is that you can kind of read this out loud to yourself, and it will make some semblance of sense (in English, at least).

This URI represents a DnaComponent; its name is pFAB105, and its annotated by feature.

... more coming soon ...

External links

  • Turtle -- definition of the format
  • Notation3 -- a predecessor of Turtle
  • N3 Primer -- a readable tutorial outlining the ideas behind Notation3 (and thus Turtle)

Adopted to SBOL by Michal Galdzicki July 11, 2011
from : http://wikitravel.org/en/Wikitravel:Turtle_RDF  by Ryan Holliday. Based on work by Evan Prodromou and Wikitravel user(s) Roland2.
Text is available under Creative Commons Attribution-ShareAlike 3.0 (CC-by-SA 3.0).
Comments