*/
public void actionPerformed(ActionEvent event) {
resultFound = false;
CurrentParameters resultParaSet=null;
//get the network object, this contains the graph
final CyNetwork network = applicationManager.getCurrentNetwork();
final CyNetworkView networkView = this.applicationManager.getCurrentNetworkView();
ParameterSet currentParamsCopy = getMainPanel().getCurrentParamsCopy();
// curParams.setNetworkID(network.getSUID());
if (network == null) {
System.err.println("Can't get a network.");
return;
}
if (network.getNodeCount() < 1) {
JOptionPane.showMessageDialog(null/*Cytoscape.getDesktop()*/,
"Network has not been loaded!", "Error", JOptionPane.WARNING_MESSAGE);
return;
}
//get selected node
List<CyNode> nodes = network.getNodeList();
Set<Long> selectedNodes = new HashSet<Long>();
for (Iterator iterator = nodes.iterator(); iterator.hasNext();)
{
CyNode n = (CyNode)iterator.next();
if (((Boolean)network.getRow(n).get("selected", java.lang.Boolean.class)).booleanValue())
selectedNodes.add(n.getSUID());
}
// Set selectedNodes = network.getSelectedNodes();
Long[] selectedNodesRGI = new Long[selectedNodes.size()];
int c = 0;
for(Iterator i = selectedNodes.iterator(); i.hasNext();)
{
Long nodeID = (Long) i.next();
selectedNodesRGI[c++]=nodeID;
}
/* for (Iterator i = selectedNodes.iterator(); i.hasNext();) {
CyNode node = (CyNode) i.next();
selectedNodesRGI[c] = node.getSUID();
c++;
}*/
//notice, here we set the selected nodes
currentParamsCopy.setSelectedNodes(selectedNodesRGI);
Algorithm alg1 = null;
boolean newNet=isDirty(network);//judge new network
ParameterSet savedParamsCopy;
if (this.clusterUtil.containsNetworkAlgorithm(network.getSUID().longValue())) {
// alg1 = this.clusterUtil.getNetworkAlgorithm(network.getSUID().longValue());
savedParamsCopy = this.clusterUtil.getCurrentParameters().getParamsCopy(network.getSUID());
analyze=checkParams(currentParamsCopy, newNet);
} else {
//clusterUtil.getNetworkAlgorithm(network.getSUID().longValue())
savedParamsCopy = this.clusterUtil.getCurrentParameters().getParamsCopy(null);
this.analyze = 0;
}
if (analyze == INTERRUPTED || analyze == EXISTS)
JOptionPane.showMessageDialog(AnalyzeAction.this.swingApplication.getJFrame(),
interruptedMessage, "Interrupted", JOptionPane.WARNING_MESSAGE);
else{
final int resultId = this.clusterUtil.getCurrentResultId();
if ((this.analyze == 0) || (isDirty(network)) || (!currentParamsCopy.getAlgorithm().equals(savedParamsCopy.getAlgorithm())) ||
(currentParamsCopy.isIncludeLoops() != savedParamsCopy.isIncludeLoops()) ||
(currentParamsCopy.getDegreeCutoff() != savedParamsCopy.getDegreeCutoff())) {
this.analyze = 1;
// logger.debug("Analysis: score network, find clusters");
this.clusterUtil.getCurrentParameters().setParams(currentParamsCopy, resultId, network.getSUID());
} else if (!checkEqual(savedParamsCopy, currentParamsCopy)) {
this.analyze = 2;
// logger.debug("Analysis: find clusters");
this.clusterUtil.getCurrentParameters().setParams(currentParamsCopy, resultId, network.getSUID());
} else {
this.analyze = 3;
interruptedMessage = "The parameters you specified have not changed.";
this.clusterUtil.getCurrentParameters().setParams(currentParamsCopy, resultId, network.getSUID());
}
if(currentParamsCopy.getAlgorithm().equals(ParameterSet.MCODE ))
alg1 = new MCODE(network.getSUID(), this.clusterUtil);
if(currentParamsCopy.getAlgorithm().equals(ParameterSet.EAGLE ))
alg1 = new EAGLE(network.getSUID(), this.clusterUtil);
if(currentParamsCopy.getAlgorithm().equals(ParameterSet.FAGEC ))
alg1 = new FAGEC(network.getSUID(), this.clusterUtil);
this.clusterUtil.addNetworkAlgorithm(network.getSUID().longValue(), alg1);
/*
//if (!networkManager.containsKey(network.getIdentifier())){
newNet=true;
alg = curParams.getAlg();
//alg = new Algorithm(null);
networkManager.put(network.getSUID(), alg);
//}
//else alg = (Algorithm) networkManager.get(network.getIdentifier());
//check the validation the input parameters
analyze=checkParams(curParams, newNet);
resultId = this.clusterUtil.getCurrentResultId();
if (analyze == INTERRUPTED || analyze == EXISTS)
JOptionPane.showMessageDialog(nullCytoscape.getDesktop(),
interruptedMessage, "Interrupted", JOptionPane.WARNING_MESSAGE);
else{
//update the parameter set with this result title
clusterUtil.getCurrentParameters().setParams(curParams, (resultCounter + 1),
network.getSUID());*/
if ((currentParamsCopy.getScope().equals(ParameterSet.SELECTION)) &&
(currentParamsCopy.getSelectedNodes().length < 1)) {
this.analyze = 3;
interruptedMessage = "You must select ONE OR MORE NODES\nfor this scope.";
}
if (this.analyze == 3) {
JOptionPane.showMessageDialog(this.swingApplication.getJFrame(),
interruptedMessage,
"Analysis Interrupted",
2);
}
else {
final Algorithm alg2=alg1;
AnalysisCompletedListener listener = new AnalysisCompletedListener()
{
public void handleEvent(AnalysisCompletedEvent e)
{
ResultPanel resultsPanel = null;
boolean resultFound = false;
AnalyzeAction.this.setDirty(network, false);
if (e.isSuccessful()) {
if ((e.getClusters() != null) && (!e.getClusters().isEmpty())) {
// CyAttributes cyAttributes = Cytoscape.getNodeAttributes();
/*int length=0;
for(int i=0; i < e.getClusters().size(); i++){
Cluster c = (Cluster)e.getClusters().get(i);
CyNetwork clusterNetwork = c.getNetwork();
length = length + clusterNetwork.getNodeCount();
//length = length + complexes[i].getGPCluster().getNodeIndicesArray().length;
}
int[] clusteredNodes;
clusteredNodes = new int[length];
int index=0;
for(int i=0; i < e.getClusters().size(); i++){
Cluster c = (Cluster)e.getClusters().get(i);
CyNetwork clusterNetwork = c.getNetwork();
Iterator itr = clusterNetwork.getNodeList().iterator();
//Iterator itr = complexes[i].getGPCluster().nodesIterator();
while(itr.hasNext()){
CyNode node = (CyNode) itr.next();
System.out.println(node.getSUID());
CyRow nodeRow = clusterNetwork.getRow(node);
nodeRow.set("Cluster", Integer.valueOf(i) );
//cyAttributes.setAttribute(node.getSUID(), "Cluster", i);
}
}*/
resultFound = true;
AnalyzeAction.this.clusterUtil.addNetworkResult(network.getSUID().longValue());
DiscardResultAction discardResultAction = new DiscardResultAction(
"Discard Result",
resultId,
AnalyzeAction.this.applicationManager,