ndexbio / ndex2-client

NDEx2 Client
BSD 3-Clause "New" or "Revised" License
6 stars 6 forks source link

Improve networkx conversion #91

Closed coleslaw481 closed 8 months ago

coleslaw481 commented 2 years ago

Right now conversion of NiceCXNetwork to networkx does not convert CX data types to native python types when stored in networkx Graph. It would be nice to leverage PandasDataConverter and update it to NOT merge list data types, but convert values in the list to native types. using this logic:

* :py:const:`~ndex2.constants.LIST_OF_STRING`

           * If `value` is **NOT** of type :py:class:`list` then the `value` converted
             as if it's datatype is :py:const:`~ndex2.constants.STRING_DATATYPE`
             and put in a :py:class:`list` and returned. If `value` is a
             list, each element is converted as if it's datatype is
             :py:const:`~ndex2.constants.STRING_DATATYPE` and returned as a
             :py:class:`list`

        * :py:const:`~ndex2.constants.LIST_OF_BOOLEAN`

           * If `value` is **NOT** of type :py:class:`list` then the `value` converted
             as if it's datatype is :py:const:`~ndex2.constants.BOOLEAN_DATATYPE`
             and put in a :py:class:`list` and returned. If `value` is a
             list, each element is converted as if it's datatype is
             :py:const:`~ndex2.constants.BOOLEAN_DATATYPE` and returned as a
             :py:class:`list`

        * :py:const:`~ndex2.constants.LIST_OF_DOUBLE`

           * If `value` is **NOT** of type :py:class:`list` then the `value` converted
             as if it's datatype is :py:const:`~ndex2.constants.DOUBLE_DATATYPE`
             and put in a :py:class:`list` and returned. If `value` is a
             list, each element is converted as if it's datatype is
             :py:const:`~ndex2.constants.DOUBLE_DATATYPE` and returned as a
             :py:class:`list`

        * :py:const:`~ndex2.constants.LIST_OF_INTEGER` or :py:const:`~ndex2.constants.LIST_OF_LONG`

           * If `value` is **NOT** of type :py:class:`list` then the `value` converted
             as if it's datatype is :py:const:`~ndex2.constants.INTEGER_DATATYPE`
             and put in a :py:class:`list` and returned. If `value` is a
             list, each element is converted as if it's datatype is
             :py:const:`~ndex2.constants.INTEGER_DATATYPE` and returned as a
             :py:class:`list`
coleslaw481 commented 8 months ago

NiceCXNetwork is being deprecated in favor of CX2Network which, as of 3.7.0 has new networkx converters. See: https://ndex2.readthedocs.io/en/latest/createcx2.html#networkx