{"id":10059,"library":"prefixmaps","title":"Prefixmaps Library","description":"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.","status":"active","version":"0.2.6","language":"python","source_language":"en","source_url":"https://github.com/prefixcommons/prefixmaps","tags":["semantic web","curie","iri","namespaces","ontologies","identifiers","linked data"],"install":[{"cmd":"pip install prefixmaps","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for data validation and parsing of prefix map schemas.","package":"pydantic"}],"imports":[{"wrong":"from prefixmaps import PrefixMap","symbol":"Context","correct":"from prefixmaps import Context"},{"symbol":"PrefixExpansion","correct":"from prefixmaps import PrefixExpansion"},{"symbol":"load_context","correct":"from prefixmaps import load_context"}],"quickstart":{"code":"from prefixmaps import PrefixMap\n\n# Initialize with the default OBO Foundry prefix map (loaded from the web)\npm = PrefixMap()\n\n# Expand a CURIE (Compact URI) to a full IRI\ncurie = \"GO:0008150\"\niri = pm.expand(curie)\nprint(f\"Expanded {curie} to: {iri}\")\n\n# Compress a full IRI to a CURIE (if a matching prefix is found)\nfull_iri = \"http://purl.obolibrary.org/obo/BFO_0000001\"\ncompressed_curie = pm.compress(full_iri)\nprint(f\"Compressed {full_iri} to: {compressed_curie}\")\n\n# Check if a prefix exists in the map\nprint(f\"Has prefix 'GO': {pm.has_prefix('GO')}\")\nprint(f\"Has prefix 'UNKNOWN': {pm.has_prefix('UNKNOWN')}\")","lang":"python","description":"Demonstrates initializing a PrefixMap, expanding a CURIE, compressing an IRI, and checking for prefix existence."},"warnings":[{"fix":"Use `pm = PrefixMap()` for the default registry or `PrefixMap.load_default_registry()` for explicit loading.","message":"The 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.","severity":"breaking","affected_versions":"<0.2.0"},{"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.","message":"Initializing `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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always check the return value of `pm.expand(curie)`: `iri = pm.expand(curie); if iri is None: print(f\"Unknown prefix for {curie}\")`.","message":"The `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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"Direct 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.","severity":"deprecated","affected_versions":">=0.2.0"}],"env_vars":null,"search_vec":"'0.2.6':9 'communiti':45 'community-maintain':44 'compact':24 'curi':23,66 'current':6 'data':60,72 'expans':29 'form':33 'foundri':53 'full':36 'function':63 'identifi':34,70 'improv':62 'iri':37,67 'leverag':43 'librari':2,5 'like':49 'link':71 'maintain':46 'manag':15 'map':20 'namespac':68 'obo':52 'occur':55 'ontolog':69 'particular':21 'period':56 'prefix':19,47,59 'prefixmap':1,4 'primarili':41 'python':12 'registri':48 'releas':54 'resolv':17 'semant':18,64 'short':32 'short-form':31 'simplifi':27 'tool':13 'updat':58 'uri':25 'versa':40 'version':8 'vice':39 'web':65","created_at":"2026-04-17T01:22:10.334848+00:00","updated_at":"2026-04-17T01:22:10.334848+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.2.6","cli_name":"prefixmaps","cli_version":"sh: 1: prefixmaps: not found","type":"library","homepage":null,"github":"https://github.com/linkml/prefixmaps","docs":null,"changelog":null,"pypi":"https://pypi.org/project/prefixmaps/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}