public void DistanceCalculationwithTwoContigs() { const int KmerLength = 6; IList <ISequence> sequences = new List <ISequence>() { new Sequence(Alphabets.DNA, "GATCTGATAA") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor substrate 1 (IRS1) on chromosome 2.X1:0.5K" }, new Sequence(Alphabets.DNA, "ATCTGATAAG") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor on chromosome 2.F:0.5K" }, new Sequence(Alphabets.DNA, "TCTGATAAGG") { ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor on chromosome 2.2:0.5K" }, new Sequence(Alphabets.DNA, "TTTTTGATGG") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor substrate 1 (IRS1) on chromosome 2.Y1:0.5K" }, new Sequence(Alphabets.DNA, "TTTTGATGGC") { ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor on chromosome 2.R:0.5K" }, new Sequence(Alphabets.DNA, "TTTGATGGCA") { ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor on chromosome 2.1:0.5K" } }; IList <ISequence> contigs = new List <ISequence> { new Sequence(Alphabets.DNA, "GATCTGATAAGG"), new Sequence(Alphabets.DNA, "TTTTTGATGGCA") }; ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, KmerLength); MatePairMapper mapPairedReads = new MatePairMapper(); ContigMatePairs pairs = mapPairedReads.MapContigToMatePairs(sequences, maps); OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairs); DistanceCalculator calc = new DistanceCalculator(contigpairedReads); contigpairedReads = calc.CalculateDistance(); Assert.AreEqual(contigpairedReads.Values.Count, 1); Assert.IsTrue(contigpairedReads.ContainsKey(contigs[0])); Dictionary <ISequence, IList <ValidMatePair> > map = contigpairedReads[contigs[0]]; Assert.IsTrue(map.ContainsKey(contigs[1])); IList <ValidMatePair> valid = map[contigs[1]]; Assert.AreEqual(valid.First().DistanceBetweenContigs[0], (float)478.000031); Assert.AreEqual(valid.First().DistanceBetweenContigs[1], (float)477.0); Assert.AreEqual(valid.First().StandardDeviation[0], (float)14.1421356); Assert.AreEqual(valid.First().StandardDeviation[1], (float)14.1421356); Assert.AreEqual(valid.First().Weight, 2); }
public void DistanceCalculationwithTwoContigsWeightedMean() { const int KmerLength = 6; List <ISequence> sequences = new List <ISequence>(); Sequence seq = new Sequence(Alphabets.DNA, "GATCTGATAA".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "substrate 1 (IRS1) on chromosome 2.x1:2K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "ATCTGATAAG".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "on chromosome 2.f:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TCTGATAAGG".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor" + "on chromosome 2.2:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTTGATGG".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "substrate 1 (IRS1) on chromosome 2.y1:2K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTGATGGC".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor" + "on chromosome 2.r:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTGATGGCA".Select(a => (byte)a).ToArray()); seq.ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor" + "on chromosome 2.1:0.5K"; sequences.Add(seq); IList <ISequence> contigs = new List <ISequence> { new Sequence(Alphabets.DNA, "GATCTGATAAGG".Select(a => (byte)a).ToArray()), new Sequence(Alphabets.DNA, "TTTTTGATGGCA".Select(a => (byte)a).ToArray()) }; ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, KmerLength); MatePairMapper mapPairedReads = new MatePairMapper(); ContigMatePairs pairedReads = mapPairedReads.MapContigToMatePairs(sequences, maps); OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairedReads); DistanceCalculator calc = new DistanceCalculator(contigpairedReads); contigpairedReads = calc.CalculateDistance(); Assert.AreEqual(contigpairedReads.Values.Count, 1); Assert.IsTrue(contigpairedReads.ContainsKey(contigs[0])); Dictionary <ISequence, IList <ValidMatePair> > map = contigpairedReads[contigs[0]]; Assert.IsTrue(map.ContainsKey(contigs[1])); IList <ValidMatePair> valid = map[contigs[1]]; Assert.AreEqual(valid.First().DistanceBetweenContigs[0], (float)1228.0); Assert.AreEqual(valid.First().DistanceBetweenContigs[1], (float)1227.0); Assert.AreEqual(valid.First().StandardDeviation[0], (float)60); Assert.AreEqual(valid.First().StandardDeviation[1], (float)60); Assert.AreEqual(valid.First().Weight, 2); }
public void FilterMatePairWithTwoContigs() { const int kmerLength = 6; IList <ISequence> sequences = new List <ISequence>(); Sequence seq = new Sequence(Alphabets.DNA, "GATCTGATAA"); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor substrate 1 (IRS1) on chromosome 2.X1:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "ATCTGATAAG"); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor on chromosome 2.F:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TCTGATAAGG"); seq.ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor on chromosome 2.2:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTTGATGG"); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor substrate 1 (IRS1) on chromosome 2.Y1:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTGATGGC"); seq.ID = ">gi|263191773|ref|NG_015830.1| H**o sapiens insulin receptor on chromosome 2.R:0.5K"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTGATGGCA"); seq.ID = ">gi|263191773|ref | H**o sapiens ........insulin receptor on chromosome 2.1:0.5K"; sequences.Add(seq); IList <ISequence> contigs = new List <ISequence> { new Sequence(Alphabets.DNA, "GATCTGATAAGG"), new Sequence(Alphabets.DNA, "TTTTTGATGGCA") }; ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, kmerLength); MatePairMapper mapPairedReads = new MatePairMapper(); ContigMatePairs pairs = mapPairedReads.MapContigToMatePairs(sequences, maps); OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); ContigMatePairs contigpairedReads = filter.FilterPairedReads(pairs); Assert.AreEqual(contigpairedReads.Values.Count, 1); Assert.IsTrue(contigpairedReads.ContainsKey(contigs[0])); Dictionary <ISequence, IList <ValidMatePair> > map = contigpairedReads[contigs[0]]; Assert.IsTrue(map.ContainsKey(contigs[1])); List <ValidMatePair> valid = Sort(map[contigs[1]], sequences); Assert.AreEqual(valid[0].ForwardReadStartPosition[0], 1); Assert.AreEqual(valid[0].ReverseReadReverseComplementStartPosition[0], 10); Assert.AreEqual(valid[0].ReverseReadStartPosition[0], 10); Assert.AreEqual(valid[1].ForwardReadStartPosition[0], 0); Assert.AreEqual(valid[1].ReverseReadReverseComplementStartPosition[0], 11); Assert.AreEqual(valid[1].ReverseReadStartPosition[0], 9); }
public void TracePathTestWithPalindromicContig() { const int kmerLength = 6; const int dangleThreshold = 3; const int redundantThreshold = 7; List <ISequence> sequences = new List <ISequence>(); Sequence seq = new Sequence(Alphabets.DNA, "ATGCCTC"); seq.DisplayID = ">10.x1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "CCTCCTAT"); seq.DisplayID = "1"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TCCTATC"); seq.DisplayID = "2"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TGCCTCCT"); seq.DisplayID = "3"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "ATCTTAGC"); seq.DisplayID = "4"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "CTATCTTAG"); seq.DisplayID = "5"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "CTTAGCG"); seq.DisplayID = "6"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "GCCTCCTAT"); seq.DisplayID = ">8.x1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TAGCGCGCTA"); seq.DisplayID = ">8.y1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "AGCGCGC"); seq.DisplayID = ">9.x1:abc"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTTT"); seq.DisplayID = "7"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTTAAA"); seq.DisplayID = "8"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TAAAAA"); seq.DisplayID = "9"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTTAG"); seq.DisplayID = "10"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "TTTAGC"); seq.DisplayID = "11"; sequences.Add(seq); seq = new Sequence(Alphabets.DNA, "GCGCGCCGCGCG"); seq.DisplayID = "12"; sequences.Add(seq); KmerLength = kmerLength; SequenceReads.Clear(); AddSequenceReads(sequences); CreateGraph(); DanglingLinksThreshold = dangleThreshold; DanglingLinksPurger = new DanglingLinksPurger(dangleThreshold); RedundantPathLengthThreshold = redundantThreshold; RedundantPathsPurger = new RedundantPathsPurger(redundantThreshold); UnDangleGraph(); RemoveRedundancy(); IList <ISequence> contigs = BuildContigs(); ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, kmerLength); MatePairMapper builder = new MatePairMapper(); CloneLibrary.Instance.AddLibrary("abc", (float)5, (float)15); ContigMatePairs pairedReads = builder.MapContigToMatePairs(sequences, maps); ContigMatePairs overlap; OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); overlap = filter.FilterPairedReads(pairedReads, 0); DistanceCalculator dist = new DistanceCalculator(); dist.CalculateDistance(overlap); Graph.BuildContigGraph(contigs, this.KmerLength); TracePath path = new TracePath(); IList <ScaffoldPath> paths = path.FindPaths(Graph, overlap, kmerLength, 3); Assert.AreEqual(paths.Count, 3); Assert.AreEqual(paths.First().Count, 3); ScaffoldPath scaffold = paths.First(); DeBruijnGraph graph = Graph; Assert.IsTrue(graph.GetNodeSequence(scaffold[0].Key).ToString().Equals("ATGCCTCCTATCTTAGC")); Assert.IsTrue(graph.GetNodeSequence(scaffold[1].Key).ToString().Equals("TTAGCGCG")); Assert.IsTrue(graph.GetNodeSequence(scaffold[2].Key).ToString().Equals("GCGCGC")); }
public void TracePathTestWithPalindromicContig() { const int kmerLengthConst = 5; const int dangleThreshold = 3; const int redundantThreshold = 6; var sequences = new List <ISequence>() { new Sequence(Alphabets.DNA, "ATGCCTC") { ID = "0" }, new Sequence(Alphabets.DNA, "CCTCCTAT") { ID = "1" }, new Sequence(Alphabets.DNA, "TCCTATC") { ID = "2" }, new Sequence(Alphabets.DNA, "TGCCTCCT") { ID = "3" }, new Sequence(Alphabets.DNA, "ATCTTAGC") { ID = "4" }, new Sequence(Alphabets.DNA, "CTATCTTAG") { ID = "5" }, new Sequence(Alphabets.DNA, "CTTAGCG") { ID = "6" }, new Sequence(Alphabets.DNA, "GCCTCCTAT") { ID = "7" }, new Sequence(Alphabets.DNA, "TAGCGCGCTA") { ID = "8" }, new Sequence(Alphabets.DNA, "AGCGCGC") { ID = "9" }, new Sequence(Alphabets.DNA, "TTTTTT") { ID = "10" }, new Sequence(Alphabets.DNA, "TTTTTAAA") { ID = "11" }, new Sequence(Alphabets.DNA, "TAAAAA") { ID = "12" }, new Sequence(Alphabets.DNA, "TTTTAG") { ID = "13" }, new Sequence(Alphabets.DNA, "TTTAGC") { ID = "14" }, new Sequence(Alphabets.DNA, "GCGCGCCGCGCG") { ID = "15" }, }; KmerLength = kmerLengthConst; SequenceReads.Clear(); SetSequenceReads(sequences); CreateGraph(); DanglingLinksThreshold = dangleThreshold; DanglingLinksPurger = new DanglingLinksPurger(dangleThreshold); RedundantPathLengthThreshold = redundantThreshold; RedundantPathsPurger = new RedundantPathsPurger(redundantThreshold); UnDangleGraph(); RemoveRedundancy(); IList <ISequence> contigs = BuildContigs().ToList(); ReadContigMapper mapper = new ReadContigMapper(); ReadContigMap maps = mapper.Map(contigs, sequences, kmerLengthConst); MatePairMapper builder = new MatePairMapper(); CloneLibrary.Instance.AddLibrary("abc", 5, 15); ContigMatePairs pairedReads = builder.MapContigToMatePairs(sequences, maps); OrientationBasedMatePairFilter filter = new OrientationBasedMatePairFilter(); ContigMatePairs overlap = filter.FilterPairedReads(pairedReads, 0); DistanceCalculator dist = new DistanceCalculator(overlap); overlap = dist.CalculateDistance(); ContigGraph graph = new ContigGraph(); graph.BuildContigGraph(contigs, this.KmerLength); TracePath path = new TracePath(); IList <ScaffoldPath> paths = path.FindPaths(graph, overlap, kmerLengthConst, 3); Assert.AreEqual(paths.Count, 3); Assert.AreEqual(paths.First().Count, 3); ScaffoldPath scaffold = paths.First(); Assert.AreEqual("ATGCCTCCTATCTTAGC", graph.GetNodeSequence(scaffold[0].Key).ConvertToString()); Assert.AreEqual("TTAGCGCG", graph.GetNodeSequence(scaffold[1].Key).ConvertToString()); Assert.AreEqual("GCGCGC", graph.GetNodeSequence(scaffold[2].Key).ConvertToString()); }