pybel
pybel copied to clipboard
Troubles with loading .json files created with pybel 14.0.8

when trying to load a neurommsig subgraph (.json extension) I get the following message:
"Invalid extension for file:
The image shows the first lines of the .json file
Is there a way to convert the old files into a format supported by pybel?
Thank you in advance!
Best Leon
I was pretty careful to make sure old files could be loaded. However, there are many flavors of JSON (nodelink JSON, SBEL JSON, GraphDati JSON) so you have to make sure to use the file extension bel.nodelink.json
if you're using pybel.load
. If you don't want to worry about automatic inference of the data type, you can try pybel.from_nodelink_file
Thank you for the quick reply!
I tried the import with the pybel.from_nodelink_file but get a new error unfortunately:
File "/opt/anaconda3/lib/python3.8/site-packages/pybel/struct/graph.py", line 932, in <dictcomp>
key: sorted(self._clean_value(key, values), key=lambda e: (e.namespace, e.identifier, e.name))
File "/opt/anaconda3/lib/python3.8/site-packages/pybel/struct/graph.py", line 969, in _clean_value
raise NotImplementedError(f'where is key {key}?')
NotImplementedError: where is key NeuroMMSig-Disease?
Am I doing sth wrong or are the json-files I am trying to load exported incorrectly?
This is happening because there is an underlying semantic error in the BEL document -there is no annotation definition for "NeuroMMSig-Disease".
I agree that this isn't a very informative message, and it should probably give a warning instead of crashing the whole program. I might have to take care of this one with an update to the underlying code since I don't think there's an option to disable this check.
You could add an annotation definition in the JSON file (in the "annotations" key) before processing with PyBEL and that should be a quick fix. Let me know if you run into any issues doing that. Are you getting these files from the NeuroMMSig service? Or did daniel send you a dump?
Great, thank you! Adding the key to the annotation_list let's me importing the subgraph with pybel.