linkml / prefixmaps

Semantic prefix map registry
https://linkml.io/prefixmaps/
Apache License 2.0
10 stars 3 forks source link

Add high level converter getter #42

Closed cthoyt closed 9 months ago

cthoyt commented 9 months ago

This PR adds a high-level wrapper around prefixmaps.load_context()/prefixmaps.load_multi_context() in combination with Context.as_converter() to make a simple high-level function for gettingcuries.Converter`s.

Now, the following can can be done:

from prefixmaps import load_converter

converter = load_converter(["obo", "bioregistry.upper", "linked_data", "prefixcc"])

>>> converter.expand("CHEBI:1")
'http://purl.obolibrary.org/obo/CHEBI_1'
>>> converter.expand("GEO:1")
'http://purl.obolibrary.org/obo/GEO_1'
>>> converter.expand("owl:Class")
'http://www.w3.org/2002/07/owl#Class'
>>> converter.expand("FlyBase:FBgn123")
'http://identifiers.org/fb/FBgn123'

This PR also updates the README examples accordingly.

Note, this is an omni-function, so if it's called with a string like in load_converter("obo"), it defers to the correct single context loading function.

cthoyt commented 9 months ago

@hrshdhgd it appears tests are failing due to poetry issues. Can you please help debug?

hrshdhgd commented 9 months ago

merge down the main branch to yours and it should work!