MappingServiceGraph
- class MappingServiceGraph(*args: Any, converter: Converter, predicates: None | str | list[str] = None, **kwargs: Any)[source]
Bases:
GraphA service that implements identifier mapping based on a converter.
Instantiate the graph.
- Parameters:
args – Positional arguments to pass to
rdflib.Graph.__init__()converter – A converter object
predicates – A predicate or set of predicates. If not given, this service will use owl:sameAs as a predicate for mapping IRIs.
kwargs – Keyword arguments to pass to
rdflib.Graph.__init__()
In the following example, a service graph is instantiated using a small example converter, then an example SPARQL query is made directly to show how it makes results:
from curies import Converter from curies.mapping_service import CURIEServiceGraph converter = Converter.from_priority_prefix_map( { "CHEBI": [ "https://www.ebi.ac.uk/chebi/searchId.do?chebiId=", "http://identifiers.org/chebi/", "http://purl.obolibrary.org/obo/CHEBI_", ], "GO": ["http://purl.obolibrary.org/obo/GO_"], "OBO": ["http://purl.obolibrary.org/obo/"], # ... } ) graph = MappingServiceGraph(converter=converter) sparql = ( "SELECT ?o WHERE {" " VALUES ?s {" " <http://purl.obolibrary.org/obo/CHEBI_1>" " }" " ?s owl:sameAs ?o" "}" ) res = graph.query(sparql)
The results of this are:
subject
object
Methods Summary
triples(triple)Generate triples, overriden to dynamically generate mappings based on this graph's converter.
Methods Documentation