althonos / pronto

A Python frontend to (Open Biomedical) Ontologies.
https://pronto.readthedocs.io
MIT License
229 stars 48 forks source link

How to delete terms in ontology? #137

Open saiden89 opened 3 years ago

saiden89 commented 3 years ago

Hi, I've read the documentation quite extensively, yet I haven't found any method or function to delete a term from an ontology. For example:

from pronto import Ontology
go = Ontology("http://purl.obolibrary.org/obo/go.obo")

If I try

del go['GO:0000001']

I get:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-29-441de0cde0ef> in <module>
----> 1 del go['GO:0000001']

TypeError: 'Ontology' object does not support item deletion

Is there any way to achieve item deletion?

althonos commented 3 years ago

Short story: there is none for now.

Basically, there are plenty of places where a term can be referenced, and a deletion routine should either make sure these references don't exist anymore, or delete them as well. I've been postponing this because until now my impression was that pronto was mostly used to perform read-only access to ontologies, but I can add it to the roadmap for the next release if that's something you'd need!

saiden89 commented 3 years ago

I imagined something like this, but I asked just to be sure. For the moment I've solved the problem using owlready2, even if sometimes is randomly unreliable in destroying entities It wouldn't hurt to have such a functionality in a future release, but there is no need to rush. Thank you for the explanation, and kudos for the library!