From 23cce1afb29b477c1f0f9d4efe7de2c17014a7a4 Mon Sep 17 00:00:00 2001 From: Koncopd Date: Thu, 21 Nov 2024 16:23:17 +0100 Subject: [PATCH 1/5] add bionty data to gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 291058c..07146bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +# bionty data +data/ +sources/ +versions/ + # macOS .DS_Store .AppleDouble From 86bfb7ac6c4d62dd496a2dceb0ac983b66b3eac7 Mon Sep 17 00:00:00 2001 From: Koncopd Date: Thu, 21 Nov 2024 16:36:24 +0100 Subject: [PATCH 2/5] use new search --- bionty/base/_public_ontology.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/bionty/base/_public_ontology.py b/bionty/base/_public_ontology.py index 12e433b..890f2eb 100644 --- a/bionty/base/_public_ontology.py +++ b/bionty/base/_public_ontology.py @@ -561,24 +561,18 @@ def search( self, string: str, *, - field: PublicOntologyField | str | None = None, + field: PublicOntologyField | str | list[PublicOntologyField | str] = None, limit: int | None = None, case_sensitive: bool = False, - synonyms_field: PublicOntologyField | str | None = "synonyms", ): - """Search a given string against a PublicOntology field. + """Search a given string against a PublicOntology field or fields. Args: string: The input string to match against the field values. - field: The PublicOntologyField of the ontology the input string is matching against. - top_hit: Return all entries ranked by matching ratios. - If True, only return the top match. - Defaults to False. - limit: Maximum amount of top results to return. - If None, return all results. - Defaults to None. + field: The PublicOntologyField or several fileds of the ontology + the input string is matching against. Search all fields containing strings by default. + limit: Maximum amount of top results to return. If None, return all results. case_sensitive: Whether the match is case sensitive. - synonyms_field: By default also search against the synonyms (If None, skips search). Returns: Ranked search results. @@ -590,13 +584,17 @@ def search( """ from lamin_utils._search import search + if isinstance(field, PublicOntologyField): + field = field.name + elif field is not None and not isinstance(field, str): + field = [f.name if isinstance(f, PublicOntologyField) else f for f in field] + return search( df=self._df, string=string, - field=self._get_default_field(field), + field=field, limit=limit, case_sensitive=case_sensitive, - synonyms_field=str(synonyms_field), ) def diff( From d1359359ccbeb14e59690a208a9efdf514465467 Mon Sep 17 00:00:00 2001 From: Koncopd Date: Thu, 21 Nov 2024 17:09:07 +0100 Subject: [PATCH 3/5] set index in search result --- bionty/base/_public_ontology.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bionty/base/_public_ontology.py b/bionty/base/_public_ontology.py index 890f2eb..2acbbd7 100644 --- a/bionty/base/_public_ontology.py +++ b/bionty/base/_public_ontology.py @@ -589,13 +589,16 @@ def search( elif field is not None and not isinstance(field, str): field = [f.name if isinstance(f, PublicOntologyField) else f for f in field] - return search( + result = search( df=self._df, string=string, field=field, limit=limit, case_sensitive=case_sensitive, ) + if "ontology_id" in result.columns: + result = result.set_index("ontology_id") + return result def diff( self, compare_to: PublicOntology, **kwargs From a4809fc491cc178ecfd71347c8d7417d3f336998 Mon Sep 17 00:00:00 2001 From: Koncopd Date: Fri, 22 Nov 2024 16:32:36 +0100 Subject: [PATCH 4/5] add lower bound on lamin-utils --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ac63464..767a525 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,8 @@ classifiers = [ ] dependencies = [ "lamindb", - "lamindb_setup>=0.77.6", + "lamindb-setup>=0.77.6", + "lamin-utils>=0.13.9", "filelock", "requests", "pyyaml", From c77d51fc8d0e9425f418c18c7c6a76e3beb03e62 Mon Sep 17 00:00:00 2001 From: Koncopd Date: Fri, 22 Nov 2024 16:33:54 +0100 Subject: [PATCH 5/5] fix --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 767a525..02ab984 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,8 +17,8 @@ classifiers = [ ] dependencies = [ "lamindb", - "lamindb-setup>=0.77.6", - "lamin-utils>=0.13.9", + "lamindb_setup>=0.77.6", + "lamin_utils>=0.13.9", "filelock", "requests", "pyyaml",