biolink / biolink-model-toolkit

A collection of useful python functions for looking up information and working with the Biolink Model
https://biolink.github.io/biolink-model-toolkit/
BSD 3-Clause "New" or "Revised" License
20 stars 11 forks source link

Raise error for unrecognized element name #48

Closed patrickkwang closed 2 years ago

patrickkwang commented 3 years ago

Currently, providing an unrecognized element name to e.g. get_descendants() returns an empty list. This is also the behavior when there are simply no descendants (with reflexive=False).

>>> tk.get_descendants("biolink:invalid", reflexive=False)
[]
>>> tk.get_descendants("biolink:disease", reflexive=False)
[]

I think it would be more natural to raise a ValueError in the first case.

patrickkwang commented 3 years ago

Another interesting case:

>>> tk.get_descendants("biolink:invalid", reflexive=True)
[]