Prefix Manager#
In KGX, the PrefixManager
acts as a central resource for,
CURIE to IRI expansion
IRI to CURIE contraction
Under the hood, PrefixManager
makes use of prefixcommons-py.
Each time the PrefixManager
class is initialized, it makes use of the Biolink Model
JSON-LD context for a default set of prefix to IRI mappings.
These defaults can be overridden by using update_prefix_map
and providing your custom
mappings.
kgx.prefix_manager#
- class kgx.prefix_manager.PrefixManager(url: Optional[str] = None)[source]#
Bases:
object
Manages prefix mappings.
These include mappings for CURIEs such as GO:0008150, as well as shortforms such as biolink types such as Disease
- contract(uri: str, fallback: bool = True) Optional[str] [source]#
Contract a given URI to a CURIE, based on mappings from prefix_map.
- expand(curie: str, fallback: bool = True) str [source]#
Expand a given CURIE to an URI, based on mappings from prefix_map.
- set_prefix_map(m: Dict) None [source]#
Populate prefix_map with contents from a JSON-LD context from self.url
- Parameters:
m (dict) – Dictionary of prefix to URI mappings