The Metarelate API

Querying Using SPARQL 1.1

The Application Programming Interface provides a set of Python functions which use the SPARQL query language to return data from a selected Metarelate Store. The API provides for the most common query types, working with the information storage model, to enable the retrieval of relevant information from the selected Metarelate Store.

SPARQL queries may be run directly on the store to retrieve information in ways not provided for by the API.

API

Classes

These Classes represent the metadata translations in the metarelate repository

class metarelate.Component(uri, com_type=None, properties=None)

A Component is a typed, identifiable collection of metadata.

One may be an identified as a source or target for a mapping.

A component is deemed as either simple or compound:

  • A component is simple if it contains properties but no

component members

create_rdf(fuseki_process, graph=None)

create rdf representation using the provided fuseki process

creation_sparql(graph)

return SPARQL string for creation of a Concept

dot(graph=None, parent=None, name=None)

Generate a Dot digraph representation of this mapping component.

Args:
  • graph:

    The containing Dot graph.

  • parent:

    The parent Dot node of this property.

Kwargs:
  • name:

    Name of the relationship between the nodes.

class metarelate.ComponentProperty(predicate, component)

A property which is only a predicate(Item) and an object(Component)

dot(graph, parent, name=None)

Generate a Dot digraph representation of this mapping property.

Args:
  • graph:

    The containing Dot graph.

  • parent:

    The parent Dot node of this property.

Kwargs:
  • name:

    Name of the relationship between the nodes.

class metarelate.Contact

a named contact in the knowledgebase

class metarelate.Item

Represents an rdf data item, as an rdf:literal, or as a subject URI and, optionally, an associated skos notation in the form of an immutable named tuple.

dot()

Return a string representation of the mapping item.

If the skos notation is available, this has priority.

Returns:
String.
is_uri()

Determine whether the mapping data item is a valid URI.

Returns:
Boolean.
class metarelate.KBaseSummary(results)

Summary of the knowledge base

class metarelate.Mapping(uri=None, source=None, target=None, invertible='"False"', creator=None, note=None, replaces=None, valuemaps=None, rightsHolders=None, rights=None, contributors=None, dateAccepted=None, inverted='"False"')

Represents an mapping relationship between a source Component and a target Component.

create_rdf(fuseki_process, graph=None)

create the rdf representation using the provided fuseki process

dot()

Generate a Dot digraph representation of this mapping.

Returns:
The pydot.Dot instance.
json_referrer()

return the data contents of the mapping instance ready for encoding as a json string

class metarelate.Property

Abstract Property class

class metarelate.StatementProperty(predicate, rdfobject)

A property which is only a predicate(Item) and an object(Item)

dot(graph, parent, name=None)

Generate a Dot digraph representation of this mapping property.

Args:
  • graph:

    The containing Dot graph.

  • parent:

    The parent Dot node of this property.

Kwargs:
  • name:

    Name of the relationship between the nodes.

get_identifiers(fuseki_process)

Returns a dictionary of key value pairs, providing a pattern of skos:notations which match the component explicitly

metarelate.careful_update(adict, bdict)

Carefully updates a dictionary with another dictionary, raising a ValueError if keys are shared.

metarelate.get_notation(uri)

Returns the skos:notation for a uri if it exists, or None. If uri is not a http uri, the input is returned as the notation.

metarelate.make_hash(pred_obj, omitted=None)

creates and returns an sha-1 hash of the elements in the pred_obj (object list) dictionary skipping any ‘ommited’ (list) predicates and objects

Args:

  • pred_obj:

    A dictionary of predicates and lists of objects, or single objects which will be used, in order, to construct the hash

  • omitted:

    A list of predicate strings to be ignored when building the hash

Control

The fuseki module provides the interface to the metarelate repository, managing the communication with the data store.