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

            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).TestDir();

            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.");
        }
Beispiel #2
0
        public void TestMUMmerAlignerSingleMumRNA()
        {
            string reference = "AUGCUUUUCCCCCCC";
            string search    = "UAUAUUUUGG";

            Sequence         referenceSeq = null;
            Sequence         searchSeq    = null;
            List <ISequence> searchSeqs   = null;

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

            searchSeqs = new List <ISequence>();
            searchSeqs.Add(searchSeq);

            MUMmerAligner mummer = new MUMmerAligner();

            mummer.LengthOfMUM       = 3;
            mummer.PairWiseAlgorithm = new NeedlemanWunschAligner();

            mummer.SimilarityMatrix = new SimilarityMatrix(SimilarityMatrix.StandardSimilarityMatrix.AmbiguousRna);
            mummer.GapOpenCost      = -8;
            mummer.GapExtensionCost = -2;
            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();
            PairwiseAlignedSequence            alignedSeq     = new PairwiseAlignedSequence();

            alignedSeq.FirstSequence  = new Sequence(Alphabets.RNA, "-AUGCUUUUCCCCCCC");
            alignedSeq.SecondSequence = new Sequence(Alphabets.RNA, "UAU-AUUUU-----GG");
            alignedSeq.Consensus      = new Sequence(AmbiguousRnaAlphabet.Instance, "UAUGMUUUUCCCCCSS");
            alignedSeq.Score          = -14;
            alignedSeq.FirstOffset    = 1;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(CompareAlignment(result, expectedOutput));
        }
Beispiel #3
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          = 5,
                FirstOffset    = 0,
                SecondOffset   = 3
            };

            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(CompareAlignment(result, expectedOutput));
        }
Beispiel #4
0
        public void TestMUMmerAlignerMultipleMum()
        {
            string reference = "ATGCGCATCCCCTT";
            string search    = "GCGCCCCCTA";

            Sequence referenceSeq = null;
            Sequence searchSeq    = null;

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

            List <ISequence> searchSeqs = new List <ISequence>();

            searchSeqs.Add(searchSeq);

            MUMmerAligner mummer = new MUMmerAligner();

            mummer.LengthOfMUM       = 4;
            mummer.PairWiseAlgorithm = new NeedlemanWunschAligner();

            IList <IPairwiseSequenceAlignment> result = mummer.AlignSimple(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();

            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "ATGCGCATCCCCTT");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "--GCGC--CCCCTA");
            alignedSeq.Consensus      = new Sequence(AmbiguousDnaAlphabet.Instance, "ATGCGCATCCCCTW");
            alignedSeq.Score          = -11;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 2;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(CompareAlignment(result, expectedOutput));
        }
Beispiel #5
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);
        }
Beispiel #6
0
        /// <summary>
        /// Initializes static members of the SequenceAligners class.
        /// Static constructor
        /// </summary>
        static SequenceAligners()
        {
            NUCmer          = new NucmerPairwiseAligner();
            MUMmer          = new MUMmerAligner();
            NeedlemanWunsch = new NeedlemanWunschAligner();
            SmithWaterman   = new SmithWatermanAligner();

            var knownAligners = new List <ISequenceAligner> {
                SmithWaterman, NeedlemanWunsch, MUMmer, NUCmer
            };

            // Get the registered aligners
            IEnumerable <ISequenceAligner> registeredAligners = GetAligners();

            if (null != registeredAligners)
            {
                knownAligners.AddRange(registeredAligners
                                       .Where(aligner => aligner != null &&
                                              knownAligners.All(sa => string.Compare(sa.Name, aligner.Name, StringComparison.OrdinalIgnoreCase) != 0)));
            }

            All = knownAligners;
        }
Beispiel #7
0
        public void TestMUMmer3MultipleMumWithCustomMatrix()
        {
            string reference = "ATGCGCATCCCCTT";
            string search    = "GCGCCCCCTA";

            Sequence referenceSeq = null;
            Sequence searchSeq    = null;

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

            List <ISequence> searchSeqs = new List <ISequence>();

            searchSeqs.Add(searchSeq);

            int[,] customMatrix = new int[256, 256];

            customMatrix[(byte)'A', (byte)'A'] = 3;
            customMatrix[(byte)'A', (byte)'T'] = -2;
            customMatrix[(byte)'A', (byte)'G'] = -2;
            customMatrix[(byte)'A', (byte)'c'] = -2;

            customMatrix[(byte)'G', (byte)'G'] = 3;
            customMatrix[(byte)'G', (byte)'A'] = -2;
            customMatrix[(byte)'G', (byte)'T'] = -2;
            customMatrix[(byte)'G', (byte)'C'] = -2;

            customMatrix[(byte)'T', (byte)'T'] = 3;
            customMatrix[(byte)'T', (byte)'A'] = -2;
            customMatrix[(byte)'T', (byte)'G'] = -2;
            customMatrix[(byte)'T', (byte)'C'] = -2;

            customMatrix[(byte)'C', (byte)'C'] = 3;
            customMatrix[(byte)'C', (byte)'T'] = -2;
            customMatrix[(byte)'C', (byte)'A'] = -2;
            customMatrix[(byte)'C', (byte)'G'] = -2;

            DiagonalSimilarityMatrix matrix = new DiagonalSimilarityMatrix(3, -2);

            int gapOpenCost = -6;

            MUMmerAligner mummer = new MUMmerAligner();

            mummer.LengthOfMUM       = 4;
            mummer.PairWiseAlgorithm = new NeedlemanWunschAligner();
            mummer.SimilarityMatrix  = matrix;
            mummer.GapOpenCost       = gapOpenCost;
            mummer.GapExtensionCost  = -2;

            IList <IPairwiseSequenceAlignment> result = mummer.AlignSimple(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();

            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "ATGCGCATCCCCTT");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "--GCGC--CCCCTA");
            alignedSeq.Consensus      = new Sequence(AmbiguousDnaAlphabet.Instance, "ATGCGCATCCCCTW");
            alignedSeq.Score          = 1;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 2;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(CompareAlignment(result, expectedOutput));
        }