Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast test for URI containment #33

Open
jakebeal opened this issue Sep 12, 2021 · 0 comments
Open

Fast test for URI containment #33

jakebeal opened this issue Sep 12, 2021 · 0 comments
Milestone

Comments

@jakebeal
Copy link
Contributor

I sometimes need to check whether a given URI is likely to be in an ontology. Given that there are multiple legal prefixes, there isn't a simple way to check this without just looking up the term, which is costly when the term is not in the ontology.

Example of a current function for this including partial workaround:

def has_SO_uri(uri: str) -> bool:
    """Test if a given URI is in the ontology (effectively an exception-checking wrapper around get_term_by_uri)

    :param ontology: Ontology to check for term containment
    :param str: URI to look up
    :return: true if this is a URI in the
    """
    if not (uri.startswith("https://identifiers.org/SO") or uri.startswith("http://identifiers.org/so/SO")):
        return False
    try:
        tyto.SO.get_term_by_uri(uri)
        return True
    except LookupError:
        return False
@jakebeal jakebeal added this to the beta-2 milestone Sep 21, 2021
@bbartley bbartley modified the milestones: beta-2, 1.0 Nov 22, 2021
@jakebeal jakebeal modified the milestones: 1.0, 1.1 Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants