public void AssemblerTest() { const int KmerLength = 11; const int DangleThreshold = 3; const int RedundantThreshold = 10; List <ISequence> readSeqs = TestInputs.GetDanglingReads(); using (ParallelDeNovoAssembler assembler = new ParallelDeNovoAssembler()) { assembler.KmerLength = KmerLength; assembler.DanglingLinksThreshold = DangleThreshold; assembler.RedundantPathLengthThreshold = RedundantThreshold; IDeNovoAssembly result = assembler.Assemble(readSeqs); // Compare the two graphs Assert.AreEqual(1, result.AssembledSequences.Count()); HashSet <string> expectedContigs = new HashSet <string>() { "ATCGCTAGCATCGAACGATCATT" }; foreach (ISequence contig in result.AssembledSequences) { Assert.IsTrue(expectedContigs.Contains(new string(contig.Select(a => (char)a).ToArray()))); } } }
public void TestContigBuilder1() { const int KmerLength = 11; const int DangleThreshold = 3; const int RedundantThreshold = 10; List <ISequence> readSeqs = TestInputs.GetDanglingReads(); this.SequenceReads.Clear(); this.SetSequenceReads(readSeqs); this.KmerLength = KmerLength; DanglingLinksThreshold = DangleThreshold; DanglingLinksPurger = new DanglingLinksPurger(DangleThreshold); RedundantPathLengthThreshold = RedundantThreshold; RedundantPathsPurger = new RedundantPathsPurger(RedundantThreshold); ContigBuilder = new SimplePathContigBuilder(); CreateGraph(); UnDangleGraph(); RemoveRedundancy(); long graphCount = Graph.NodeCount; long graphEdges = Graph.GetNodes().Select(n => n.ExtensionsCount).Sum(); IEnumerable <ISequence> contigs = BuildContigs(); long contigsBuiltGraphCount = this.Graph.NodeCount; long contigsBuilt = Graph.GetNodes().Select(n => n.ExtensionsCount).Sum(); // Compare the two graphs Assert.AreEqual(1, contigs.Count()); HashSet <string> expectedContigs = new HashSet <string>() { "ATCGCTAGCATCGAACGATCATT" }; foreach (ISequence contig in contigs) { string s = new string(contig.Select(a => (char)a).ToArray()); Assert.IsTrue(expectedContigs.Contains(s)); } Assert.AreEqual(graphCount, contigsBuiltGraphCount); Assert.AreEqual(graphEdges, contigsBuilt); }
public void TestDanglingLinksPurger() { const int KmerLength = 11; const int DangleThreshold = 3; List <ISequence> readSeqs = TestInputs.GetDanglingReads(); SequenceReads.Clear(); this.SetSequenceReads(readSeqs); this.KmerLength = KmerLength; DanglingLinksThreshold = DangleThreshold; DanglingLinksPurger = new DanglingLinksPurger(DangleThreshold); CreateGraph(); long graphCount = Graph.NodeCount; long graphEdges = Graph.GetNodes().Select(n => n.ExtensionsCount).Sum(); HashSet <string> graphNodes = new HashSet <string>(Graph.GetNodes().Select(n => Graph.GetNodeSequence(n).ConvertToString())); DanglingLinksThreshold = DangleThreshold; UnDangleGraph(); long dangleRemovedGraphCount = Graph.NodeCount; long dangleRemovedGraphEdge = Graph.GetNodes().Select(n => n.ExtensionsCount).Sum(); HashSet <string> dangleRemovedGraphNodes = new HashSet <string>(Graph.GetNodes().Select(n => Graph.GetNodeSequence(n).ConvertToString())); // Compare the two graphs Assert.AreEqual(2, graphCount - dangleRemovedGraphCount); Assert.AreEqual(4, graphEdges - dangleRemovedGraphEdge); graphNodes.ExceptWith(dangleRemovedGraphNodes); HashSet <string> expected = new HashSet <string> { "ATCGAACGATG", "TCGAACGATGA" }; AlignmentHelpers.CompareSequenceLists(expected, graphNodes); }
public void TestDanglingLinksPurger() { const int KmerLength = 11; const int DangleThreshold = 3; List <ISequence> readSeqs = TestInputs.GetDanglingReads(); SequenceReads.Clear(); this.SetSequenceReads(readSeqs); this.KmerLength = KmerLength; DanglingLinksThreshold = DangleThreshold; DanglingLinksPurger = new DanglingLinksPurger(DangleThreshold); CreateGraph(); long graphCount = Graph.NodeCount; long graphEdges = Graph.GetNodes().Select(n => n.ExtensionsCount).Sum(); HashSet <string> graphNodes = new HashSet <string>( Graph.GetNodes().Select(n => new string(Graph.GetNodeSequence(n).Select(a => (char)a).ToArray()))); DanglingLinksThreshold = DangleThreshold; UnDangleGraph(); long dangleRemovedGraphCount = Graph.NodeCount; long dangleRemovedGraphEdge = Graph.GetNodes().Select(n => n.ExtensionsCount).Sum(); HashSet <string> dangleRemovedGraphNodes = new HashSet <string>( Graph.GetNodes().Select(n => { return(new string(Graph.GetNodeSequence(n).Select(a => (char)a).ToArray())); })); // Compare the two graphs Assert.AreEqual(2, graphCount - dangleRemovedGraphCount); Assert.AreEqual(4, graphEdges - dangleRemovedGraphEdge); graphNodes.ExceptWith(dangleRemovedGraphNodes); Assert.IsTrue(graphNodes.Contains("TCGAACGATGA")); Assert.IsTrue(graphNodes.Contains("ATCGAACGATG")); }