biolink / ontobio

python library for working with ontologies and ontology associations
https://ontobio.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
122 stars 30 forks source link

ontobio doesn't work with obographs 0.2.1 #468

Closed cmungall closed 3 years ago

cmungall commented 4 years ago

https://github.com/geneontology/obographs/releases/tag/v0.2.1 release in Feb

I'm surprised that ontobio ontol.py doesn't work with this? this release is incorporated in robot, are we not using this?

When I try and parse the json I get


Traceback (most recent call last):
  File "/Users/cjm/repos/ontobio/bin/ogr.py", line 197, in <module>
    main()
  File "/Users/cjm/repos/ontobio/bin/ogr.py", line 145, in main
    relations=args.properties)
  File "/Users/cjm/repos/ontobio/ontobio/ontol.py", line 562, in traverse_nodes
    g = self.get_filtered_graph(**args)
  File "/Users/cjm/repos/ontobio/ontobio/ontol.py", line 109, in get_filtered_graph
    self.all_synonyms()
  File "/Users/cjm/repos/ontobio/ontobio/ontol.py", line 880, in all_synonyms
    syns = syns + self.synonyms(n, include_label=include_label)
  File "/Users/cjm/repos/ontobio/ontobio/ontol.py", line 782, in synonyms
    syns.append(Synonym(nid, **obj))

Seems to be caused by


        "synonyms" : [ {
          "pred" : "hasExactSynonym",
          "val" : "cell nucleus",
          "xrefs" : [ ],
          "synonymType" : "http://purl.obolibrary.org/obo/go-test#systematic_synonym"
        } ],

see the attached file for an example of the nucleus example in this repo translated

nucleus.json.txt

dougli1sqrd commented 4 years ago

Are you saying that obographs will parse nucleus.json.txt but ontol.py will not? As far as I'm aware, there's no coordination between ontol.py and obographs. I ran this in ontobio, and it doesn't crash like you have above, but it makes a graph with 0 nodes, so clearly something is going wrong.

dougli1sqrd commented 4 years ago

Hey @cmungall, What command did you use to load the file?

I did this, and I think it worked for me:

$ python3 -m venv env
$ source env/bin/activate
$ python
>>> from ontobio.ontol_factory import OntologyFactory
>>> ont = OntologyFactory().create(open("nucleus.json.txt"))
>>> ont.graph.size()
14

I think the problem is in the implementation of synonyms() on Ontology. On Line 782 we attempt to make a Synonym object by de-structuring the obj (like **obj) and passing in the key-value pairs from the synonyms key. So using your above example, it's passing in "synonymType"="http://purl.obolibrary.org/obo/go-test#systematic_synonym" but there isn't a synonymType key in the Synonym.__init__().

kltm commented 4 years ago

@cmungall to answer "this release is incorporated in robot, are we not using this?" in a public space for others, the GO pipeline isolates robot and obograph use to a single docker image, the the versions are already locked there. Without an update to those images, the current product from that stage does not seem to exhibit any issues with the versions of ontobio we have baked into our requirements.txt.

cmungall commented 4 years ago

@dougli1sqrd on the right track. But the error isn't revealed until a synonym object is created, it's lazy so created on demand

>>>ont = OntologyFactory().create("nucleus.json")
>>> ont.synonyms("http://purl.obolibrary.org/obo/GO_0005634")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cjm/repos/ontobio/ontobio/ontol.py", line 778, in synonyms
    if 'meta' in n:
TypeError: argument of type 'NoneType' is not iterable
>>> ont.synonyms("http://purl.obolibrary.org/obo/GO_0005634")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cjm/repos/ontobio/ontobio/ontol.py", line 778, in synonyms
    if 'meta' in n:
TypeError: argument of type 'NoneType' is not iterable
matentzn commented 4 years ago

+1 running into the same issues now.

matentzn commented 4 years ago

Is anyone working on this issue?

dougli1sqrd commented 4 years ago
>>> 
>>> ont.synonyms("GO:0005634")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dougli1sqrd/lbl/biolink/ontobio/ontobio/ontol.py", line 782, in synonyms
    syns.append(Synonym(nid, **obj))
TypeError: __init__() got an unexpected keyword argument 'synonymType'