Author: clopes
Date: 2012-01-11 14:08:59 -0800 (Wed, 11 Jan 2012)
New Revision: 27984
Added:
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/MCODEAnalyzeAction.java
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/task/MCODEAnalyzeTask.java
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEResources.java
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
Log:
Fixed an OutOfMemoryError by using lightweight MCODEGraph objects in the
analysis, rather than creating CySubNetworks, which also makes the analysis
much faster.
Modified:
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEAnalyzeAction.java
===================================================================
---
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEAnalyzeAction.java
2012-01-11 21:49:37 UTC (rev 27983)
+++
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/MCODEAnalyzeAction.java
2012-01-11 22:08:59 UTC (rev 27984)
@@ -29,6 +29,8 @@
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.work.TaskManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* * Copyright (c) 2004 Memorial Sloan-Kettering Cancer Center
@@ -84,6 +86,8 @@
private final MCODEUtil mcodeUtil;
int analyze = FIRST_TIME;
+
+ private static final Logger logger =
LoggerFactory.getLogger(MCODEAnalyzeAction.class);
public MCODEAnalyzeAction(final String title,
final
CyApplicationManager applicationManager,
@@ -165,13 +169,13 @@
// These statements determine which portion of the algorithm
needs to be conducted by
// testing which parameters have been modified compared to the
last saved parameters.
- // Here we ensure that only relavant parameters are looked at.
For example, fluff density
+ // Here we ensure that only relevant parameters are looked at.
For example, fluff density
// parameter is irrelevant if fluff is not used in the current
parameters. Also, none of
// the clustering parameters are relevant if the optimization
is used
if (currentParamsCopy.isIncludeLoops() !=
savedParamsCopy.isIncludeLoops() ||
currentParamsCopy.getDegreeCutoff() !=
savedParamsCopy.getDegreeCutoff() || analyze == FIRST_TIME) {
analyze = RESCORE;
- System.out.println("Analysis: score network, find
clusters");
+ logger.debug("Analysis: score network, find clusters");
mcodeUtil.getCurrentParameters().setParams(currentParamsCopy, resultId,
network.getSUID());
} else if
(!currentParamsCopy.getScope().equals(savedParamsCopy.getScope()) ||
(!currentParamsCopy.getScope().equals(MCODEParameterSet.NETWORK) &&
currentParamsCopy
@@ -187,7 +191,7 @@
.isFluff() &&
currentParamsCopy.getFluffNodeDensityCutoff() != savedParamsCopy
.getFluffNodeDensityCutoff())))) {
analyze = REFIND;
- System.out.println("Analysis: find clusters");
+ logger.debug("Analysis: find clusters");
mcodeUtil.getCurrentParameters().setParams(currentParamsCopy, resultId,
network.getSUID());
} else {
analyze = INTERRUPTION;
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-11 21:49:37 UTC (rev 27983)
+++
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEAlgorithm.java
2012-01-11 22:08:59 UTC (rev 27984)
@@ -16,8 +16,9 @@
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;
/**
* * Copyright (c) 2004 Memorial Sloan-Kettering Cancer Center
@@ -62,6 +63,8 @@
private boolean cancelled = false;
private TaskMonitor taskMonitor = null;
+
+ private static final Logger logger =
LoggerFactory.getLogger(MCODEAlgorithm.class);
//data structure for storing information required for each node
private static class NodeInfo {
@@ -208,7 +211,7 @@
String callerID = "MCODEAlgorithm.MCODEAlgorithm";
if (inputNetwork == null) {
- System.err.println("In " + callerID + ": inputNetwork
was null.");
+ logger.error("In " + callerID + ": inputNetwork was
null.");
return;
}
@@ -231,15 +234,13 @@
NodeInfo nodeInfo = null;
List<Integer> al = null;
int i = 0;
-
List<CyNode> nodes = inputNetwork.getNodeList();
for (CyNode n : nodes) {
nodeInfo = calcNodeInfo(inputNetwork, n.getIndex());
nodeInfoHashMap.put(n.getIndex(), nodeInfo);
- // Score node
double nodeScore = scoreNode(nodeInfo);
-
+
// Save score for later use in TreeMap
// Add a list of nodes to each score in case nodes have
the same score
if (nodeScoreSortedMap.containsKey(nodeScore)) {
@@ -254,7 +255,7 @@
if (taskMonitor != null) {
i++;
- taskMonitor.setProgress((i * 100) / (double)
inputNetwork.getNodeCount());
+ taskMonitor.setProgress((i * 100) / (double)
nodes.size());
}
}
@@ -301,12 +302,12 @@
String callerID = "MCODEAlgorithm.findClusters";
if (inputNetwork == null) {
- System.err.println("In " + callerID + ": inputNetwork
was null.");
+ logger.error("In " + callerID + ": inputNetwork was
null.");
return null;
}
if (nodeInfoHashMap == null || nodeScoreSortedMap == null) {
- System.err.println("In " + callerID + ":
nodeInfoHashMap or nodeScoreSortedMap was null.");
+ logger.error("In " + callerID + ": nodeInfoHashMap or
nodeScoreSortedMap was null.");
return null;
}
@@ -352,11 +353,11 @@
}
// Create an input graph for
the filter and haircut methods
- CyNetwork clusterNetwork =
createClusterNetwork(alCluster, inputNetwork);
+ MCODEGraph clusterGraph =
createClusterGraph(alCluster, inputNetwork);
- if
(!filterCluster(clusterNetwork)) {
+ if
(!filterCluster(clusterGraph)) {
if (params.isHaircut())
{
-
haircutCluster(clusterNetwork, alCluster);
+
haircutCluster(clusterGraph, alCluster);
}
if (params.isFluff()) {
@@ -364,8 +365,8 @@
}
currentCluster.setALCluster(alCluster);
- clusterNetwork =
createClusterNetwork(alCluster, inputNetwork);
-
currentCluster.setNetwork(clusterNetwork);
+ clusterGraph =
createClusterGraph(alCluster, inputNetwork);
+
currentCluster.setGraph(clusterGraph);
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);
@@ -397,7 +398,7 @@
// the ones that contain the selected node(s) and return those
List<MCODECluster> selectedALClusters = new
ArrayList<MCODECluster>();
- if (!params.getScope().equals(MCODEParameterSet.NETWORK)) {
+ if (MCODEParameterSet.SELECTION.equals(params.getScope())) {
for (MCODECluster cluster : alClusters) {
List<Integer> alCluster =
cluster.getALCluster();
List<Integer> alSelectedNodes = new
ArrayList<Integer>();
@@ -470,7 +471,7 @@
}
// Create an input graph for the filter and haircut methods
- CyNetwork clusterNetwork = createClusterNetwork(alCluster,
inputNetwork);
+ MCODEGraph clusterNetwork = createClusterGraph(alCluster,
inputNetwork);
if (params.isHaircut()) {
haircutCluster(clusterNetwork, alCluster);
@@ -481,14 +482,14 @@
}
cluster.setALCluster(alCluster);
- clusterNetwork = createClusterNetwork(alCluster, inputNetwork);
- cluster.setNetwork(clusterNetwork);
+ clusterNetwork = createClusterGraph(alCluster, inputNetwork);
+ cluster.setGraph(clusterNetwork);
cluster.setClusterScore(scoreCluster(cluster));
return cluster;
}
- private CyNetwork createClusterNetwork(List<Integer> alCluster,
CyNetwork inputNetwork) {
+ private MCODEGraph createClusterGraph(List<Integer> alCluster,
CyNetwork inputNetwork) {
Set<CyNode> nodes = new HashSet<CyNode>();
for (int index : alCluster) {
@@ -496,9 +497,9 @@
nodes.add(n);
}
- CyNetwork clusterNetwork =
mcodeUtil.createSubNetwork(inputNetwork, nodes);
+ MCODEGraph clusterGraph = mcodeUtil.createGraph(inputNetwork,
nodes);
- return clusterNetwork;
+ return clusterGraph;
}
/**
@@ -530,8 +531,8 @@
int numNodes = 0;
double density = 0.0, score = 0.0;
- numNodes = cluster.getNetwork().getNodeCount();
- density = calcDensity(cluster.getNetwork(), true);
+ numNodes = cluster.getGraph().getNodeCount();
+ density = calcDensity(cluster.getGraph(), true);
score = density * numNodes;
return score;
@@ -552,14 +553,14 @@
String callerID = "MCODEAlgorithm.calcNodeInfo";
if (inputNetwork == null) {
- System.err.println("In " + callerID + ": gpInputGraph
was null.");
+ logger.error("In " + callerID + ": gpInputGraph was
null.");
return null;
}
// Get neighborhood of this node (including the node)
CyNode rootNode = inputNetwork.getNode(nodeIndex);
List<CyNode> neighbors = inputNetwork.getNeighborList(rootNode,
CyEdge.Type.ANY);
-
+
if (neighbors.size() < 2) {
// If there are no neighbors or just one neighbor,
nodeInfo calculation is trivial
NodeInfo nodeInfo = new NodeInfo();
@@ -591,13 +592,13 @@
} else {
neighborhood = neighborIndexes;
}
-
+
// extract neighborhood subgraph
- CySubNetwork gpNodeNeighborhood =
mcodeUtil.createSubNetwork(inputNetwork, neighbors);
-
- if (gpNodeNeighborhood == null) {
+ MCODEGraph neighborhoodGraph =
mcodeUtil.createGraph(inputNetwork, neighbors);
+
+ if (neighborhoodGraph == null) {
// this shouldn't happen
- System.err.println("In " + callerID + ":
gpNodeNeighborhood was null.");
+ logger.error("In " + callerID + ": gpNodeNeighborhood
was null.");
return null;
}
@@ -605,19 +606,19 @@
NodeInfo nodeInfo = new NodeInfo();
// Density
- if (gpNodeNeighborhood != null) {
- nodeInfo.density = calcDensity(gpNodeNeighborhood,
params.isIncludeLoops());
+ if (neighborhoodGraph != null) {
+ nodeInfo.density = calcDensity(neighborhoodGraph,
params.isIncludeLoops());
}
-
+
nodeInfo.numNodeNeighbors = neighborhood.length;
// Calculate the highest k-core
Integer k = null;
- Object[] returnArray = getHighestKCore(gpNodeNeighborhood);
+ Object[] returnArray = getHighestKCore(neighborhoodGraph);
k = (Integer) returnArray[0];
- CyNetwork kCore = (CyNetwork) returnArray[1];
+ MCODEGraph kCore = (MCODEGraph) returnArray[1];
nodeInfo.coreLevel = k.intValue();
-
+
// Calculate the core density - amplifies the density of
heavily interconnected regions and attenuates
// that of less connected regions
if (kCore != null) {
@@ -626,7 +627,7 @@
// Record neighbor array for later use in cluster detection step
nodeInfo.nodeNeighbors = neighborhood;
-
+
return nodeInfo;
}
@@ -771,16 +772,16 @@
/**
* Checks if the cluster needs to be filtered according to heuristics
in this method
*
- * @param clusterNetwork The cluster to check if it passes the filter
+ * @param clusterGraph The cluster to check if it passes the filter
* @return true if cluster should be filtered, false otherwise
*/
- private boolean filterCluster(CyNetwork clusterNetwork) {
- if (clusterNetwork == null) {
+ private boolean filterCluster(MCODEGraph clusterGraph) {
+ if (clusterGraph == null) {
return true;
}
// filter if the cluster does not satisfy the user specified
k-core
- CyNetwork kCore = getKCore(clusterNetwork, params.getKCore());
+ MCODEGraph kCore = getKCore(clusterGraph, params.getKCore());
return kCore == null;
}
@@ -788,13 +789,13 @@
/**
* Gives the cluster a haircut (removed singly connected nodes by
taking a 2-core)
*
- * @param clusterNetwork The cluster graph
+ * @param clusterGraph The cluster graph
* @param cluster The cluster node ID list (in the original
graph)
* @return true
*/
- private boolean haircutCluster(CyNetwork clusterNetwork, List<Integer>
cluster) {
+ private boolean haircutCluster(MCODEGraph clusterGraph, List<Integer>
cluster) {
// get 2-core
- CyNetwork kCore = getKCore(clusterNetwork, 2);
+ MCODEGraph kCore = getKCore(clusterGraph, 2);
if (kCore != null) {
// clear the cluster and add all 2-core nodes back into
it
@@ -817,14 +818,14 @@
* possible edges.
* @return The density of the network
*/
- public double calcDensity(CyNetwork network, boolean includeLoops) {
+ public double calcDensity(MCODEGraph network, boolean includeLoops) {
int possibleEdgeNum = 0, actualEdgeNum = 0, loopCount = 0;
double density = 0;
String callerID = "MCODEAlgorithm.calcDensity";
if (network == null) {
- System.err.println("In " + callerID + ": network was
null.");
+ logger.error("In " + callerID + ": network was null.");
return (-1.0);
}
@@ -862,17 +863,17 @@
* @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 CyNetwork getKCore(CyNetwork inputNetwork, int k) {
+ public MCODEGraph getKCore(MCODEGraph inputNetwork, int k) {
String callerID = "MCODEAlgorithm.getKCore";
if (inputNetwork == null) {
- System.err.println("In " + callerID + ": inputNetwork
was null.");
+ logger.error("In " + callerID + ": inputNetwork was
null.");
return null;
}
// filter all nodes with degree less than k until convergence
boolean firstLoop = true;
- CyNetwork outputNetwork = null;
+ MCODEGraph outputNetwork = null;
while (true) {
int numDeleted = 0;
@@ -896,9 +897,9 @@
CyNode n = inputNetwork.getNode(index);
outputNodes.add(n);
}
-
- outputNetwork =
mcodeUtil.createSubNetwork(inputNetwork, outputNodes);
-
+
+ outputNetwork =
mcodeUtil.createGraph(inputNetwork.getRootNetwork(), outputNodes);
+
if (outputNetwork.getNodeCount() == 0) {
return null;
}
@@ -926,16 +927,16 @@
* 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(CyNetwork network) {
+ public Object[] getHighestKCore(MCODEGraph network) {
String callerID = "MCODEAlgorithm.getHighestKCore";
if (network == null) {
- System.err.println("In " + callerID + ": network was
null.");
+ logger.error("In " + callerID + ": network was null.");
return (null);
}
int i = 1;
- CyNetwork curNet = null, prevNet = null;
+ MCODEGraph 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-11 21:49:37 UTC (rev 27983)
+++
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODECluster.java
2012-01-11 22:08:59 UTC (rev 27984)
@@ -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 CyNetwork network;
+ private MCODEGraph graph;
private int seedNode;
private Map<Integer, Boolean> nodeSeenHashMap; // stores the nodes that
have already been included in higher ranking clusters
private double clusterScore;
@@ -84,14 +84,18 @@
this.view = view;
}
- public CyNetwork getNetwork() {
- return network;
+ public MCODEGraph getGraph() {
+ return graph;
}
- public void setNetwork(CyNetwork network) {
- this.network = network;
+ public void setGraph(MCODEGraph graph) {
+ this.graph = graph;
}
+ public CyNetwork getNetwork() {
+ return graph != null ? graph.getSubNetwork() : null;
+ }
+
public double getClusterScore() {
return clusterScore;
}
Added:
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
(rev 0)
+++
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/model/MCODEGraph.java
2012-01-11 22:08:59 UTC (rev 27984)
@@ -0,0 +1,139 @@
+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/task/MCODEAnalyzeTask.java
===================================================================
---
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/task/MCODEAnalyzeTask.java
2012-01-11 21:49:37 UTC (rev 27983)
+++
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/task/MCODEAnalyzeTask.java
2012-01-11 22:08:59 UTC (rev 27984)
@@ -11,6 +11,8 @@
import org.cytoscape.model.CyNetwork;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Copyright (c) 2004 Memorial Sloan-Kettering Cancer Center
@@ -62,6 +64,8 @@
private boolean interrupted;
private CyNetwork network;
private Image imageList[];
+
+ private static final Logger logger =
LoggerFactory.getLogger(MCODEAnalyzeTask.class);
/**
* Scores and finds clusters in a given network
@@ -111,7 +115,7 @@
return;
}
- System.err.println("Network was scored in " +
alg.getLastScoreTime() + " ms.");
+ logger.error("Network was scored in " +
alg.getLastScoreTime() + " ms.");
}
taskMonitor.setProgress(0);
Modified:
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEResources.java
===================================================================
---
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEResources.java
2012-01-11 21:49:37 UTC (rev 27983)
+++
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEResources.java
2012-01-11 22:08:59 UTC (rev 27984)
@@ -27,5 +27,4 @@
public static URL getUrl(ImageName img) {
return MCODEResources.class.getResource(img.toString());
}
-
}
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-11 21:49:37 UTC (rev 27983)
+++
csplugins/trunk/toronto/clopes/mcode/src/main/java/org/cytoscape/mcode/internal/util/MCODEUtil.java
2012-01-11 22:08:59 UTC (rev 27984)
@@ -40,6 +40,7 @@
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.CyEdge;
@@ -72,6 +73,8 @@
import org.cytoscape.view.vizmap.mappings.BoundaryRangeValues;
import org.cytoscape.view.vizmap.mappings.ContinuousMapping;
import org.cytoscape.view.vizmap.mappings.DiscreteMapping;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* * Copyright (c) 2004 Memorial Sloan-Kettering Cancer Center
@@ -140,6 +143,8 @@
private Map<Long, Set<Integer>> networkResults;
private int currentResultId;
+
+ private static final Logger logger =
LoggerFactory.getLogger(MCODEUtil.class);
public MCODEUtil(final RenderingEngineFactory<CyNetwork>
renderingEngineFactory,
final CyNetworkViewFactory
networkViewFactory,
@@ -294,7 +299,7 @@
for (View<CyNode> nv : clusterView.getNodeViews()) {
if (interrupted) {
- System.err.println("Interrupted: Node Setup");
+ logger.error("Interrupted: Node Setup");
// before we short-circuit the method we reset
the interruption so that the method can run without
// problems the next time around
if (layouter != null) layouter.resetDoLayout();
@@ -351,7 +356,7 @@
if (clusterView.getEdgeViews() != null) {
for (int i = 0; i < clusterView.getEdgeViews().size();
i++) {
if (interrupted) {
- System.err.println("Interrupted: Edge
Setup");
+ logger.error("Interrupted: Edge Setup");
if (layouter != null)
layouter.resetDoLayout();
resetLoading();
@@ -428,7 +433,7 @@
return image;
}
-
+
public CySubNetwork createSubNetwork(final CyNetwork net,
Collection<CyNode> nodes) {
final CyRootNetwork root = rootNetworkMgr.getRootNetwork(net);
final Set<CyEdge> edges = new HashSet<CyEdge>();
@@ -448,6 +453,26 @@
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);
--
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.