org.cytoscape.cyni
Class AbstractCyniTask

java.lang.Object
  extended by org.cytoscape.work.AbstractTask
      extended by org.cytoscape.cyni.AbstractCyniTask
All Implemented Interfaces:
org.cytoscape.work.Task

public abstract class AbstractCyniTask
extends org.cytoscape.work.AbstractTask

This is a basic implementation of a CyniAlgorithm Task that does some bookkeeping, but primarily delegates to the doCyniTask() method.


Field Summary
protected  org.cytoscape.model.CyNetworkFactory netFactory
           
protected  org.cytoscape.model.CyNetworkManager netMgr
           
protected  Map<Integer,ArrayList<Integer>> nodeParents
          This variable maps an integer representing a node/row with a list of integers that represents a list of parents for that node/row In oder to use it correctly, this variable needs to be initialized and a previous map between a node and its corresponding integer is also required
protected  int nThreads
          Indicates the maximum number of threads that this task can use
protected  boolean selectedOnly
          Indicates whether to apply the algorithm to all rows or only the selected rows.
protected  org.cytoscape.view.model.CyNetworkViewFactory viewFactory
           
protected  org.cytoscape.view.model.CyNetworkViewManager viewMgr
           
protected  org.cytoscape.view.vizmap.VisualMappingManager vmMgr
           
 
Fields inherited from class org.cytoscape.work.AbstractTask
cancelled
 
Constructor Summary
AbstractCyniTask(String name, AbstractCyniAlgorithmContext context, org.cytoscape.model.CyNetworkFactory networkFactory, org.cytoscape.view.model.CyNetworkViewFactory networkViewFactory, org.cytoscape.model.CyNetworkManager networkManager, org.cytoscape.view.model.CyNetworkViewManager networkViewManager, org.cytoscape.model.CyNetworkTableManager netTableMgr, org.cytoscape.model.subnetwork.CyRootNetworkManager rootNetMgr, org.cytoscape.view.vizmap.VisualMappingManager visualMapperManager)
          Constructor.
 
Method Summary
protected  void addColumns(org.cytoscape.model.CyNetwork origNet, org.cytoscape.model.CyNetwork newNet, org.cytoscape.model.CyTable origTable, Class<? extends org.cytoscape.model.CyIdentifiable> tableType, String namespace)
          Add a column that belongs to a table associated to a network to a new table associated to a new network
protected  void addVirtualColumn(org.cytoscape.model.CyColumn col, org.cytoscape.model.CyTable subTable)
          Add a virtual column to a table
protected  void cloneRow(org.cytoscape.model.CyNetwork newNet, Class<? extends org.cytoscape.model.CyIdentifiable> tableType, org.cytoscape.model.CyRow from, org.cytoscape.model.CyRow to)
          Clone a row to be added to a new network
protected  void copyColumn(org.cytoscape.model.CyColumn col, org.cytoscape.model.CyTable subTable)
          Copy a column to a table
protected  org.cytoscape.view.model.CyNetworkView displayNewNetwork(org.cytoscape.model.CyNetwork newNetwork, org.cytoscape.model.CyNetwork oldNetwork, boolean directed)
          This method displays the new network and return a network view that might be used to modify the display features such as the layout
protected abstract  void doCyniTask(org.cytoscape.work.TaskMonitor taskMonitor)
          This method is designed to actually encapsulate the cyni algorithm.
protected  org.cytoscape.model.CyNetwork getNetworkAssociatedToTable(org.cytoscape.model.CyTable table)
          Checks if the table is associated to a network, if so it return the associated network otherwise it returns null
 boolean isGraphCyclic(int nodeToCheck)
          This method allows checking if there is a cycle in a graph starting from a defined node.
protected  void removeNodesWithoutEdges(org.cytoscape.model.CyNetwork network)
          Remove nodes that does not have any edge
 void run(org.cytoscape.work.TaskMonitor taskMonitor)
           
 
Methods inherited from class org.cytoscape.work.AbstractTask
cancel, insertTasksAfterCurrentTask, insertTasksAfterCurrentTask, setTaskIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

netFactory

protected org.cytoscape.model.CyNetworkFactory netFactory

viewFactory

protected org.cytoscape.view.model.CyNetworkViewFactory viewFactory

netMgr

protected org.cytoscape.model.CyNetworkManager netMgr

viewMgr

protected org.cytoscape.view.model.CyNetworkViewManager viewMgr

vmMgr

protected org.cytoscape.view.vizmap.VisualMappingManager vmMgr

nodeParents

protected Map<Integer,ArrayList<Integer>> nodeParents
This variable maps an integer representing a node/row with a list of integers that represents a list of parents for that node/row In oder to use it correctly, this variable needs to be initialized and a previous map between a node and its corresponding integer is also required


selectedOnly

protected final boolean selectedOnly
Indicates whether to apply the algorithm to all rows or only the selected rows.


nThreads

protected int nThreads
Indicates the maximum number of threads that this task can use

Constructor Detail

AbstractCyniTask

public AbstractCyniTask(String name,
                        AbstractCyniAlgorithmContext context,
                        org.cytoscape.model.CyNetworkFactory networkFactory,
                        org.cytoscape.view.model.CyNetworkViewFactory networkViewFactory,
                        org.cytoscape.model.CyNetworkManager networkManager,
                        org.cytoscape.view.model.CyNetworkViewManager networkViewManager,
                        org.cytoscape.model.CyNetworkTableManager netTableMgr,
                        org.cytoscape.model.subnetwork.CyRootNetworkManager rootNetMgr,
                        org.cytoscape.view.vizmap.VisualMappingManager visualMapperManager)
Constructor.

Parameters:
name - The name of the algorithm.
context - The context with the parameters to apply the algorithm
netTableMgr - The network table manager to generate a new network and its table
rootNetMgr - The root network manager to generate a new root network
Method Detail

run

public final void run(org.cytoscape.work.TaskMonitor taskMonitor)
Specified by:
run in interface org.cytoscape.work.Task
Specified by:
run in class org.cytoscape.work.AbstractTask

addColumns

protected void addColumns(org.cytoscape.model.CyNetwork origNet,
                          org.cytoscape.model.CyNetwork newNet,
                          org.cytoscape.model.CyTable origTable,
                          Class<? extends org.cytoscape.model.CyIdentifiable> tableType,
                          String namespace)
Add a column that belongs to a table associated to a network to a new table associated to a new network

Parameters:
origNet - The original network
newNet - The new network
origTable - The original table
tableType - The type of the table
namespace - The namespace of the table

addVirtualColumn

protected void addVirtualColumn(org.cytoscape.model.CyColumn col,
                                org.cytoscape.model.CyTable subTable)
Add a virtual column to a table

Parameters:
col - The column to add.
subTable - The CyTable to add the column.

copyColumn

protected void copyColumn(org.cytoscape.model.CyColumn col,
                          org.cytoscape.model.CyTable subTable)
Copy a column to a table

Parameters:
col - The column to copy
subTable - The CyTable to add the column.

cloneRow

protected void cloneRow(org.cytoscape.model.CyNetwork newNet,
                        Class<? extends org.cytoscape.model.CyIdentifiable> tableType,
                        org.cytoscape.model.CyRow from,
                        org.cytoscape.model.CyRow to)
Clone a row to be added to a new network

Parameters:
newNet - The new network.
tableType - The type of the table.
from - The source row
to - The target row

getNetworkAssociatedToTable

protected org.cytoscape.model.CyNetwork getNetworkAssociatedToTable(org.cytoscape.model.CyTable table)
Checks if the table is associated to a network, if so it return the associated network otherwise it returns null

Parameters:
table - The table to check
Returns:
null if no network is associated to the table or the network associated

removeNodesWithoutEdges

protected void removeNodesWithoutEdges(org.cytoscape.model.CyNetwork network)
Remove nodes that does not have any edge

Parameters:
network - The network to remove nodes

displayNewNetwork

protected org.cytoscape.view.model.CyNetworkView displayNewNetwork(org.cytoscape.model.CyNetwork newNetwork,
                                                                   org.cytoscape.model.CyNetwork oldNetwork,
                                                                   boolean directed)
This method displays the new network and return a network view that might be used to modify the display features such as the layout

Parameters:
newNetwork - The new network
oldNetwork - The old network in case we are using a table associated to a network otherwise it is a null
directed - Tells whether the new network is a directed graph or not
Returns:
the new network view

isGraphCyclic

public boolean isGraphCyclic(int nodeToCheck)
This method allows checking if there is a cycle in a graph starting from a defined node. It also uses the nodeParents variable so to make a good use of this function, the nodeParents variable needs to be previously initialized

Parameters:
nodeToCheck - The index corresponding to the starting node from where we want to check if there is a cycle in the graph
Returns:
True if the graph is cyclic or false if not or the nodeParents has not been initialized

doCyniTask

protected abstract void doCyniTask(org.cytoscape.work.TaskMonitor taskMonitor)
This method is designed to actually encapsulate the cyni algorithm. It will be called from within the run() method of the task.

Parameters:
taskMonitor - Provided to allow updates to the task status.


Copyright © 2013. All Rights Reserved.