From eb9ac2186358a1e6d70c1159008cd370b99d937e Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Tue, 5 Oct 2021 17:04:59 +0200 Subject: [PATCH 1/3] Update gilda_utils.py --- src/pyobo/gilda_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pyobo/gilda_utils.py b/src/pyobo/gilda_utils.py index 5cd7a664..6302c491 100644 --- a/src/pyobo/gilda_utils.py +++ b/src/pyobo/gilda_utils.py @@ -2,7 +2,7 @@ """PyOBO's Gilda utilities.""" -from typing import Iterable, Optional, Tuple, Union +from typing import Iterable, Optional, Tuple, Union, Type import bioregistry import gilda.api @@ -80,7 +80,9 @@ def normalize_identifier(prefix: str, identifier: str) -> str: def get_grounder( - prefix: Union[str, Iterable[str]], unnamed: Optional[Iterable[str]] = None + prefix: Union[str, Iterable[str]], + unnamed: Optional[Iterable[str]] = None, + grounder_cls: Optional[Type[Grounder]] = None, ) -> Grounder: """Get a Gilda grounder for the given namespace.""" unnamed = set() if unnamed is None else set(unnamed) @@ -97,7 +99,9 @@ def get_grounder( terms.extend(p_terms) terms = filter_out_duplicates(terms) terms = multidict((term.norm_text, term) for term in terms) - return Grounder(terms) + if grounder_cls is None: + grounder_cls = Grounder + return grounder_cls(terms) def get_gilda_terms(prefix: str, identifiers_are_names: bool = False) -> Iterable[gilda.term.Term]: From 23e115d4e8746dd97a30e4979569bddeb357e874 Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Fri, 12 Nov 2021 14:42:56 +0100 Subject: [PATCH 2/3] Update gilda_utils.py --- src/pyobo/gilda_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pyobo/gilda_utils.py b/src/pyobo/gilda_utils.py index 6302c491..47e528eb 100644 --- a/src/pyobo/gilda_utils.py +++ b/src/pyobo/gilda_utils.py @@ -100,8 +100,9 @@ def get_grounder( terms = filter_out_duplicates(terms) terms = multidict((term.norm_text, term) for term in terms) if grounder_cls is None: - grounder_cls = Grounder - return grounder_cls(terms) + return Grounder(terms) + else: + return grounder_cls(terms) def get_gilda_terms(prefix: str, identifiers_are_names: bool = False) -> Iterable[gilda.term.Term]: From c33110c5145c9f442087683c4f08de7b3a7cdf7e Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Fri, 12 Nov 2021 14:43:33 +0100 Subject: [PATCH 3/3] Update gilda_utils.py --- src/pyobo/gilda_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyobo/gilda_utils.py b/src/pyobo/gilda_utils.py index 10528d80..6c49274f 100644 --- a/src/pyobo/gilda_utils.py +++ b/src/pyobo/gilda_utils.py @@ -2,7 +2,7 @@ """PyOBO's Gilda utilities.""" -from typing import Iterable, Optional, Tuple, Union, Type +from typing import Iterable, Optional, Tuple, Type, Union import bioregistry import gilda.api