Author: clopes
Date: 2012-01-12 15:10:02 -0800 (Thu, 12 Jan 2012)
New Revision: 28005

Removed:
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEGraph.java
Modified:
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
   
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
Log:
Deleted the MCODEGraph--it uses CySubNetworks again.
Fixed MCODE sub-network attributes + MCODE style/vizmappers

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
   2012-01-12 22:55:52 UTC (rev 28004)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
   2012-01-12 23:10:02 UTC (rev 28005)
@@ -16,6 +16,7 @@
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNode;
+import org.cytoscape.model.subnetwork.CySubNetwork;
 import org.cytoscape.work.TaskMonitor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -353,11 +354,11 @@
                                                }
 
                                                // Create an input graph for 
the filter and haircut methods
-                                               MCODEGraph clusterGraph = 
createClusterGraph(alCluster, inputNetwork);
+                                               CySubNetwork clusterNet = 
createClusterNetwork(alCluster, inputNetwork);
 
-                                               if 
(!filterCluster(clusterGraph)) {
+                                               if (!filterCluster(clusterNet)) 
{
                                                        if (params.isHaircut()) 
{
-                                                               
haircutCluster(clusterGraph, alCluster);
+                                                               
haircutCluster(clusterNet, alCluster);
                                                        }
 
                                                        if (params.isFluff()) {
@@ -365,8 +366,8 @@
                                                        }
 
                                                        
currentCluster.setALCluster(alCluster);
-                                                       clusterGraph = 
createClusterGraph(alCluster, inputNetwork);
-                                                       
currentCluster.setGraph(clusterGraph);
+                                                       clusterNet = 
createClusterNetwork(alCluster, inputNetwork);
+                                                       
currentCluster.setNetwork(clusterNet);
                                                        
currentCluster.setClusterScore(scoreCluster(currentCluster));
                                                        
currentCluster.setNodeSeenHashMap(nodeSeenHashMapSnapShot);//store the list of 
all the nodes that have already been seen and incorporated in other clusters
                                                        
currentCluster.setResultId(resultId);
@@ -471,7 +472,7 @@
                }
 
                // Create an input graph for the filter and haircut methods
-               MCODEGraph clusterNetwork = createClusterGraph(alCluster, 
inputNetwork);
+               CySubNetwork clusterNetwork = createClusterNetwork(alCluster, 
inputNetwork);
 
                if (params.isHaircut()) {
                        haircutCluster(clusterNetwork, alCluster);
@@ -482,14 +483,14 @@
                }
 
                cluster.setALCluster(alCluster);
-               clusterNetwork = createClusterGraph(alCluster, inputNetwork);
-               cluster.setGraph(clusterNetwork);
+               clusterNetwork = createClusterNetwork(alCluster, inputNetwork);
+               cluster.setNetwork(clusterNetwork);
                cluster.setClusterScore(scoreCluster(cluster));
 
                return cluster;
        }
 
-       private MCODEGraph createClusterGraph(List<Integer> alCluster, 
CyNetwork inputNetwork) {
+       private CySubNetwork createClusterNetwork(List<Integer> alCluster, 
CyNetwork inputNetwork) {
                Set<CyNode> nodes = new HashSet<CyNode>();
 
                for (int index : alCluster) {
@@ -497,9 +498,9 @@
                        nodes.add(n);
                }
 
-               MCODEGraph clusterGraph = mcodeUtil.createGraph(inputNetwork, 
nodes);
+               CySubNetwork outputNetwork = 
mcodeUtil.createSubNetwork(inputNetwork, nodes);
 
-               return clusterGraph;
+               return outputNetwork;
        }
 
        /**
@@ -531,8 +532,8 @@
                int numNodes = 0;
                double density = 0.0, score = 0.0;
 
-               numNodes = cluster.getGraph().getNodeCount();
-               density = calcDensity(cluster.getGraph(), true);
+               numNodes = cluster.getNetwork().getNodeCount();
+               density = calcDensity(cluster.getNetwork(), true);
                score = density * numNodes;
 
                return score;
@@ -594,9 +595,9 @@
                }
                
                // extract neighborhood subgraph
-               MCODEGraph neighborhoodGraph = 
mcodeUtil.createGraph(inputNetwork, neighbors);
+               CySubNetwork neighborhoodNet = 
mcodeUtil.createSubNetwork(inputNetwork, neighbors);
                
-               if (neighborhoodGraph == null) {
+               if (neighborhoodNet == null) {
                        // this shouldn't happen
                        logger.error("In " + callerID + ": gpNodeNeighborhood 
was null.");
                        return null;
@@ -606,17 +607,17 @@
                NodeInfo nodeInfo = new NodeInfo();
 
                // Density
-               if (neighborhoodGraph != null) {
-                       nodeInfo.density = calcDensity(neighborhoodGraph, 
params.isIncludeLoops());
+               if (neighborhoodNet != null) {
+                       nodeInfo.density = calcDensity(neighborhoodNet, 
params.isIncludeLoops());
                }
                
                nodeInfo.numNodeNeighbors = neighborhood.length;
 
                // Calculate the highest k-core
                Integer k = null;
-               Object[] returnArray = getHighestKCore(neighborhoodGraph);
+               Object[] returnArray = getHighestKCore(neighborhoodNet);
                k = (Integer) returnArray[0];
-               MCODEGraph kCore = (MCODEGraph) returnArray[1];
+               CySubNetwork kCore = (CySubNetwork) returnArray[1];
                nodeInfo.coreLevel = k.intValue();
                
                // Calculate the core density - amplifies the density of 
heavily interconnected regions and attenuates
@@ -772,16 +773,16 @@
        /**
         * Checks if the cluster needs to be filtered according to heuristics 
in this method
         *
-        * @param clusterGraph The cluster to check if it passes the filter
+        * @param clusterNetwork The cluster to check if it passes the filter
         * @return true if cluster should be filtered, false otherwise
         */
-       private boolean filterCluster(MCODEGraph clusterGraph) {
-               if (clusterGraph == null) {
+       private boolean filterCluster(CySubNetwork clusterNetwork) {
+               if (clusterNetwork == null) {
                        return true;
                }
 
                // filter if the cluster does not satisfy the user specified 
k-core
-               MCODEGraph kCore = getKCore(clusterGraph, params.getKCore());
+               CySubNetwork kCore = getKCore(clusterNetwork, 
params.getKCore());
 
                return kCore == null;
        }
@@ -789,13 +790,13 @@
        /**
         * Gives the cluster a haircut (removed singly connected nodes by 
taking a 2-core)
         *
-        * @param clusterGraph The cluster graph
+        * @param clusterNetwork The cluster network
         * @param cluster        The cluster node ID list (in the original 
graph)
         * @return true
         */
-       private boolean haircutCluster(MCODEGraph clusterGraph, List<Integer> 
cluster) {
+       private boolean haircutCluster(CySubNetwork clusterNetwork, 
List<Integer> cluster) {
                // get 2-core
-               MCODEGraph kCore = getKCore(clusterGraph, 2);
+               CySubNetwork kCore = getKCore(clusterNetwork, 2);
 
                if (kCore != null) {
                        // clear the cluster and add all 2-core nodes back into 
it
@@ -818,7 +819,7 @@
         *                     possible edges.
         * @return The density of the network
         */
-       public double calcDensity(MCODEGraph network, boolean includeLoops) {
+       public double calcDensity(CySubNetwork network, boolean includeLoops) {
                int possibleEdgeNum = 0, actualEdgeNum = 0, loopCount = 0;
                double density = 0;
 
@@ -863,7 +864,7 @@
         * @param k            The k of the k-core to find e.g. 4 will find a 
4-core
         * @return Returns a subgraph with the core, if any was found at given k
         */
-       public MCODEGraph getKCore(MCODEGraph inputNetwork, int k) {
+       public CySubNetwork getKCore(CySubNetwork inputNetwork, int k) {
                String callerID = "MCODEAlgorithm.getKCore";
 
                if (inputNetwork == null) {
@@ -873,7 +874,7 @@
 
                // filter all nodes with degree less than k until convergence
                boolean firstLoop = true;
-               MCODEGraph outputNetwork = null;
+               CySubNetwork outputNetwork = null;
 
                while (true) {
                        int numDeleted = 0;
@@ -898,7 +899,7 @@
                                        outputNodes.add(n);
                                }
                                
-                               outputNetwork = 
mcodeUtil.createGraph(inputNetwork.getRootNetwork(), outputNodes);
+                               outputNetwork = 
mcodeUtil.createSubNetwork(inputNetwork.getRootNetwork(), outputNodes);
                                
                                if (outputNetwork.getNodeCount() == 0) {
                                        return null;
@@ -920,14 +921,14 @@
        }
 
        /**
-        * Find the highest k-core in the input graph.
+        * Find the highest k-core in the input network.
         *
         * @param network The input network
         * @return Returns the k-value and the core as an Object array.
         *         The first object is the highest k value i.e. objectArray[0]
         *         The second object is the highest k-core as a CyNetwork i.e. 
objectArray[1]
         */
-       public Object[] getHighestKCore(MCODEGraph network) {
+       public Object[] getHighestKCore(CySubNetwork network) {
                String callerID = "MCODEAlgorithm.getHighestKCore";
 
                if (network == null) {
@@ -936,7 +937,7 @@
                }
 
                int i = 1;
-               MCODEGraph curNet = null, prevNet = null;
+               CySubNetwork curNet = null, prevNet = null;
 
                while ((curNet = getKCore(network, i)) != null) {
                        network = curNet;

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
     2012-01-12 22:55:52 UTC (rev 28004)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
     2012-01-12 23:10:02 UTC (rev 28005)
@@ -3,7 +3,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.subnetwork.CySubNetwork;
 import org.cytoscape.view.model.CyNetworkView;
 
 /**
@@ -49,7 +49,7 @@
 
        private List<Integer> alCluster;
        private CyNetworkView view; // keeps track of layout so that layout 
process doesn't have to be repeated unecessarily
-       private MCODEGraph graph;
+       private CySubNetwork network;
        private int seedNode;
        private Map<Integer, Boolean> nodeSeenHashMap; // stores the nodes that 
have already been included in higher ranking clusters
        private double clusterScore;
@@ -84,18 +84,14 @@
                this.view = view;
        }
 
-       public MCODEGraph getGraph() {
-               return graph;
+       public CySubNetwork getNetwork() {
+               return network;
        }
 
-       public void setGraph(MCODEGraph graph) {
-               this.graph = graph;
+       public void setNetwork(CySubNetwork network) {
+               this.network = network;
        }
 
-       public CyNetwork getNetwork() {
-               return graph != null ? graph.getSubNetwork() : null;
-       }
-       
        public double getClusterScore() {
                return clusterScore;
        }

Deleted: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEGraph.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEGraph.java
       2012-01-12 22:55:52 UTC (rev 28004)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEGraph.java
       2012-01-12 23:10:02 UTC (rev 28005)
@@ -1,139 +0,0 @@
-package org.cytoscape.mcode.internal.model;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyEdge.Type;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.subnetwork.CyRootNetwork;
-import org.cytoscape.model.subnetwork.CySubNetwork;
-
-public class MCODEGraph {
-
-       private final CyRootNetwork rootNetwork;
-       private final Set<CyNode> nodes;
-       private final Set<CyEdge> edges;
-       private final Map<Integer, CyNode> nodeMap;
-       private final Map<Integer, CyEdge> edgeMap;
-       
-       private CySubNetwork subNetwork;
-       
-       public MCODEGraph(final CyRootNetwork rootNetwork, final 
Collection<CyNode> nodes, final Collection<CyEdge> edges) {
-               if (rootNetwork == null)
-                       throw new NullPointerException("rootNetwork is null!");
-               if (nodes == null)
-                       throw new NullPointerException("nodes is null!");
-               if (edges == null)
-                       throw new NullPointerException("edges is null!");
-               
-               this.rootNetwork = rootNetwork;
-               this.nodes = new HashSet<CyNode>(nodes.size());
-               this.edges = new HashSet<CyEdge>(edges.size());
-               this.nodeMap = new HashMap<Integer, CyNode>(nodes.size());
-               this.edgeMap = new HashMap<Integer, CyEdge>(edges.size());
-               
-               for (CyNode n : nodes) addNode(n);
-               for (CyEdge e : edges) addEdge(e);
-       }
-
-       public boolean addNode(CyNode node) {
-               if (nodes.contains(node)) return false;
-               node = rootNetwork.getNode(node.getIndex());
-               
-               if (nodes.add(node)) {
-                       nodeMap.put(node.getIndex(), node);
-                       return true;
-               }
-               
-               return false;
-       }
-
-       public boolean addEdge(CyEdge edge) {
-               if (edges.contains(edge)) return false;
-               
-               if (nodes.contains(edge.getSource()) && 
nodes.contains(edge.getTarget())) {
-                       edge = rootNetwork.getEdge(edge.getIndex());
-                       
-                       if (edges.add(edge)) {
-                               edgeMap.put(edge.getIndex(), edge);
-                               return true;
-                       }
-               }
-               
-               return false;
-       }
-
-       public int getNodeCount() {
-               return nodes.size();
-       }
-
-       public int getEdgeCount() {
-               return edges.size();
-       }
-
-       public List<CyNode> getNodeList() {
-               return new ArrayList<CyNode>(nodes);
-       }
-
-       public List<CyEdge> getEdgeList() {
-               return new ArrayList<CyEdge>(edges);
-       }
-
-       public boolean containsNode(CyNode node) {
-               return nodes.contains(node);
-       }
-
-       public boolean containsEdge(CyEdge edge) {
-               return edges.contains(edge);
-       }
-
-       public CyNode getNode(int index) {
-               return nodeMap.get(index);
-       }
-
-       public CyEdge getEdge(int index) {
-               return edgeMap.get(index);
-       }
-
-       public List<CyEdge> getAdjacentEdgeList(CyNode node, Type edgeType) {
-               List<CyEdge> rootList = rootNetwork.getAdjacentEdgeList(node, 
edgeType);
-               List<CyEdge> list = new ArrayList<CyEdge>(rootList.size());
-               
-               for (CyEdge e : rootList) {
-                       if (containsEdge(e))
-                               list.add(e);
-               }
-               
-               return list;
-       }
-
-       public List<CyEdge> getConnectingEdgeList(CyNode source, CyNode target, 
Type edgeType) {
-               List<CyEdge> rootList = 
rootNetwork.getConnectingEdgeList(source, target, edgeType);
-               List<CyEdge> list = new ArrayList<CyEdge>(rootList.size());
-               
-               for (CyEdge e : rootList) {
-                       if (containsEdge(e))
-                               list.add(e);
-               }
-               
-               return list;
-       }
-
-       public CyRootNetwork getRootNetwork() {
-               return rootNetwork;
-       }
-
-       public CySubNetwork getSubNetwork() {
-               if (subNetwork == null) {
-                       subNetwork = rootNetwork.addSubNetwork(nodes, edges);
-               }
-               
-               return subNetwork;
-       }
-}

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
 2012-01-12 22:55:52 UTC (rev 28004)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
 2012-01-12 23:10:02 UTC (rev 28005)
@@ -40,14 +40,15 @@
 import org.cytoscape.mcode.internal.model.MCODEAlgorithm;
 import org.cytoscape.mcode.internal.model.MCODECluster;
 import org.cytoscape.mcode.internal.model.MCODECurrentParameters;
-import org.cytoscape.mcode.internal.model.MCODEGraph;
 import org.cytoscape.mcode.internal.util.layout.SpringEmbeddedLayouter;
 import org.cytoscape.mcode.internal.view.MCODELoader;
+import org.cytoscape.model.CyColumn;
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNetworkManager;
 import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
 import org.cytoscape.model.CyTableEntry;
 import org.cytoscape.model.subnetwork.CyRootNetwork;
 import org.cytoscape.model.subnetwork.CyRootNetworkManager;
@@ -433,11 +434,11 @@
 
                return image;
        }
-       
+private int subNetCount; // TODO: delete
        public CySubNetwork createSubNetwork(final CyNetwork net, 
Collection<CyNode> nodes) {
                final CyRootNetwork root = rootNetworkMgr.getRootNetwork(net);
                final Set<CyEdge> edges = new HashSet<CyEdge>();
-
+System.out.println(">> MCODE: Creating sub-network: " + (++subNetCount)); // 
TODO: delete
                for (CyNode n : nodes) {
                        Set<CyEdge> adjacentEdges = new 
HashSet<CyEdge>(net.getAdjacentEdgeList(n, CyEdge.Type.ANY));
 
@@ -453,26 +454,6 @@
 
                return subNet;
        }
-       
-       public MCODEGraph createGraph(final CyNetwork net, Collection<CyNode> 
nodes) {
-               final CyRootNetwork root = rootNetworkMgr.getRootNetwork(net);
-               final Set<CyEdge> edges = new HashSet<CyEdge>();
-               
-               for (CyNode n : nodes) {
-                       Set<CyEdge> adjacentEdges = new 
HashSet<CyEdge>(net.getAdjacentEdgeList(n, CyEdge.Type.ANY));
-                       
-                       // Get only the edges that connect nodes that belong to 
the subnetwork:
-                       for (CyEdge e : adjacentEdges) {
-                               if (nodes.contains(e.getSource()) && 
nodes.contains(e.getTarget())) {
-                                       edges.add(e);
-                               }
-                       }
-               }
-               
-               final MCODEGraph graph = new MCODEGraph(root, nodes, edges);
-               
-               return graph;
-       }
 
        public CyNetworkView createNetworkView(final CyNetwork net, VisualStyle 
vs) {
                final CyNetworkView view = 
networkViewFactory.createNetworkView(net, false);
@@ -499,6 +480,29 @@
                }
        }
 
+       public void addVirtualColumns(CySubNetwork subNetwork, CyNetwork 
parent) {
+               CyTable tbl = subNetwork.getDefaultNodeTable();
+               CyTable parentTbl = parent.getDefaultNodeTable();
+               
+               // Add virtual columns for all of the parent network columns 
(only nodes):
+               final Collection<CyColumn> columns = parentTbl.getColumns();
+               
+               for (CyColumn col : columns) {
+                       final String colName = col.getName();
+                       
+                       if (tbl.getColumn(colName) == null)
+                               tbl.addVirtualColumn(colName, colName, 
parentTbl, CyNode.SUID, false);
+               }
+               
+               // Add MCODE columns
+               if (tbl.getColumn("MCODE_Cluster") == null)
+                       tbl.addVirtualColumn("MCODE_Cluster", "MCODE_Cluster", 
parentTbl, CyNetwork.SUID, false);
+               if (tbl.getColumn("MCODE_Node_Status") == null)
+                       tbl.addVirtualColumn("MCODE_Node_Status", 
"MCODE_Node_Status", parentTbl, CyNetwork.SUID, false);
+               if (tbl.getColumn("MCODE_Score") == null)
+                       tbl.addVirtualColumn("MCODE_Score", "MCODE_Score", 
parentTbl, CyNetwork.SUID, false);
+       }
+       
        @SuppressWarnings("unchecked")
        public VisualStyle getClusterStyle() {
                if (clusterStyle == null) {

Modified: 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
===================================================================
--- 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
 2012-01-12 22:55:52 UTC (rev 28004)
+++ 
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/view/MCODEResultsPanel.java
 2012-01-12 23:10:02 UTC (rev 28005)
@@ -61,6 +61,8 @@
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.subnetwork.CySubNetwork;
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
@@ -302,7 +304,6 @@
         * @return panel A JPanel with the contents of the explore panel, get's
         *         added to the explore collapsable panel's content pane
         */
-       @SuppressWarnings("unchecked")
        private JPanel createExploreContent(int selectedRow) {
                JPanel panel = new JPanel();
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
@@ -413,44 +414,47 @@
         *         used for scoring at the time
         */
        public double setNodeAttributesAndGetMaxScore() {
-               network.getDefaultNodeTable().deleteColumn("MCODE_Cluster");
-               network.getDefaultNodeTable().deleteColumn("MCODE_Node_Status");
-               network.getDefaultNodeTable().deleteColumn("MCODE_Score");
-
-               network.getDefaultNodeTable().createListColumn("MCODE_Cluster", 
String.class, false);
-               network.getDefaultNodeTable().createColumn("MCODE_Node_Status", 
String.class, false);
-               network.getDefaultNodeTable().createColumn("MCODE_Score", 
Double.class, false);
-
                for (CyNode n : network.getNodeList()) {
                        int rgi = n.getIndex();
+                       CyTable netNodeTbl = network.getDefaultNodeTable();
+                       
+                       if (netNodeTbl.getColumn("MCODE_Cluster") == null)
+                               netNodeTbl.createColumn("MCODE_Cluster", 
String.class, false);
+                       if (netNodeTbl.getColumn("MCODE_Node_Status") == null)
+                               netNodeTbl.createColumn("MCODE_Node_Status", 
String.class, false);
+                       if (netNodeTbl.getColumn("MCODE_Score") == null)
+                               netNodeTbl.createColumn("MCODE_Score", 
Double.class, false);
 
-                       CyRow row = network.getRow(n);
-                       row.set("MCODE_Node_Status", "Unclustered");
+                       CyRow nodeRow = network.getRow(n);
+                       nodeRow.set("MCODE_Node_Status", "Unclustered");
+                       nodeRow.set("MCODE_Score", 
alg.getNodeScore(n.getIndex(), resultId));
 
                        for (int c = 0; c < clusters.length; c++) {
                                MCODECluster cluster = clusters[c];
-
+                               CySubNetwork clusterNet = cluster.getNetwork();
+                               
+                               // TODO: encapsulate it with sub-net creation
+                               mcodeUtil.addVirtualColumns(clusterNet, 
network);
+                               
                                if (cluster.getALCluster().contains(rgi)) {
                                        List<String> clusterArrayList = new 
ArrayList<String>();
 
-                                       if (row.isSet("MCODE_Cluster")) {
-                                               clusterArrayList = 
row.getList("MCODE_Cluster", String.class);
+                                       if (nodeRow.isSet("MCODE_Cluster")) {
+                                               clusterArrayList = 
nodeRow.getList("MCODE_Cluster", String.class);
                                                
clusterArrayList.add(cluster.getClusterName());
                                        } else {
                                                
clusterArrayList.add(cluster.getClusterName());
                                        }
 
-                                       row.set("MCODE_Cluster", 
clusterArrayList);
+                                       nodeRow.set("MCODE_Cluster", 
clusterArrayList);
 
                                        if (cluster.getSeedNode() == rgi) {
-                                               row.set("MCODE_Node_Status", 
"Seed");
+                                               
nodeRow.set("MCODE_Node_Status", "Seed");
                                        } else {
-                                               row.set("MCODE_Node_Status", 
"Clustered");
+                                               
nodeRow.set("MCODE_Node_Status", "Clustered");
                                        }
                                }
                        }
-
-                       row.set("MCODE_Score", alg.getNodeScore(n.getIndex(), 
resultId));
                }
 
                return alg.getMaxScore(resultId);
@@ -482,9 +486,11 @@
 
                                @Override
                                protected CyNetworkView doInBackground() throws 
Exception {
-                                       CyNetwork newNetwork = 
mcodeUtil.createSubNetwork(clusterNetwork, clusterNetwork.getNodeList());
+                                       CySubNetwork newNetwork = 
mcodeUtil.createSubNetwork(clusterNetwork, clusterNetwork.getNodeList());
                                        
newNetwork.getRow(newNetwork).set(CyNetwork.NAME, title);
 
+                                       mcodeUtil.addVirtualColumns(newNetwork, 
network);
+                                       
                                        VisualStyle vs = 
mcodeUtil.getNetworkViewStyle(networkView);
                                        CyNetworkView newNetworkView = 
mcodeUtil.createNetworkView(newNetwork, vs);
 
@@ -637,7 +643,6 @@
                        listIt(enumerations);
                }
 
-               @SuppressWarnings("unchecked")
                public void listIt(HashMap<?, ?> enumerations) {
                        // First we sort the hash map of attributes values and 
their occurrences
                        ArrayList<?> enumerationsSorted = sortMap(enumerations);
@@ -739,8 +744,7 @@
        }
 
        /**
-        * Handles the selection of all available node attributes for the
-        * enumeration within the cluster
+        * Handles the selection of all available node attributes for the 
enumeration within the cluster
         */
        private class enumerateAction extends AbstractAction {
 

-- 
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