Exemple #1
0
        private void ValidateMUMmerAlignGeneralTestCases(string nodeName)
        {
            // Gets the reference sequence from the configuration file
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);

            Assert.IsNotNull(filePath);
            ApplicationLog.WriteLine(string.Format(null, "MUMmer P2 : Successfully validated the File Path '{0}'.", filePath));

            var fastaParserObj = new FastAParser();
            IEnumerable<ISequence> referenceSeqs = fastaParserObj.Parse(filePath);

            ISequence referenceSeq = referenceSeqs.ElementAt(0);

            // Gets the reference sequence from the configuration file
            string queryFilePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode);

            Assert.IsNotNull(queryFilePath);
            ApplicationLog.WriteLine(string.Format(null, "MUMmer P2 : Successfully validated the Search File Path '{0}'.", queryFilePath));

            var fastaParserObj1 = new FastAParser();
            IEnumerable<ISequence> querySeqs = fastaParserObj1.Parse(queryFilePath);

            string mumLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode);

            var mum = new MUMmerAligner
            {
                LengthOfMUM = long.Parse(mumLength, null),
                StoreMUMs = true,
                PairWiseAlgorithm = new NeedlemanWunschAligner(),
                GapOpenCost = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapOpenCostNode), null)
            };

            IList<IPairwiseSequenceAlignment> align = mum.Align(referenceSeq, querySeqs);

            // Validate FinalMUMs and MUMs Properties.
            Assert.IsNotNull(mum.MUMs);

            string expectedScore = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ScoreNodeName);

            string[] expectedSequences = utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ExpectedSequencesNode);
            IList<IPairwiseSequenceAlignment> expectedOutput = new List<IPairwiseSequenceAlignment>();

            IPairwiseSequenceAlignment seqAlign = new PairwiseSequenceAlignment();
            var alignedSeq = new PairwiseAlignedSequence
            {
                FirstSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[0]),
                SecondSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[1]),
                Score = Convert.ToInt32(expectedScore, null),
                FirstOffset = Int32.MinValue,
                SecondOffset = Int32.MinValue,
            };
            seqAlign.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(seqAlign);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(align, expectedOutput));

            ApplicationLog.WriteLine("MUMmer P2 : Successfully validated the aligned sequences.");
        }
Exemple #2
0
        public void TestMUMmerAlignerSingleMum()
        {
            const string reference = "TTAATTTTAG";
            const string search = "AGTTTAGAG";

            ISequence referenceSeq = new Sequence(Alphabets.DNA, reference);
            ISequence searchSeq = new Sequence(Alphabets.DNA, search);

            var searchSeqs = new List<ISequence> {searchSeq};

            MUMmerAligner mummer = new MUMmerAligner
            {
                LengthOfMUM = 3,
                PairWiseAlgorithm = new NeedlemanWunschAligner(),
                GapExtensionCost = -2
            };

            IList<IPairwiseSequenceAlignment> result = mummer.Align(referenceSeq, searchSeqs);

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

            IList<IPairwiseSequenceAlignment> expectedOutput = new List<IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment align = new PairwiseSequenceAlignment();
            PairwiseAlignedSequence alignedSeq = new PairwiseAlignedSequence
            {
                FirstSequence = new Sequence(Alphabets.DNA, "TTAATTTTAG--"),
                SecondSequence = new Sequence(Alphabets.DNA, "---AGTTTAGAG"),
                Consensus = new Sequence(AmbiguousDnaAlphabet.Instance, "TTAAKTTTAGAG"),
                Score = -6,
                FirstOffset = 0,
                SecondOffset = 3
            };
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(CompareAlignment(result, expectedOutput));
        }
Exemple #3
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-UUUUGG-----"),
                Consensus = new Sequence(AmbiguousRnaAlphabet.Instance, "UAURCUUUUSSCCCCC"),
                Score = -14,
                FirstOffset = 1,
                SecondOffset = 0
            });
            expectedOutput.Add(align);
            AlignmentHelpers.CompareAlignment(result, expectedOutput);
        }