Registry / data / prefixcommons

prefixcommons

JSON →
library0.1.12pypypi✓ verified 87d ago

PrefixCommons is a Python API designed for working with ID prefixes, enabling the canonicalization, expansion, and contraction of CURIEs (Compact URIs). It is currently at version 0.1.12 and maintains an infrequent release cadence, often aligned with specific project requirements such as those from the Alliance of Genome Resources.

pip install prefixcommons
INSTALL
IMPORT
SIG · PREFIXCOMMONS
P
prefixcommons
datapythonv0.1.12
Install
4.4s avg
Import
592ms
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.12 · 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.103.910 runs
installs and imports cleanly · install 0.0s · import 0.613s · 38.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.4s · import 0.571s · 40MB
37MB installed
● package 37MB
Code
Verified usage

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

expand_uri
from prefixcommons.curie_util import expand_uri
from prefixcommons import expand_uri
Core utility functions like expand_uri and contract_uri reside in the `curie_util` submodule, not directly under the top-level package.
contract_uri
from prefixcommons.curie_util import contract_uri
from prefixcommons import contract_uri
Core utility functions like expand_uri and contract_uri reside in the `curie_util` submodule, not directly under the top-level package.
read_biocontext
from prefixcommons.curie_util import read_biocontext
Helper function to load a common set of biomedical prefixes.

This quickstart demonstrates how to expand and contract CURIEs using the default prefix map provided by the library, as well as how to supply a custom prefix map or load a pre-defined biomedical context map for more specific use cases.

from prefixcommons.curie_util import expand_uri, contract_uri, read_biocontext # Using the default prefix map expanded_go = expand_uri('GO:0008150') print(f"Expanded GO: {expanded_go}") contracted_go = contract_uri('http://purl.obolibrary.org/obo/GO_0008150') print(f"Contracted GO: {contracted_go}\n") # Using a custom prefix map custom_map = {'EXAMPLE': 'http://example.org/myterms/'} expanded_custom = expand_uri('EXAMPLE:001', prefix_map=custom_map) print(f"Expanded custom: {expanded_custom}") # Loading a biomedical context map bio_context = read_biocontext() expanded_ncbi = expand_uri('NCBIGENE:12345', prefix_map=bio_context) print(f"Expanded NCBIGENE from bio_context: {expanded_ncbi}")
Debug
Known issues
gotchaThe default prefix map, loaded internally from `resources/prefixcommons.jsonld`, may not be exhaustive for all domains or may become stale over time. For robust applications, relying solely on this default map for critical or very specific prefixes is not recommended.
fix
Consider explicitly loading domain-specific context maps using functions like `prefixcommons.curie_util.read_biocontext()` or provide your own custom `prefix_map` dictionary to functions like `expand_uri` and `contract_uri`.
affects: All versions
gotchaPrefixCommons has an infrequent release cadence, often tied to specific project needs. While stable, this means that updates to its default prefix maps for very new or niche identifiers might not be as frequent as external data sources.
fix
For applications requiring the absolute latest or highly specialized prefix definitions, it is advisable to rely on custom-maintained prefix maps or external services rather than solely on the library's built-in defaults. Monitor the GitHub repository for updates.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'prefixcommons.curie_util'
Attempting to import core utility functions directly from the top-level `prefixcommons` package instead of their specific submodule `curie_util`.
fix
Change your import statement from `from prefixcommons import expand_uri` (or similar) to `from prefixcommons.curie_util import expand_uri, contract_uri`.
KeyError: 'UNKNOWN_PREFIX'
The CURIE prefix (e.g., 'MYAPP' in 'MYAPP:123') is not found in the currently active prefix map when attempting to expand or contract a URI.
fix
Ensure that the `prefix_map` supplied to `expand_uri` or `contract_uri` (or the default map being used) contains the required prefix. You can load specific contexts using `prefixcommons.curie_util.read_biocontext()` or pass a custom dictionary: `expand_uri('MYAPP:123', prefix_map={'MYAPP': 'http://example.com/myapp/'})`.
Upgrade
Version history
0.1.12latest on PyPI · released Jul 19, 2022
Audit
Dependencies
requestsrequiredUsed for fetching external resources and context maps, although core functionality doesn't strictly depend on it for local maps.
Agent activity
2 hits · last 30 days
node
2
Resources
prefixcommons — pip install prefixcommons · libregistry