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

Cannot parse graph of full file #1

Open
kkaris opened this issue Sep 26, 2023 · 0 comments
Open

Cannot parse graph of full file #1

kkaris opened this issue Sep 26, 2023 · 0 comments

Comments

@kkaris
Copy link

kkaris commented Sep 26, 2023

Using pybel to parse human_2.0.bel.nodelink.json in this repository errors with NotImplementedError: where is key cbn_pathway?. Looking into the file itself, it seems like the key cbn_pathway does exist, I'm wondering if the generated data files might be out of date with respect to pybel?

The following code reproduces the error:

import pybel
import requests
full_res = requests.get('https://raw.githubusercontent.com/pybel/cbn-bel/master/bel/human_2.0.bel.nodelink.json')
full_graph = pybel.from_nodelink(full_res.json())

Python version 3.11.4
OS: Ubuntu 20.04.6
pybel version: 0.15.5

The traceback I get:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[13], line 1
----> 1 full_graph = pybel.from_nodelink(full_res.json())

File ~/.virtualenvs/py3114/lib/python3.11/site-packages/pybel/io/nodelink.py:100, in from_nodelink(graph_json_dict, check_version)
     98 if pybel_version[1] < 14:  # if minor version is less than 14
     99     raise ValueError("Invalid NodeLink JSON from old version of PyBEL (v{}.{}.{})".format(*pybel_version))
--> 100 graph = _from_nodelink_json_helper(graph_json_dict)
    101 return ensure_version(graph, check_version=check_version)

File ~/.virtualenvs/py3114/lib/python3.11/site-packages/pybel/io/nodelink.py:204, in _from_nodelink_json_helper(data)
    201         edge_data[CITATION] = citation_dict(**edge_data[CITATION])
    203     if ANNOTATIONS in edge_data:
--> 204         edge_data[ANNOTATIONS] = graph._clean_annotations(edge_data[ANNOTATIONS])
    206     graph.add_edge(u, v, key=hash_edge(u, v, edge_data), **edge_data)
    208 return graph

File ~/.virtualenvs/py3114/lib/python3.11/site-packages/pybel/struct/graph.py:1011, in BELGraph._clean_annotations(self, annotations_dict)
    994 def _clean_annotations(self, annotations_dict: AnnotationsHint) -> AnnotationsDict:
    995     """Fix the formatting of annotation dict.
    996 
    997     .. seealso:: https://github.com/vtoure/bep/blob/master/docs/published/BEP-0013.md
   (...)
   1009        ``{'ECO': dict(namespace='ECO', identifier='0007682', name='reporter gene assay...')}``
   1010     """
-> 1011     return {
   1012         key: sorted(
   1013             self._clean_value(key, values),
   1014             key=lambda e: (e.namespace, e.identifier, e.name),
   1015         )
   1016         for key, values in annotations_dict.items()
   1017     }

File ~/.virtualenvs/py3114/lib/python3.11/site-packages/pybel/struct/graph.py:1013, in <dictcomp>(.0)
    994 def _clean_annotations(self, annotations_dict: AnnotationsHint) -> AnnotationsDict:
    995     """Fix the formatting of annotation dict.
    996 
    997     .. seealso:: https://github.com/vtoure/bep/blob/master/docs/published/BEP-0013.md
   (...)
   1009        ``{'ECO': dict(namespace='ECO', identifier='0007682', name='reporter gene assay...')}``
   1010     """
   1011     return {
   1012         key: sorted(
-> 1013             self._clean_value(key, values),
   1014             key=lambda e: (e.namespace, e.identifier, e.name),
   1015         )
   1016         for key, values in annotations_dict.items()
   1017     }

File ~/.virtualenvs/py3114/lib/python3.11/site-packages/pybel/struct/graph.py:1052, in BELGraph._clean_value(self, key, values)
   1049     return self._clean_value_helper(key=key, namespace=key, values=values)
   1051 if self.raise_on_missing_annotations:
-> 1052     raise NotImplementedError(f"where is key {key}?")
   1054 return self._clean_value_helper(key=key, namespace=key, values=values)

NotImplementedError: where is key cbn_pathway?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant