This example plugin uses the Cytoscape network and attributes data structures to perform a simple node selection operation. When the user selects one or more nodes in the graph and then activates the plugin, it will iterate over each selected node and additionally select all neighbors of that node.

To run the plugin, save the jar file below to your local disk in the Cytoscape plugins directory. Then run Cytoscape and load in a sample yeast network (for example, galFiltered.sif in the sampleData directory of the public Cytoscape distribution). Select one or more nodes, then activate the plugin via the Plugins->NeighborNodeSelection menu option.

NeighborNodeSelection.java
NeighborNodeSelection.jar

Looking at the Plugin

   1     public NeighborNodeSelection() {
   2         NeighborNodeSelectionAction action = new NeighborNodeSelectionAction();
   3         action.setPreferredMenu("Plugins");
   4         Cytoscape.getDesktop().getCyMenus().addAction(action);
   5     }
   6 

The plugin constructor adds an entry to the menus of the window. This is a very common operation, giving the user the ability to execute the plugin on command. A plugin could add more than one menu entry, if it provided more than one possible operation. What actually happens is that the plugin defines an extension of the CytoscapeAction class, which is an extension of the Swing AbstractAction class. The code in this extension class gets called whenever the user selects the item that appears in the menu. (See the Swing section of the Java tutorial and the Java API for more information).

The plugin works with several core objects. The CyNetwork object is a graph and also contains the associated data. The plugin uses the network to find the neighbors of the currently selected nodes. The CyNetworkView contains information on what node views are currently selected.

At the end of the algorithm, the plugin calls the redrawGraph method on the window. This is required to let Cytoscape know that it should redraw the graph (for example, to update the appearance of newly selected nodes).

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux