Implementing Attribute Equations Functions

You need the equations.jar file for this which comes with Cytoscape 2.8 and later. But, it is will be extremely helpful to study the source code for the built-in functions that are in the "equations" core Cytoscape library under src/org/cytoscape/equations/builtins. In fact, in many cases you may want to implement a function with a signature (= argument list) identical to that of an existing function, in which case you should probably start with a copy of an existing function with the same argument list.

Should you choose to or are required to implement a new function entirely from scratch, you can derive a class either from org.cytoscape.equations.Function or org.cytoscape.equations.AbstractFunction. While you gain some additional flexibility in the choice of arguments that your function may have by deriving your class directly from the Function class, this is not recommended and we suggest to derive your function from the AbstractFunction class instead. Deriving from AbstractFunction will greatly reduce the complexity of your task and save you the work of implementing Function.getUsageDescription(), Function.argTypesAreValid(), and Function.getPossibleArgTypes(). From now on we will assume that you intend to follow this route!

The first step is implementing the constructor for your function. Here is the constructor for the Subsitute built-in function:

public Substitute() {
        super(new ArgDescriptor[] {
                        new ArgDescriptor(ArgType.STRING, "text", "The source text."),
                        new ArgDescriptor(ArgType.STRING, "original", "The text that will be replaced."),
                        new ArgDescriptor(ArgType.STRING, "replacement", "The replacement text."),
                        new ArgDescriptor(ArgType.OPT_INT, "nth_appearance", "Which occurrence to replace.")
                });
}

This constructor should take no arguments and include a call to super where you need to specify the arguments that your function will take. The single argument in the call to super is an array of type org.cytoscape.equations.ArgDescriptorand it will usually be an array literal. Each ArgDescriptor constructor takes 3 parameters. The first is the type of argument and is an enum value of type org.cytoscape.

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