mev-4.0.01/source/org/tigr/microarray/mev/cluster/gui/impl/gsh/GSHGUI.java

Code
Comments
Other
Rev Date Author Line
2 26 Feb 07 jari 1 /*
2 26 Feb 07 jari 2 Copyright @ 1999-2004, The Institute for Genomic Research (TIGR).
2 26 Feb 07 jari 3 All rights reserved.
2 26 Feb 07 jari 4  */
2 26 Feb 07 jari 5 /*
2 26 Feb 07 jari 6  * $RCSfile: GSHGUI.java,v $
2 26 Feb 07 jari 7  * $Revision: 1.9 $
2 26 Feb 07 jari 8  * $Date: 2006/02/23 20:59:51 $
2 26 Feb 07 jari 9  * $Author: caliente $
2 26 Feb 07 jari 10  * $State: Exp $
2 26 Feb 07 jari 11  */
2 26 Feb 07 jari 12 package org.tigr.microarray.mev.cluster.gui.impl.gsh;
2 26 Feb 07 jari 13
2 26 Feb 07 jari 14 import java.awt.event.ActionEvent;
2 26 Feb 07 jari 15 import java.awt.event.WindowEvent;
2 26 Feb 07 jari 16 import java.util.Arrays;
2 26 Feb 07 jari 17
2 26 Feb 07 jari 18 import javax.swing.JOptionPane;
2 26 Feb 07 jari 19 import javax.swing.tree.DefaultMutableTreeNode;
2 26 Feb 07 jari 20
2 26 Feb 07 jari 21 import org.tigr.microarray.mev.cluster.Cluster;
2 26 Feb 07 jari 22 import org.tigr.microarray.mev.cluster.Node;
2 26 Feb 07 jari 23 import org.tigr.microarray.mev.cluster.NodeList;
2 26 Feb 07 jari 24 import org.tigr.microarray.mev.cluster.NodeValueList;
2 26 Feb 07 jari 25 import org.tigr.microarray.mev.cluster.algorithm.Algorithm;
2 26 Feb 07 jari 26 import org.tigr.microarray.mev.cluster.algorithm.AlgorithmData;
2 26 Feb 07 jari 27 import org.tigr.microarray.mev.cluster.algorithm.AlgorithmEvent;
2 26 Feb 07 jari 28 import org.tigr.microarray.mev.cluster.algorithm.AlgorithmException;
2 26 Feb 07 jari 29 import org.tigr.microarray.mev.cluster.algorithm.AlgorithmListener;
2 26 Feb 07 jari 30 import org.tigr.microarray.mev.cluster.algorithm.AlgorithmParameters;
2 26 Feb 07 jari 31 import org.tigr.microarray.mev.cluster.gui.Experiment;
2 26 Feb 07 jari 32 import org.tigr.microarray.mev.cluster.gui.IClusterGUI;
2 26 Feb 07 jari 33 import org.tigr.microarray.mev.cluster.gui.IData;
2 26 Feb 07 jari 34 import org.tigr.microarray.mev.cluster.gui.IDistanceMenu;
2 26 Feb 07 jari 35 import org.tigr.microarray.mev.cluster.gui.IFramework;
2 26 Feb 07 jari 36 import org.tigr.microarray.mev.cluster.gui.IViewer;
2 26 Feb 07 jari 37 import org.tigr.microarray.mev.cluster.gui.LeafInfo;
2 26 Feb 07 jari 38 import org.tigr.microarray.mev.cluster.gui.helpers.CentroidUserObject;
2 26 Feb 07 jari 39 import org.tigr.microarray.mev.cluster.gui.helpers.ClusterTableViewer;
2 26 Feb 07 jari 40 import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentClusterTableViewer;
2 26 Feb 07 jari 41 import org.tigr.microarray.mev.cluster.gui.impl.dialogs.DialogListener;
2 26 Feb 07 jari 42 import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLGUI;
2 26 Feb 07 jari 43 import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLInitDialog;
2 26 Feb 07 jari 44 import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLTreeData;
2 26 Feb 07 jari 45 import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLViewer;
2 26 Feb 07 jari 46 import org.tigr.microarray.mev.script.scriptGUI.IScriptGUI;
2 26 Feb 07 jari 47 import org.tigr.util.FloatMatrix;
2 26 Feb 07 jari 48
2 26 Feb 07 jari 49 public class GSHGUI implements IClusterGUI, IScriptGUI {
2 26 Feb 07 jari 50     
2 26 Feb 07 jari 51     private Algorithm algorithm;
2 26 Feb 07 jari 52     private IData data;
2 26 Feb 07 jari 53     private Experiment experiment;
2 26 Feb 07 jari 54     private int[][] clusters;
2 26 Feb 07 jari 55     private FloatMatrix means;
2 26 Feb 07 jari 56     private FloatMatrix variances;
2 26 Feb 07 jari 57     private boolean clusterGenes;
2 26 Feb 07 jari 58     
2 26 Feb 07 jari 59     /**
2 26 Feb 07 jari 60      * Default constructor.
2 26 Feb 07 jari 61      */
2 26 Feb 07 jari 62     public GSHGUI() {
2 26 Feb 07 jari 63     }
2 26 Feb 07 jari 64     
2 26 Feb 07 jari 65     /**
2 26 Feb 07 jari 66      * Initialize the algorithm's parameters and execute it.
2 26 Feb 07 jari 67      */
2 26 Feb 07 jari 68     public DefaultMutableTreeNode execute(IFramework framework) throws AlgorithmException {
2 26 Feb 07 jari 69         this.data = framework.getData();
2 26 Feb 07 jari 70          
2 26 Feb 07 jari 71         IDistanceMenu menu = framework.getDistanceMenu();
2 26 Feb 07 jari 72         int function = menu.getDistanceFunction();        
2 26 Feb 07 jari 73         if (function == Algorithm.DEFAULT) {        
2 26 Feb 07 jari 74             function = Algorithm.EUCLIDEAN;            
2 26 Feb 07 jari 75         }
2 26 Feb 07 jari 76         
2 26 Feb 07 jari 77         // the default values
2 26 Feb 07 jari 78         int k = 10;
2 26 Feb 07 jari 79         int f = 20;
2 26 Feb 07 jari 80         int s = 5;
2 26 Feb 07 jari 81         
2 26 Feb 07 jari 82         GSHInitDialog gsh_dialog = new GSHInitDialog(framework.getFrame(), k, f, s);
2 26 Feb 07 jari 83         if (gsh_dialog.showModal() != JOptionPane.OK_OPTION) {
2 26 Feb 07 jari 84             return null;
2 26 Feb 07 jari 85         }
2 26 Feb 07 jari 86         k = gsh_dialog.getClusters();
2 26 Feb 07 jari 87         f = gsh_dialog.getFM();
2 26 Feb 07 jari 88         s = gsh_dialog.getST();
2 26 Feb 07 jari 89         clusterGenes = gsh_dialog.isClusterGenesSelected();
2 26 Feb 07 jari 90         if (k < 1) {
2 26 Feb 07 jari 91             JOptionPane.showMessageDialog(framework.getFrame(), "Number of clusters must be greater than 0!", "Error", JOptionPane.ERROR_MESSAGE);
2 26 Feb 07 jari 92             return null;
2 26 Feb 07 jari 93         }
2 26 Feb 07 jari 94         if (f < 1) {
2 26 Feb 07 jari 95             JOptionPane.showMessageDialog(framework.getFrame(), "Number of faked matrix must be greater than 0!", "Error", JOptionPane.ERROR_MESSAGE);
2 26 Feb 07 jari 96             return null;
2 26 Feb 07 jari 97         }
2 26 Feb 07 jari 98         if (s < 1) {
2 26 Feb 07 jari 99             JOptionPane.showMessageDialog(framework.getFrame(), "Number of swap must be greater than 0!", "Error", JOptionPane.ERROR_MESSAGE);
2 26 Feb 07 jari 100             return null;
2 26 Feb 07 jari 101         }
2 26 Feb 07 jari 102         boolean isHierarchicalTree = gsh_dialog.isHierarchicalTree();
2 26 Feb 07 jari 103         // hcl init
2 26 Feb 07 jari 104         int hcl_method = 0;
2 26 Feb 07 jari 105         boolean hcl_samples = false;
2 26 Feb 07 jari 106         boolean hcl_genes = false;
2 26 Feb 07 jari 107         int hcl_function = 4;
2 26 Feb 07 jari 108         boolean hcl_absolute = false;
2 26 Feb 07 jari 109         if (isHierarchicalTree) {
2 26 Feb 07 jari 110             
2 26 Feb 07 jari 111             HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(menu.getDistanceFunction()), menu.isAbsoluteDistance(), true);
2 26 Feb 07 jari 112             if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) {
2 26 Feb 07 jari 113                 return null;
2 26 Feb 07 jari 114             }
2 26 Feb 07 jari 115             hcl_method = hcl_dialog.getMethod();
2 26 Feb 07 jari 116             hcl_samples = hcl_dialog.isClusterExperiments();
2 26 Feb 07 jari 117             hcl_genes = hcl_dialog.isClusterGenes();
2 26 Feb 07 jari 118             hcl_function = hcl_dialog.getDistanceMetric();
2 26 Feb 07 jari 119             hcl_absolute = hcl_dialog.getAbsoluteSelection();
2 26 Feb 07 jari 120         }
2 26 Feb 07 jari 121         
2 26 Feb 07 jari 122         this.experiment = framework.getData().getExperiment();
2 26 Feb 07 jari 123         Listener listener = new Listener();
2 26 Feb 07 jari 124         try {
2 26 Feb 07 jari 125             algorithm = framework.getAlgorithmFactory().getAlgorithm("GSH");
2 26 Feb 07 jari 126             algorithm.addAlgorithmListener(listener);
2 26 Feb 07 jari 127             
2 26 Feb 07 jari 128             int genes = experiment.getNumberOfGenes();
2 26 Feb 07 jari 129             
2 26 Feb 07 jari 130             AlgorithmData data = new AlgorithmData();
2 26 Feb 07 jari 131             FloatMatrix matrix = experiment.getMatrix();
2 26 Feb 07 jari 132             if(!clusterGenes)
2 26 Feb 07 jari 133                 matrix = matrix.transpose();
2 26 Feb 07 jari 134             
2 26 Feb 07 jari 135             data.addMatrix("experiment", matrix);
2 26 Feb 07 jari 136             data.addParam("distance-factor", String.valueOf(1.0f));
2 26 Feb 07 jari 137
2 26 Feb 07 jari 138             data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance()));
2 26 Feb 07 jari 139             data.addParam("gsh-cluster-genes", String.valueOf(this.clusterGenes));
2 26 Feb 07 jari 140
2 26 Feb 07 jari 141             data.addParam("distance-function", String.valueOf(function));
2 26 Feb 07 jari 142             data.addParam("number-of-clusters", String.valueOf(k));
2 26 Feb 07 jari 143             data.addParam("number-of-fakedMatrix", String.valueOf(f));
2 26 Feb 07 jari 144             data.addParam("number-of-swap", String.valueOf(s));
2 26 Feb 07 jari 145             // hcl parameters
2 26 Feb 07 jari 146             if (isHierarchicalTree) {
2 26 Feb 07 jari 147                 data.addParam("hierarchical-tree", String.valueOf(true));
2 26 Feb 07 jari 148                 data.addParam("method-linkage", String.valueOf(hcl_method));
2 26 Feb 07 jari 149                 data.addParam("calculate-genes", String.valueOf(hcl_genes));
2 26 Feb 07 jari 150                 data.addParam("calculate-experiments", String.valueOf(hcl_samples));
2 26 Feb 07 jari 151                 data.addParam("hcl-distance-function", String.valueOf(hcl_function));
2 26 Feb 07 jari 152                 data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute));
2 26 Feb 07 jari 153             }
2 26 Feb 07 jari 154             
2 26 Feb 07 jari 155             long start = System.currentTimeMillis();
2 26 Feb 07 jari 156             AlgorithmData result = algorithm.execute(data);
2 26 Feb 07 jari 157             long time = System.currentTimeMillis() - start;
2 26 Feb 07 jari 158             // getting the results
2 26 Feb 07 jari 159             Cluster result_cluster = result.getCluster("cluster");
2 26 Feb 07 jari 160             NodeList nodeList = result_cluster.getNodeList();
2 26 Feb 07 jari 161             
2 26 Feb 07 jari 162             AlgorithmParameters resultMap = result.getParams();
2 26 Feb 07 jari 163             k = resultMap.getInt("number-of-clusters"); // NEED THIS TO GET THE VALUE OF NUMBER-OF-CLUSTERS
2 26 Feb 07 jari 164             
2 26 Feb 07 jari 165             this.clusters = new int[k][];
2 26 Feb 07 jari 166             for (int i=0; i<k; i++) {
2 26 Feb 07 jari 167                 clusters[i] = nodeList.getNode(i).getFeaturesIndexes();
2 26 Feb 07 jari 168             }
2 26 Feb 07 jari 169             this.means = result.getMatrix("clusters-means");
2 26 Feb 07 jari 170             this.variances = result.getMatrix("clusters-variances");
2 26 Feb 07 jari 171             
2 26 Feb 07 jari 172             GeneralInfo info = new GeneralInfo();
2 26 Feb 07 jari 173             info.clusters = k;
2 26 Feb 07 jari 174             info.time = time;
2 26 Feb 07 jari 175             info.FM = f;
2 26 Feb 07 jari 176             info.ST = s;
2 26 Feb 07 jari 177             info.function = menu.getFunctionName(function);
2 26 Feb 07 jari 178             info.hcl = isHierarchicalTree;
2 26 Feb 07 jari 179             info.hcl_genes = hcl_genes;
2 26 Feb 07 jari 180             info.hcl_samples = hcl_samples;
2 26 Feb 07 jari 181             info.hcl_method = hcl_method;
2 26 Feb 07 jari 182             return createResultTree(result_cluster, info);
2 26 Feb 07 jari 183             
2 26 Feb 07 jari 184         } finally {
2 26 Feb 07 jari 185             if (algorithm != null) {
2 26 Feb 07 jari 186                 algorithm.removeAlgorithmListener(listener);
2 26 Feb 07 jari 187             }
2 26 Feb 07 jari 188         }
2 26 Feb 07 jari 189     }
2 26 Feb 07 jari 190     
2 26 Feb 07 jari 191     
2 26 Feb 07 jari 192     
2 26 Feb 07 jari 193     public AlgorithmData getScriptParameters(IFramework framework) {
2 26 Feb 07 jari 194         this.data = framework.getData();
2 26 Feb 07 jari 195         // the default values
2 26 Feb 07 jari 196         int k = 10;
2 26 Feb 07 jari 197         int f = 20;
2 26 Feb 07 jari 198         int s = 5;
2 26 Feb 07 jari 199
2 26 Feb 07 jari 200         IDistanceMenu menu = framework.getDistanceMenu();
2 26 Feb 07 jari 201         int function = menu.getDistanceFunction();        
2 26 Feb 07 jari 202         if (function == Algorithm.DEFAULT) {        
2 26 Feb 07 jari 203             function = Algorithm.EUCLIDEAN;            
2 26 Feb 07 jari 204         }        
2 26 Feb 07 jari 205                 
2 26 Feb 07 jari 206         GSHInitDialog gsh_dialog = new GSHInitDialog(framework.getFrame(), k, f, s);
2 26 Feb 07 jari 207         if (gsh_dialog.showModal() != JOptionPane.OK_OPTION) {
2 26 Feb 07 jari 208             return null;
2 26 Feb 07 jari 209         }
2 26 Feb 07 jari 210         k = gsh_dialog.getClusters();
2 26 Feb 07 jari 211         f = gsh_dialog.getFM();
2 26 Feb 07 jari 212         s = gsh_dialog.getST();
2 26 Feb 07 jari 213         clusterGenes = gsh_dialog.isClusterGenesSelected();
2 26 Feb 07 jari 214         if (k < 1) {
2 26 Feb 07 jari 215             JOptionPane.showMessageDialog(framework.getFrame(), "Number of clusters must be greater than 0!", "Error", JOptionPane.ERROR_MESSAGE);
2 26 Feb 07 jari 216             return null;
2 26 Feb 07 jari 217         }
2 26 Feb 07 jari 218         if (f < 1) {
2 26 Feb 07 jari 219             JOptionPane.showMessageDialog(framework.getFrame(), "Number of faked matrix must be greater than 0!", "Error", JOptionPane.ERROR_MESSAGE);
2 26 Feb 07 jari 220             return null;
2 26 Feb 07 jari 221         }
2 26 Feb 07 jari 222         if (s < 1) {
2 26 Feb 07 jari 223             JOptionPane.showMessageDialog(framework.getFrame(), "Number of swap must be greater than 0!", "Error", JOptionPane.ERROR_MESSAGE);
2 26 Feb 07 jari 224             return null;
2 26 Feb 07 jari 225         }
2 26 Feb 07 jari 226         boolean isHierarchicalTree = gsh_dialog.isHierarchicalTree();
2 26 Feb 07 jari 227         // hcl init
2 26 Feb 07 jari 228         int hcl_method = 0;
2 26 Feb 07 jari 229         boolean hcl_samples = false;
2 26 Feb 07 jari 230         boolean hcl_genes = false;
2 26 Feb 07 jari 231         int hcl_function = 4;
2 26 Feb 07 jari 232         boolean hcl_absolute = false;
2 26 Feb 07 jari 233         if (isHierarchicalTree) {
2 26 Feb 07 jari 234             
2 26 Feb 07 jari 235             HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(menu.getDistanceFunction()), menu.isAbsoluteDistance(), true);           
2 26 Feb 07 jari 236             if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) {
2 26 Feb 07 jari 237                 return null;
2 26 Feb 07 jari 238             }
2 26 Feb 07 jari 239             hcl_method = hcl_dialog.getMethod();
2 26 Feb 07 jari 240             hcl_samples = hcl_dialog.isClusterExperiments();
2 26 Feb 07 jari 241             hcl_genes = hcl_dialog.isClusterGenes();
2 26 Feb 07 jari 242             hcl_function = hcl_dialog.getDistanceMetric();
2 26 Feb 07 jari 243             hcl_absolute = hcl_dialog.getAbsoluteSelection();
2 26 Feb 07 jari 244         }
2 26 Feb 07 jari 245         
2 26 Feb 07 jari 246         this.experiment = framework.getData().getExperiment();
2 26 Feb 07 jari 247         Listener listener = new Listener();
2 26 Feb 07 jari 248
2 26 Feb 07 jari 249         int genes = experiment.getNumberOfGenes();
2 26 Feb 07 jari 250         
2 26 Feb 07 jari 251         AlgorithmData data = new AlgorithmData();
2 26 Feb 07 jari 252         data.addParam("distance-factor", String.valueOf(1.0f));
2 26 Feb 07 jari 253
2 26 Feb 07 jari 254         data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance()));
2 26 Feb 07 jari 255         data.addParam("gsh-cluster-genes", String.valueOf(this.clusterGenes));
2 26 Feb 07 jari 256         
2 26 Feb 07 jari 257         data.addParam("distance-function", String.valueOf(function));
2 26 Feb 07 jari 258         data.addParam("number-of-clusters", String.valueOf(k));
2 26 Feb 07 jari 259         data.addParam("number-of-fakedMatrix", String.valueOf(f));
2 26 Feb 07 jari 260         data.addParam("number-of-swap", String.valueOf(s));
2 26 Feb 07 jari 261         // hcl parameters
2 26 Feb 07 jari 262         if (isHierarchicalTree) {
2 26 Feb 07 jari 263             data.addParam("hierarchical-tree", String.valueOf(true));
2 26 Feb 07 jari 264             data.addParam("method-linkage", String.valueOf(hcl_method));
2 26 Feb 07 jari 265             data.addParam("calculate-genes", String.valueOf(hcl_genes));
2 26 Feb 07 jari 266             data.addParam("calculate-experiments", String.valueOf(hcl_samples));
2 26 Feb 07 jari 267             data.addParam("hcl-distance-function", String.valueOf(hcl_function));
2 26 Feb 07 jari 268             data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute));
2 26 Feb 07 jari 269         }
2 26 Feb 07 jari 270         
2 26 Feb 07 jari 271         //script control parameters
2 26 Feb 07 jari 272         
2 26 Feb 07 jari 273         // alg name
2 26 Feb 07 jari 274         data.addParam("name", "GSH");
2 26 Feb 07 jari 275         
2 26 Feb 07 jari 276         // alg type
2 26 Feb 07 jari 277         if(clusterGenes)
2 26 Feb 07 jari 278             data.addParam("alg-type", "cluster-genes");
2 26 Feb 07 jari 279         else
2 26 Feb 07 jari 280             data.addParam("alg-type", "cluster-experiments");
2 26 Feb 07 jari 281         
2 26 Feb 07 jari 282         // output class
2 26 Feb 07 jari 283         if(clusterGenes)
2 26 Feb 07 jari 284             data.addParam("output-class", "multi-gene-cluster-output");
2 26 Feb 07 jari 285         else
2 26 Feb 07 jari 286             data.addParam("output-class", "multi-experiment-cluster-output");
2 26 Feb 07 jari 287         
2 26 Feb 07 jari 288         //output nodes
2 26 Feb 07 jari 289         String [] outputNodes = new String[1];
2 26 Feb 07 jari 290         outputNodes[0] = "Multi-cluster";
2 26 Feb 07 jari 291         data.addStringArray("output-nodes", outputNodes);
2 26 Feb 07 jari 292         
2 26 Feb 07 jari 293         return data;
2 26 Feb 07 jari 294     }
2 26 Feb 07 jari 295     
2 26 Feb 07 jari 296     
2 26 Feb 07 jari 297     public DefaultMutableTreeNode executeScript(IFramework framework, AlgorithmData algData, Experiment experiment) throws AlgorithmException {
2 26 Feb 07 jari 298         this.data = framework.getData();
2 26 Feb 07 jari 299         this.experiment = experiment;
2 26 Feb 07 jari 300         
2 26 Feb 07 jari 301         this.clusterGenes = algData.getParams().getBoolean("gsh-cluster-genes");
2 26 Feb 07 jari 302         
2 26 Feb 07 jari 303         Listener listener = new Listener();
2 26 Feb 07 jari 304         try {
2 26 Feb 07 jari 305             
2 26 Feb 07 jari 306             FloatMatrix matrix = experiment.getMatrix();
2 26 Feb 07 jari 307             if(!clusterGenes)
2 26 Feb 07 jari 308                 matrix = matrix.transpose();
2 26 Feb 07 jari 309             algData.addMatrix("experiment", matrix);
2 26 Feb 07 jari 310             
2 26 Feb 07 jari 311             algorithm = framework.getAlgorithmFactory().getAlgorithm("GSH");
2 26 Feb 07 jari 312             algorithm.addAlgorithmListener(listener);
2 26 Feb 07 jari 313             int genes = experiment.getNumberOfGenes();            
2 26 Feb 07 jari 314             
2 26 Feb 07 jari 315             long start = System.currentTimeMillis();
2 26 Feb 07 jari 316             AlgorithmData result = algorithm.execute(algData);
2 26 Feb 07 jari 317             long time = System.currentTimeMillis() - start;
2 26 Feb 07 jari 318             // getting the results
2 26 Feb 07 jari 319             Cluster result_cluster = result.getCluster("cluster");
2 26 Feb 07 jari 320             NodeList nodeList = result_cluster.getNodeList();
2 26 Feb 07 jari 321             
2 26 Feb 07 jari 322             AlgorithmParameters resultMap = result.getParams();
2 26 Feb 07 jari 323             int k = resultMap.getInt("number-of-clusters"); // NEED THIS TO GET THE VALUE OF NUMBER-OF-CLUSTERS
2 26 Feb 07 jari 324             
2 26 Feb 07 jari 325             this.clusters = new int[k][];
2 26 Feb 07 jari 326             for (int i=0; i<k; i++) {
2 26 Feb 07 jari 327                 clusters[i] = nodeList.getNode(i).getFeaturesIndexes();
2 26 Feb 07 jari 328             }
2 26 Feb 07 jari 329             this.means = result.getMatrix("clusters-means");
2 26 Feb 07 jari 330             this.variances = result.getMatrix("clusters-variances");
2 26 Feb 07 jari 331             
2 26 Feb 07 jari 332             AlgorithmParameters params = algData.getParams();
2 26 Feb 07 jari 333             
2 26 Feb 07 jari 334             GeneralInfo info = new GeneralInfo();
2 26 Feb 07 jari 335             info.clusters = k;
2 26 Feb 07 jari 336             info.time = time;
2 26 Feb 07 jari 337             info.FM = params.getInt("number-of-fakedMatrix");
2 26 Feb 07 jari 338             info.ST = params.getInt("number-of-swap");
2 26 Feb 07 jari 339             int function = params.getInt("distance-function");
2 26 Feb 07 jari 340             info.function = framework.getDistanceMenu().getFunctionName(function);
2 26 Feb 07 jari 341             info.hcl = params.getBoolean("hierarchical-tree");
2 26 Feb 07 jari 342             info.hcl_genes = params.getBoolean("calculate-genes");
2 26 Feb 07 jari 343             info.hcl_samples = params.getBoolean("calculate-experiments");
2 26 Feb 07 jari 344             if(info.hcl)
2 26 Feb 07 jari 345                 info.hcl_method = params.getInt("method-linkage");
2 26 Feb 07 jari 346             
2 26 Feb 07 jari 347             return createResultTree(result_cluster, info);
2 26 Feb 07 jari 348             
2 26 Feb 07 jari 349         } finally {
2 26 Feb 07 jari 350             if (algorithm != null) {
2 26 Feb 07 jari 351                 algorithm.removeAlgorithmListener(listener);
2 26 Feb 07 jari 352             }
2 26 Feb 07 jari 353         }
2 26 Feb 07 jari 354         
2 26 Feb 07 jari 355     }
2 26 Feb 07 jari 356     
2 26 Feb 07 jari 357     
2 26 Feb 07 jari 358     /**
2 26 Feb 07 jari 359      * Creates a result tree to be inserted into the framework analysis node.
2 26 Feb 07 jari 360      */
2 26 Feb 07 jari 361     private DefaultMutableTreeNode createResultTree(Cluster result_cluster, GeneralInfo info) {
2 26 Feb 07 jari 362         DefaultMutableTreeNode root;
2 26 Feb 07 jari 363         if(this.clusterGenes)
2 26 Feb 07 jari 364             root = new DefaultMutableTreeNode("GSH - genes");
2 26 Feb 07 jari 365         else
2 26 Feb 07 jari 366             root = new DefaultMutableTreeNode("GSH - samples");
2 26 Feb 07 jari 367         addResultNodes(root, result_cluster, info);
2 26 Feb 07 jari 368         return root;
2 26 Feb 07 jari 369     }
2 26 Feb 07 jari 370     
2 26 Feb 07 jari 371     /**
2 26 Feb 07 jari 372      * Adds result nodes into the tree root.
2 26 Feb 07 jari 373      */
2 26 Feb 07 jari 374     private void addResultNodes(DefaultMutableTreeNode root, Cluster result_cluster, GeneralInfo info) {
2 26 Feb 07 jari 375         addExpressionImages(root);
2 26 Feb 07 jari 376         addHierarchicalTrees(root, result_cluster, info);
2 26 Feb 07 jari 377         addCentroidViews(root);
2 26 Feb 07 jari 378         addTableViews(root);
2 26 Feb 07 jari 379         addClusterInfo(root);
2 26 Feb 07 jari 380         addGeneralInfo(root, info);
2 26 Feb 07 jari 381     }
2 26 Feb 07 jari 382     
2 26 Feb 07 jari 383     private void addTableViews(DefaultMutableTreeNode root) {
2 26 Feb 07 jari 384         DefaultMutableTreeNode node = new DefaultMutableTreeNode("Table views");
2 26 Feb 07 jari 385         IViewer tabViewer;
2 26 Feb 07 jari 386         int i;
2 26 Feb 07 jari 387         
2 26 Feb 07 jari 388         if(clusterGenes)
2 26 Feb 07 jari 389             tabViewer = new ClusterTableViewer(this.experiment, this.clusters, this.data);
2 26 Feb 07 jari 390         else
2 26 Feb 07 jari 391             tabViewer = new ExperimentClusterTableViewer(this.experiment, this.clusters, this.data);
2 26 Feb 07 jari 392         //return; // placeholder for ExptClusterTableViewer
2 26 Feb 07 jari 393         //expViewer = new GSHExperimentClusterViewer(this.experiment, this.clusters);
2 26 Feb 07 jari 394         
2 26 Feb 07 jari 395         for (i=0; i<this.clusters.length-1; i++) {
2 26 Feb 07 jari 396             node.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), tabViewer, new Integer(i))));
2 26 Feb 07 jari 397         }
2 26 Feb 07 jari 398         //if(clusterGenes)
2 26 Feb 07 jari 399         node.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned ", tabViewer, new Integer(i))));
2 26 Feb 07 jari 400         //else
2 26 Feb 07 jari 401         //node.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Experiments", expViewer, new Integer(i))));
2 26 Feb 07 jari 402         
2 26 Feb 07 jari 403         root.add(node);
2 26 Feb 07 jari 404     }
2 26 Feb 07 jari 405     
2 26 Feb 07 jari 406     /**
2 26 Feb 07 jari 407      * Adds nodes to display clusters data.
2 26 Feb 07 jari 408      */
2 26 Feb 07 jari 409     private void addExpressionImages(DefaultMutableTreeNode root) {
2 26 Feb 07 jari 410         DefaultMutableTreeNode node = new DefaultMutableTreeNode("Expression Images");
2 26 Feb 07 jari 411         IViewer expViewer;
2 26 Feb 07 jari 412         int i;
2 26 Feb 07 jari 413         
2 26 Feb 07 jari 414         if(clusterGenes)
2 26 Feb 07 jari 415             expViewer = new GSHExperimentViewer(this.experiment, this.clusters);
2 26 Feb 07 jari 416         else
2 26 Feb 07 jari 417             expViewer = new GSHExperimentClusterViewer(this.experiment, this.clusters);
2 26 Feb 07 jari 418         
2 26 Feb 07 jari 419         for (i=0; i<this.clusters.length-1; i++) {
2 26 Feb 07 jari 420             node.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expViewer, new Integer(i))));
2 26 Feb 07 jari 421         }
2 26 Feb 07 jari 422         if(clusterGenes)
2 26 Feb 07 jari 423             node.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Genes", expViewer, new Integer(i))));
2 26 Feb 07 jari 424         else
2 26 Feb 07 jari 425             node.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Experiments", expViewer, new Integer(i))));
2 26 Feb 07 jari 426         
2 26 Feb 07 jari 427         root.add(node);
2 26 Feb 07 jari 428     }
2 26 Feb 07 jari 429     
2 26 Feb 07 jari 430     
2 26 Feb 07 jari 431     
2 26 Feb 07 jari 432     /**
2 26 Feb 07 jari 433      * Adds nodes to display hierarchical trees.
2 26 Feb 07 jari 434      */
2 26 Feb 07 jari 435     private void addHierarchicalTrees(DefaultMutableTreeNode root, Cluster result_cluster, GeneralInfo info) {
2 26 Feb 07 jari 436         if (!info.hcl) {
2 26 Feb 07 jari 437             return;
2 26 Feb 07 jari 438         }
2 26 Feb 07 jari 439         DefaultMutableTreeNode node = new DefaultMutableTreeNode("Hierarchical Trees");
2 26 Feb 07 jari 440         NodeList nodeList = result_cluster.getNodeList();
2 26 Feb 07 jari 441         int [][] clusters = null;
2 26 Feb 07 jari 442         int k = this.clusters.length;
2 26 Feb 07 jari 443         
2 26 Feb 07 jari 444         if(!this.clusterGenes){
2 26 Feb 07 jari 445             clusters = new int[k][];
2 26 Feb 07 jari 446             for (int i=0; i<k; i++) {
2 26 Feb 07 jari 447                 clusters[i] = nodeList.getNode(i).getFeaturesIndexes();
2 26 Feb 07 jari 448             }
2 26 Feb 07 jari 449             if(info.hcl_samples)
2 26 Feb 07 jari 450                 clusters = getOrderedIndices(nodeList, clusters, info.hcl_genes);
2 26 Feb 07 jari 451         }
2 26 Feb 07 jari 452         for (int i=0; i<nodeList.getSize()-1; i++) {
2 26 Feb 07 jari 453             if(this.clusterGenes)
2 26 Feb 07 jari 454                 node.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), createHCLViewer(nodeList.getNode(i), info, null))));
2 26 Feb 07 jari 455             else
2 26 Feb 07 jari 456                 node.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), createHCLViewer(nodeList.getNode(i), info, clusters), new Integer(i))));
2 26 Feb 07 jari 457         }
2 26 Feb 07 jari 458         if(this.clusterGenes)
2 26 Feb 07 jari 459             node.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Genes", createHCLViewer(nodeList.getNode(nodeList.getSize()-1), info, null))));
2 26 Feb 07 jari 460         else
2 26 Feb 07 jari 461             node.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Experiments", createHCLViewer(nodeList.getNode(nodeList.getSize()-1), info, clusters), new Integer(nodeList.getSize()-1))));
2 26 Feb 07 jari 462         
2 26 Feb 07 jari 463         
2 26 Feb 07 jari 464         root.add(node);
2 26 Feb 07 jari 465     }
2 26 Feb 07 jari 466     
2 26 Feb 07 jari 467     /**
2 26 Feb 07 jari 468      * Creates an <code>HCLViewer</code>.
2 26 Feb 07 jari 469      */
2 26 Feb 07 jari 470     private IViewer createHCLViewer(Node clusterNode, GeneralInfo info, int [][] sampleClusters) {
2 26 Feb 07 jari 471         HCLTreeData genes_result = info.hcl_genes ? getResult(clusterNode, 0) : null;
2 26 Feb 07 jari 472         HCLTreeData samples_result = info.hcl_samples ? getResult(clusterNode, info.hcl_genes ? 4 : 0) : null;
2 26 Feb 07 jari 473         if(this.clusterGenes)
2 26 Feb 07 jari 474             return new HCLViewer(this.experiment, clusterNode.getFeaturesIndexes(), genes_result, samples_result);
2 26 Feb 07 jari 475         else
2 26 Feb 07 jari 476             return new HCLViewer(this.experiment, clusterNode.getFeaturesIndexes(), genes_result, samples_result, sampleClusters, true);
2 26 Feb 07 jari 477     }
2 26 Feb 07 jari 478     
2 26 Feb 07 jari 479     /**
2 26 Feb 07 jari 480      * Returns a hcl tree data from the specified cluster node.
2 26 Feb 07 jari 481      */
2 26 Feb 07 jari 482     private HCLTreeData getResult(Node clusterNode, int pos) {
2 26 Feb 07 jari 483         HCLTreeData data = new HCLTreeData();
2 26 Feb 07 jari 484         NodeValueList valueList = clusterNode.getValues();
2 26 Feb 07 jari 485         data.child_1_array = (int[])valueList.getNodeValue(pos).value;
2 26 Feb 07 jari 486         data.child_2_array = (int[])valueList.getNodeValue(pos+1).value;
2 26 Feb 07 jari 487         data.node_order = (int[])valueList.getNodeValue(pos+2).value;
2 26 Feb 07 jari 488         data.height = (float[])valueList.getNodeValue(pos+3).value;
2 26 Feb 07 jari 489         return data;
2 26 Feb 07 jari 490     }
2 26 Feb 07 jari 491     
2 26 Feb 07 jari 492     /**
2 26 Feb 07 jari 493      * Adds node with cluster information.
2 26 Feb 07 jari 494      */
2 26 Feb 07 jari 495     private void addClusterInfo(DefaultMutableTreeNode root) {
2 26 Feb 07 jari 496         DefaultMutableTreeNode node = new DefaultMutableTreeNode("Cluster Information");
2 26 Feb 07 jari 497         if(this.clusterGenes)
2 26 Feb 07 jari 498             node.add(new DefaultMutableTreeNode(new LeafInfo("Genes in Clusters (#,%)", new GSHInfoViewer(this.clusters, this.experiment.getNumberOfGenes()))));
2 26 Feb 07 jari 499         else
2 26 Feb 07 jari 500             node.add(new DefaultMutableTreeNode(new LeafInfo("Samples in Clusters (#,%)", new GSHInfoViewer(this.clusters, this.experiment.getNumberOfSamples(), false))));
2 26 Feb 07 jari 501         root.add(node);
2 26 Feb 07 jari 502     }
2 26 Feb 07 jari 503     
2 26 Feb 07 jari 504     /**
2 26 Feb 07 jari 505      * Adds nodes to display centroid charts.
2 26 Feb 07 jari 506      */
2 26 Feb 07 jari 507     private void addCentroidViews(DefaultMutableTreeNode root) {
2 26 Feb 07 jari 508         DefaultMutableTreeNode centroidNode = new DefaultMutableTreeNode("Centroid Graphs");
2 26 Feb 07 jari 509         DefaultMutableTreeNode expressionNode = new DefaultMutableTreeNode("Expression Graphs");
2 26 Feb 07 jari 510         
2 26 Feb 07 jari 511         GSHCentroidViewer centroidViewer;
2 26 Feb 07 jari 512         GSHExperimentCentroidViewer expCentroidViewer;
2 26 Feb 07 jari 513         if(clusterGenes){
2 26 Feb 07 jari 514             centroidViewer = new GSHCentroidViewer(this.experiment, clusters);
2 26 Feb 07 jari 515             centroidViewer.setMeans(this.means.A);
2 26 Feb 07 jari 516             centroidViewer.setVariances(this.variances.A);
2 26 Feb 07 jari 517             for (int i=0; i<(this.clusters.length - 1); i++) {
2 26 Feb 07 jari 518                 centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE))));
2 26 Feb 07 jari 519                 expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE))));
2 26 Feb 07 jari 520             }
2 26 Feb 07 jari 521             
2 26 Feb 07 jari 522             centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Genes ", centroidViewer, new CentroidUserObject((this.clusters.length - 1), CentroidUserObject.VARIANCES_MODE))));
2 26 Feb 07 jari 523             expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Genes ", centroidViewer, new CentroidUserObject((this.clusters.length - 1), CentroidUserObject.VALUES_MODE))));
2 26 Feb 07 jari 524             
2 26 Feb 07 jari 525             GSHCentroidsViewer centroidsViewer = new GSHCentroidsViewer(this.experiment, clusters);
2 26 Feb 07 jari 526             centroidsViewer.setMeans(this.means.A);
2 26 Feb 07 jari 527             centroidsViewer.setVariances(this.variances.A);
2 26 Feb 07 jari 528             
2 26 Feb 07 jari 529             centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", centroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE))));
2 26 Feb 07 jari 530             expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", centroidsViewer, new Integer(CentroidUserObject.VALUES_MODE))));
2 26 Feb 07 jari 531             
2 26 Feb 07 jari 532         }
2 26 Feb 07 jari 533         else{
2 26 Feb 07 jari 534             expCentroidViewer = new GSHExperimentCentroidViewer(this.experiment, clusters);
2 26 Feb 07 jari 535             
2 26 Feb 07 jari 536             expCentroidViewer.setMeans(this.means.A);
2 26 Feb 07 jari 537             expCentroidViewer.setVariances(this.variances.A);
2 26 Feb 07 jari 538             for (int i=0; i<this.clusters.length-1; i++) {
2 26 Feb 07 jari 539                 centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE))));
2 26 Feb 07 jari 540                 expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE))));
2 26 Feb 07 jari 541             }
2 26 Feb 07 jari 542             centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Experiments", expCentroidViewer, new CentroidUserObject(this.clusters.length-1, CentroidUserObject.VARIANCES_MODE))));
2 26 Feb 07 jari 543             expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Unassigned Experiments", expCentroidViewer, new CentroidUserObject(this.clusters.length-1, CentroidUserObject.VALUES_MODE))));
2 26 Feb 07 jari 544             
2 26 Feb 07 jari 545             GSHExperimentCentroidsViewer expCentroidsViewer = new GSHExperimentCentroidsViewer(this.experiment, clusters);
2 26 Feb 07 jari 546             expCentroidsViewer.setMeans(this.means.A);
2 26 Feb 07 jari 547             expCentroidsViewer.setVariances(this.variances.A);
2 26 Feb 07 jari 548             
2 26 Feb 07 jari 549             centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", expCentroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE))));
2 26 Feb 07 jari 550             expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", expCentroidsViewer, new Integer(CentroidUserObject.VALUES_MODE))));
2 26 Feb 07 jari 551         }
2 26 Feb 07 jari 552         root.add(centroidNode);
2 26 Feb 07 jari 553         root.add(expressionNode);
2 26 Feb 07 jari 554     }
2 26 Feb 07 jari 555     
2 26 Feb 07 jari 556     /**
2 26 Feb 07 jari 557      * Adds node with general iformation.
2 26 Feb 07 jari 558      */
2 26 Feb 07 jari 559     private void addGeneralInfo(DefaultMutableTreeNode root, GeneralInfo info) {
2 26 Feb 07 jari 560         DefaultMutableTreeNode node = new DefaultMutableTreeNode("General Information");
2 26 Feb 07 jari 561         node.add(new DefaultMutableTreeNode("Clusters: "+String.valueOf(info.clusters)));
2 26 Feb 07 jari 562         node.add(new DefaultMutableTreeNode("Faked_Matrix: " + String.valueOf(info.FM)));
2 26 Feb 07 jari 563         node.add(new DefaultMutableTreeNode("Swap_Time: " + String.valueOf(info.ST)));
2 26 Feb 07 jari 564         node.add(new DefaultMutableTreeNode("HCL: "+info.getMethodName()));
2 26 Feb 07 jari 565         node.add(new DefaultMutableTreeNode("Time: "+String.valueOf(info.time)+" ms"));
2 26 Feb 07 jari 566         node.add(new DefaultMutableTreeNode(info.function));
2 26 Feb 07 jari 567         root.add(node);
2 26 Feb 07 jari 568     }
2 26 Feb 07 jari 569     
2 26 Feb 07 jari 570     /***************************************************************************************
2 26 Feb 07 jari 571      * Code to order sample clustering results based on HCL runs.  sampleClusters contain an array
2 26 Feb 07 jari 572      * of sample indices for each experiment cluster.  Note that these indicies are ordered in
2 26 Feb 07 jari 573      * an order which matches HCL input matrix sample order so that HCL results (node-order) can
2 26 Feb 07 jari 574      * be used to order leaf indices to match HCL samples results
2 26 Feb 07 jari 575      */
2 26 Feb 07 jari 576     private int [][] getOrderedIndices(NodeList nodeList, int [][] sampleClusters, boolean calcGeneHCL){
2 26 Feb 07 jari 577         HCLTreeData result;
2 26 Feb 07 jari 578         for(int i = 0; i < sampleClusters.length ; i++){
2 26 Feb 07 jari 579             if(sampleClusters[i].length > 0){
2 26 Feb 07 jari 580                 result = getResult(nodeList.getNode(i), calcGeneHCL ? 4 : 0);  //get sample Result
2 26 Feb 07 jari 581                 sampleClusters[i] = getSampleOrder(result, sampleClusters[i]);
2 26 Feb 07 jari 582             }
2 26 Feb 07 jari 583         }
2 26 Feb 07 jari 584         return sampleClusters;
2 26 Feb 07 jari 585     }
2 26 Feb 07 jari 586     
2 26 Feb 07 jari 587     private int[] getSampleOrder(HCLTreeData result, int[] indices) {
2 26 Feb 07 jari 588         return getLeafOrder(result.node_order, result.child_1_array, result.child_2_array, indices);
2 26 Feb 07 jari 589     }
2 26 Feb 07 jari 590     
2 26 Feb 07 jari 591     private int[] getLeafOrder(int[] nodeOrder, int[] child1, int[] child2, int[] indices) {
2 26 Feb 07 jari 592         int[] leafOrder = new int[nodeOrder.length];
2 26 Feb 07 jari 593         Arrays.fill(leafOrder, -1);
2 26 Feb 07 jari 594         fillLeafOrder(leafOrder, child1, child2, 0, child1.length-2, indices);
2 26 Feb 07 jari 595         return leafOrder;
2 26 Feb 07 jari 596     }
2 26 Feb 07 jari 597     
2 26 Feb 07 jari 598     private int fillLeafOrder(int[] leafOrder, int[] child1, int[] child2, int pos, int index, int[] indices) {
2 26 Feb 07 jari 599         if (child1[index] != -1) {
2 26 Feb 07 jari 600             pos = fillLeafOrder(leafOrder, child1, child2, pos, child1[index], indices);
2 26 Feb 07 jari 601         }
2 26 Feb 07 jari 602         if (child2[index] != -1) {
2 26 Feb 07 jari 603             pos = fillLeafOrder(leafOrder, child1, child2, pos, child2[index], indices);
2 26 Feb 07 jari 604         } else {
2 26 Feb 07 jari 605             leafOrder[pos] = indices == null ? index : indices[index];
2 26 Feb 07 jari 606             pos++;
2 26 Feb 07 jari 607         }
2 26 Feb 07 jari 608         return pos;
2 26 Feb 07 jari 609     }
2 26 Feb 07 jari 610     
2 26 Feb 07 jari 611     
2 26 Feb 07 jari 612     
2 26 Feb 07 jari 613     /****************************************************************************************
2 26 Feb 07 jari 614      * End of Sample Cluster index ordering code
2 26 Feb 07 jari 615      */
2 26 Feb 07 jari 616     
2 26 Feb 07 jari 617     
2 26 Feb 07 jari 618     /**
2 26 Feb 07 jari 619      * The class to listen to progress, monitor and algorithms events.
2 26 Feb 07 jari 620      */
2 26 Feb 07 jari 621     private class Listener extends DialogListener implements AlgorithmListener {
2 26 Feb 07 jari 622         
2 26 Feb 07 jari 623         public void valueChanged(AlgorithmEvent event) {
2 26 Feb 07 jari 624             switch (event.getId()) {
2 26 Feb 07 jari 625                 case AlgorithmEvent.SET_UNITS:
2 26 Feb 07 jari 626                     break;
2 26 Feb 07 jari 627                 case AlgorithmEvent.PROGRESS_VALUE:
2 26 Feb 07 jari 628                     break;
2 26 Feb 07 jari 629                 case AlgorithmEvent.MONITOR_VALUE:
2 26 Feb 07 jari 630                     break;
2 26 Feb 07 jari 631             }
2 26 Feb 07 jari 632         }
2 26 Feb 07 jari 633         
2 26 Feb 07 jari 634         public void actionPerformed(ActionEvent e) {
2 26 Feb 07 jari 635             String command = e.getActionCommand();
2 26 Feb 07 jari 636             if (command.equals("cancel-command")) {
2 26 Feb 07 jari 637                 algorithm.abort();
2 26 Feb 07 jari 638             }
2 26 Feb 07 jari 639         }
2 26 Feb 07 jari 640         
2 26 Feb 07 jari 641         public void windowClosing(WindowEvent e) {
2 26 Feb 07 jari 642             algorithm.abort();
2 26 Feb 07 jari 643         }
2 26 Feb 07 jari 644     }
2 26 Feb 07 jari 645     
2 26 Feb 07 jari 646     // the general info structure
2 26 Feb 07 jari 647     private class GeneralInfo {
2 26 Feb 07 jari 648         public int clusters;
2 26 Feb 07 jari 649         public long time;
2 26 Feb 07 jari 650         public String function;
2 26 Feb 07 jari 651         
2 26 Feb 07 jari 652         public int FM;
2 26 Feb 07 jari 653         public int ST;
2 26 Feb 07 jari 654         
2 26 Feb 07 jari 655         private boolean hcl;
2 26 Feb 07 jari 656         private int hcl_method;
2 26 Feb 07 jari 657         private boolean hcl_genes;
2 26 Feb 07 jari 658         private boolean hcl_samples;
2 26 Feb 07 jari 659         
2 26 Feb 07 jari 660         public String getMethodName() {
2 26 Feb 07 jari 661             return hcl ? HCLGUI.GeneralInfo.getMethodName(hcl_method) : "no linkage";
2 26 Feb 07 jari 662         }
2 26 Feb 07 jari 663         
2 26 Feb 07 jari 664     }
2 26 Feb 07 jari 665 }