Constants

Contains constants used by the NDEx2 Python Client

ndex2.constants.BOOLEAN_DATATYPE = 'boolean'

Boolean data type for CX

ndex2.constants.CARTESIAN_LAYOUT_ASPECT = 'cartesianLayout'

Name of opaque aspect containing coordinates of nodes

"cartesianLayout": [ 
    {
        "node": 0,
        "x": 25.0,
        "y": 50.0
    }, {
        "node": 1,
        "x": -10.0,
        "y": -200.0
    }
]

Note

Although the name implies a cartesian coordinate system, that is actually wrong. The Y access is inverted so lower values of Y are rendered higher on a graph. 0,0 is considered upper left corner, but negative values are allowed

ndex2.constants.DOUBLE_DATATYPE = 'double'

Double data type for CX

ndex2.constants.EDGE_ID = '@id'

Key for id of edge

ndex2.constants.EDGE_INTERACTION = 'i'

Key for edge interaction

ndex2.constants.EDGE_SOURCE = 's'

Key for edge source

ndex2.constants.EDGE_TARGET = 't'

Key for edge target

ndex2.constants.INTEGER_DATATYPE = 'integer'

Integer data type for CX

ndex2.constants.LAYOUT_NODE = 'node'

Key for node id in CARTESIAN_LAYOUT_ASPECT opaque aspect

ndex2.constants.LAYOUT_X = 'x'

Key for X coordinate in CARTESIAN_LAYOUT_ASPECT opaque aspect

ndex2.constants.LAYOUT_Y = 'y'

Key for Y coordinate in CARTESIAN_LAYOUT_ASPECT opaque aspect

ndex2.constants.LIST_OF_BOOLEAN = 'list_of_boolean'

List of Boolean data type for CX

ndex2.constants.LIST_OF_DOUBLE = 'list_of_double'

List of Double data type for CX

ndex2.constants.LIST_OF_INTEGER = 'list_of_integer'

List of Integer data type for CX

ndex2.constants.LIST_OF_LONG = 'list_of_long'

List of Long data type for CX

ndex2.constants.LIST_OF_STRING = 'list_of_string'

List of String data type for CX

ndex2.constants.LONG_DATATYPE = 'long'

Long data type for CX

ndex2.constants.NET_ATTR_NAME = 'n'

Key for network attribute name

ndex2.constants.NET_ATTR_VALUE = 'v'

Key for network attribute value

ndex2.constants.NODE_ATTR_DATATYPE = 'd'

Key for node attribute data type

ndex2.constants.NODE_ATTR_NAME = 'n'

Key for node attribute name

ndex2.constants.NODE_ATTR_PROPERTYOF = 'po'

Key for node property of

ndex2.constants.NODE_ATTR_VALUE = 'v'

Key for node attribute value

ndex2.constants.NODE_ID = '@id'

Key for id of node

ndex2.constants.NODE_NAME = 'n'

Key for node name

ndex2.constants.NODE_REPRESENTS = 'r'

Key for node represents

ndex2.constants.STRING_DATATYPE = 'string'

String data type for CX

ndex2.constants.VALID_ATTRIBUTE_DATATYPES = ['boolean', 'double', 'integer', 'long', 'string', 'list_of_boolean', 'list_of_double', 'list_of_integer', 'list_of_long', 'list_of_string']

List of valid attribute data types

Miscellaneous

class ndex2.util.DataConverter[source]

Base class for subclasses that convert CX data types to/from native data types

convert_value(value=None, datatype=None)[source]

Defines method to converts value from CX to native data type using datatype as a guide

Parameters:
Raises:

NotImplementedError – Always raises this error cause subclasses should implement

Returns:

Always raises NotImplementedError

class ndex2.util.PandasDataConverter[source]

Converts CX values to native Python data types via PandasDataConverter.convert_value() method

New in version 3.5.0.

convert_value(value=None, datatype=None)[source]

Converts value parameter passed in to type based on value of datatype parameter passed in. This is used in data conversion by to_pandas_dataframe()

New in version 3.5.0.

Conversion rules for different values of datatype parameter:

Example usage:

from ndex2.util import PandasDataConverter

converter = PandasDataConverter()

# converts number to type str
res = converter.convert_value(123, 'string')

# would output <class 'str'>
print(type(res))
Parameters:
Raises:

NDExError – If there is an error with conversion

Returns:

Converted value

Return type:

list, str, int, float, or bool

Exceptions

class ndex2.exceptions.NDExError[source]

Base Exception for all NDEx2 Python Client Exceptions

Warning

Many methods in this code base still incorrectly raise errors not derived from this base class

class ndex2.exceptions.NDExNotFoundError[source]

Raised if resource requested was not found

class ndex2.exceptions.NDExUnauthorizedError[source]

Raised if unable to authenticate, either due to lack of or invalid credentials.

class ndex2.exceptions.NDExInvalidParameterError[source]

Raised if invalid parameter is passed in

class ndex2.exceptions.NDExInvalidCXError[source]

Raised due to invalid CX

class ndex2.exceptions.NDExUnsupportedCallError[source]

Raised if call is unsupported, for example a method that is only supported in 2.0+ of NDEx server is attempted against a server running 1.0