PyOpenWorm.data module

class PyOpenWorm.data.Data(conf=None, **kwargs)[source]

Bases: PyOpenWorm.configure.Configure

Provides configuration for access to the database.

Usually doesn’t need to be accessed directly

closeDatabase()[source]

Close a the configured database

init_database()[source]

Open the configured database

classmethod load(file_name)[source]

Load a file into a new Data instance storing configuration in a JSON format

classmethod open(file_name)[source]

Load a file into a new Data instance storing configuration in a JSON format

class PyOpenWorm.data.DataUser(*args, **kwargs)[source]

Bases: PyOpenWorm.configure.Configureable

A convenience wrapper for users of the database

Classes which use the database should inherit from DataUser.

add_reference(g, reference_iri)[source]

Add a citation to a set of statements in the database

Parameters:triples – A set of triples to annotate
add_statements(graph)[source]

Add a set of statements to the database. Annotates the addition with uploader name, etc

Parameters:graph – An iterable of triples
infer()[source]

Fire FuXi rule engine to infer triples

retract_statements(graph)[source]

Remove a set of statements from the database.

Parameters:graph – An iterable of triples
class PyOpenWorm.data.RDFSource(**kwargs)[source]

Bases: PyOpenWorm.configure.Configureable, PyOpenWorm.configure.ConfigValue

Base class for data sources.

Alternative sources should dervie from this class

open()[source]

Called on PyOpenWorm.connect() to set up and return the rdflib graph. Must be overridden by sub-classes.

class PyOpenWorm.data.SerializationSource(**kwargs)[source]

Bases: PyOpenWorm.data.RDFSource

Reads from an RDF serialization or, if the configured database is more recent, then from that.

The database store is configured with:

"rdf.source" = "serialization"
"rdf.store" = <your rdflib store name here>
"rdf.serialization" = <your RDF serialization>
"rdf.serialization_format" = <rdflib serialization format>
"rdf.store_conf" = <your rdflib store configuration here>
open()[source]

Called on PyOpenWorm.connect() to set up and return the rdflib graph. Must be overridden by sub-classes.

class PyOpenWorm.data.TrixSource(**kwargs)[source]

Bases: PyOpenWorm.data.SerializationSource

A SerializationSource specialized for TriX

The database store is configured with:

"rdf.source" = "trix"
"rdf.trix_location" = <location of the TriX file>
"rdf.store" = <your rdflib store name here>
"rdf.store_conf" = <your rdflib store configuration here>
class PyOpenWorm.data.SPARQLSource(**kwargs)[source]

Bases: PyOpenWorm.data.RDFSource

Reads from and queries against a remote data store

"rdf.source" = "sparql_endpoint"
open()[source]

Called on PyOpenWorm.connect() to set up and return the rdflib graph. Must be overridden by sub-classes.

class PyOpenWorm.data.SleepyCatSource(**kwargs)[source]

Bases: PyOpenWorm.data.RDFSource

Reads from and queries against a local Sleepycat database

The database can be configured like:

"rdf.source" = "Sleepycat"
"rdf.store_conf" = <your database location here>
open()[source]

Called on PyOpenWorm.connect() to set up and return the rdflib graph. Must be overridden by sub-classes.

class PyOpenWorm.data.DefaultSource(**kwargs)[source]

Bases: PyOpenWorm.data.RDFSource

Reads from and queries against a configured database.

The default configuration.

The database store is configured with:

"rdf.source" = "default"
"rdf.store" = <your rdflib store name here>
"rdf.store_conf" = <your rdflib store configuration here>

Leaving unconfigured simply gives an in-memory data store.

open()[source]

Called on PyOpenWorm.connect() to set up and return the rdflib graph. Must be overridden by sub-classes.

class PyOpenWorm.data.ZODBSource(*args, **kwargs)[source]

Bases: PyOpenWorm.data.RDFSource

Reads from and queries against a configured Zope Object Database.

If the configured database does not exist, it is created.

The database store is configured with:

"rdf.source" = "ZODB"
"rdf.store_conf" = <location of your ZODB database>

Leaving unconfigured simply gives an in-memory data store.

open()[source]

Called on PyOpenWorm.connect() to set up and return the rdflib graph. Must be overridden by sub-classes.