Exemple #1
0
    def __init__(self, url=None):
        if url is None:
            url = "https://raw.githubusercontent.com/biolink/biolink-model/master/context.jsonld"

        # if set, this falls back to other prefixmappings
        self.fallback = True
            
        # NOTE: this is cached
        # to clear cache: rm ~/.cachier/.prefixcommons.curie_util.read_remote_jsonld_context
        self.set_prefixmap(cu.read_remote_jsonld_context(url))
Exemple #2
0
    def __init__(self, url: str = None):
        """
        Initialize an instance of PrefixManager.

        Parameters
        ----------
        url: str
            The URL from which to read a JSON-LD context for prefix mappings

        """
        if url is None:
            url = "https://raw.githubusercontent.com/biolink/biolink-model/master/context.jsonld"

        # NOTE: this is cached
        self.set_prefix_map(cu.read_remote_jsonld_context(url))
Exemple #3
0
    def __init__(self, url: str = None):
        """
        Initialize an instance of PrefixManager.

        Parameters
        ----------
        url: str
            The URL from which to read a JSON-LD context for prefix mappings

        """
        if url:
            context = cu.read_remote_jsonld_context(url)
        else:
            context = get_jsonld_context()
        self.set_prefix_map(context)
Exemple #4
0
import logging
import networkx as nx
from typing import List, Set, Dict, Tuple
import rdflib
from rdflib import URIRef, Namespace, RDF, RDFS, OWL
from kgx.utils.rdf_utils import find_category, category_mapping, equals_predicates, property_mapping, predicate_mapping, process_iri, make_curie, is_property_multivalued
from prefixcommons.curie_util import read_remote_jsonld_context

biolink_prefix_map = read_remote_jsonld_context(
    'https://biolink.github.io/biolink-model/context.jsonld')


class RdfGraphMixin(object):
    """
    A mixin that defines the following methods,
        - load_networkx_graph(): template method that all deriving classes should implement
        - add_node(): method to add a node from a RDF form to property graph form
        - add_node_attribute(): method to add a node attribute from a RDF form to property graph form
        - add_edge(): method to add an edge from a RDF form to property graph form
        - add_edge_attribute(): method to add an edge attribute from an RDF form to property graph form

    """

    # TODO: use OBO IRI from biolink model context once https://github.com/biolink/biolink-model/issues/211 is resolved
    OBO = Namespace('http://purl.obolibrary.org/obo/')
    OBAN = Namespace(biolink_prefix_map['OBAN'])
    PMID = Namespace(biolink_prefix_map['PMID'])
    # TODO: double check: is this the correct prefix change? (biolink --> biolinkml)
    BIOLINK = Namespace(biolink_prefix_map['biolinkml'])
    DEFAULT_EDGE_LABEL = 'related_to'