Skip to content

Commit

Permalink
Simplify loading of converter in CurieService
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt authored Nov 23, 2023
1 parent 5d05043 commit dd25508
Showing 1 changed file with 2 additions and 4 deletions.
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)

0 comments on commit dd25508

Please sign in to comment.