示例#1
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);
        }
示例#2
0
        void ValidateMUMmerAlignGeneralTestCases(string nodeName)
        {
            ISequence referenceSeq                = null;
            IEnumerable <ISequence> querySeqs     = null;
            IEnumerable <ISequence> referenceSeqs = null;

            // Gets the reference sequence from the configurtion file
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                              Constants.FilePathNode);

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

            FastAParser fastaParserObj = new FastAParser(filePath);

            referenceSeqs = fastaParserObj.Parse();

            referenceSeq = referenceSeqs.ElementAt(0);

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

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

            FastAParser fastaParserObj1 = new FastAParser(queryFilePath);

            querySeqs = fastaParserObj1.Parse();

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

            MUMmerAligner mum = new MUMmerAligner();

            mum.LengthOfMUM = long.Parse(mumLength, null);
            mum.StoreMUMs   = true;

            mum.PairWiseAlgorithm = new NeedlemanWunschAligner();
            mum.GapOpenCost       =
                int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapOpenCostNode),
                          (IFormatProvider)null);
            IList <IPairwiseSequenceAlignment> align = null;

            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();
            PairwiseAlignedSequence    alignedSeq = new PairwiseAlignedSequence();

            alignedSeq.FirstSequence  = new Sequence(referenceSeq.Alphabet, expectedSequences[0]);
            alignedSeq.SecondSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[1]);
            alignedSeq.Score          = Convert.ToInt32(expectedScore, (IFormatProvider)null);
            seqAlign.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(seqAlign);
            Assert.IsTrue(CompareAlignment(align, expectedOutput));

            Console.WriteLine("MUMmer P2 : Successfully validated the aligned sequences.");
            ApplicationLog.WriteLine("MUMmer P2 : Successfully validated the aligned sequences.");
        }