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

Troubles with loading .json files created with pybel 14.0.8 #492

Open
leon-k-martin opened this issue Apr 29, 2021 · 4 comments
Open

Troubles with loading .json files created with pybel 14.0.8 #492

leon-k-martin opened this issue Apr 29, 2021 · 4 comments

Comments

@leon-k-martin
Copy link

leon-k-martin commented Apr 29, 2021

Bildschirmfoto 2021-04-29 um 13 37 34

when trying to load a neurommsig subgraph (.json extension) I get the following message:
"Invalid extension for file: .json"

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

@cthoyt
Copy link
Member

cthoyt commented Apr 29, 2021

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

@leon-k-martin
Copy link
Author

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?

@cthoyt
Copy link
Member

cthoyt commented Apr 29, 2021

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?

@leon-k-martin
Copy link
Author

Great, thank you!
Adding the key to the annotation_list let's me importing the subgraph with pybel.

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

2 participants