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

Add get_uri method to term.py class #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pronto/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ def objects(self, r: Relationship) -> Iterator["Term"]:
yield ont.get_term(other)
done.add(node)

def get_uri(self, term, ontology):
prefix, local = term.id.split(":")
if prefix in ontology.metadata.idspaces:
return "{}{}".format(ontology.metadata.idspaces[prefix][0], local)
else:
return "http://purl.obolibrary.org/obo/{}_{}".format(prefix, local)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not smart to assume OBO URIs for any old ontology. This should raise an exception like a KeyError if there's no idspace defined for the prefix.

Copy link
Owner

@althonos althonos Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cthoyt : Not necessarily, because the prefix could also originate from an import. In that case, you'd have to check the ontology attribute of imported prefixes.


@typechecked()
def superclasses(
self,
Expand Down