CytoscapeRPC is a Cytoscape plug-in which allows XML-RPC clients to call Cytoscape to alter and query networks.
See the install page.
For the plugins javadoc (including all the functions that can be called over XML-RPC) see the: API page (bioinformatics.tudelft.nl).
The XML-RPC standard requires that all functions have a return value. Functions which add data or modify variables in Cytoscape normally would not return anything but due to this constraint it now returns True. When something goes wrong while executing the function (some data not available, non-existing identifiers) it returns a XML-RPC error.
|1001||Not found||Error code for arguments that are provided but not found in Cytoscape.|
|1002||Not exists||Error code for Cytoscape variables that should exist but are not found.|
|1003||Wrong type||Error code for arguments with the wrong type.|
|1004||Input argument mismatch||Error code for when lists of arguments do not have the same length.|
CytoscapeRPC has a number of functions which only exist to show what the possible input arguments are for other functions. These functions are listed below. See the API for more information.
|listAttributeTypes||get the names of the attribute types that can be used for nodes and edges.|
|getArrowShapeNames||get the names of the arrows that can be used with edges.|
|getLayoutNames||get the names of the available layouts. Note that none of the yFiles layouts are available.|
|getLineStyleNames||get the names of the different line styles.|
|getNodeColorPropertyNames||get the property names of nodes which can be set with the node color visual mapper.|
|getNodeShapeNames||get the names of the shapes that a node can have.|
|getVisualStyleModifiables||get the names of the modifiable elements of a visual style.|
|getVisualStyleNames||get a list of visual styles that can currently be applied.|
|test||tests if the connection is working. Should return the string "It works!".|
Overwriting visual attributes
Cytoscape allows you to bypass the VizMapper to directly set node and edge visual attributes. Normally this would be done by right-clicking and choosing for the "Visual Mapping Bypass". This hack was also implemented for CytoscapeRPC: the setNodeProperty and setEdgeProperty allow you to set any visual property to a specific value.
Each visual property type (such as a color, edge type or node shape) has a string representation which can be converted to the property type itself. Use the VizMapper to find out which strings represent which types. The getVisualStyleModifiables functions returns a list of properties which can be set using this function.
When adding attributes to nodes or edges the attribute type (data type) needs to be specified. This can be one of the following: "BOOLEAN", "COMPLEX", "FLOATING", "INTEGER", "SIMPLE_LIST", "SIMPLE_MAP" or "STRING".
Client Code Examples
Some example programs in different languages using the CytoscapeRPC plugin. The procedure is the same for all languages: open an XML-RPC connection to the Cytoscape host and call a number of functions. For more examples see CytoscapeRPCExamples. For additional info on how to set properties of e.g. layouts see: CytoscapeProperties.
Here we use the Frontier RPC libraries, these need to be installed separately on your system.
# Tell Frontier where the server lives
my $url = "http://localhost:9000/Cytoscape";
my $client = Frontier::Client->new( url => $url,
debug => 0,
# We need a coder because of the 'intelligent' var casting in perl
my $coder = Frontier::RPC2->new;
# Create a network to work with
my $networkID = $client->call('Cytoscape.createNetwork', 'TestNetwork');
# Lets see if the name we gave the network is still the same
push @args, $coder->string("$networkID");
my $networkTitle = $client->call('Cytoscape.getNetworkTitle', @args);
print $networkTitle, "\n";
For a more elaborate example see CytoscapeRPCPerlExample
This code uses the PEAR XML-RPC2 package. See their documentation for more info.
$options = array(
'prefix' => 'Cytoscape.'
$client = XML_RPC2_Client::create('http://localhost:9000/Cytoscape', $options);
$result = $client->test();
Xmlrpclib is part of the standard Python distribution so no additional packages are required. When using Ipython you can use command line completion to see which method names are available.
XmlRpc is part of the standard library so no additional packages have to be installed.
puts "Testing the Ruby CytoscapeRPC client."
# Create the connection to the server
server = XMLRPC::Client.new("localhost", "/Cytoscape", 9000)
# Perform test function to see if the connection works
# Create a new network
server.call("Cytoscape.createNetwork", "Cytoscape Ruby test")
You can call the XML-RPC functions directly from R using the XML-RPC library but there is also the excellent RCytoscape package created by Paul Shannon. The later makes working with CytoscapeRPC a lot easier.
Some (Python) scripts to make working with Cytoscape easier.
- LoadNetwork.py a script to load sif, noa and ede files into Cytoscape.