Author: scooter
Date: 2010-11-08 11:32:10 -0800 (Mon, 08 Nov 2010)
New Revision: 22757
Added:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/ConnectedComponents/
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/ConnectedComponents/ConnectedComponentsCluster.java
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GLayCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GSimpleGraphData.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/MCL/Clustering.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/NodeCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/RunTransClust.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/geometric_clustering/CalculateClustersTask.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/greedy/AffinityObject.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NestedNetworkView.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
Log:
A little clean-up + addition of ConnectedComponents
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ClusterMaker.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -65,6 +65,7 @@
import clusterMaker.algorithms.MCL.MCLCluster;
import clusterMaker.algorithms.MCODE.MCODECluster;
import clusterMaker.algorithms.glay.GLayCluster;
+import clusterMaker.algorithms.ConnectedComponents.ConnectedComponentsCluster;
// import clusterMaker.algorithms.QT.QTCluster;
// import clusterMaker.algorithms.Spectral.SpectralCluster;
// import clusterMaker.algorithms.CP.CPCluster;
@@ -96,9 +97,9 @@
*/
public ClusterMaker() {
- vizMenus = new HashMap();
- vizMap = new HashMap();
- algMap = new HashMap();
+ vizMenus = new HashMap<JMenuItem, ClusterViz>();
+ vizMap = new HashMap<String, ClusterViz>();
+ algMap = new HashMap<String, ClusterAlgorithm>();
JMenu menu = new JMenu("Cluster");
addClusterAlgorithm(menu, new HierarchicalCluster());
addClusterAlgorithm(menu, new KMeansCluster());
@@ -109,8 +110,9 @@
// addClusterAlgorithm(menu, new CPCluster());
addClusterAlgorithm(menu, new APCluster());
addClusterAlgorithm(menu, new GLayCluster());
- addClusterAlgorithm(menu, new FORCECluster());
+ // addClusterAlgorithm(menu, new FORCECluster());
addClusterAlgorithm(menu, new TransClustCluster());
+ addClusterAlgorithm(menu, new ConnectedComponentsCluster());
// addClusterAlgorithm(new HOPACHCluster());
menu.addSeparator();
Added:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/ConnectedComponents/ConnectedComponentsCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/ConnectedComponents/ConnectedComponentsCluster.java
(rev 0)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/ConnectedComponents/ConnectedComponentsCluster.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -0,0 +1,182 @@
+/* vim: set ts=2: */
+/**
+ * Copyright (c) 2008 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.ConnectedComponents;
+
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.swing.JPanel;
+
+// Cytoscape imports
+import cytoscape.CyEdge;
+import cytoscape.CyNetwork;
+import cytoscape.CyNode;
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.layout.Tunable;
+import cytoscape.layout.TunableListener;
+import cytoscape.logger.CyLogger;
+import cytoscape.task.TaskMonitor;
+
+import clusterMaker.ClusterMaker;
+import clusterMaker.algorithms.AbstractNetworkClusterer;
+import clusterMaker.algorithms.ClusterAlgorithm;
+import clusterMaker.algorithms.ClusterResults;
+import clusterMaker.algorithms.DistanceMatrix;
+import clusterMaker.algorithms.EdgeAttributeHandler;
+import clusterMaker.algorithms.NodeCluster;
+import clusterMaker.ui.ClusterViz;
+import clusterMaker.ui.NewNetworkView;
+
+// clusterMaker imports
+
+public class ConnectedComponentsCluster extends AbstractNetworkClusterer {
+
+ EdgeAttributeHandler edgeAttributeHandler = null;
+
+ TaskMonitor monitor = null;
+ CyLogger logger = null;
+
+ public ConnectedComponentsCluster() {
+ super();
+ clusterAttributeName =
Cytoscape.getCurrentNetwork().getIdentifier()+"_MCL_cluster";
+ logger = CyLogger.getLogger(ConnectedComponentsCluster.class);
+ initializeProperties();
+ }
+
+ public String getShortName() {return "ConnectedComponents";};
+ public String getName() {return "Connected Components cluster";};
+
+ public JPanel getSettingsPanel() {
+ // Everytime we ask for the panel, we want to update our
attributes
+ edgeAttributeHandler.updateAttributeList();
+
+ return clusterProperties.getTunablePanel();
+ }
+
+ public ClusterViz getVisualizer() {
+ return new NewNetworkView(true);
+ }
+
+ public void initializeProperties() {
+ super.initializeProperties();
+
+ // Use the standard edge attribute handling stuff....
+ edgeAttributeHandler = new
EdgeAttributeHandler(clusterProperties, true);
+
+ super.advancedProperties();
+
+ clusterProperties.initializeProperties();
+ updateSettings(true);
+ }
+
+ public void updateSettings() {
+ updateSettings(false);
+ }
+
+ public void updateSettings(boolean force) {
+ clusterProperties.updateValues();
+ super.updateSettings(force);
+
+ edgeAttributeHandler.updateSettings(force);
+ }
+
+ public void doCluster(TaskMonitor monitor) {
+ this.monitor = monitor;
+ CyNetwork network = Cytoscape.getCurrentNetwork();
+ String networkID = network.getIdentifier();
+
+ CyAttributes netAttributes = Cytoscape.getNetworkAttributes();
+ CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
+
+ DistanceMatrix matrix = edgeAttributeHandler.getMatrix();
+ if (matrix == null) {
+ logger.error("Can't get distance matrix: no attribute
value?");
+ return;
+ }
+
+ logger.info("Calculating Connected Components");
+ monitor.setStatus("Calculating Connected Components");
+
+ Map<Integer, List<CyNode>> components =
matrix.findConnectedComponents();
+
+ // Create the NodeClusters
+ Map<Integer, NodeCluster> clusterMap = new HashMap<Integer,
NodeCluster>();
+ for (Integer cluster: components.keySet()) {
+ clusterMap.put(cluster, new
NodeCluster(components.get(cluster)));
+ }
+
+ // Now get the sorted cluster map
+ int clusterNumber = 1;
+ HashMap<NodeCluster,NodeCluster> cMap = new
HashMap<NodeCluster, NodeCluster>();
+ for (NodeCluster cluster: NodeCluster.sortMap(clusterMap)) {
+
+ if (cMap.containsKey(cluster))
+ continue;
+
+ cMap.put(cluster,cluster);
+
+ cluster.setClusterNumber(clusterNumber);
+ clusterNumber++;
+ }
+
+ List<NodeCluster> clusters = new ArrayList<NodeCluster>
(cMap.keySet());
+
+ logger.info("Removing groups");
+
+ // Remove any leftover groups from previous runs
+ removeGroups(netAttributes, networkID);
+
+ logger.info("Creating groups");
+ monitor.setStatus("Creating groups");
+
+ List<List<CyNode>> nodeClusters =
+ createGroups(netAttributes, networkID, nodeAttributes,
clusters);
+
+ ClusterResults results = new ClusterResults(network,
nodeClusters);
+ monitor.setStatus("Done. MCL results:\n"+results);
+
+ // Tell any listeners that we're done
+ pcs.firePropertyChange(ClusterAlgorithm.CLUSTER_COMPUTED, null,
this);
+ }
+
+ public void halt() {
+ }
+}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GLayCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GLayCluster.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GLayCluster.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -165,7 +165,7 @@
t = clusterProperties.get("clusters");
t.setValue(new Integer(fa.getClusterNumber()));
- List<NodeCluster> clusterList = new ArrayList();
+ List<NodeCluster> clusterList = new ArrayList<NodeCluster>();
for (int cluster = 0; cluster < fa.getClusterNumber();
cluster++) {
clusterList.add(new NodeCluster());
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GSimpleGraphData.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GSimpleGraphData.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/GLay/GSimpleGraphData.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -35,13 +35,13 @@
this.selectedOnly = selectedOnly;
this.undirectedEdges = undirectedEdges;
if (!selectedOnly) {
- this.nodeList = network.nodesList();
+ this.nodeList =
(List<Node>)network.nodesList();
} else {
- this.nodeList = new
ArrayList(network.getSelectedNodes());
+ this.nodeList = new
ArrayList<Node>(network.getSelectedNodes());
}
this.nodeCount = nodeList.size();
- this.connectingEdges =
network.getConnectingEdges(nodeList);
+ this.connectingEdges =
(List<Edge>)network.getConnectingEdges(nodeList);
this.edgeCount = this.connectingEdges.size();
this.graphIndices = new int[this.nodeCount];
this.degree = new int[this.nodeCount];
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/MCL/Clustering.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/MCL/Clustering.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/MCL/Clustering.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -1,3 +1,34 @@
+/**
+ * Copyright (c) 2010 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.MCL;
import java.util.Vector;
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/NodeCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/NodeCluster.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/NodeCluster.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -59,6 +60,12 @@
clusterNumber = clusterCount;
}
+ public NodeCluster(Collection<CyNode> collection) {
+ super(collection);
+ clusterCount++;
+ clusterNumber = clusterCount;
+ }
+
public boolean add(List<CyNode>nodeList, int index) {
return add(nodeList.get(index));
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/RunTransClust.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/RunTransClust.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/RunTransClust.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -150,4 +150,4 @@
}
}
-}
\ No newline at end of file
+}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/geometric_clustering/CalculateClustersTask.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/geometric_clustering/CalculateClustersTask.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/geometric_clustering/CalculateClustersTask.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -15,7 +15,6 @@
}
- @Override
public void run() {
boolean already[] = new boolean[this.cc.getNodeNumber()];
int[] clusters = new int[this.cc.getNodeNumber()];
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/greedy/AffinityObject.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/greedy/AffinityObject.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/TransClust/de/layclust/greedy/AffinityObject.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -20,7 +20,6 @@
}
}
- @Override
public int compareTo(Object o) {
AffinityObject a = (AffinityObject) o;
if(this.affinity<a.affinity){
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NestedNetworkView.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NestedNetworkView.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NestedNetworkView.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -146,7 +146,7 @@
String cluster_type =
networkAttributes.getStringAttribute(netId,
ClusterMaker.CLUSTER_TYPE_ATTRIBUTE);
if (cluster_type != "MCL" && cluster_type != "GLay" &&
cluster_type != "AP" && cluster_type != "FORCE" &&
- cluster_type != "MCODE" && cluster_type != "TransClust")
+ cluster_type != "MCODE" && cluster_type != "TransClust" &&
cluster_type != "ConnectedComponents")
return false;
if (networkAttributes.hasAttribute(netId,
ClusterMaker.CLUSTER_ATTRIBUTE)) {
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
2010-11-08 17:38:41 UTC (rev 22756)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/ui/NewNetworkView.java
2010-11-08 19:32:10 UTC (rev 22757)
@@ -143,7 +143,7 @@
String cluster_type =
networkAttributes.getStringAttribute(netId,
ClusterMaker.CLUSTER_TYPE_ATTRIBUTE);
if (cluster_type != "MCL" && cluster_type != "GLay" &&
cluster_type != "AP" && cluster_type != "FORCE" &&
- cluster_type != "MCODE" && cluster_type != "TransClust")
+ cluster_type != "MCODE" && cluster_type != "TransClust" &&
cluster_type != "ConnectedComponents")
return false;
if (networkAttributes.hasAttribute(netId,
ClusterMaker.CLUSTER_ATTRIBUTE)) {
--
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.