Example #1
0
        public void PerformMUMmerPerf()
        {
            Stopwatch _watchObj = new Stopwatch();
            IList <IPairwiseSequenceAlignment> alignment = null;

            // Get Sequence file path.
            string refPath =
                Utility._xmlUtil.GetTextValue(Constants.MUMmerNodeName,
                                              Constants.RefFilePathNode);
            string queryPath =
                Utility._xmlUtil.GetTextValue(Constants.MUMmerNodeName,
                                              Constants.QueryFilePathNode);
            string smFilePath =
                Utility._xmlUtil.GetTextValue(Constants.MUMmerNodeName,
                                              Constants.SMFilePathNode);

            // Create a List for input files.
            List <string> lstInputFiles = new List <string>();

            lstInputFiles.Add(refPath);
            lstInputFiles.Add(queryPath);

            FastaParser       parserObj = new FastaParser();
            IList <ISequence> seqs1     = parserObj.Parse(refPath);

            parserObj = new FastaParser();
            IList <ISequence> seqs2 = parserObj.Parse(queryPath);

            IAlphabet alphabet          = Alphabets.DNA;
            ISequence originalSequence1 = seqs1[0];
            ISequence originalSequence2 = seqs2[0];

            ISequence aInput = new Sequence(alphabet, originalSequence1.ToString());
            ISequence bInput = new Sequence(alphabet, originalSequence2.ToString());

            SimilarityMatrix sm = new SimilarityMatrix(smFilePath);

            mummerObj                  = new MUMmer3();
            mummerObj.GapOpenCost      = -10;
            mummerObj.GapExtensionCost = -10;
            mummerObj.SimilarityMatrix = sm;
            mummerObj.LengthOfMUM      = Int32.Parse(
                Utility._xmlUtil.GetTextValue(Constants.MUMmerNodeName,
                                              Constants.MUMLengthNode));

            _watchObj.Reset();
            _watchObj.Start();
            long memoryStart = GC.GetTotalMemory(false);

            // Align sequences using MUMmer.

            alignment = mummerObj.AlignSimple(aInput, seqs2);

            _watchObj.Stop();
            long memoryEnd = GC.GetTotalMemory(false);

            string memoryUsed = (memoryEnd - memoryStart).ToString();

            // Display MUMmer perf test case execution details.
            DisplayTestCaseHeader(lstInputFiles, _watchObj, memoryUsed,
                                  "MUMmer");

            Console.WriteLine(string.Format(
                                  "MUMmer AlignSimple() method, Alignment Score is : {0}",
                                  alignment[0].PairwiseAlignedSequences[0].Score.ToString()));

            // Dispose MUMmer object.
            mummerObj = null;
        }
Example #2
0
        /// <summary>
        /// Validates the Mummer align method for several test cases for the parameters passed.
        /// </summary>
        /// <param name="nodeName">Node name to be read from xml</param>
        /// <param name="isSeqList">Is MUMmer alignment with List of sequences</param>
        static void ValidateMUMmerAlignGeneralTestCases(string nodeName, bool isFilePath,
                                                        bool isSeqList)
        {
            ISequence         referenceSeq           = null;
            ISequence         querySeq               = null;
            IList <ISequence> querySeqs              = null;
            string            referenceSequence      = string.Empty;
            string            querySequence          = string.Empty;
            IList <IPairwiseSequenceAlignment> align = null;

            if (isFilePath)
            {
                // Gets the reference sequence from the configurtion file
                string filePath = Utility._xmlUtil.GetTextValue(nodeName,
                                                                Constants.FilePathNode);

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

                FastaParser       parser        = new FastaParser();
                IList <ISequence> referenceSeqs = parser.Parse(filePath);
                referenceSeq      = referenceSeqs[0];
                referenceSequence = referenceSeq.ToString();

                // Gets the reference sequence from the configurtion file
                string queryFilePath = Utility._xmlUtil.GetTextValue(nodeName,
                                                                     Constants.SearchSequenceFilePathNode);

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

                FastaParser queryParser = new FastaParser();
                querySeqs     = queryParser.Parse(queryFilePath);
                querySeq      = querySeqs[0];
                querySequence = querySeq.ToString();
            }
            else
            {
                // Gets the reference sequence from the configurtion file
                referenceSequence = Utility._xmlUtil.GetTextValue(nodeName,
                                                                  Constants.SequenceNode);

                string referenceSeqAlphabet = Utility._xmlUtil.GetTextValue(nodeName,
                                                                            Constants.AlphabetNameNode);

                referenceSeq = new Sequence(Utility.GetAlphabet(referenceSeqAlphabet),
                                            referenceSequence);

                querySequence = Utility._xmlUtil.GetTextValue(nodeName,
                                                              Constants.SearchSequenceNode);

                referenceSeqAlphabet = Utility._xmlUtil.GetTextValue(nodeName,
                                                                     Constants.SearchSequenceAlphabetNode);

                querySeq = new Sequence(Utility.GetAlphabet(referenceSeqAlphabet),
                                        querySequence);
                querySeqs = new List <ISequence>();
                querySeqs.Add(querySeq);
            }

            string mumLength = Utility._xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode);

            MUMmer mum = new MUMmer3();

            mum.LengthOfMUM       = long.Parse(mumLength, null);
            mum.PairWiseAlgorithm = new NeedlemanWunschAligner();
            mum.GapOpenCost       = int.Parse(Utility._xmlUtil.GetTextValue(nodeName, Constants.GapOpenCostNode),
                                              (IFormatProvider)null);

            if (isSeqList)
            {
                querySeqs.Add(referenceSeq);
                align = mum.Align(querySeqs);
            }
            else
            {
                align = mum.AlignSimple(referenceSeq, querySeqs);
            }

            string expectedScore = Utility._xmlUtil.GetTextValue(nodeName, Constants.ScoreNodeName);

            Assert.AreEqual(expectedScore,
                            align[0].PairwiseAlignedSequences[0].Score.ToString((IFormatProvider)null));
            Console.WriteLine(string.Format(null,
                                            "MUMmer BVT : Successfully validated the score for the sequence '{0}' and '{1}'.",
                                            referenceSequence, querySequence));
            ApplicationLog.WriteLine(string.Format(null,
                                                   "MUMmer BVT : Successfully validated the score for the sequence '{0}' and '{1}'.",
                                                   referenceSequence, querySequence));

            string[] expectedSequences = Utility._xmlUtil.GetTextValues(nodeName,
                                                                        Constants.ExpectedSequencesNode);

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

            IPairwiseSequenceAlignment seqAlign   = new PairwiseSequenceAlignment();
            PairwiseAlignedSequence    alignedSeq = new PairwiseAlignedSequence();

            alignedSeq.FirstSequence  = new Sequence(referenceSeq.Alphabet, expectedSequences[0]);
            alignedSeq.SecondSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[1]);
            alignedSeq.Score          = int.Parse(expectedScore);
            seqAlign.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(seqAlign);
            Assert.IsTrue(CompareAlignment(align, expectedOutput));
            Console.WriteLine("MUMmer BVT : Successfully validated the aligned sequences.");
            ApplicationLog.WriteLine("MUMmer BVT : Successfully validated the aligned sequences.");
        }