py4cytoscape.py4cytoscape_utils.node_name_to_node_suid

node_name_to_node_suid(node_names, network=None, base_url='http://127.0.0.1:1234/v1', *, unique_list=False)[source]

Translate one node name or a list of node names into a list of SUIDs.

List can contain either names or SUIDs. If the list contains all SUIDs and no names, the list is returned.

If a name occurs multiple times in the list and unique_list=True, a different SUID is returned for each name instance, provided that the network has enough same-named edges. If not, an error is returned.

If a name occures multiple times but unique_list=False, a list of SUIDs is returned for each name instance. If there is only one name, the SUID is returned as a scalar.

Parameters
  • node_names (str or list) – an node name or a list of node names

  • network (SUID or str or None) – Name or SUID of a network. Default is the “current” network active in Cytoscape.

  • base_url (str) – Ignore unless you need to specify a custom domain, port or version to connect to the CyREST API. Default is http://127.0.0.1:1234 and the latest version of the CyREST API supported by this version of py4cytoscape.

  • unique_list (bool) – True if duplicate node names refer to different nodes; False if it doesn’t matter

Returns

[<SUID or SUID list corresponding to each name>] or None if node_names is None

Return type

list

Raises
  • CyError – if network name or SUID doesn’t exist

  • requests.exceptions.RequestException – if can’t connect to Cytoscape or Cytoscape returns an error

Examples

>>> node_name_to_node_suid('YDR277C')
[1022]
>>> node_name_to_node_suid(['YDR277C', 'YDL194W'], network='myNetwork')
[1022, 1023]
>>> node_name_to_node_suid('YDR277C, YDL194W', network='myNetwork')
[1022, 1023]
>>> node_name_to_node_suid([1022, 1023], network='myNetwork')
[1022, 1023]
>>> node_name_to_node_suid(['YDR277C', 'YDR277C'], network='myNetwork', unique_list=True)
[1022, 1024]
>>> node_name_to_node_suid(['YDR277C', 'YDR277C', 'YDL194W'], network='myNetwork')
[[1022, 1024], [1022, 1024], 1023]

Note

To identify a node whose name contains a comma, use ‘\’ to escape the comma. For example, ‘node1, node\,2’ identifies ‘node1’ and ‘node,2’.