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

obojson parser requires optional fields to be present #20

Open
cmungall opened this issue May 2, 2022 · 1 comment
Open

obojson parser requires optional fields to be present #20

cmungall opened this issue May 2, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@cmungall
Copy link

cmungall commented May 2, 2022

given:

{
  "graphs": [
    {
      "id": "test",
      "nodes": [
        {
          "id": "GO:0005773",
          "lbl": "vacuole",
          "meta": {
            "definition": {
              "val": "..."
            }
          }
        }
      ]
    }
  ]
}

pronto gives:

  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/pronto/parsers/obojson.py", line 19, in parse_from
    doc = fastobo.load_graph(handle).compact_ids()
ValueError: graphs[0].nodes[0].meta.definition: missing field `xrefs` at line 10 column 27

this can be fixed with inclusion of empty dicts and lists

{
  "graphs": [
      {
          
          "id": "test",
          "meta": {},
          "equivalentNodesSets": [],
          "logicalDefinitionAxioms": [],
          "domainRangeAxioms": [],
          "propertyChainAxioms": [],
          "nodes": [
              {
                  "id": "GO:0005773",
                  "lbl": "vacuole",
                  "meta": {
                      "definition": {
                          "val": "...",
                          "xrefs": []
                          
                      }
                  }
              }
          ]
      }
  ]
}

but this imposes a bit of a burden on lightweight producers

@althonos althonos transferred this issue from fastobo/fastobo May 3, 2022
@althonos althonos added the bug Something isn't working label May 3, 2022
althonos added a commit that referenced this issue May 4, 2022
althonos added a commit that referenced this issue May 4, 2022
@althonos
Copy link
Member

althonos commented May 4, 2022

Hi @cmungall

I fixed the fastobo-graphs source, and will push a new release of fastobo-py later on. However, in the example you use, isn't the type attribute required for node objects? And if it isn't, how should the node be treated (default to class)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants