Registry / data / prefixmaps

prefixmaps

JSON →
library0.2.6pypypi✓ verified 86d ago

The `prefixmaps` library, currently at version 0.2.6, is a Python tool for managing and resolving semantic prefix maps, particularly for CURIEs (Compact URIs). It simplifies the expansion of short-form identifiers into full IRIs and vice versa, primarily by leveraging community-maintained prefix registries like those from OBO Foundry. Releases occur periodically to update prefix data and improve functionality.

pip install prefixmaps
INSTALL
IMPORT
SIG · PREFIXMAPS
P
prefixmaps
datapythonv0.2.6
Install
3.7s avg
Import
—
Disk
38MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 40MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 3.7s · import 0.000s · 40MB
38MB installed
● package 38MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Context
✓ from prefixmaps import Context
✗ from prefixmaps import PrefixMap
PrefixExpansion
✓ from prefixmaps import PrefixExpansion
load_context
✓ from prefixmaps import load_context

Demonstrates initializing a PrefixMap, expanding a CURIE, compressing an IRI, and checking for prefix existence.

from prefixmaps import PrefixMap # Initialize with the default OBO Foundry prefix map (loaded from the web) pm = PrefixMap() # Expand a CURIE (Compact URI) to a full IRI curie = "GO:0008150" iri = pm.expand(curie) print(f"Expanded {curie} to: {iri}") # Compress a full IRI to a CURIE (if a matching prefix is found) full_iri = "http://purl.obolibrary.org/obo/BFO_0000001" compressed_curie = pm.compress(full_iri) print(f"Compressed {full_iri} to: {compressed_curie}") # Check if a prefix exists in the map print(f"Has prefix 'GO': {pm.has_prefix('GO')}") print(f"Has prefix 'UNKNOWN': {pm.has_prefix('UNKNOWN')}")
prefixmaps --version
Debug
Known issues
breakingThe method for loading the default registry has changed across minor versions. Directly calling `prefixmaps.io.get_and_parse_default_registry()` is now deprecated or removed.
fix
Use `pm = PrefixMap()` for the default registry or `PrefixMap.load_default_registry()` for explicit loading.
affects: <0.2.0
gotchaInitializing `PrefixMap()` without arguments attempts to load the default prefix registry from a remote web source (e.g., OBO Foundry). This operation will fail without an internet connection or if the remote source is temporarily unavailable.
fix
For offline or controlled environments, consider using `PrefixMap.load_from_json(filepath)` or `PrefixMap.load_from_shacl(filepath)` with a locally cached registry file. The library also allows specifying a custom URL for the registry.
affects: >=0.1.0
gotchaThe `expand()` method returns `None` if a given CURIE's prefix is not found in the loaded `PrefixMap`, rather than raising an error. This requires explicit `None` checking in application code.
fix
Always check the return value of `pm.expand(curie)`: `iri = pm.expand(curie); if iri is None: print(f"Unknown prefix for {curie}")`.
affects: >=0.1.0
deprecatedDirect access to `prefixmaps.io.get_and_parse_default_registry()` is deprecated. This function was an internal detail that has been superseded by the `PrefixMap` constructor and class methods.
fix
Use `pm = PrefixMap()` to load the default registry or `PrefixMap.load_default_registry()` if you need to load it explicitly without creating a new `PrefixMap` instance immediately.
affects: >=0.2.0
Upgrade
Version history
0.2.6latest on PyPI · released Oct 17, 2024
Audit
Dependencies
pydanticrequiredUsed for data validation and parsing of prefix map schemas.
Agent activity
4 hits · last 30 days
node
4
Resources
prefixmaps — pip install prefixmaps · libregistry