laminlabs / bionty-base

Access public biological ontologies.
https://bionty-base.lamin.ai
Apache License 2.0
15 stars 3 forks source link

Lookup case sensitivity #425

Closed Zethson closed 1 year ago

Zethson commented 1 year ago

I had data like "Celiac disease" and tried finding a match with

disease_bionty = bt.Disease(source="mondo", version="2023-02-06")
disease_bionty_lookup = disease_bionty.lookup()

but I could not find any matches with disease_bionty_lookup.Celiac[...]. The actual match is disease_bionty_lookup.celiac_disease -> lower case. I know how the lookup is constructed, but is there any reasonable way to make the match easier? Sure, fuzzy matching would have found this super easily with case_sensitive=False

Zethson commented 1 year ago

I'd like to further point out that the result is: DOID:10608 (using MONDO atm). In other words, filtering only for MONDO ids may not be the right thing to do with the MONDO ontology. I'll need to check this out.

sunnyosun commented 1 year ago

Thank you for raising it! I also really don't like that lookup is case-sensitive, maybe namedtuple isn't the ideal way to go (it was just the most lightweight implementation with autocompletion).

Need to look into more!

sunnyosun commented 1 year ago

I found a good implementation! https://stackoverflow.com/a/32107024

I'd just switch to this one, it also perfectly avoided conversion to pythonic keys that doesn't allow special characters, because one can do both lookup. and lookup[""]!

Zethson commented 1 year ago

The solution:

from jedi import settings
settings.case_insensitive_completion = True
Zethson commented 1 year ago

image