Author: scooter
Date: 2011-08-19 14:37:01 -0700 (Fri, 19 Aug 2011)
New Revision: 26610

Added:
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
Modified:
   csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/FeatureVector/FeatureVectorCluster.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/EisenCluster.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/HierarchicalCluster.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMCluster.java
   
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
Log:
More refactoring and cleanup


Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java    
    2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java    
    2011-08-19 21:37:01 UTC (rev 26610)
@@ -69,8 +69,8 @@
 import 
clusterMaker.algorithms.attributeClusterers.hierarchical.HierarchicalCluster;
 import clusterMaker.algorithms.attributeClusterers.kmeans.KMeansCluster;
 import clusterMaker.algorithms.attributeClusterers.kmedoid.KMedoidCluster;
+import 
clusterMaker.algorithms.attributeClusterers.FeatureVector.FeatureVectorCluster;
 
-import clusterMaker.algorithms.FeatureVector.FeatureVectorCluster;
 import clusterMaker.algorithms.networkClusterers.TransClust.TransClustCluster;
 import clusterMaker.algorithms.networkClusterers.MCL.MCLCluster;
 import clusterMaker.algorithms.networkClusterers.MCODE.MCODECluster;
@@ -81,6 +81,7 @@
 // import clusterMaker.algorithms.Spectral.SpectralCluster;
 // import clusterMaker.algorithms.CP.CPCluster;
 import clusterMaker.algorithms.networkClusterers.AP.APCluster;
+
 import clusterMaker.algorithms.clusterFilters.AbstractNetworkFilter;
 import clusterMaker.algorithms.clusterFilters.HairCutFilter;
 import clusterMaker.algorithms.clusterFilters.CuttingEdgeFilter;

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
    2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
    2011-08-19 21:37:01 UTC (rev 26610)
@@ -34,8 +34,10 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 
+import cytoscape.CyNode;
 import cytoscape.Cytoscape;
 import cytoscape.data.CyAttributes;
 import cytoscape.groups.CyGroup;
@@ -174,7 +176,53 @@
                }
        }
 
-       protected void createGroups() {
+       protected void createGroups(int nClusters, int[] clusters) {
+               if (matrix.isTransposed()) {
+                       return;
+               }
+
+               if (monitor != null) 
+                       monitor.setStatus("Creating groups");
+
+               HashMap<String,List<CyNode>> groupMap = new 
HashMap<String,List<CyNode>>();
+               attrList = new ArrayList<String>(matrix.nRows());
+               // Create the attribute list
+               for (int cluster = 0; cluster < nClusters; cluster++) {
+                       List<CyNode> memberList = new ArrayList<CyNode>();
+                       for (int i = 0; i < matrix.nRows(); i++) {
+                               if (clusters[i] == cluster) {
+                                       
attrList.add(matrix.getRowLabel(i)+"\t"+cluster);
+                                       if (debug)
+                                               
logger.debug(matrix.getRowLabel(i)+"\t"+cluster);
+                                       memberList.add(matrix.getRowNode(i));
+                               }
+                       }
+                       groupMap.put("Cluster_"+cluster, memberList);
+               }
+
+               List<String> groupNames = new ArrayList<String>();
+
+               if (createGroups) {
+                       // Create our groups
+                       CyGroup group = null;
+                       for (String clusterName: groupMap.keySet()) {
+                               List<CyNode> memberList = 
groupMap.get(clusterName);
+                               groupNames.add(clusterName);
+
+                               if (debug)
+                                       logger.debug("Creating group: 
"+clusterName);
+
+                               // Create the group
+                               group = CyGroupManager.createGroup(clusterName, 
memberList, null);
+                               if (group != null) 
+                                       CyGroupManager.setGroupViewer(group, 
"namedSelection", Cytoscape.getCurrentNetworkView(), false);
+                       }
+                       CyGroupManager.setGroupViewer(group, "namedSelection", 
Cytoscape.getCurrentNetworkView(), true);
+               }
+
+               CyAttributes netAttr = Cytoscape.getNetworkAttributes();
+               String netID = Cytoscape.getCurrentNetwork().getIdentifier();
+               netAttr.setListAttribute(netID, ClusterMaker.GROUP_ATTRIBUTE, 
groupNames);
        }
 
        public static boolean isAvailable(String type) {
@@ -198,31 +246,5 @@
 
                return true;
        }
-       
-       public static void getAttributesList(List<String>attributeList, 
CyAttributes attributes, 
-                                     String prefix) {
-               String[] names = attributes.getAttributeNames();
-               for (int i = 0; i < names.length; i++) {
-                       if (attributes.getType(names[i]) == 
CyAttributes.TYPE_FLOATING ||
-                           attributes.getType(names[i]) == 
CyAttributes.TYPE_INTEGER) {
-                               attributeList.add(prefix+names[i]);
-                       }
-               }
-       }
 
-       public static String[] getAllAttributes() {
-               // Create the list by combining node and edge attributes into a 
single list
-               List<String> attributeList = new ArrayList<String>();
-               getAttributesList(attributeList, 
Cytoscape.getNodeAttributes(),"node.");
-               getAttributesList(attributeList, 
Cytoscape.getEdgeAttributes(),"edge.");
-               Collections.sort(attributeList);
-               return attributeList.toArray(new String[1]);
-       }
-
-       public static String[] getNodeAttributes() {
-               List<String> attributeList = new ArrayList<String>();
-               getAttributesList(attributeList, 
Cytoscape.getNodeAttributes(),"node.");
-               Collections.sort(attributeList);
-               return attributeList.toArray(new String[1]);
-       }
 }

Added: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
                           (rev 0)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
   2011-08-19 21:37:01 UTC (rev 26610)
@@ -0,0 +1,104 @@
+/* vim: set ts=2: */
+/**
+ * Copyright (c) 20118 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions, and the following disclaimer.
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions, and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *   3. Redistributions must acknowledge that this software was
+ *      originally developed by the UCSF Computer Graphics Laboratory
+ *      under support by the NIH National Center for Research Resources,
+ *      grant P41-RR01081.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+package clusterMaker.algorithms.attributeClusterers;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.logger.CyLogger;
+import cytoscape.task.TaskMonitor;
+
+import clusterMaker.algorithms.AbstractClusterAlgorithm;
+
+/**
+ * This abstract class is the base class for all of the attribute clusterers 
provided by
+ * clusterMaker.  Fundamentally, an attribute clusterer is an algorithm which 
functions to
+ * partition nodes or node attributes based on properties of the attributes.
+ */
+public abstract class AbstractAttributeClusterer extends 
AbstractClusterAlgorithm {
+       // Common instance variables
+       protected String[] attributeArray = new String[1];
+       protected String dataAttributes = null;
+       protected DistanceMetric distanceMetric = DistanceMetric.EUCLIDEAN;
+       protected boolean clusterAttributes = false;
+       protected boolean createGroups = true;
+       protected boolean ignoreMissing = false;
+       protected boolean selectedOnly = false;
+       protected boolean adjustDiagonals = false;
+       protected boolean zeroMissing = false;
+       protected TaskMonitor monitor = null;
+       protected CyLogger logger = null;
+
+       protected void getAttributesList(List<String>attributeList, 
CyAttributes attributes, String prefix) {
+               String[] names = attributes.getAttributeNames();
+               for (int i = 0; i < names.length; i++) {
+                       if (attributes.getType(names[i]) == 
CyAttributes.TYPE_FLOATING ||
+                           attributes.getType(names[i]) == 
CyAttributes.TYPE_INTEGER) {
+                               attributeList.add(prefix+names[i]);
+                       }
+               }
+       }
+
+       protected String[] getAllAttributes() {
+               // Create the list by combining node and edge attributes into a 
single list
+               List<String> attributeList = new ArrayList<String>();
+               getAttributesList(attributeList, 
Cytoscape.getNodeAttributes(),"node.");
+               getAttributesList(attributeList, 
Cytoscape.getEdgeAttributes(),"edge.");
+               Collections.sort(attributeList);
+               return attributeList.toArray(new String[1]);
+       }
+
+       protected String[] getNodeAttributes() {
+               List<String> attributeList = new ArrayList<String>();
+               getAttributesList(attributeList, 
Cytoscape.getNodeAttributes(),"node.");
+               Collections.sort(attributeList);
+               return attributeList.toArray(new String[1]);
+       }
+
+       protected String[] getAttributeArray(String dataAttributes) {
+               String indices[] = dataAttributes.split(",");
+               String selectedAttributes[] = new String[indices.length];
+               for (int i = 0; i < indices.length; i++) {
+                       selectedAttributes[i] = 
attributeArray[Integer.parseInt(indices[i])];
+               }
+               return selectedAttributes;
+       }
+
+       public boolean isAvailable() {
+               return 
AbstractAttributeClusterAlgorithm.isAvailable(getShortName());
+       }
+
+}

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/FeatureVector/FeatureVectorCluster.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/FeatureVector/FeatureVectorCluster.java
   2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/FeatureVector/FeatureVectorCluster.java
   2011-08-19 21:37:01 UTC (rev 26610)
@@ -55,26 +55,19 @@
 
 import clusterMaker.algorithms.AbstractClusterAlgorithm;
 import clusterMaker.algorithms.ClusterAlgorithm;
-import 
clusterMaker.algorithms.attributeClusterers.AbstractAttributeClusterAlgorithm;
+import clusterMaker.algorithms.attributeClusterers.AbstractAttributeClusterer;
 import clusterMaker.algorithms.attributeClusterers.DistanceMetric;
 import clusterMaker.algorithms.attributeClusterers.Matrix;
 import clusterMaker.ui.ClusterViz;
 
 // clusterMaker imports
 
-public class FeatureVectorCluster extends AbstractClusterAlgorithm implements 
TunableListener {
-       String[] attributeArray = new String[1];
+public class FeatureVectorCluster extends AbstractAttributeClusterer 
implements TunableListener {
 
-       DistanceMetric distanceMetric = DistanceMetric.EUCLIDEAN;
-       boolean ignoreMissing = true;
-       boolean selectedOnly = false;
-       boolean zeroMissing = false;
        boolean createEdges = false;
        double edgeCutoff = 0.5;
        String dataAttributes = null;
        String edgeAttribute = null;
-       TaskMonitor monitor = null;
-       CyLogger logger = null;
        final static String interaction = "distance";
 
        public FeatureVectorCluster() {
@@ -89,7 +82,7 @@
        public JPanel getSettingsPanel() {
                // Everytime we ask for the panel, we want to update our 
attributes
                Tunable attributeTunable = 
clusterProperties.get("attributeList");
-               attributeArray = 
AbstractAttributeClusterAlgorithm.getNodeAttributes();
+               attributeArray = getNodeAttributes();
                attributeTunable.setLowerBound((Object)attributeArray);
 
                return clusterProperties.getTunablePanel();
@@ -117,7 +110,7 @@
                                                  Tunable.GROUP, new 
Integer(1)));
 
                // The attribute to use to get the weights
-               attributeArray = 
AbstractAttributeClusterAlgorithm.getNodeAttributes();
+               attributeArray = getNodeAttributes();
                clusterProperties.add(new Tunable("attributeList",
                                                  "Array sources",
                                                  Tunable.LIST, "",
@@ -367,7 +360,6 @@
        }
 
        public boolean isAvailable() {
-               // return EisenCluster.isAvailable(getShortName());
                return false;
        }
 
@@ -391,13 +383,4 @@
                edgeAttributes.setAttribute(edge_name, 
Semantics.CANONICAL_NAME, edge_name);
                return edge;
        }
-
-       private String[] getAttributeArray(String dataAttributes) {
-               String indices[] = dataAttributes.split(",");
-               String selectedAttributes[] = new String[indices.length];
-               for (int i = 0; i < indices.length; i++) {
-                       selectedAttributes[i] = 
attributeArray[Integer.parseInt(indices[i])];
-               }
-               return selectedAttributes;
-       }
 }

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/EisenCluster.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/EisenCluster.java
    2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/EisenCluster.java
    2011-08-19 21:37:01 UTC (rev 26610)
@@ -527,33 +527,6 @@
                return nodeList;
        }
 
-       public static void getAttributesList(List<String>attributeList, 
CyAttributes attributes, 
-                                     String prefix) {
-               String[] names = attributes.getAttributeNames();
-               for (int i = 0; i < names.length; i++) {
-                       if (attributes.getType(names[i]) == 
CyAttributes.TYPE_FLOATING ||
-                           attributes.getType(names[i]) == 
CyAttributes.TYPE_INTEGER) {
-                               attributeList.add(prefix+names[i]);
-                       }
-               }
-       }
-
-       public static String[] getAllAttributes() {
-               // Create the list by combining node and edge attributes into a 
single list
-               List<String> attributeList = new ArrayList<String>();
-               getAttributesList(attributeList, 
Cytoscape.getNodeAttributes(),"node.");
-               getAttributesList(attributeList, 
Cytoscape.getEdgeAttributes(),"edge.");
-               Collections.sort(attributeList);
-               return attributeList.toArray(new String[1]);
-       }
-
-       public static String[] getNodeAttributes() {
-               List<String> attributeList = new ArrayList<String>();
-               getAttributesList(attributeList, 
Cytoscape.getNodeAttributes(),"node.");
-               Collections.sort(attributeList);
-               return attributeList.toArray(new String[1]);
-       }
-               
        /**
         * This function searches the distance matrix to find the pair with the 
shortest
         * distance between them. The indices of the pair are returned in ip 
and jp; the

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/HierarchicalCluster.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/HierarchicalCluster.java
     2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/hierarchical/HierarchicalCluster.java
     2011-08-19 21:37:01 UTC (rev 26610)
@@ -47,7 +47,7 @@
 import cytoscape.task.TaskMonitor;
 
 import clusterMaker.algorithms.ClusterAlgorithm;
-import clusterMaker.algorithms.AbstractClusterAlgorithm;
+import clusterMaker.algorithms.attributeClusterers.AbstractAttributeClusterer;
 import clusterMaker.algorithms.attributeClusterers.DistanceMetric;
 import clusterMaker.algorithms.attributeClusterers.Matrix;
 import clusterMaker.ui.ClusterViz;
@@ -55,7 +55,7 @@
 
 // clusterMaker imports
 
-public class HierarchicalCluster extends AbstractClusterAlgorithm {
+public class HierarchicalCluster extends AbstractAttributeClusterer {
        /**
         * Linkage types
         */
@@ -64,19 +64,8 @@
                                         ClusterMethod.MAXIMUM_LINKAGE,
                                         ClusterMethod.CENTROID_LINKAGE };
 
-       String[] attributeArray = new String[1];
 
        ClusterMethod clusterMethod =  ClusterMethod.AVERAGE_LINKAGE;
-       DistanceMetric distanceMetric = DistanceMetric.EUCLIDEAN;
-       boolean clusterAttributes = false;
-       boolean createGroups = true;
-       boolean ignoreMissing = false;
-       boolean selectedOnly = false;
-       boolean adjustDiagonals = false;
-       boolean zeroMissing = false;
-       String dataAttributes = null;
-       TaskMonitor monitor = null;
-       CyLogger logger = null;
        TreeView treeView = null;
 
        public HierarchicalCluster() {
@@ -91,7 +80,7 @@
        public JPanel getSettingsPanel() {
                // Everytime we ask for the panel, we want to update our 
attributes
                Tunable attributeTunable = 
clusterProperties.get("attributeList");
-               attributeArray = EisenCluster.getAllAttributes();
+               attributeArray = getAllAttributes();
                attributeTunable.setLowerBound((Object)attributeArray);
 
                return clusterProperties.getTunablePanel();
@@ -128,7 +117,7 @@
                                                  Tunable.GROUP, new 
Integer(1)));
 
                // The attribute to use to get the weights
-               attributeArray = EisenCluster.getAllAttributes();
+               attributeArray = getAllAttributes();
                clusterProperties.add(new Tunable("attributeList",
                                                  "Array sources",
                                                  Tunable.LIST, "",
@@ -280,10 +269,6 @@
                pcs.firePropertyChange(ClusterAlgorithm.CLUSTER_COMPUTED, null, 
this);
        }
 
-       public boolean isAvailable() {
-               return EisenCluster.isAvailable(getShortName());
-       }
-
        private void setParameters(EisenCluster algorithm) {
                algorithm.setCreateGroups(createGroups);
                algorithm.setIgnoreMissing(ignoreMissing);
@@ -292,12 +277,4 @@
                algorithm.setZeroMissing(zeroMissing);
        }
 
-       private String[] getAttributeArray(String dataAttributes) {
-               String indices[] = dataAttributes.split(",");
-               String selectedAttributes[] = new String[indices.length];
-               for (int i = 0; i < indices.length; i++) {
-                       selectedAttributes[i] = 
attributeArray[Integer.parseInt(indices[i])];
-               }
-               return selectedAttributes;
-       }
 }

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
      2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
      2011-08-19 21:37:01 UTC (rev 26610)
@@ -96,26 +96,10 @@
                // Cluster
                int ifound = kmeans(nClusters, nIterations, matrix, metric, 
clusters);
 
-               groupMap = new HashMap<String,List<CyNode>>();
-               attrList = new ArrayList<String>(matrix.nRows());
-               // Create the attribute list
-               for (int cluster = 0; cluster < nClusters; cluster++) {
-                       List<CyNode> memberList = new ArrayList<CyNode>();
-                       for (int i = 0; i < matrix.nRows(); i++) {
-                               if (clusters[i] == cluster) {
-                                       
attrList.add(matrix.getRowLabel(i)+"\t"+cluster);
-                                       if (debug)
-                                               
logger.debug(matrix.getRowLabel(i)+"\t"+cluster);
-                                       memberList.add(matrix.getRowNode(i));
-                               }
-                       }
-                       groupMap.put("Cluster_"+cluster, memberList);
-               }
-               rowOrder = matrix.indexSort(clusters, clusters.length);
-
                if (!interimRun) {
                        if (!matrix.isTransposed())
-                               createGroups();
+                               createGroups(nClusters, clusters);
+                       rowOrder = matrix.indexSort(clusters, clusters.length);
                        // Update the network attributes
                        updateAttributes("kmeans");
                }

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
 2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
 2011-08-19 21:37:01 UTC (rev 26610)
@@ -47,8 +47,7 @@
 import cytoscape.task.TaskMonitor;
 
 import clusterMaker.algorithms.ClusterAlgorithm;
-import clusterMaker.algorithms.AbstractClusterAlgorithm;
-import 
clusterMaker.algorithms.attributeClusterers.AbstractAttributeClusterAlgorithm;
+import clusterMaker.algorithms.attributeClusterers.AbstractAttributeClusterer;
 import clusterMaker.algorithms.attributeClusterers.DistanceMetric;
 import clusterMaker.algorithms.attributeClusterers.Matrix;
 import clusterMaker.ui.ClusterViz;
@@ -56,19 +55,9 @@
 
 // clusterMaker imports
 
-public class KMeansCluster extends AbstractClusterAlgorithm {
-       String[] attributeArray = new String[1];
-
+public class KMeansCluster extends AbstractAttributeClusterer {
        int kNumber = 0;
        int rNumber = 0;
-       DistanceMetric distanceMetric = DistanceMetric.EUCLIDEAN;
-       boolean clusterAttributes = false;
-       boolean createGroups = true;
-       boolean ignoreMissing = false;
-       boolean selectedOnly = false;
-       String dataAttributes = null;
-       TaskMonitor monitor = null;
-       CyLogger logger = null;
        KnnView knnView = null;
 
        public KMeansCluster() {
@@ -83,7 +72,7 @@
        public JPanel getSettingsPanel() {
                // Everytime we ask for the panel, we want to update our 
attributes
                Tunable attributeTunable = 
clusterProperties.get("attributeList");
-               attributeArray = 
AbstractAttributeClusterAlgorithm.getAllAttributes();
+               attributeArray = getAllAttributes();
                attributeTunable.setLowerBound((Object)attributeArray);
 
                // We also want to update the number our "guestimate" for k
@@ -140,7 +129,7 @@
                                                  Tunable.GROUP, new 
Integer(1)));
 
                // The attribute to use to get the weights
-               attributeArray = 
AbstractAttributeClusterAlgorithm.getAllAttributes();
+               attributeArray = getAllAttributes();
                clusterProperties.add(new Tunable("attributeList",
                                                  "Array sources",
                                                  Tunable.LIST, "",
@@ -256,16 +245,4 @@
                pcs.firePropertyChange(ClusterAlgorithm.CLUSTER_COMPUTED, null, 
this);
        }
 
-       public boolean isAvailable() {
-               return 
AbstractAttributeClusterAlgorithm.isAvailable(getShortName());
-       }
-
-       private String[] getAttributeArray(String dataAttributes) {
-               String indices[] = dataAttributes.split(",");
-               String selectedAttributes[] = new String[indices.length];
-               for (int i = 0; i < indices.length; i++) {
-                       selectedAttributes[i] = 
attributeArray[Integer.parseInt(indices[i])];
-               }
-               return selectedAttributes;
-       }
 }

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMCluster.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMCluster.java
    2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMCluster.java
    2011-08-19 21:37:01 UTC (rev 26610)
@@ -97,26 +97,9 @@
 
                // Cluster
                int ifound = kmedoid(nClusters, nIterations, matrix, metric, 
clusters);
-
-               groupMap = new HashMap<String,List<CyNode>>();
-               attrList = new ArrayList<String>(matrix.nRows());
-               // Create the attribute list
-               for (int cluster = 0; cluster < nClusters; cluster++) {
-                       List<CyNode> memberList = new ArrayList<CyNode>();
-                       for (int i = 0; i < matrix.nRows(); i++) {
-                               if (clusters[i] == cluster) {
-                                       
attrList.add(matrix.getRowLabel(i)+"\t"+cluster);
-                                       if (debug)
-                                               
logger.debug(matrix.getRowLabel(i)+"\t"+cluster);
-                                       memberList.add(matrix.getRowNode(i));
-                               }
-                       }
-                       groupMap.put("Cluster_"+cluster, memberList);
-               }
-
                if (!interimRun) {
                        if (!matrix.isTransposed())
-                               createGroups();
+                               createGroups(nClusters, clusters);
                        rowOrder = matrix.indexSort(clusters, clusters.length);
                        updateAttributes("kmedoid");
                }

Modified: 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
       2011-08-19 14:53:42 UTC (rev 26609)
+++ 
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
       2011-08-19 21:37:01 UTC (rev 26610)
@@ -48,7 +48,7 @@
 
 import clusterMaker.algorithms.ClusterAlgorithm;
 import clusterMaker.algorithms.AbstractClusterAlgorithm;
-import 
clusterMaker.algorithms.attributeClusterers.AbstractAttributeClusterAlgorithm;
+import clusterMaker.algorithms.attributeClusterers.AbstractAttributeClusterer;
 import clusterMaker.algorithms.attributeClusterers.DistanceMetric;
 import clusterMaker.algorithms.attributeClusterers.Matrix;
 import clusterMaker.ui.ClusterViz;
@@ -56,19 +56,9 @@
 
 // clusterMaker imports
 
-public class KMedoidCluster extends AbstractClusterAlgorithm {
-       String[] attributeArray = new String[1];
-
+public class KMedoidCluster extends AbstractAttributeClusterer {
        int kNumber = 0;
        int rNumber = 0;
-       DistanceMetric distanceMetric = DistanceMetric.EUCLIDEAN;
-       boolean clusterAttributes = false;
-       boolean createGroups = true;
-       boolean ignoreMissing = false;
-       boolean selectedOnly = false;
-       String dataAttributes = null;
-       TaskMonitor monitor = null;
-       CyLogger logger = null;
        KnnView knnView = null;
 
        public KMedoidCluster() {
@@ -83,7 +73,7 @@
        public JPanel getSettingsPanel() {
                // Everytime we ask for the panel, we want to update our 
attributes
                Tunable attributeTunable = 
clusterProperties.get("attributeList");
-               attributeArray = 
AbstractAttributeClusterAlgorithm.getAllAttributes();
+               attributeArray = getAllAttributes();
                attributeTunable.setLowerBound((Object)attributeArray);
 
                // We also want to update the number our "guestimate" for k
@@ -140,7 +130,7 @@
                                                  Tunable.GROUP, new 
Integer(1)));
 
                // The attribute to use to get the weights
-               attributeArray = 
AbstractAttributeClusterAlgorithm.getAllAttributes();
+               attributeArray = getAllAttributes();
                clusterProperties.add(new Tunable("attributeList",
                                                  "Array sources",
                                                  Tunable.LIST, "",
@@ -256,16 +246,4 @@
                pcs.firePropertyChange(ClusterAlgorithm.CLUSTER_COMPUTED, null, 
this);
        }
 
-       public boolean isAvailable() {
-               return 
AbstractAttributeClusterAlgorithm.isAvailable(getShortName());
-       }
-
-       private String[] getAttributeArray(String dataAttributes) {
-               String indices[] = dataAttributes.split(",");
-               String selectedAttributes[] = new String[indices.length];
-               for (int i = 0; i < indices.length; i++) {
-                       selectedAttributes[i] = 
attributeArray[Integer.parseInt(indices[i])];
-               }
-               return selectedAttributes;
-       }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to