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(self)[source]

Close a the configured database

init_database(self)[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

classmethod process_config(config_dict, **kwargs)[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(self, 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(self, graph)[source]

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

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

Fire FuXi rule engine to infer triples

retract_statements(self, 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

get(self)[source]

Gets a config value from this Configureable’s conf

See also

Configure.get
open(self)[source]

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

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

Bases: PyOpenWorm.data.RDFSource

Reads from and queries against a remote data store

"rdf.source" = "sparql_endpoint"
open(self)[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(self)[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(self)[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(self)[source]

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