From a49f59ebf5a9e8627f5a4dab14da363f9bd9b630 Mon Sep 17 00:00:00 2001 From: Philipp Spohr <spohr.philipp@web.de> Date: Thu, 14 Dec 2017 14:14:30 +0100 Subject: [PATCH] Fixes to meta-graph bugs introduced recently --- .../swing/components/SolutionTab.java | 10 ++++++---- .../tasks/CreateClusterViewsTask.java | 7 ++++--- .../tasks/CreateMetaGraphTask.java | 7 +++++-- .../yoshikoWrapper/tasks/GetClustersTask.java | 18 +++++++++++++++++- .../yoshikoWrapper/tasks/GetSolutionsTask.java | 17 ++++++++++++++--- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java index 104d39a..b0c4e99 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java @@ -203,22 +203,24 @@ public class SolutionTab extends JPanel { layout = new GroupLayout(this); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER,true) + .addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) + .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addGap(8) .addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE) .addComponent(hideSingles,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE) .addGap(8) .addComponent(scrollPane,PREFERRED_SIZE,PREFERRED_SIZE,Short.MAX_VALUE) - .addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) - .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) + .addGap(4) ); layout.setVerticalGroup(layout.createSequentialGroup() + .addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) + .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) .addGap(8) .addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(hideSingles,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) .addGap(8) .addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) - .addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) - .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) + .addGap(4) ); this.setLayout(layout); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateClusterViewsTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateClusterViewsTask.java index 72d6270..0531fa7 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateClusterViewsTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateClusterViewsTask.java @@ -22,6 +22,10 @@ public class CreateClusterViewsTask implements Task { @Tunable public ArrayList<YoshikoCluster> clusters; //TODO: Make Tunable, reference by ID? + /** + * Killswitch, used to determine if the algorithm has been terminated. + * We can use this to cancel at a given point (so we don't need to finish the entire task) + */ private boolean isTerminated; /** @@ -77,11 +81,8 @@ public class CreateClusterViewsTask implements Task { StyleManager.style(subnetView,CyCore.visualMappingManager.getCurrentVisualStyle()); CyCore.networkViewManager.addNetworkView(subnetView); } - } ); - - } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java index 1f24dea..cf0ffb6 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java @@ -94,7 +94,7 @@ public class CreateMetaGraphTask extends AbstractTask{ //Link clusters node in meta graph and subnet graph to use Cytoscape Nested Network feature clusterNode.setNetworkPointer(subnet); //Set node attributes - metaGraph.getRow(clusterNode).set("name", LocalizationManager.get("clusters")+" "+c.getID()); + metaGraph.getRow(clusterNode).set("name", LocalizationManager.get("clusters")+" "+(c.getID()+1)); metaGraph.getRow(clusterNode).set(StyleManager.CLUSTERSIZE_COLUMN_NAME,c.getSize()); map.put(c, clusterNode); } @@ -105,12 +105,13 @@ public class CreateMetaGraphTask extends AbstractTask{ taskMonitor.setStatusMessage(LocalizationManager.get("metaGraph_edges")); Iterator<YoshikoCluster> it1 = solution.getClusters().iterator(); - Iterator<YoshikoCluster> it2 = solution.getClusters().iterator(); while (it1.hasNext()) { YoshikoCluster c1 = it1.next(); + Iterator<YoshikoCluster> it2 = solution.getClusters().iterator(); while(it2.hasNext()) { YoshikoCluster c2 = it2.next(); + System.out.println("Debug: Processing edges between cluster "+c1.getID()+" and "+c2.getID()); if(isTerminated) { throw new Exception("Terminated by user!"); @@ -126,7 +127,9 @@ public class CreateMetaGraphTask extends AbstractTask{ for (CyNode c1n : c1.getSubNetwork().getNodeList()) { for (CyNode c2n : c2.getSubNetwork().getNodeList()) { if (solution.getOriginalGraph().containsEdge(c1n, c2n) || solution.getOriginalGraph().containsEdge(c2n, c1n)) { + System.out.println("Debug: Found relevant edge from "+c1n.getSUID()+ " to "+c2n.getSUID()); if (!metaGraph.containsEdge(map.get(c1), map.get(c2))){ + System.out.println("We create a new edge for it"); CyEdge edge = metaGraph.addEdge(map.get(c1), map.get(c2), false); metaGraph.getRow(edge).set(StyleManager.EDGESTRENGTH_COLUMN_NAME,1); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java index 0afa05e..6a49b1e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java @@ -9,16 +9,32 @@ import org.cytoscape.work.Tunable; import de.hhu.ba.yoshikoWrapper.core.ResultList; import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster; import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult; -import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution; +/** + * A task that retrieves the clusters associated with a given solution in a given result. This is meant to be used via CyRest / command line functionality exclusively + * + * @author Philipp Spohr, Dec 12, 2017 + * + */ public class GetClustersTask implements ObservableTask { + + /** + * The ID of the result for which the clusters are to be retrieved + */ @Tunable(description="The result ID for which the solutions should be displayed", context="nogui") public int resultID = -1; + /** + * The ID of the solution for which the clusters are to be retrieved + */ @Tunable(description="The solution ID for which the solutions should be displayed", context="nogui") public long solutionID = -1; + + /** + * The clusters as a collection when they are retrieved + */ private Collection<YoshikoCluster> clusters; @Override diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java index b36ef96..b4d60d6 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java @@ -10,11 +10,23 @@ import de.hhu.ba.yoshikoWrapper.core.ResultList; import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult; import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution; +/** + * Basic task that retrieves solutions associated with a run (result) + * This is meant to be invoked from cmd / CyRest exclusively to receive solution IDs + * @author Philipp Spohr, Dec 12, 2017 + * + */ public class GetSolutionsTask implements ObservableTask { + /** + * The result ID for the result/run for which the solutions are to be retrieved + */ @Tunable(description="The result ID for which the solutions should be displayed", context="nogui") public int resultID = -1; + /** + * The solutions as a collection in case the task was successful + */ private Collection<YoshikoSolution> solutions; @Override @@ -27,9 +39,7 @@ public class GetSolutionsTask implements ObservableTask { } @Override - public void cancel() { - // TODO Auto-generated method stub - } + public void cancel() {} //There is nothing here that remains in an instable state as we are simply reading / retrieving data @SuppressWarnings("unchecked") @Override @@ -44,4 +54,5 @@ public class GetSolutionsTask implements ObservableTask { return null; } + } -- GitLab