Overview

The following document describes a general architecture for Cytoscape that uses OSGi. Subsequent sections describe the primary interfaces of the new Cytoscape API, the primary services made available by Cytoscape, and the interfaces to services that Cytoscape will expect plugins to implement. We then describe the overall organization of the bundles that will comprise the application. The primary "action" in cytoscape will be an Algorithm, which we describe in some detail. In addition we describe how the user interface might interact with these Algorithms in a manner that separates the action from the user interface implementation. Finally, we list current actions and categorize them based on relationship to the user interface.

Sample Code

We've built a sample version of Cytoscape that consists of OSGi compatible bundles and runs on OSGi. The source code is available here:

We've also built a sample plugin that is an OSGi bundle that uses OSGi's service registry to make itself available to Cytoscape. This code provides the ability to read SBML files.

Cytoscape PUBLIC API

The core network and network view interfaces. We should consider rolling groups into network/view.

The core attribute interface.

Interfaces for writing various types to data. Session writing will not be provided as a service since on the internal core will ever write a session.

Interfaces for reading various types of data along with file filters that can be used to define how files get read.

The interfaces used for defining general actions in Cytoscape. Algorithms are strictly separated from any sort of UI. The interfaces defining the user interface. Tunable objects are the primary mechanism for communicating data between Algorithms and the UI. If an Algorithm wants to be present in the UI, then it must provide its own SwingFactory. Eventually we'll have interfaces for things like CommandLineFactory (we could perhaps infer this automatically) or AJAXFactory.

The interface for defining a web service client.

The (substantially simplified) interfaces for defining visual styles.

The service interfaces for Cytoscape. These interfaces represent much of the functionality that is currently included in Cytoscape.java as static methods. These services will be implemented by cytoscape.

Plugin Implemented Services

The general mechanism for plugins to provide services to the rest of Cytoscape is to implement a public Cytoscape interface and register that object as a service with OSGi's service registry. The primary example of this is the Algorithm/AlgorithmFactory interface. Another example is the CyNetworkFileFilter.

Here is some example plugin code that would provide an SBML reader:

package sbmlreader;

import org.cytoscape.io.import.CyNetworkFileFilter;

import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

import java.util.Hashtable;

public class SBMLReaderPlugin implements BundleActivator {

        private ServiceRegistration filterReg;

        public void start(BundleContext bc) {
                // defin the service metadata
                Hashtable metadata = new Hashtable();
                metadata.put("file.extensions",".sbml,.xml");
                metadata.put("description","SBML files");
                metadata.put("service.pid",SBMLFilter.class.getName());

                //                                               just an interface, implementation of interface, metadata
                filterReg = bc.registerService(CyNetworkFileFilter.class.getName(), new SBMLFilter(), metadata);
        }

        public void stop(BundleContext bc) {
                filterReg.unregister();
        }
}

Here is code that would exist in the Cytoscape core, consume services that have been registered as implementing CyNetworkFileFilter. Since SBMLReaderPlugin has done this, it will be found and used within the core normally.

package cytoscape;

import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.cytoscape.io.import.CyNetworkFileFilter;

public class ServiceHandler {

    private BundleContext bc;

    // perhaps called at startup or some other time
    public ServiceHandler(BundleContext bc) {
        this.bc = bc;
        registerCyFileFilters();
    }

    public void registerCyFileFilters() {
        try {
           ServiceReference[] sr = bc.getServiceReferences(CyNetworkFileFilter.class.getName(), null);
           for (ServiceReference r : sr ) {
               CyNetworkFileFilter filter = (CyNetworkFileFilter)bc.getService(r));
               // do something with filter
           }
        } catch (Exception e) { e.printStackTrace(); }
    }

CORE Bundle Organization

Plugin Bundle Organization

Algorithms

Algorithms can implement additional interfaces, e.g. ProgressTrackable, which would mean a progress monitor could be added.

CIShell does all of this now.

Workflow

JMenu Context

WARNING This scheme currently does not support the case where the Algorithm interacts with the GUI, i.e. returns a result to the GUI.

Scripting

This Algorithm model is separated from the GUI so that it can be easily used in a scripting context (i.e headless mode).

Event Handling

OSGi provides a basic event handling service. We could consider using this service.

Visual Styles Refactoring

A VisualStyle consists of a NodeAppearanceCalculator, EdgeAppearanceCalculator, and GlobalAppearanceCalculator.

NodeAppearanceCalculators and EdgeAppearanceCalculators consist of lists of Calculator objects. Each calculator has a specific VisualPropertyType. Only one Calculator of a given VisualPropertyType is allowed in either NodeAppearanceCalculators or EdgeAppearanceCalculators.

Possible Improvements for VisualStyles

UI Services

The Cytoscape GUI will look for GUI services. Each GUI service will have (among other things) two key pieces of information in its metadata. The first will be a location where the GUI Services JPanel can be placed. Some possible locations are:

The second piece of metadata will be an action style which indicates whether the GUI Service will be instantiated from a menu item or a toolbar button. Some possible action styles are:

The GUI service should also be able to use the Algorithm metadata to further define its functionality.

Possible GUI Service MetaData

Possible Algorithm MetaData

Current Cytoscape Actions

OSGI_Refactoring_Possibilities (last edited 2009-02-12 01:03:49 by localhost)

MoinMoin Appliance - Powered by TurnKey Linux