A scripting language for creating RDF graphs.
- Define, extend, and expand parameterisable templates for common patterns of RDF triples.
- Share your RDFScript templates with collaborators, or import their templates for use in your own script.
- Serialise as turtle, n3, rdf/xml, or easily extend RDFScript with a custom serialiser.
- Perform complex manipulations of the graph by hooking into Python code defined as extensions.
RDFScript requires Python 3.x.
Python package dependencies are listed in setup.py
.
- Download or clone repository.
git clone https://github.com/lgrozinger/rdfscript.git
- Navigate to RDFScript directory.
cd rdfscript
(This method requires setuptools, which can be installed from your package manager on most *nix systems, and is probably called python3-setuptools or similar)
3a. As a non-root user. python setup.py install --user
(This method requires pip)
3b.python -m pip install rdflib lxml requests ply pathlib pysbolgraph
Running the example in examples/templates.rdfsh
python run.py -s rdfxml examples/templates.rdfsh -o <output-file>
Run the REPL
python run.py -s rdfxml -o <output-file>
Display command line options, including available serialisations.
python run.py -h
The example files in examples/
are commented with some explaination of the language.
- Get the ShortBOL2 template libraries. In a suitable directory
git clone https://github.com/lgrozinger/ShortBOL2
- In the rdfscript directory
python run.py -s sbolxml <YOUR_SHORTBOL2_DIR>/example.rdfsh -o <output-file>
output-file
is an SBOL file.
dev
is for the latest code that should work.
Extensions provide a way to execute Python code to do additional, more complex processing of the RDF triples generated by expanding templates.
Extensions intended as built-ins should be added to the extensions
package. 'Third party' extensions can also be added at the command line, as long as they are in the Python PATH.
For an example of an extension
, see AtLeastOne
in https://github.com/lgrozinger/rdfscript/blob/dev/extensions/cardinality.py
Please branch off of dev
for feature development, or work directly on dev
for bug-fixes.
A test suite using the Python3 unittest
package is under the test/
directory.
Run the tests from the project root using python -m unittest
The concept, design and implementation draws heavily on work from Matt Pocock on ShortBOL. Many thanks to Matt