SynBioDex / tyto

Use ontology terms in your Python application
Apache License 2.0
18 stars 3 forks source link

Access to ambiguous terms #68

Open jakebeal opened 2 years ago

jakebeal commented 2 years ago

Right now, if a term has an ambiguous name, tyto has no way to allow access to that term. Case sensitivity allows handling of some of the problem cases, but not all.

For example, NCIT has two concepts with the name "Cell", meaning one gets:

> tyto.NCIT.Cell
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-8-9040bf094937>", line 1, in <module>
    tyto.NCIT.Cell
  File "/usr/local/lib/python3.9/site-packages/tyto/tyto.py", line 47, in __getattr__
    return self.__getattribute__('get_uri_by_term')(name)
  File "/usr/local/lib/python3.9/site-packages/tyto/tyto.py", line 123, in get_uri_by_term
    uri = self._handler('get_uri_by_term', exception, sanitized_term)
  File "/usr/local/lib/python3.9/site-packages/tyto/tyto.py", line 72, in _handler
    response = method(self, *args)
  File "/usr/local/lib/python3.9/site-packages/tyto/endpoint/endpoint.py", line 103, in get_uri_by_term
    raise Exception(f'Ambiguous term {term}--found multiple URIs {response}')
Exception: Ambiguous term Cell--found multiple URIs ['http://purl.obolibrary.org/obo/NCIT_C48694', 'http://purl.obolibrary.org/obo/NCIT_C12508']

One way to deal with this might be to have tyto allow querying of synonyms.