Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify loading of converter in CurieService #486

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions backend/src/monarch_py/service/curie_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### make a singleton class that uses prefixmap and curies to expand curies

from curies import Converter
from prefixmaps.io.parser import load_multi_context
from prefixmaps import load_converter


class CurieService:
Expand All @@ -17,9 +17,7 @@ def __new__(cls):
def initialize(self):
# this is a magic keyword that represents the "merged" context from Chris M's algorithm
# (https://github.com/linkml/prefixmaps/blob/main/src/prefixmaps/data/merged.csv)
context = load_multi_context(["merged"])
extended_prefix_map = context.as_extended_prefix_map()
self.converter = Converter.from_extended_prefix_map(extended_prefix_map)
self.converter = load_converter(["merged"])

def expand(self, curie: str) -> str:
return self.converter.expand(curie)
Loading