pronto icon indicating copy to clipboard operation
pronto copied to clipboard

Accessing children of a relationship

Open manulera opened this issue 2 years ago • 3 comments

Is it possible to access the children of a relationship? For example, with the method term.subclasses() I can access all the inverse is_a relationships. Is there a way to access other relationships this way? E.g regulates in GO?

I am new to the use of ontologies, so I am not sure if that's the case, but this example from the documentation seems to be doing exactly that.

go = pronto.Ontology.from_obo_library("go.obo")
go['GO:0048870']
list(go['GO:0048870'].objects(go.get_relationship('part_of')))

However, when I run it I get this:

NotImplementedWarning: `Term.objects` is not semantically correct, most of the logic rules have not been implemented. Consider using an actual reasoner instead.
  list(go['GO:0048870'].objects(go.get_relationship('part_of')))

Any tips on this?

manulera avatar Jun 21 '22 17:06 manulera

The warning is a little confusing, and I think it's actually a red herring/false positive.

The issue here is that GO changed since the documentation was written, and this term has no direct part-of relationships any more. The actual return value of [] is correct

Try another term, it will give results, without warning:

>>> list(go['GO:0060887'].objects(go.get_relationship('part_of')))
[Term('GO:0060173', name='limb development')]

FWIW, I usually do this:

>>> [r for r in go['GO:0060887'].relationships]
[Relationship('part_of', name='part of')]

See also #119

cmungall avatar Jul 06 '22 05:07 cmungall

Hi @cmungall thanks for the detailed response and the examples, and sorry for the super-late answer. I tried your example and indeed it works. However, I think my question was not well formulated, I meant to ask whether it was possible to get the inverse relationship (what I would think of as a child). For example, for the term GO:0006366, get all these children and the relationship that links them to GO:0006366:

Screenshot 2022-07-27 at 14 07 56

manulera avatar Jul 27 '22 13:07 manulera

HI @cmungall any advise on this?

manulera avatar Jan 23 '23 10:01 manulera