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: - value (object) – Value to convert
- datatype (str) – CX data type which is one of the following:
ndex2.constants.VALID_ATTRIBUTE_DATATYPES
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()
methodNew 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:
STRING_DATATYPE
orNone
- value is converted by
str
and returned
- value is converted by
-
-
INTEGER_DATATYPE
orLONG_DATATYPE
LIST_OF_STRING
,LIST_OF_BOOLEAN
LIST_OF_DOUBLE
,LIST_OF_INTEGER
,LIST_OF_LONG
- If value is NOT of type
list
then the value converted as if it’s datatype isSTRING_DATATYPE
. If value is a list, each element is converted as if it’s datatype isSTRING_DATATYPE
and values oflist
are converted to a comma delimitedstr
- If value is NOT of type
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: - value (object) – Value to convert
- datatype (str) – CX data type which is one of the following:
ndex2.constants.VALID_ATTRIBUTE_DATATYPES
Raises: NDExError – If there is an error with conversion
Returns: Converted value
Return type:
-