py4cytoscape.networks.create_network_from_cytoscapejs
-
create_network_from_cytoscapejs
(cytoscapejs, title=None, collection='My CytoscapeJS Network Collection', base_url='http://127.0.0.1:1234/v1')[source] Create a network from CytoscapeJS JSON.
Takes the dict-encoded JSON formatted for a CytoscapeJS network (including node coordinates) and creates a Cytoscape network. Both nodes and edges can have named attribute values, where the names become Cytoscape columns and the values are associated with their node or edge. Once the network is created, it becomes the Cytoscape current network.
Notes
If
title
is supplied, it is used as the Cytoscape network name. Otherwise, if the JSON’s [‘data’][‘name’] element is present, its value is used as Cytoscape’s network name. If neither, the network gets a generic name.If
collection
is supplied, it is used as the collection to contain the network, even if the collection must be created first. Ifcollection
is None, the new network is created in an unnamed collection.- Parameters
cytoscapejs (dict) – network (nodes, edges, attributes, node positions and metadata) in CytoscapeJS format
title (str) – network name (None means use the name in
cytoscapejs
… if no name, use a generic name)collection (str) – collection name (None means create an unnamed collection)
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.
- Returns
The
SUID
of the new network- Return type
int
- Raises
requests.exceptions.RequestException – if can’t connect to Cytoscape or Cytoscape returns an error
Examples
>>> create_network_from_cytoscapejs({...}) 213043 >>> create_network_from_cytoscapejs({...}, 'new network', 'new collection') 220209