Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package nl.tudelft.pl2016gr2.core.algorithms.subgraph;

import nl.tudelft.pl2016gr2.model.graph.SequenceGraph;
import nl.tudelft.pl2016gr2.model.graph.nodes.GraphNode;

import java.util.ArrayList;
Expand All @@ -12,25 +11,26 @@
*/
public class OrderedGraph {

private final SequenceGraph subgraph;
private final ArrayList<GraphNode> graphOrderEndX;
private final int amountOfGenomes;
private final ArrayList<GraphNode> graphOrder;

/**
* Construct an ordered graph.
*
* @param subgraph the subgraph.
* @param graphOrder the graph order.
* @param amountOfGenomes the amount of genomes in the graph.
* @param graphOrder the graph order.
*/
public OrderedGraph(SequenceGraph subgraph, ArrayList<GraphNode> graphOrder) {
this.subgraph = subgraph;
this.graphOrderEndX = graphOrder;
public OrderedGraph(int amountOfGenomes, ArrayList<GraphNode> graphOrder) {
this.amountOfGenomes = amountOfGenomes;
this.graphOrder = graphOrder;
graphOrder.trimToSize();
}

public SequenceGraph getSubgraph() {
return subgraph;
public int getGenomeSize() {
return amountOfGenomes;
}

public ArrayList<GraphNode> getGraphOrder() {
return graphOrderEndX;
return graphOrder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private SubgraphAlgorithmManager() {
* @return a pair containing as left value the ordered graph of the top subgraph and as right
* value the ordered graph of the bottom subgraph.
*/
@SuppressWarnings("checkstyle:MethodLength")
@SuppressWarnings({"checkstyle:MethodLength", "checkstyle:VariableDeclarationUsageDistance"})
public static Pair<OrderedGraph, OrderedGraph> compareTwoGraphs(Collection<Integer> topGenomes,
Collection<Integer> bottomGenomes, SequenceGraph mainGraph, GraphOrdererThread mainGraphOrder,
IPhylogeneticTreeRoot<?> treeRoot) {
Expand All @@ -56,10 +56,14 @@ public static Pair<OrderedGraph, OrderedGraph> compareTwoGraphs(Collection<Integ
topSubGraphThread.start();
bottomSubGraphThread.start();

FilterBubbleThread topFilter = new FilterBubbleThread(topSubGraphThread.getSubGraph(),
topGenomes, treeRoot);
FilterBubbleThread bottomFilter = new FilterBubbleThread(bottomSubGraphThread.getSubGraph(),
bottomGenomes, treeRoot);
FilterBubbleThread topFilter = new FilterBubbleThread(
topSubGraphThread.getSubGraph().getOrderedGraph(), topGenomes, treeRoot);
FilterBubbleThread bottomFilter = new FilterBubbleThread(
bottomSubGraphThread.getSubGraph().getOrderedGraph(), bottomGenomes, treeRoot);
int topGenomeCount = topSubGraphThread.getSubGraph().getGenomes().size();
int bottomGenomeCount = bottomSubGraphThread.getSubGraph().getGenomes().size();
topSubGraphThread = null; // allow garbage collecting
bottomSubGraphThread = null; // allow garbage collecting
topFilter.start();
bottomFilter.start();

Expand All @@ -69,9 +73,8 @@ public static Pair<OrderedGraph, OrderedGraph> compareTwoGraphs(Collection<Integ
addDummyNodes(topGraphOrder);
addDummyNodes(bottomGraphOrder);

OrderedGraph orderedTopGraph = new OrderedGraph(topSubGraphThread.getSubGraph(), topGraphOrder);
OrderedGraph orderedBottomGraph = new OrderedGraph(bottomSubGraphThread.getSubGraph(),
bottomGraphOrder);
OrderedGraph orderedTopGraph = new OrderedGraph(topGenomeCount, topGraphOrder);
OrderedGraph orderedBottomGraph = new OrderedGraph(bottomGenomeCount, bottomGraphOrder);
return new Pair<>(orderedTopGraph, orderedBottomGraph);
}

Expand All @@ -84,6 +87,7 @@ public static Pair<OrderedGraph, OrderedGraph> compareTwoGraphs(Collection<Integ
* @param treeRoot the root of the phylogenetic tree.
* @return the ordered graph.
*/
@SuppressWarnings("checkstyle:VariableDeclarationUsageDistance")
public static OrderedGraph alignOneGraph(Collection<Integer> genomes, SequenceGraph mainGraph,
GraphOrdererThread mainGraphOrder, IPhylogeneticTreeRoot<?> treeRoot) {
dummyRootNodeId = Integer.MAX_VALUE;
Expand All @@ -93,11 +97,13 @@ public static OrderedGraph alignOneGraph(Collection<Integer> genomes, SequenceGr
SequenceGraph subgraph = topSubGraphThread.getSubGraph();

ArrayList<GraphNode> orderedNodes = subgraph.getOrderedGraph();
int amountOfGenomes = subgraph.getGenomes().size();
subgraph = null; // allow garbage collection
orderedNodes = performBubblingAlgorithms(orderedNodes, genomes, treeRoot);

CompareSubgraphs.alignVertically(orderedNodes);
addDummyNodes(orderedNodes);
return new OrderedGraph(subgraph, orderedNodes);
return new OrderedGraph(amountOfGenomes, orderedNodes);
}

/**
Expand Down Expand Up @@ -190,14 +196,13 @@ public void run() {

private static class FilterBubbleThread extends Thread {

private final SequenceGraph subgraph;
private final Collection<Integer> genomes;
private final IPhylogeneticTreeRoot<?> treeRoot;
private ArrayList<GraphNode> orderedNodes;

private FilterBubbleThread(SequenceGraph subgraph, Collection<Integer> genomes,
private FilterBubbleThread(ArrayList<GraphNode> orderedSubgraph, Collection<Integer> genomes,
IPhylogeneticTreeRoot<?> treeRoot) {
this.subgraph = subgraph;
this.orderedNodes = orderedSubgraph;
this.genomes = genomes;
this.treeRoot = treeRoot;
}
Expand All @@ -213,7 +218,6 @@ public ArrayList<GraphNode> getOrderedNodes() {

@Override
public void run() {
orderedNodes = subgraph.getOrderedGraph();
orderedNodes = performBubblingAlgorithms(orderedNodes, genomes, treeRoot);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,12 @@ private void updateGraph() {
}
clearCanvas();
if (topGraph != null) {
drawGraph(topPane, topEdgeCanvas, topGraph, topGraph.getSubgraph().getGenomes().size(),
startLevel, startLevel + levelsToDraw);
drawGraph(topPane, topEdgeCanvas, topGraph, topGraph.getGenomeSize(), startLevel,
startLevel + levelsToDraw);
}
if (bottomGraph != null) {
drawGraph(bottomPane, bottomEdgeCanvas, bottomGraph,
bottomGraph.getSubgraph().getGenomes().size(), startLevel, startLevel + levelsToDraw);
drawGraph(bottomPane, bottomEdgeCanvas, bottomGraph, bottomGraph.getGenomeSize(), startLevel,
startLevel + levelsToDraw);
}
}

Expand Down