Skip to content

Cannot parse graph of full file #1

@kkaris

Description

@kkaris

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions