Cytoscape.js Layout Web Service
This repository implements a web service for Cytoscape.js layouts. Applications not directly working on a Cytoscape.js canvas or applications that prefer a backend service for layout may use this as a service.
Setup the server
First go and pull everything from this git repository. Then execute:
to install all of the dependencies for the server.
To run the server on the port that is assigned in the index.html(3000 by default) execute:
npm run dev
Test the server
To test the server execute:
and you will have 4 basic test cases executed, that check if the server is up and working as expected with different types of inputs.
This web service supports the following input formats for graphs:
The supported layout styles are:
Request to layout the graph:
needs to be send to https://cytoscape-layout-service.herokuapp.com, and the type of the request must be 'text' or 'text/plain'. By default nodes with their positions (x,y) and their dimension (width, height) if given will be returned. If you want edges to be returned as well, you should set edges option to the request, which is false by default:
The format of the request depends on the format used for specifying the topology of the underlying graph as described below.
In any case it contains an array where the first element of the array is also an array that consists of the topology of the graph (JSON, GraphML or SBGN-ML), and the second element is a JSON object, where the options for the layout are defined needs to be passed as a body of the request. Name field of the options body must be specified, other fields are optional.
If user wants to provide
height for each node individually, they should include them in the data object as in the samples below.
Sample JSON request body (simple)
Sample JSON request body (dimensions included)
After the request is sent, the server will layout the given graph and return the JSON file with the node names and their positions. If an error occurs, the response of the server will consist of the error's body.
Compounds are supported built into the SBGN-ML format (e.g. molecular complexes and compartments). Similarly the server will recognize compound structures in GraphML and JSON formats as well. Conventions used by Cytoscape.js for representing compounds with GraphML and JSON formats are supported by this web service.
Clusters are supported only in GraphML and JSON formats. In JSON format, clusterID field has to go to the data section of each node that has a cluster assigned to it. Similarly, in GraphML, clusterID key needs to be provided for each node that is part of a cluster.
Following is a list of third-party libraries used in building this web service: