Prefixmaps Library

0.2.6 · active · verified Fri Apr 17

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.

Common errors

Warnings

Install

Imports

Quickstart

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')}")

view raw JSON →