ndexbio / ndex_webapp_python_exporters

Command line exporters written in Python used by the NDex REST service
0 stars 0 forks source link

graphml conversion issues invalid literal for int() with base 10: 'null' #2

Open coleslaw481 opened 5 years ago

coleslaw481 commented 5 years ago

In cx format a number field like int can be set to null or NaN. The current graphml converter just pushes these values into the graphml xml format and exits, but that xml file cannot be loaded in networkx cause null/NaN is not a valid int. Either exclude that field since in the conversion or pick a default value and document on wiki which approach is used.

Example network that exhibits the error:

http://www.ndexbio.org/#/network/01b46d52-c3a5-11e5-8fbc-06603eb7f303

To reproduce download above network as cx first convert to graphml

# requires python 3.6+ and its easiest to use Anaconda or Miniconda
pip install ndex_webapp_python_exporters

cat network.cx | ndex_exporters.py graphml > result.graphml

Then in terminal with python 3.6+ and networkx 1.11 installed run the following:

python
import networkx
graph = networkx.readwrite.read_graphml('result.graphml')
coleslaw481 commented 5 years ago

Talked with Jing and current thinking is to omit any attributes with int data type and null or NaN as a value.