@Test(dataProvider = "CompleteCycleData") public void testSplitterCompleteCycle( final List<String> strings, final boolean hasTop, final boolean hasBot) { final SeqGraph graph = new SeqGraph(11); int edgeWeight = 1; final SeqVertex top = hasTop ? new SeqVertex("AAAAAAAA") : null; final SeqVertex bot = hasBot ? new SeqVertex("GGGGGGGG") : null; final List<SeqVertex> v = new ArrayList<>(); for (final String s : strings) { v.add(new SeqVertex(s)); } graph.addVertices(v.toArray(new SeqVertex[v.size()])); final SeqVertex first = v.get(0); if (hasTop) { graph.addVertex(top); for (final SeqVertex vi : v) graph.addEdge(top, vi, new BaseEdge(vi == first, edgeWeight++)); } if (hasBot) { graph.addVertex(bot); for (final SeqVertex vi : v) graph.addEdge(vi, bot, new BaseEdge(vi == first, edgeWeight++)); } final Set<String> haplotypes = new HashSet<>(); final KBestHaplotypeFinder originalPaths = new KBestHaplotypeFinder((SeqGraph) graph.clone(), graph.getSources(), graph.getSinks()); for (final KBestHaplotype path : originalPaths) haplotypes.add(new String(path.bases())); final SharedVertexSequenceSplitter splitter = new SharedVertexSequenceSplitter(graph, v); splitter.split(); if (PRINT_GRAPHS) graph.printGraph( new File(Utils.join("_", strings) + "_" + hasTop + "_" + hasBot + ".original.dot"), 0); if (PRINT_GRAPHS) splitter.splitGraph.printGraph( new File(Utils.join("_", strings) + "_" + hasTop + "_" + hasBot + ".split.dot"), 0); splitter.updateGraph(top, bot); if (PRINT_GRAPHS) graph.printGraph( new File(Utils.join("_", strings) + "_" + hasTop + "_" + hasBot + ".updated.dot"), 0); final KBestHaplotypeFinder splitPaths = new KBestHaplotypeFinder(graph, graph.getSources(), graph.getSinks()); for (final KBestHaplotype path : splitPaths) { final String h = new String(path.bases()); Assert.assertTrue(haplotypes.contains(h), "Failed to find haplotype " + h); } final List<byte[]> sortedOriginalPaths = new ArrayList<>(originalPaths.size()); for (final KBestHaplotype kbh : originalPaths.unique()) sortedOriginalPaths.add(kbh.bases()); Collections.sort(sortedOriginalPaths, BaseUtils.BASES_COMPARATOR); final List<byte[]> sortedSplitPaths = new ArrayList<>(splitPaths.size()); for (final KBestHaplotype kbh : splitPaths.unique()) sortedSplitPaths.add(kbh.bases()); Collections.sort(sortedSplitPaths, BaseUtils.BASES_COMPARATOR); Assert.assertEquals( sortedSplitPaths, sortedOriginalPaths, Utils.join("_", strings) + "_" + hasTop + "_" + hasBot); }