Esempio n. 1
0
        public void SmithWatermanAlignerMultipleAlignments1()
        {
            IPairwiseSequenceAligner sw = new SmithWatermanAligner
            {
                SimilarityMatrix = new DiagonalSimilarityMatrix(5, -20),
                GapOpenCost      = -5
            };

            ISequence sequence1 = new Sequence(Alphabets.DNA, "AAATTCCCAG");
            ISequence sequence2 = new Sequence(Alphabets.DNA, "AAAGCCC");
            IList <IPairwiseSequenceAlignment> result = sw.AlignSimple(sequence1, sequence2);

            AlignmentHelpers.LogResult(sw, result);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment         align          = new PairwiseSequenceAlignment(sequence1, sequence2);

            // First alignment
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "AAA"),
                SecondSequence = new Sequence(Alphabets.DNA, "AAA"),
                Consensus      = new Sequence(Alphabets.DNA, "AAA"),
                Score          = 15,
                FirstOffset    = 0,
                SecondOffset   = 0
            });

            // Second alignment
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "CCC"),
                SecondSequence = new Sequence(Alphabets.DNA, "CCC"),
                Consensus      = new Sequence(Alphabets.DNA, "CCC"),
                Score          = 15,
                FirstOffset    = 0,
                SecondOffset   = 1
            });

            expectedOutput.Add(align);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }
Esempio n. 2
0
        public void TestMUMmerAlignerSingleMumRNA()
        {
            const string reference = "AUGCUUUUCCCCCCC";
            const string search    = "UAUAUUUUGG";

            MUMmerAligner mummer = new MUMmerAligner
            {
                LengthOfMUM       = 3,
                PairWiseAlgorithm = new NeedlemanWunschAligner(),
                SimilarityMatrix  = new SimilarityMatrix(SimilarityMatrix.StandardSimilarityMatrix.AmbiguousRna),
                GapOpenCost       = -8,
                GapExtensionCost  = -2
            };

            ISequence        referenceSeq = new Sequence(Alphabets.RNA, reference);
            List <ISequence> searchSeqs   = new List <ISequence> {
                new Sequence(Alphabets.RNA, search)
            };
            IList <IPairwiseSequenceAlignment> result = mummer.Align(referenceSeq, searchSeqs);

            // Check if output is not null
            Assert.AreNotEqual(0, result.Count);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment         align          = new PairwiseSequenceAlignment();

            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.RNA, "-AUGCUUUUCCCCCCC--"),
                SecondSequence = new Sequence(Alphabets.RNA, "UAUA-UUUU-------GG"),
                Consensus      = new Sequence(AmbiguousRnaAlphabet.Instance, "UAURCUUUUCCCCCCCGG"),
                Score          = -2,
                FirstOffset    = 1,
                SecondOffset   = 0
            });
            expectedOutput.Add(align);
            AlignmentHelpers.CompareAlignment(result, expectedOutput);
        }
Esempio n. 3
0
        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();
            var  graphNodes = Graph.GetNodes().Select(n => Graph.GetNodeSequence(n)).ToList();

            DanglingLinksThreshold = DangleThreshold;
            UnDangleGraph();

            long dangleRemovedGraphCount = Graph.NodeCount;
            long dangleRemovedGraphEdge  = Graph.GetNodes().Select(n => n.ExtensionsCount).Sum();
            var  dangleRemovedGraphNodes = Graph.GetNodes().Select(n => Graph.GetNodeSequence(n)).ToList();

            // Compare the two graphs
            Assert.AreEqual(2, graphCount - dangleRemovedGraphCount);
            Assert.AreEqual(4, graphEdges - dangleRemovedGraphEdge);
            var checkList = graphNodes.Except(dangleRemovedGraphNodes, new SequenceEqualityComparer());

            HashSet <string> expected = new HashSet <string> {
                "ATCGAACGATG", "TCGAACGATGA"
            };

            AlignmentHelpers.CompareSequenceLists(expected, checkList);
        }
Esempio n. 4
0
        public void ValidatePairwiseAlignedSequenceCustomBreakLength()
        {
            var referenceSeqs = new List <ISequence>()
            {
                new Sequence(Alphabets.DNA, "CAAAAGGGATTGCAAATGTTGGAGTGAATGCCATTACCTACCGGCTAGGAGGAGT")
                {
                    ID = "R1"
                },
                new Sequence(Alphabets.DNA, "CCCCCCCCC")
                {
                    ID = "R2"
                },
                new Sequence(Alphabets.DNA, "TTTTT")
                {
                    ID = "R3"
                }
            };

            var searchSeqs = new List <ISequence>()
            {
                new Sequence(Alphabets.DNA, "CATTAATGATAAAGGGAAAGAAGTCCTCGTGCTATGGGGCATTCACCATCCATCTACTAGTGCTGACCAA")
                {
                    ID = "Q1"
                },
                new Sequence(Alphabets.DNA, "CAAAGTCTCTATCAGAATGCAGATGCAGATGTTTTTGTGGGGTCATCAAGATATAGCAAGAAGTTCAAGC")
                {
                    ID = "Q2"
                },
                new Sequence(Alphabets.DNA, "AAGCAAAATTAAACAGAGAAGAAATAGATGGGGTAAAGCTGGAATCAACAAGGATTTACCAGATTTTGGC")
                {
                    ID = "Q3"
                },
            };

            var nucmer = new NucmerPairwiseAligner
            {
                MaximumSeparation = 0,
                MinimumScore      = 2,
                SeparationFactor  = 0.12F,
                LengthOfMUM       = 5,
                BreakLength       = 2,
                ForwardOnly       = true,
            };

            var result = nucmer.Align(referenceSeqs, searchSeqs).Select(a => a as IPairwiseSequenceAlignment).ToList();

            // Check if output is not null
            Assert.AreNotEqual(null, result);

            var expectedOutput = new List <IPairwiseSequenceAlignment>();

            IPairwiseSequenceAlignment align = new PairwiseSequenceAlignment();

            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "AAAGGGA"),
                SecondSequence = new Sequence(Alphabets.DNA, "AAAGGGA"),
                Consensus      = new Sequence(Alphabets.DNA, "AAAGGGA"),
                Score          = 21,
                FirstOffset    = 8,
                SecondOffset   = 0
            });
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "CATTA"),
                SecondSequence = new Sequence(Alphabets.DNA, "CATTA"),
                Consensus      = new Sequence(Alphabets.DNA, "CATTA"),
                Score          = 15,
                FirstOffset    = 0,
                SecondOffset   = 31
            });
            expectedOutput.Add(align);

            align = new PairwiseSequenceAlignment();
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "ATGTT"),
                SecondSequence = new Sequence(Alphabets.DNA, "ATGTT"),
                Consensus      = new Sequence(Alphabets.DNA, "ATGTT"),
                Score          = 15,
                FirstOffset    = 13,
                SecondOffset   = 0
            });
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "GAATGC"),
                SecondSequence = new Sequence(Alphabets.DNA, "GAATGC"),
                Consensus      = new Sequence(Alphabets.DNA, "GAATGC"),
                Score          = 18,
                FirstOffset    = 0,
                SecondOffset   = 11
            });
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "TTTTT"),
                SecondSequence = new Sequence(Alphabets.DNA, "TTTTT"),
                Consensus      = new Sequence(Alphabets.DNA, "TTTTT"),
                Score          = 15,
                FirstOffset    = 31,
                SecondOffset   = 0
            });
            expectedOutput.Add(align);

            align = new PairwiseSequenceAlignment();
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "CAAAA"),
                SecondSequence = new Sequence(Alphabets.DNA, "CAAAA"),
                Consensus      = new Sequence(Alphabets.DNA, "CAAAA"),
                Score          = 15,
                FirstOffset    = 3,
                SecondOffset   = 0
            });
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "GGATT"),
                SecondSequence = new Sequence(Alphabets.DNA, "GGATT"),
                Consensus      = new Sequence(Alphabets.DNA, "GGATT"),
                Score          = 15,
                FirstOffset    = 45,
                SecondOffset   = 0
            });
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "GCAAA"),
                SecondSequence = new Sequence(Alphabets.DNA, "GCAAA"),
                Consensus      = new Sequence(Alphabets.DNA, "GCAAA"),
                Score          = 15,
                FirstOffset    = 0,
                SecondOffset   = 9
            });
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "TTACC"),
                SecondSequence = new Sequence(Alphabets.DNA, "TTACC"),
                Consensus      = new Sequence(Alphabets.DNA, "TTACC"),
                Score          = 15,
                FirstOffset    = 22,
                SecondOffset   = 0
            });
            expectedOutput.Add(align);

            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));

            ApplicationLog.WriteLine("PairwiseAlignedSequence P1: Successfully validated Sequence with Custom Break Length.");
        }
Esempio n. 5
0
        public void ValidatePairwiseAlignedSequenceMultipleRefQuery()
        {
            var referenceSeqs = new List <ISequence>()
            {
                new Sequence(Alphabets.DNA, "ATGCGCATCCCC")
                {
                    ID = "R1"
                },
                new Sequence(Alphabets.DNA, "TAGCT")
                {
                    ID = "R2"
                }
            };

            var searchSeqs = new List <ISequence>()
            {
                new Sequence(Alphabets.DNA, "CCGCGCCCCCTC")
                {
                    ID = "Q1"
                },
                new Sequence(Alphabets.DNA, "AGCT")
                {
                    ID = "Q2"
                }
            };

            var nucmer = new NucmerPairwiseAligner
            {
                FixedSeparation  = 0,
                MinimumScore     = 2,
                SeparationFactor = -1,
                LengthOfMUM      = 3,
                ForwardOnly      = true,
            };

            IList <IPairwiseSequenceAlignment> result = nucmer.Align(referenceSeqs, searchSeqs).Select(a => a as IPairwiseSequenceAlignment).ToList();

            // Check if output is not null
            Assert.AreNotEqual(null, result);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment         align          = new PairwiseSequenceAlignment();
            var alignedSeq = new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "GCGCATCCCC"),
                SecondSequence = new Sequence(Alphabets.DNA, "GCGC--CCCC"),
                Consensus      = new Sequence(Alphabets.DNA, "GCGCATCCCC"),
                Score          = -5,
                FirstOffset    = 0,
                SecondOffset   = 0
            };

            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);

            align      = new PairwiseSequenceAlignment();
            alignedSeq = new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "AGCT"),
                SecondSequence = new Sequence(Alphabets.DNA, "AGCT"),
                Consensus      = new Sequence(Alphabets.DNA, "AGCT"),
                Score          = 12,
                FirstOffset    = 0,
                SecondOffset   = 1
            };
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);

            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
            ApplicationLog.WriteLine("PairwiseAlignedSequence P1: Successfully validated Sequence with Multiple Reference.");
        }
        /// <summary>
        ///     Validates PairwiseOverlapAlignment algorithm for the parameters passed.
        /// </summary>
        /// <param name="isTextFile">Is text file an input.</param>
        /// <param name="alignParam">parameter based on which certain validations are done.</param>
        /// <param name="alignType">Is the Align type Simple or Align with Gap Extension cost?</param>
        private void ValidatePairwiseOverlapAlignment(bool isTextFile, AlignmentParamType alignParam, AlignmentType alignType)
        {
            ISequence aInput;
            ISequence bInput;

            IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.AlphabetNameNode));

            if (isTextFile)
            {
                // Read the xml file for getting both the files for aligning.
                string filePath1 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.FilePathNode1).TestDir();
                string filePath2 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.FilePathNode2).TestDir();

                //Parse the files and get the sequence.
                var parser = new FastAParser {
                    Alphabet = alphabet
                };
                aInput = parser.Parse(filePath1).ElementAt(0);
                bInput = parser.Parse(filePath2).ElementAt(0);
            }
            else
            {
                // Read the xml file for getting both the files for aligning.
                string origSequence1 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.SequenceNode1);
                string origSequence2 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.SequenceNode2);
                aInput = new Sequence(alphabet, origSequence1);
                bInput = new Sequence(alphabet, origSequence2);
            }

            var aInputString = aInput.ConvertToString();
            var bInputString = bInput.ConvertToString();

            ApplicationLog.WriteLine($"PairwiseOverlapAligner BVT : First sequence used is '{aInputString}'.");
            ApplicationLog.WriteLine($"PairwiseOverlapAligner BVT : Second sequence used is '{bInputString}'.");

            string blosumFilePath = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.BlosumFilePathNode).TestDir();

            var sm               = new SimilarityMatrix(new StreamReader(blosumFilePath));
            int gapOpenCost      = int.Parse(this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.GapOpenCostNode), null);
            int gapExtensionCost = int.Parse(this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.GapExtensionCostNode), null);

            var pairwiseOverlapObj = new PairwiseOverlapAligner();

            if (AlignmentParamType.AllParam != alignParam)
            {
                pairwiseOverlapObj.SimilarityMatrix = sm;
                pairwiseOverlapObj.GapOpenCost      = gapOpenCost;
            }

            IList <IPairwiseSequenceAlignment> result = null;

            switch (alignParam)
            {
            case AlignmentParamType.AlignList:
                var sequences = new List <ISequence> {
                    aInput, bInput
                };
                switch (alignType)
                {
                case AlignmentType.Align:
                    result = pairwiseOverlapObj.Align(sequences);
                    break;

                default:
                    result = pairwiseOverlapObj.AlignSimple(sequences);
                    break;
                }
                break;

            case AlignmentParamType.AlignTwo:
                switch (alignType)
                {
                case AlignmentType.Align:
                    result = pairwiseOverlapObj.Align(aInput, bInput);
                    break;

                default:
                    result = pairwiseOverlapObj.AlignSimple(aInput, bInput);
                    break;
                }
                break;

            case AlignmentParamType.AllParam:
                switch (alignType)
                {
                case AlignmentType.Align:
                    result = pairwiseOverlapObj.Align(sm, gapOpenCost,
                                                      gapExtensionCost, aInput, bInput);
                    break;

                default:
                    result = pairwiseOverlapObj.AlignSimple(sm, gapOpenCost, aInput, bInput);
                    break;
                }
                break;

            default:
                break;
            }

            // Read the xml file for getting both the files for aligning.
            string expectedSequence1;
            string expectedSequence2;
            string expectedScore;

            switch (alignType)
            {
            case AlignmentType.Align:
                expectedScore     = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.ExpectedGapExtensionScoreNode);
                expectedSequence1 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.ExpectedGapExtensionSequence1Node);
                expectedSequence2 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.ExpectedGapExtensionSequence2Node);
                break;

            default:
                expectedScore     = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.ExpectedScoreNode);
                expectedSequence1 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.ExpectedSequenceNode1);
                expectedSequence2 = this.utilityObj.xmlUtil.GetTextValue(Constants.PairwiseOverlapAlignAlgorithmNodeName, Constants.ExpectedSequenceNode2);
                break;
            }

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            var seperators = new[] { ';' };

            string[] expectedSequences1 = expectedSequence1.Split(seperators);
            string[] expectedSequences2 = expectedSequence2.Split(seperators);

            IPairwiseSequenceAlignment align = new PairwiseSequenceAlignment();

            for (int i = 0; i < expectedSequences1.Length; i++)
            {
                PairwiseAlignedSequence alignedSeq = new PairwiseAlignedSequence
                {
                    FirstSequence  = new Sequence(alphabet, expectedSequences1[i]),
                    SecondSequence = new Sequence(alphabet, expectedSequences2[i]),
                    Score          = Convert.ToInt32(expectedScore, null)
                };
                align.PairwiseAlignedSequences.Add(alignedSeq);
            }

            expectedOutput.Add(align);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));

            ApplicationLog.WriteLine(string.Format(null, "PairwiseOverlapAligner BVT : Final Score '{0}'.", expectedScore));
            ApplicationLog.WriteLine(string.Format(null, "PairwiseOverlapAligner BVT : Aligned First Sequence is '{0}'.", expectedSequence1));
            ApplicationLog.WriteLine(string.Format(null, "PairwiseOverlapAligner BVT : Aligned Second Sequence is '{0}'.", expectedSequence2));
        }
Esempio n. 7
0
 /// <summary>
 ///     Compare the alignment of mummer and defined alignment
 /// </summary>
 /// <param name="actualAlignment"></param>
 /// <param name="expectedAlignment">expected output</param>
 /// <returns>Compare result of alignments</returns>
 private static bool CompareAlignment(IList <IPairwiseSequenceAlignment> actualAlignment,
                                      IList <IPairwiseSequenceAlignment> expectedAlignment)
 {
     return(AlignmentHelpers.CompareAlignment(actualAlignment, expectedAlignment));
 }
Esempio n. 8
0
        public void TestNUCmer3MultipleReferencesAndQueries()
        {
            Sequence         referenceSeq  = null;
            Sequence         searchSeq     = null;
            List <ISequence> referenceSeqs = null;
            List <ISequence> searchSeqs    = null;

            referenceSeqs = new List <ISequence>();

            string reference = "ATGCGCATCCCC";

            referenceSeq    = new Sequence(Alphabets.DNA, reference);
            referenceSeq.ID = "R1";
            referenceSeqs.Add(referenceSeq);

            reference       = "TAGCT";
            referenceSeq    = new Sequence(Alphabets.DNA, reference);
            referenceSeq.ID = "R11";
            referenceSeqs.Add(referenceSeq);

            searchSeqs = new List <ISequence>();

            string search = "CCGCGCCCCCTC";

            searchSeq    = new Sequence(Alphabets.DNA, search);
            searchSeq.ID = "Q1";
            searchSeqs.Add(searchSeq);

            search       = "AGCT";
            searchSeq    = new Sequence(Alphabets.DNA, search);
            searchSeq.ID = "Q11";
            searchSeqs.Add(searchSeq);

            NucmerPairwiseAligner nucmer = new NucmerPairwiseAligner();

            nucmer.FixedSeparation  = 0;
            nucmer.MinimumScore     = 2;
            nucmer.SeparationFactor = -1;
            nucmer.LengthOfMUM      = 3;
            nucmer.ForwardOnly      = true;
            IList <IPairwiseSequenceAlignment> result = nucmer.Align(referenceSeqs, searchSeqs).Select(a => a as IPairwiseSequenceAlignment).ToList();

            // Check if output is not null
            Assert.AreNotEqual(null, result);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment         align          = new PairwiseSequenceAlignment();
            PairwiseAlignedSequence            alignedSeq     = new PairwiseAlignedSequence();

            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "GCGCATCCCC");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "GCGC--CCCC");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "GCGCATCCCC");
            alignedSeq.Score          = -5;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            align      = new PairwiseSequenceAlignment();
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "AGCT");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "AGCT");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "AGCT");
            alignedSeq.Score          = 12;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 1;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }
Esempio n. 9
0
        public void TestNUCmer3CustomBreakLength()
        {
            Sequence         referenceSeq  = null;
            Sequence         searchSeq     = null;
            List <ISequence> referenceSeqs = null;
            List <ISequence> searchSeqs    = null;

            referenceSeqs = new List <ISequence>();

            string reference = "CAAAAGGGATTGCAAATGTTGGAGTGAATGCCATTACCTACCGGCTAGGAGGAGT";

            referenceSeq    = new Sequence(Alphabets.DNA, reference);
            referenceSeq.ID = "R1";
            referenceSeqs.Add(referenceSeq);

            reference       = "CCCCCCCCC";
            referenceSeq    = new Sequence(Alphabets.DNA, reference);
            referenceSeq.ID = "R2";
            referenceSeqs.Add(referenceSeq);

            reference       = "TTTTT";
            referenceSeq    = new Sequence(Alphabets.DNA, reference);
            referenceSeq.ID = "R3";
            referenceSeqs.Add(referenceSeq);

            searchSeqs = new List <ISequence>();

            string search = "CATTAATGATAAAGGGAAAGAAGTCCTCGTGCTATGGGGCATTCACCATCCATCTACTAGTGCTGACCAA";

            searchSeq    = new Sequence(Alphabets.DNA, search);
            searchSeq.ID = "Q1";
            searchSeqs.Add(searchSeq);

            search       = "CAAAGTCTCTATCAGAATGCAGATGCAGATGTTTTTGTGGGGTCATCAAGATATAGCAAGAAGTTCAAGC";
            searchSeq    = new Sequence(Alphabets.DNA, search);
            searchSeq.ID = "Q2";
            searchSeqs.Add(searchSeq);

            search       = "AAGCAAAATTAAACAGAGAAGAAATAGATGGGGTAAAGCTGGAATCAACAAGGATTTACCAGATTTTGGC";
            searchSeq    = new Sequence(Alphabets.DNA, search);
            searchSeq.ID = "Q3";
            searchSeqs.Add(searchSeq);

            NucmerPairwiseAligner nucmer = new NucmerPairwiseAligner();

            nucmer.MaximumSeparation = 0;
            nucmer.MinimumScore      = 2;
            nucmer.SeparationFactor  = 0.12F;
            nucmer.LengthOfMUM       = 5;
            nucmer.BreakLength       = 2;
            nucmer.ForwardOnly       = true;
            IList <IPairwiseSequenceAlignment> result = nucmer.Align(referenceSeqs, searchSeqs).Select(a => a as IPairwiseSequenceAlignment).ToList();

            // Check if output is not null
            Assert.AreNotEqual(null, result);

            List <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment        align          = new PairwiseSequenceAlignment();
            PairwiseAlignedSequence           alignedSeq     = new PairwiseAlignedSequence();

            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "AAAGGGA");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "AAAGGGA");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "AAAGGGA");
            alignedSeq.Score          = 21;
            alignedSeq.FirstOffset    = 8;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "CATTA");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "CATTA");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "CATTA");
            alignedSeq.Score          = 15;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 31;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);

            align      = new PairwiseSequenceAlignment();
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "ATGTT");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "ATGTT");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "ATGTT");
            alignedSeq.Score          = 15;
            alignedSeq.FirstOffset    = 13;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "GAATGC");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "GAATGC");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "GAATGC");
            alignedSeq.Score          = 18;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 11;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "TTTTT");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "TTTTT");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "TTTTT");
            alignedSeq.Score          = 15;
            alignedSeq.FirstOffset    = 31;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);

            align      = new PairwiseSequenceAlignment();
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "CAAAA");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "CAAAA");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "CAAAA");
            alignedSeq.Score          = 15;
            alignedSeq.FirstOffset    = 3;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "GGATT");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "GGATT");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "GGATT");
            alignedSeq.Score          = 15;
            alignedSeq.FirstOffset    = 45;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "GCAAA");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "GCAAA");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "GCAAA");
            alignedSeq.Score          = 15;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 9;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "TTACC");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "TTACC");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "TTACC");
            alignedSeq.Score          = 15;
            alignedSeq.FirstOffset    = 22;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }