Author: kono
Date: 2011-11-02 17:12:02 -0700 (Wed, 02 Nov 2011)
New Revision: 27385
Added:
csplugins/trunk/ucsd/kono/pingo3/src/pingo/VisualStyleBuilder.java
Removed:
csplugins/trunk/ucsd/kono/pingo3/src/pingo/TheVisualStyle.java
Modified:
csplugins/trunk/ucsd/kono/pingo3/src/pingo/BiNGO.java
csplugins/trunk/ucsd/kono/pingo3/src/pingo/DisplayPingoWindow.java
csplugins/trunk/ucsd/kono/pingo3/src/pingo/PingoAnalysis.java
csplugins/trunk/ucsd/kono/pingo3/src/pingo/SettingsPanelActionListener.java
Log:
Fixed network manager bug. New network will be created in this version if
visualization check box is selected.
Modified: csplugins/trunk/ucsd/kono/pingo3/src/pingo/BiNGO.java
===================================================================
--- csplugins/trunk/ucsd/kono/pingo3/src/pingo/BiNGO.java 2011-11-02
23:52:30 UTC (rev 27384)
+++ csplugins/trunk/ucsd/kono/pingo3/src/pingo/BiNGO.java 2011-11-03
00:12:02 UTC (rev 27385)
@@ -66,8 +66,8 @@
private boolean interrupted = false;
// constructor
- public BiNGO(ModuleNetwork M, BingoParameters bp) throws IOException,
InterruptedException {
-
+ public BiNGO(ModuleNetwork M, BingoParameters bp, TaskMonitor tm)
throws IOException, InterruptedException {
+ this.taskMonitor = tm;
this.maxValue = -1;
this.M = M;
this.bp = bp;
@@ -184,7 +184,7 @@
// Use bing function
algorithm = new BingoAlgorithm(bp);
- CalculateTestTask test = algorithm.calculate_distribution();
+ CalculateTestTask test =
algorithm.calculate_distribution(taskMonitor);
test.calculate();
testMap = test.getTestMap();
Modified: csplugins/trunk/ucsd/kono/pingo3/src/pingo/DisplayPingoWindow.java
===================================================================
--- csplugins/trunk/ucsd/kono/pingo3/src/pingo/DisplayPingoWindow.java
2011-11-02 23:52:30 UTC (rev 27384)
+++ csplugins/trunk/ucsd/kono/pingo3/src/pingo/DisplayPingoWindow.java
2011-11-03 00:12:02 UTC (rev 27385)
@@ -63,7 +63,6 @@
import org.cytoscape.work.TaskMonitor;
import BiNGO.GenericTaskFactory;
-import BiNGO.TheVisualStyle;
/**
* *****************************************************************
@@ -169,6 +168,10 @@
* Method that builds up the new CyNetwork and shows it to the user.
*/
public void makeWindow() {
+
+ System.out.println("MAKE Window called: ");
+
+
final CyNetwork network = buildNetwork();
buildNodeAttributes(network);
buildEdgeAttributes(network);
@@ -219,7 +222,7 @@
layout.setNetworkView(view);
insertTasksAfterCurrentTask(layout.getTaskIterator());
- TheVisualStyle vs = new TheVisualStyle(adapter,
pingoName, Double.parseDouble(alpha));
+ final VisualStyleBuilder vs = new
VisualStyleBuilder(adapter, pingoName, Double.parseDouble(alpha));
final VisualMappingManager vmm =
adapter.getVisualMappingManager();
final VisualStyle newStyle =
vs.createVisualStyle(view.getModel());
vmm.addVisualStyle(newStyle);
Modified: csplugins/trunk/ucsd/kono/pingo3/src/pingo/PingoAnalysis.java
===================================================================
--- csplugins/trunk/ucsd/kono/pingo3/src/pingo/PingoAnalysis.java
2011-11-02 23:52:30 UTC (rev 27384)
+++ csplugins/trunk/ucsd/kono/pingo3/src/pingo/PingoAnalysis.java
2011-11-03 00:12:02 UTC (rev 27385)
@@ -50,6 +50,7 @@
import java.util.Set;
import org.cytoscape.work.TaskManager;
+import org.cytoscape.work.TaskMonitor;
import BiNGO.BingoAlgorithm;
import BiNGO.BingoParameters;
@@ -81,8 +82,10 @@
private HashMap<TestInstance, Integer> bigN;
private HashMap<TestInstance, HashSet<Gene>> neighbors;
+ private TaskMonitor taskMonitor;
- public PingoAnalysis(PingoParameters pp) throws InterruptedException,
IOException {
+ public PingoAnalysis(PingoParameters pp, TaskMonitor tm) throws
InterruptedException, IOException {
+ this.taskMonitor = tm;
this.pp = pp;
M = new ModuleNetwork(pp);
@@ -155,7 +158,7 @@
}
BingoParameters bp = makeBingoParameters(pp);
- BiNGO b = new BiNGO(M, bp);
+ BiNGO b = new BiNGO(M, bp, taskMonitor);
b.calculate();
pred = new HashMap<OntologyTerm, HashSet<Gene>>();
Modified:
csplugins/trunk/ucsd/kono/pingo3/src/pingo/SettingsPanelActionListener.java
===================================================================
--- csplugins/trunk/ucsd/kono/pingo3/src/pingo/SettingsPanelActionListener.java
2011-11-02 23:52:30 UTC (rev 27384)
+++ csplugins/trunk/ucsd/kono/pingo3/src/pingo/SettingsPanelActionListener.java
2011-11-03 00:12:02 UTC (rev 27385)
@@ -60,9 +60,13 @@
import org.cytoscape.view.model.View;
import org.cytoscape.view.presentation.property.RichVisualLexicon;
import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskManager;
+import org.cytoscape.work.TaskMonitor;
import BiNGO.AnnotationParser;
import BiNGO.BingoAlgorithm;
+import BiNGO.GenericTaskFactory;
/**
* ********************************************************************
@@ -180,7 +184,9 @@
}
}
if (consistencyCheck == true) {
- performCalculations();
+ final CalculationTask calc = new
CalculationTask();
+ final TaskManager tm =
adapter.getTaskManager();
+ tm.execute(new
GenericTaskFactory(calc));
}
} catch (Exception e) {
@@ -807,6 +813,7 @@
}
+
/**
* Method that redirects the calculations of the distribution and the
* correction. Redirects the visualization of the network and redirects
the
@@ -814,27 +821,140 @@
* @throws IOException
* @throws InterruptedException
*/
+ private class CalculationTask extends AbstractTask {
+
+ @Override
+ public void run(TaskMonitor tm) throws Exception {
+ // TODO Auto-generated method stub
+ PingoAnalysis gcb = new PingoAnalysis(params, tm);
+ ModuleNetwork M = gcb.getModuleNetwork();
+ if (M.moduleSet == null) {
+ JOptionPane.showMessageDialog(settingsPanel,
"There are no test genes in the network after filtering.");
+ } else {
+
+ System.out.println("######Viz String = " +
params.getVisualization());
+
+ if
(params.getTabMode().equals(VizPanel.TABSTRING)) {
+ String[] goCats =
params.getTargetGoCats().split("\\s+");
+ for (String s : goCats) {
+ Integer cat = new Integer(s);
+ Map<PingoAnalysis.TestInstance,
Double> pvals = gcb.getPvalues(cat);
+ Map<PingoAnalysis.TestInstance,
Integer> smallX = gcb.getSmallX(cat);
+ Map<PingoAnalysis.TestInstance,
Integer> smallN = gcb.getSmallN(cat);
+ Map<PingoAnalysis.TestInstance,
Integer> bigX = gcb.getBigX(cat);
+ Map<PingoAnalysis.TestInstance,
Integer> bigN = gcb.getBigN(cat);
+ Map<PingoAnalysis.TestInstance,
Set<Gene>> neighbors = gcb.getNeighbors(cat);
+ DisplayPingoWindow display;
+ Set<Gene> predictedGenesSet =
new HashSet<Gene>();
+ Set<Gene> graphNodes = new
HashSet<Gene>();
+ Map<Gene, Map<Gene, Double>>
graph = new HashMap<Gene, Map<Gene, Double>>();
+ for (PingoAnalysis.TestInstance
t : pvals.keySet()) {
+
predictedGenesSet.add(M.geneMap.get(t.m.name));
+
graphNodes.add(M.geneMap.get(t.m.name));
+ for (Gene g :
neighbors.get(t)) {
+ if
(!graph.containsKey(M.geneMap.get(t.m.name))) {
+
graph.put(M.geneMap.get(t.m.name), new HashMap<Gene, Double>());
+ }
+
graph.get(M.geneMap.get(t.m.name)).put(g, 0.0);
+
graphNodes.add(g);
+ }
+ }
+ // if not starmode, add
interconnections between neighbors
+ if
(params.getStarMode().equals(VizPanel.NOSTARSTRING)) {
+ for (Gene g1 :
graphNodes) {
+ for (Gene g2 :
graphNodes) {
+ // G is
double-linked hashmap
+ if
((M.G.containsKey(g1) && M.G.get(g1).containsKey(g2))
+
&& (graph.containsKey(g2) && !graph.get(g2).containsKey(g1))) {
+
if (!graph.containsKey(g1)) {
+
graph.put(g1, new HashMap<Gene, Double>());
+
}
+
graph.get(g1).put(g2, 0.0);
+ }
+ }
+ }
+ }
- public void performCalculations() throws InterruptedException,
IOException {
- PingoAnalysis gcb = new PingoAnalysis(params);
- ModuleNetwork M = gcb.getModuleNetwork();
- if (M.moduleSet == null) {
- JOptionPane.showMessageDialog(settingsPanel, "There are
no test genes in the network after filtering.");
- } else {
- if (params.getTabMode().equals(VizPanel.TABSTRING)) {
- String[] goCats =
params.getTargetGoCats().split("\\s+");
- for (String s : goCats) {
- Integer cat = new Integer(s);
- Map<PingoAnalysis.TestInstance, Double>
pvals = gcb.getPvalues(cat);
- Map<PingoAnalysis.TestInstance,
Integer> smallX = gcb.getSmallX(cat);
- Map<PingoAnalysis.TestInstance,
Integer> smallN = gcb.getSmallN(cat);
- Map<PingoAnalysis.TestInstance,
Integer> bigX = gcb.getBigX(cat);
- Map<PingoAnalysis.TestInstance,
Integer> bigN = gcb.getBigN(cat);
- Map<PingoAnalysis.TestInstance,
Set<Gene>> neighbors = gcb.getNeighbors(cat);
+ if
(params.getVisualization().equals(VIZSTRING) && params.isCytoscapeInput()) {
+
+ final Set<CyNode>
selectedNodesSet = new HashSet<CyNode>();
+ final
Collection<View<CyNode>> nodeViews = startNetworkView.getNodeViews();
+ for (final View<CyNode>
nodeView : nodeViews) {
+ final String
node = nodeView.getModel().getCyRow().get(CyTableEntry.NAME, String.class);
+ if
(graphNodes.contains(M.geneMap.get(node))) {
+
selectedNodesSet.add(nodeView.getModel());
+ }
+ }
+
+ final Set<CyEdge>
selectedEdgesSet = new HashSet<CyEdge>();
+ final
Collection<View<CyEdge>> edgeViews = startNetworkView.getEdgeViews();
+ for (View<CyEdge>
edgeView : edgeViews) {
+ final String
sourceNode = edgeView.getModel().getSource().getCyRow()
+
.get(CyTableEntry.NAME, String.class);
+ final String
targetNode = edgeView.getModel().getTarget().getCyRow()
+
.get(CyTableEntry.NAME, String.class);
+ if
(graphNodes.contains(M.geneMap.get(sourceNode))
+
&& graphNodes.contains(M.geneMap.get(targetNode))) {
+ if
(params.getStarMode().equals(VizPanel.STARSTRING)) {
+
if (predictedGenesSet.contains(M.geneMap.get(sourceNode))
+
|| predictedGenesSet.contains(M.geneMap.get(targetNode))) {
+
selectedEdgesSet.add(edgeView.getModel());
+
}
+ } else {
+
selectedEdgesSet.add(edgeView.getModel());
+ }
+ }
+ }
+
+
setSelected(startNetworkView.getModel().getNodeList(), false);
+
setSelected(startNetworkView.getModel().getEdgeList(), false);
+
setSelected(selectedNodesSet, true);
+
setSelected(selectedEdgesSet, true);
+
adapter.getCyEventHelper().flushPayloadEvents();
+
startNetworkView.updateView();
+
+
newWindowSelectedNodesEdges(s);
+
+ } else if
(params.getVisualization().equals(VIZSTRING)) {
+ display = new
DisplayPingoWindow(M, graph, pvals, smallX, smallN, bigX, bigN, params
+
.getSignificance().toString(), params.getCluster_name() + "_" + s, adapter);
+
+ // displaying the Pingo
CyNetwork.
+ display.makeWindow();
+ }
+
+ if ((goBin == null) ||
goBin.isWindowClosed())
+ goBin = new
pingo.GOlorize.GoBin(settingsPanel, startNetworkView, adapter);
+
+ CyNetwork curNetwork =
adapter.getCyApplicationManager().getCurrentNetwork();
+ CyNetworkView curNetworkView =
adapter.getCyApplicationManager().getCurrentNetworkView();
+ goBin.createResultTab(M, pvals,
smallX, smallN, bigX, bigN, neighbors, params.getCluster_name()
+ + "_" + s,
params.getAnnotationFile().toString(), params.getOntologyFile().toString(),
+
params.getTest() + "", params.getCorrection() + "", curNetwork, curNetworkView);
+ }
+ } else {
+ String[] goCats =
params.getTargetGoCats().split("\\s+");
+
+ Map<PingoAnalysis.TestInstance, Double>
pvals = new HashMap<PingoAnalysis.TestInstance, Double>();
+ Map<PingoAnalysis.TestInstance,
Integer> smallX = new HashMap<PingoAnalysis.TestInstance, Integer>();
+ Map<PingoAnalysis.TestInstance,
Integer> smallN = new HashMap<PingoAnalysis.TestInstance, Integer>();
+ Map<PingoAnalysis.TestInstance,
Integer> bigX = new HashMap<PingoAnalysis.TestInstance, Integer>();
+ Map<PingoAnalysis.TestInstance,
Integer> bigN = new HashMap<PingoAnalysis.TestInstance, Integer>();
+ Map<PingoAnalysis.TestInstance,
Set<Gene>> neighbors = new HashMap<PingoAnalysis.TestInstance, Set<Gene>>();
DisplayPingoWindow display;
Set<Gene> predictedGenesSet = new
HashSet<Gene>();
Set<Gene> graphNodes = new
HashSet<Gene>();
Map<Gene, Map<Gene, Double>> graph =
new HashMap<Gene, Map<Gene, Double>>();
+ for (String s : goCats) {
+ Integer cat = new Integer(s);
+
pvals.putAll(gcb.getPvalues(cat));
+
smallX.putAll(gcb.getSmallX(cat));
+
smallN.putAll(gcb.getSmallN(cat));
+ bigX.putAll(gcb.getBigX(cat));
+ bigN.putAll(gcb.getBigN(cat));
+
neighbors.putAll(gcb.getNeighbors(cat));
+ }
+
for (PingoAnalysis.TestInstance t :
pvals.keySet()) {
predictedGenesSet.add(M.geneMap.get(t.m.name));
graphNodes.add(M.geneMap.get(t.m.name));
@@ -846,6 +966,7 @@
graphNodes.add(g);
}
}
+
// if not starmode, add
interconnections between neighbors
if
(params.getStarMode().equals(VizPanel.NOSTARSTRING)) {
for (Gene g1 : graphNodes) {
@@ -864,7 +985,7 @@
if
(params.getVisualization().equals(VIZSTRING) && params.isCytoscapeInput()) {
- final Set<CyNode>
selectedNodesSet = new HashSet();
+ final Set<CyNode>
selectedNodesSet = new HashSet<CyNode>();
final Collection<View<CyNode>>
nodeViews = startNetworkView.getNodeViews();
for (final View<CyNode>
nodeView : nodeViews) {
final String node =
nodeView.getModel().getCyRow().get(CyTableEntry.NAME, String.class);
@@ -872,7 +993,6 @@
selectedNodesSet.add(nodeView.getModel());
}
}
-
final Set<CyEdge>
selectedEdgesSet = new HashSet<CyEdge>();
final Collection<View<CyEdge>>
edgeViews = startNetworkView.getEdgeViews();
for (View<CyEdge> edgeView :
edgeViews) {
@@ -893,139 +1013,38 @@
}
}
-
this.setSelected(startNetworkView.getModel().getNodeList(), false);
-
this.setSelected(startNetworkView.getModel().getEdgeList(), false);
-
this.setSelected(selectedNodesSet, true);
-
this.setSelected(selectedEdgesSet, true);
+
setSelected(startNetworkView.getModel().getNodeList(), false);
+
setSelected(startNetworkView.getModel().getEdgeList(), false);
+ setSelected(selectedNodesSet,
true);
+ setSelected(selectedEdgesSet,
true);
startNetworkView.updateView();
- newWindowSelectedNodesEdges(s);
+ newWindowSelectedNodesEdges("");
} else if
(params.getVisualization().equals(VIZSTRING)) {
display = new
DisplayPingoWindow(M, graph, pvals, smallX, smallN, bigX, bigN, params
-
.getSignificance().toString(), params.getCluster_name() + "_" + s, adapter);
+
.getSignificance().toString(), params.getCluster_name(), adapter);
// displaying the BiNGO
CyNetwork.
display.makeWindow();
}
- if ((goBin == null) ||
goBin.isWindowClosed())
+ if ((goBin == null) ||
goBin.isWindowClosed()) {
goBin = new
pingo.GOlorize.GoBin(settingsPanel, startNetworkView, adapter);
-
- CyNetwork curNetwork =
adapter.getCyApplicationManager().getCurrentNetwork();
- CyNetworkView curNetworkView =
adapter.getCyApplicationManager().getCurrentNetworkView();
- goBin.createResultTab(M, pvals, smallX,
smallN, bigX, bigN, neighbors, params.getCluster_name()
- + "_" + s,
params.getAnnotationFile().toString(), params.getOntologyFile().toString(),
- params.getTest() + "",
params.getCorrection() + "", curNetwork, curNetworkView);
- }
- } else {
- String[] goCats =
params.getTargetGoCats().split("\\s+");
-
- Map<PingoAnalysis.TestInstance, Double> pvals =
new HashMap<PingoAnalysis.TestInstance, Double>();
- Map<PingoAnalysis.TestInstance, Integer> smallX
= new HashMap<PingoAnalysis.TestInstance, Integer>();
- Map<PingoAnalysis.TestInstance, Integer> smallN
= new HashMap<PingoAnalysis.TestInstance, Integer>();
- Map<PingoAnalysis.TestInstance, Integer> bigX =
new HashMap<PingoAnalysis.TestInstance, Integer>();
- Map<PingoAnalysis.TestInstance, Integer> bigN =
new HashMap<PingoAnalysis.TestInstance, Integer>();
- Map<PingoAnalysis.TestInstance, Set<Gene>>
neighbors = new HashMap<PingoAnalysis.TestInstance, Set<Gene>>();
- DisplayPingoWindow display;
- Set<Gene> predictedGenesSet = new
HashSet<Gene>();
- Set<Gene> graphNodes = new HashSet<Gene>();
- Map<Gene, Map<Gene, Double>> graph = new
HashMap<Gene, Map<Gene, Double>>();
- for (String s : goCats) {
- Integer cat = new Integer(s);
- pvals.putAll(gcb.getPvalues(cat));
- smallX.putAll(gcb.getSmallX(cat));
- smallN.putAll(gcb.getSmallN(cat));
- bigX.putAll(gcb.getBigX(cat));
- bigN.putAll(gcb.getBigN(cat));
- neighbors.putAll(gcb.getNeighbors(cat));
- }
-
- for (PingoAnalysis.TestInstance t :
pvals.keySet()) {
-
predictedGenesSet.add(M.geneMap.get(t.m.name));
- graphNodes.add(M.geneMap.get(t.m.name));
- for (Gene g : neighbors.get(t)) {
- if
(!graph.containsKey(M.geneMap.get(t.m.name))) {
-
graph.put(M.geneMap.get(t.m.name), new HashMap<Gene, Double>());
- }
-
graph.get(M.geneMap.get(t.m.name)).put(g, 0.0);
- graphNodes.add(g);
}
- }
- // if not starmode, add interconnections
between neighbors
- if
(params.getStarMode().equals(VizPanel.NOSTARSTRING)) {
- for (Gene g1 : graphNodes) {
- for (Gene g2 : graphNodes) {
- // G is double-linked
hashmap
- if
((M.G.containsKey(g1) && M.G.get(g1).containsKey(g2))
- &&
(graph.containsKey(g2) && !graph.get(g2).containsKey(g1))) {
- if
(!graph.containsKey(g1)) {
-
graph.put(g1, new HashMap<Gene, Double>());
- }
-
graph.get(g1).put(g2, 0.0);
- }
- }
- }
+ goBin.createResultTab(M, pvals, smallX,
smallN, bigX, bigN, neighbors, params.getCluster_name(), params
+
.getAnnotationFile().toString(), params.getOntologyFile().toString(),
params.getTest() + "",
+ params.getCorrection()
+ "", adapter.getCyApplicationManager().getCurrentNetwork(), adapter
+
.getCyApplicationManager().getCurrentNetworkView());
}
-
- if (params.getVisualization().equals(VIZSTRING)
&& params.isCytoscapeInput()) {
-
- final Set<CyNode> selectedNodesSet =
new HashSet<CyNode>();
- final Collection<View<CyNode>>
nodeViews = startNetworkView.getNodeViews();
- for (final View<CyNode> nodeView :
nodeViews) {
- final String node =
nodeView.getModel().getCyRow().get(CyTableEntry.NAME, String.class);
- if
(graphNodes.contains(M.geneMap.get(node))) {
-
selectedNodesSet.add(nodeView.getModel());
- }
- }
- final Set<CyEdge> selectedEdgesSet =
new HashSet<CyEdge>();
- final Collection<View<CyEdge>>
edgeViews = startNetworkView.getEdgeViews();
- for (View<CyEdge> edgeView : edgeViews)
{
- final String sourceNode =
edgeView.getModel().getSource().getCyRow()
-
.get(CyTableEntry.NAME, String.class);
- final String targetNode =
edgeView.getModel().getTarget().getCyRow()
-
.get(CyTableEntry.NAME, String.class);
- if
(graphNodes.contains(M.geneMap.get(sourceNode))
- &&
graphNodes.contains(M.geneMap.get(targetNode))) {
- if
(params.getStarMode().equals(VizPanel.STARSTRING)) {
- if
(predictedGenesSet.contains(M.geneMap.get(sourceNode))
-
|| predictedGenesSet.contains(M.geneMap.get(targetNode))) {
-
selectedEdgesSet.add(edgeView.getModel());
- }
- } else {
-
selectedEdgesSet.add(edgeView.getModel());
- }
- }
- }
-
-
this.setSelected(startNetworkView.getModel().getNodeList(), false);
-
this.setSelected(startNetworkView.getModel().getEdgeList(), false);
- this.setSelected(selectedNodesSet,
true);
- this.setSelected(selectedEdgesSet,
true);
-
- startNetworkView.updateView();
- newWindowSelectedNodesEdges("");
-
- } else if
(params.getVisualization().equals(VIZSTRING)) {
- display = new DisplayPingoWindow(M,
graph, pvals, smallX, smallN, bigX, bigN, params
-
.getSignificance().toString(), params.getCluster_name(), adapter);
-
- // displaying the BiNGO CyNetwork.
- display.makeWindow();
- }
- if ((goBin == null) || goBin.isWindowClosed()) {
- goBin = new
pingo.GOlorize.GoBin(settingsPanel, startNetworkView, adapter);
- }
-
- goBin.createResultTab(M, pvals, smallX, smallN,
bigX, bigN, neighbors, params.getCluster_name(), params
-
.getAnnotationFile().toString(), params.getOntologyFile().toString(),
params.getTest() + "",
- params.getCorrection() + "",
adapter.getCyApplicationManager().getCurrentNetwork(), adapter
-
.getCyApplicationManager().getCurrentNetworkView());
}
}
}
public void newWindowSelectedNodesEdges(final String name) {
+ System.out.println("new Window called: " + name);
+
+
// keep ref to current state
CyNetwork current_network = startNetwork;
CyNetworkView current_network_view = startNetworkView;
@@ -1042,11 +1061,12 @@
else
networkName = params.getCluster_name();
+
+ System.out.println("Creating network: " + networkName);
final CyNetwork new_network =
adapter.getCyNetworkFactory().getInstance();
new_network.getCyRow().set(CyTableEntry.NAME, networkName);
- // Add nodes
final Map<String, CyNode> nodeMap = new HashMap<String,
CyNode>();
- for (CyNode node : nodes) {
+ for (final CyNode node : nodes) {
final String nodeName =
node.getCyRow().get(CyTableEntry.NAME, String.class);
CyNode newNode = nodeMap.get(nodeName);
if (newNode == null) {
@@ -1070,6 +1090,8 @@
edgeMap.put(edgeName, newEdge);
}
}
+
+ adapter.getCyNetworkManager().addNetwork(new_network);
final CyNetworkView new_network_view =
adapter.getCyNetworkViewFactory().getNetworkView(new_network);
@@ -1098,6 +1120,8 @@
adapter.getVisualMappingManager().setVisualStyle(newVS,
new_network_view);
}
+
+
adapter.getCyNetworkViewManager().addNetworkView(new_network_view);
}
Deleted: csplugins/trunk/ucsd/kono/pingo3/src/pingo/TheVisualStyle.java
===================================================================
--- csplugins/trunk/ucsd/kono/pingo3/src/pingo/TheVisualStyle.java
2011-11-02 23:52:30 UTC (rev 27384)
+++ csplugins/trunk/ucsd/kono/pingo3/src/pingo/TheVisualStyle.java
2011-11-03 00:12:02 UTC (rev 27385)
@@ -1,187 +0,0 @@
-package pingo;
-
-/**
- * * Copyright (c) 2010 Flanders Interuniversitary Institute for Biotechnology
(VIB)
- * *
- * * Authors : Steven Maere
- * *
- * * This program is free software; you can redistribute it and/or modify
- * * it under the terms of the GNU General Public License as published by
- * * the Free Software Foundation; either version 2 of the License, or
- * * (at your option) any later version.
- * *
- * * This program is distributed in the hope that it will be useful,
- * * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * * The software and documentation provided hereunder is on an "as is" basis,
- * * and the Flanders Interuniversitary Institute for Biotechnology
- * * has no obligations to provide maintenance, support,
- * * updates, enhancements or modifications. In no event shall the
- * * Flanders Interuniversitary Institute for Biotechnology
- * * be liable to any party for direct, indirect, special,
- * * incidental or consequential damages, including lost profits, arising
- * * out of the use of this software and its documentation, even if
- * * the Flanders Interuniversitary Institute for Biotechnology
- * * has been advised of the possibility of such damage. See the
- * * GNU General Public License for more details.
- * *
- * * You should have received a copy of the GNU General Public License
- * * along with this program; if not, write to the Free Software
- * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * *
- * * Authors: Steven Maere
- * * Date: Jul.27.2010
- * * Description: PiNGO is a Cytoscape plugin that leverages functional
enrichment
- * * analysis to discover lead genes from biological networks.
- **/
-
-import java.awt.Color;
-
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.plugin.CyPluginAdapter;
-import org.cytoscape.view.presentation.property.LineTypeVisualProperty;
-import org.cytoscape.view.presentation.property.NodeShapeVisualProperty;
-import org.cytoscape.view.presentation.property.RichVisualLexicon;
-import org.cytoscape.view.vizmap.VisualMappingFunction;
-import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
-import org.cytoscape.view.vizmap.VisualStyle;
-import org.cytoscape.view.vizmap.VisualStyleFactory;
-
-/**
- * *****************************************************************
- * TheVisualStyle.java Steven Maere (c) 2005-2010
- *
- * <p>
- * Class that defines the PiNGO visual style used in the Cytoscape
visualization
- * of PiNGO results.
- * </p>
- *
- * Updated on June, 2010 for Cytoscape 2.7.0+ by Keiichiro Ono
- *
- * ******************************************************************
- */
-public class TheVisualStyle {
-
- private static final Color NADA = Color.white;
- private static final Color COL_MIN = new Color(255, 255, 0);
- private static final Color COL_MAX = new Color(255, 127, 0);
-
- private static final Double DEF_NODE_SIZE = 100d;
-
- // Name of analyzed network
- private String networkName;
-
- private double alpha;
- private final String pingoVSName;
- private final String NODE_COLOR;
- private final String NODE_LABEL;
- private final String NODE_SIZE;
- private final String EDGE_COLOR;
-
- private final CyPluginAdapter adapter;
-
- public TheVisualStyle(final CyPluginAdapter adapter, final String
networkName, double alpha) {
- this.adapter = adapter;
- this.networkName = networkName;
- this.alpha = alpha;
- this.pingoVSName = "PiNGO Style for " + networkName;
- this.NODE_COLOR = "nodeFillColor_" + networkName;
- this.NODE_LABEL = "description_" + networkName;
- this.NODE_SIZE = "nodeSize_" + networkName;
- this.EDGE_COLOR = "edgeType_" + networkName;
- }
-
- public void adaptVisualStyle(VisualStyle style, CyNetwork network) {
-
- // Node default appearance definitions
- style.setDefaultValue(RichVisualLexicon.NODE_SHAPE,
NodeShapeVisualProperty.ELLIPSE);
- style.setDefaultValue(RichVisualLexicon.NODE_LABEL_FONT_SIZE,
14);
- style.setDefaultValue(RichVisualLexicon.NODE_WIDTH, 40d);
- style.setDefaultValue(RichVisualLexicon.NODE_HEIGHT, 40d);
- style.setDefaultValue(RichVisualLexicon.NODE_BORDER_WIDTH, 2d);
- style.setDefaultValue(RichVisualLexicon.NODE_BORDER_PAINT,
Color.DARK_GRAY);
- style.setDefaultValue(RichVisualLexicon.NODE_TRANSPARENCY, 210);
-
- // Edge default appearence definitions
- // FIXME
-// style.getEdgeAppearanceCalculator().getDefaultAppearance()
-// .set(VisualPropertyType.EDGE_TGTARROW_SHAPE,
ArrowShape.NONE);
-// style.getEdgeAppearanceCalculator().getDefaultAppearance()
-// .set(VisualPropertyType.EDGE_TGTARROW_COLOR,
Color.LIGHT_GRAY);
-// style.getEdgeAppearanceCalculator().getDefaultAppearance()
-// .set(VisualPropertyType.EDGE_SRCARROW_SHAPE,
ArrowShape.NONE);
-// style.getEdgeAppearanceCalculator().getDefaultAppearance()
-
- style.setDefaultValue(RichVisualLexicon.EDGE_LINE_TYPE,
LineTypeVisualProperty.SOLID);
- style.setDefaultValue(RichVisualLexicon.EDGE_WIDTH, 4d);
-
style.setDefaultValue(RichVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT,
Color.DARK_GRAY);
-
-
style.setDefaultValue(RichVisualLexicon.NETWORK_BACKGROUND_PAINT, Color.WHITE);
-
- // Display NODE_LABEL as a label
- final VisualMappingFunctionFactory passthroughF =
adapter.getVisualMappingFunctionPassthroughFactory();
- final VisualMappingFunction<String, String> labelMapping =
passthroughF.createVisualMappingFunction(NODE_LABEL,
- String.class, RichVisualLexicon.NODE_LABEL);
- style.addVisualMappingFunction(labelMapping);
-
-// // Gradient node color mapping
-// // TODO: Replace when 2.8 released.
-// // final ContinuousMapping<Double, Color> colorMapping = new
-// // ContinuousMapping<Double, Color>(
-// // Color.class, NODE_COLOR);
-// final ContinuousMapping colorMapping = new
ContinuousMapping(NADA, ObjectMapping.NODE_MAPPING);
-// colorMapping.setControllingAttributeName(NODE_COLOR, network,
false);
-// // TODO: Add generics parameter when 2.8 released.
-// final BoundaryRangeValues colbrVal1 = new BoundaryRangeValues();
-// double cols = -(Math.log(alpha) / Math.log(10));
-// colbrVal1.lesserValue = NADA;
-// colbrVal1.equalValue = COL_MIN;
-// colbrVal1.greaterValue = COL_MIN;
-// colorMapping.addPoint(cols, colbrVal1);
-//
-// // TODO: Add generics parameter when 2.8 released.
-// final BoundaryRangeValues colbrVal2 = new BoundaryRangeValues();
-// cols = -(Math.log(alpha) / Math.log(10)) + 5.0;
-// colbrVal2.lesserValue = COL_MAX;
-// colbrVal2.equalValue = COL_MAX;
-// colbrVal2.greaterValue = COL_MAX;
-// colorMapping.addPoint(cols, colbrVal2);
-//
-// final Calculator colorCalculator = new BasicCalculator("Pingo
Node Color_" + networkName, colorMapping,
-// VisualPropertyType.NODE_FILL_COLOR);
-//
style.getNodeAppearanceCalculator().setCalculator(colorCalculator);
-//
-// // Node Size Mapping
-// // TODO: Update when 2.8 released.
-// final ContinuousMapping wMapping = new
ContinuousMapping(DEF_NODE_SIZE, ObjectMapping.NODE_MAPPING);
-// wMapping.setControllingAttributeName(NODE_SIZE, network, false);
-// final ContinuousMapping hMapping = new
ContinuousMapping(DEF_NODE_SIZE, ObjectMapping.NODE_MAPPING);
-// hMapping.setControllingAttributeName(NODE_SIZE, network, false);
-//
-// // The following code defines the range of values
-//
-// BoundaryRangeValues brVals;
-// int j;
-// for (j = 0; j <= 1; j++) {
-// brVals = new BoundaryRangeValues();
-// final double size = 380d * j + 20d;
-// final double s = 99 * j + 1;
-// brVals.lesserValue = size;
-// brVals.equalValue = size;
-// brVals.greaterValue = size;
-// wMapping.addPoint(s, brVals);
-// hMapping.addPoint(s, brVals);
-// }
-//
-// final Calculator nodeSizeCalculator = new
BasicCalculator("Pingo Node Size_" + networkName, wMapping,
-// VisualPropertyType.NODE_SIZE);
-//
style.getNodeAppearanceCalculator().setCalculator(nodeSizeCalculator);
- }
-
- public VisualStyle createVisualStyle(final CyNetwork network) {
- final VisualStyleFactory vsFactory =
adapter.getVisualStyleFactory();
- final VisualStyle visualStyle =
vsFactory.getInstance(pingoVSName);
- adaptVisualStyle(visualStyle, network);
- return visualStyle;
- }
-}
Copied: csplugins/trunk/ucsd/kono/pingo3/src/pingo/VisualStyleBuilder.java
(from rev 27359, csplugins/trunk/ucsd/kono/pingo3/src/pingo/TheVisualStyle.java)
===================================================================
--- csplugins/trunk/ucsd/kono/pingo3/src/pingo/VisualStyleBuilder.java
(rev 0)
+++ csplugins/trunk/ucsd/kono/pingo3/src/pingo/VisualStyleBuilder.java
2011-11-03 00:12:02 UTC (rev 27385)
@@ -0,0 +1,187 @@
+package pingo;
+
+/**
+ * * Copyright (c) 2010 Flanders Interuniversitary Institute for Biotechnology
(VIB)
+ * *
+ * * Authors : Steven Maere
+ * *
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation; either version 2 of the License, or
+ * * (at your option) any later version.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * * The software and documentation provided hereunder is on an "as is" basis,
+ * * and the Flanders Interuniversitary Institute for Biotechnology
+ * * has no obligations to provide maintenance, support,
+ * * updates, enhancements or modifications. In no event shall the
+ * * Flanders Interuniversitary Institute for Biotechnology
+ * * be liable to any party for direct, indirect, special,
+ * * incidental or consequential damages, including lost profits, arising
+ * * out of the use of this software and its documentation, even if
+ * * the Flanders Interuniversitary Institute for Biotechnology
+ * * has been advised of the possibility of such damage. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * *
+ * * Authors: Steven Maere
+ * * Date: Jul.27.2010
+ * * Description: PiNGO is a Cytoscape plugin that leverages functional
enrichment
+ * * analysis to discover lead genes from biological networks.
+ **/
+
+import java.awt.Color;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.plugin.CyPluginAdapter;
+import org.cytoscape.view.presentation.property.LineTypeVisualProperty;
+import org.cytoscape.view.presentation.property.NodeShapeVisualProperty;
+import org.cytoscape.view.presentation.property.RichVisualLexicon;
+import org.cytoscape.view.vizmap.VisualMappingFunction;
+import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
+import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
+
+/**
+ * *****************************************************************
+ * TheVisualStyle.java Steven Maere (c) 2005-2010
+ *
+ * <p>
+ * Class that defines the PiNGO visual style used in the Cytoscape
visualization
+ * of PiNGO results.
+ * </p>
+ *
+ * Updated on June, 2010 for Cytoscape 2.7.0+ by Keiichiro Ono
+ *
+ * ******************************************************************
+ */
+public class VisualStyleBuilder {
+
+ private static final Color NADA = Color.white;
+ private static final Color COL_MIN = new Color(255, 255, 0);
+ private static final Color COL_MAX = new Color(255, 127, 0);
+
+ private static final Double DEF_NODE_SIZE = 100d;
+
+ // Name of analyzed network
+ private String networkName;
+
+ private double alpha;
+ private final String pingoVSName;
+ private final String NODE_COLOR;
+ private final String NODE_LABEL;
+ private final String NODE_SIZE;
+ private final String EDGE_COLOR;
+
+ private final CyPluginAdapter adapter;
+
+ public VisualStyleBuilder(final CyPluginAdapter adapter, final String
networkName, double alpha) {
+ this.adapter = adapter;
+ this.networkName = networkName;
+ this.alpha = alpha;
+ this.pingoVSName = "PiNGO Style for " + networkName;
+ this.NODE_COLOR = "nodeFillColor_" + networkName;
+ this.NODE_LABEL = "description_" + networkName;
+ this.NODE_SIZE = "nodeSize_" + networkName;
+ this.EDGE_COLOR = "edgeType_" + networkName;
+ }
+
+ private void adaptVisualStyle(VisualStyle style, CyNetwork network) {
+
+ // Node default appearance definitions
+ style.setDefaultValue(RichVisualLexicon.NODE_SHAPE,
NodeShapeVisualProperty.ELLIPSE);
+ style.setDefaultValue(RichVisualLexicon.NODE_LABEL_FONT_SIZE,
14);
+ style.setDefaultValue(RichVisualLexicon.NODE_WIDTH, 40d);
+ style.setDefaultValue(RichVisualLexicon.NODE_HEIGHT, 40d);
+ style.setDefaultValue(RichVisualLexicon.NODE_BORDER_WIDTH, 2d);
+ style.setDefaultValue(RichVisualLexicon.NODE_BORDER_PAINT,
Color.DARK_GRAY);
+ style.setDefaultValue(RichVisualLexicon.NODE_TRANSPARENCY, 210);
+
+ // Edge default appearence definitions
+ // FIXME
+// style.getEdgeAppearanceCalculator().getDefaultAppearance()
+// .set(VisualPropertyType.EDGE_TGTARROW_SHAPE,
ArrowShape.NONE);
+// style.getEdgeAppearanceCalculator().getDefaultAppearance()
+// .set(VisualPropertyType.EDGE_TGTARROW_COLOR,
Color.LIGHT_GRAY);
+// style.getEdgeAppearanceCalculator().getDefaultAppearance()
+// .set(VisualPropertyType.EDGE_SRCARROW_SHAPE,
ArrowShape.NONE);
+// style.getEdgeAppearanceCalculator().getDefaultAppearance()
+
+ style.setDefaultValue(RichVisualLexicon.EDGE_LINE_TYPE,
LineTypeVisualProperty.SOLID);
+ style.setDefaultValue(RichVisualLexicon.EDGE_WIDTH, 4d);
+
style.setDefaultValue(RichVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT,
Color.DARK_GRAY);
+
+
style.setDefaultValue(RichVisualLexicon.NETWORK_BACKGROUND_PAINT, Color.WHITE);
+
+ // Display NODE_LABEL as a label
+ final VisualMappingFunctionFactory passthroughF =
adapter.getVisualMappingFunctionPassthroughFactory();
+ final VisualMappingFunction<String, String> labelMapping =
passthroughF.createVisualMappingFunction(NODE_LABEL,
+ String.class, RichVisualLexicon.NODE_LABEL);
+ style.addVisualMappingFunction(labelMapping);
+
+// // Gradient node color mapping
+// // TODO: Replace when 2.8 released.
+// // final ContinuousMapping<Double, Color> colorMapping = new
+// // ContinuousMapping<Double, Color>(
+// // Color.class, NODE_COLOR);
+// final ContinuousMapping colorMapping = new
ContinuousMapping(NADA, ObjectMapping.NODE_MAPPING);
+// colorMapping.setControllingAttributeName(NODE_COLOR, network,
false);
+// // TODO: Add generics parameter when 2.8 released.
+// final BoundaryRangeValues colbrVal1 = new BoundaryRangeValues();
+// double cols = -(Math.log(alpha) / Math.log(10));
+// colbrVal1.lesserValue = NADA;
+// colbrVal1.equalValue = COL_MIN;
+// colbrVal1.greaterValue = COL_MIN;
+// colorMapping.addPoint(cols, colbrVal1);
+//
+// // TODO: Add generics parameter when 2.8 released.
+// final BoundaryRangeValues colbrVal2 = new BoundaryRangeValues();
+// cols = -(Math.log(alpha) / Math.log(10)) + 5.0;
+// colbrVal2.lesserValue = COL_MAX;
+// colbrVal2.equalValue = COL_MAX;
+// colbrVal2.greaterValue = COL_MAX;
+// colorMapping.addPoint(cols, colbrVal2);
+//
+// final Calculator colorCalculator = new BasicCalculator("Pingo
Node Color_" + networkName, colorMapping,
+// VisualPropertyType.NODE_FILL_COLOR);
+//
style.getNodeAppearanceCalculator().setCalculator(colorCalculator);
+//
+// // Node Size Mapping
+// // TODO: Update when 2.8 released.
+// final ContinuousMapping wMapping = new
ContinuousMapping(DEF_NODE_SIZE, ObjectMapping.NODE_MAPPING);
+// wMapping.setControllingAttributeName(NODE_SIZE, network, false);
+// final ContinuousMapping hMapping = new
ContinuousMapping(DEF_NODE_SIZE, ObjectMapping.NODE_MAPPING);
+// hMapping.setControllingAttributeName(NODE_SIZE, network, false);
+//
+// // The following code defines the range of values
+//
+// BoundaryRangeValues brVals;
+// int j;
+// for (j = 0; j <= 1; j++) {
+// brVals = new BoundaryRangeValues();
+// final double size = 380d * j + 20d;
+// final double s = 99 * j + 1;
+// brVals.lesserValue = size;
+// brVals.equalValue = size;
+// brVals.greaterValue = size;
+// wMapping.addPoint(s, brVals);
+// hMapping.addPoint(s, brVals);
+// }
+//
+// final Calculator nodeSizeCalculator = new
BasicCalculator("Pingo Node Size_" + networkName, wMapping,
+// VisualPropertyType.NODE_SIZE);
+//
style.getNodeAppearanceCalculator().setCalculator(nodeSizeCalculator);
+ }
+
+ public VisualStyle createVisualStyle(final CyNetwork network) {
+ final VisualStyleFactory vsFactory =
adapter.getVisualStyleFactory();
+ final VisualStyle visualStyle =
vsFactory.getInstance(pingoVSName);
+ adaptVisualStyle(visualStyle, network);
+ return visualStyle;
+ }
+}
--
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.