Example #1
0
        public void TestAlignedSequenceToString()
        {
            IList <ISequence> seqList = new List <ISequence>();

            seqList.Add(new Sequence(Alphabets.DNA, "CAAAAGGGATTGC---TGTTGGAGTGAATGCCATTACCTACCGGCTAGGAGGAGTAGTACAAAGGAGC"));
            seqList.Add(new Sequence(Alphabets.DNA, "CAAAAGGGATTGC---"));
            seqList.Add(new Sequence(Alphabets.DNA, "TAGTAGTTCTGCTATATACATTTG"));
            seqList.Add(new Sequence(Alphabets.DNA, "GTTATCATGCGAACAATTCAACAGACACTGTAGA"));
            NucmerPairwiseAligner num = new NucmerPairwiseAligner();

            num.BreakLength       = 8;
            num.FixedSeparation   = 0;
            num.MinimumScore      = 0;
            num.MaximumSeparation = 0;
            num.SeparationFactor  = 0;
            num.LengthOfMUM       = 8;
            IList <ISequence>          sequenceList = seqList;
            IList <ISequenceAlignment> alignmentObj = num.Align(sequenceList);
            AlignedSequence            alignedSeqs  = (AlignedSequence)alignmentObj[0].AlignedSequences[0];

            string actualString   = alignedSeqs.ToString();
            string expectedString = "CAAAAGGGATTGC---\r\nCAAAAGGGATTGC---\r\nCAAAAGGGATTGC---\r\n";

            Assert.AreEqual(actualString, expectedString);
        }
Example #2
0
        public void ValidateAlignedSequenceToString()
        {
            IList <ISequence> seqList = new List <ISequence>();
            string            actualAlignedSeqString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
                                                                                            Constants.AlignedSeqActualNode);

            seqList.Add(new Sequence(Alphabets.DNA,
                                     actualAlignedSeqString));
            seqList.Add(new Sequence(Alphabets.DNA, "CAAAAGGGATTGC---"));
            seqList.Add(new Sequence(Alphabets.DNA, "TAGTAGTTCTGCTATATACATTTG"));
            seqList.Add(new Sequence(Alphabets.DNA, "GTTATCATGCGAACAATTCAACAGACACTGTAGA"));
            var num = new NucmerPairwiseAligner();

            num.BreakLength       = 8;
            num.FixedSeparation   = 0;
            num.MinimumScore      = 0;
            num.MaximumSeparation = 0;
            num.SeparationFactor  = 0;
            num.LengthOfMUM       = 8;
            IList <ISequence>          sequenceList = seqList;
            IList <ISequenceAlignment> alignmentObj = num.Align(sequenceList);
            var alignedSeqs = (AlignedSequence)alignmentObj[0].AlignedSequences[0];

            string actualString   = alignedSeqs.ToString();
            string expectedString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
                                                                         Constants.AlignedSeqExpectedNode);

            Assert.AreEqual(actualString, expectedString.Replace("\\r\\n", System.Environment.NewLine));
        }
Example #3
0
        public void TestNUCmer3MultipleReferences()
        {
            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 = "CCGCGCCCCCTCAGCT";

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

            NucmerPairwiseAligner nucmer = new NucmerPairwiseAligner();

            nucmer.FixedSeparation  = 0;
            nucmer.MinimumScore     = 2;
            nucmer.SeparationFactor = -1;
            nucmer.LengthOfMUM      = 3;
            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);
            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    = 11;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(CompareAlignment(result, expectedOutput));
        }
Example #4
0
        public void TestAlignedSequenceToString()
        {
            var seqList = new List <ISequence>
            {
                new Sequence(Alphabets.DNA, "CAAAAGGGATTGC---TGTTGGAGTGAATGCCATTACCTACCGGCTAGGAGGAGTAGTACAAAGGAGC"),
                new Sequence(Alphabets.DNA, "CAAAAGGGATTGC---"),
                new Sequence(Alphabets.DNA, "TAGTAGTTCTGCTATATACATTTG"),
                new Sequence(Alphabets.DNA, "GTTATCATGCGAACAATTCAACAGACACTGTAGA")
            };

            NucmerPairwiseAligner num = new NucmerPairwiseAligner
            {
                BreakLength       = 8,
                FixedSeparation   = 0,
                MinimumScore      = 0,
                MaximumSeparation = 0,
                SeparationFactor  = 0,
                LengthOfMUM       = 8
            };

            IList <ISequence>          sequenceList = seqList;
            IList <ISequenceAlignment> alignmentObj = num.Align(sequenceList);

            Assert.AreNotEqual(0, alignmentObj.Count);

            var alignedSeqs = (AlignedSequence)alignmentObj[0].AlignedSequences[0];

            string actualString   = alignedSeqs.ToString();
            string ExpectedString = "CAAAAGGGATTGC---\r\nCAAAAGGGATTGC---\r\nCAAAAGGGATTGC---\r\n".Replace("\r\n", Environment.NewLine);

            Assert.AreEqual(ExpectedString, actualString);
        }
Example #5
0
        public static void AssignContigToMTDNA(ISequence contig)
        {
            var           delts     = GetDeltaAlignments(contig).SelectMany(x => x).ToList();
            StringBuilder sb        = new StringBuilder();
            int           alnCounts = delts.Count;

            if (alnCounts > 0)
            {
                var alns = NucmerPairwiseAligner.ConvertDeltaToAlignment(delts);
                contig.Metadata[DELTA_ALIGNMENT_METADATAKEY] = alns;
                sb.Append("ALNS=" + alnCounts.ToString());
                foreach (var d in alns)
                {
                    //if(d.IsReverseQueryDirection)
                    //{sb.Append("R;");}
                    //else{sb.Append("F;");}
                    var alnLength = d.FirstSequence.Count;
                    sb.Append(d.FirstOffset.ToString() + "-" + (d.FirstOffset + alnLength).ToString() + ";" + d.SecondOffset.ToString() + "-" + (d.SecondOffset + alnLength).ToString() + ";" + d.Score.ToString());
                }
            }
            else
            {
                sb.Append("No Alignments");
            }
            contig.ID = contig.ID + " " + sb.ToString();
        }
Example #6
0
        /// <summary>
        ///     Validates the NUCmer align method for several test cases for the parameters passed.
        /// </summary>
        /// <param name="nodeName">Node name to be read from xml</param>
        private void ValidateNUCmerAlignGeneralTestCases(string nodeName)
        {
            // Gets the reference & search sequences from the configuration file
            string[]  referenceSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode);
            string[]  searchSequences    = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode);
            IAlphabet seqAlphabet        = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode));

            var refSeqList    = referenceSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast <ISequence>().ToList();
            var searchSeqList = searchSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast <ISequence>().ToList();

            var    nucmerObj = new NucmerPairwiseAligner();
            string mumLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMLengthNode);

            // Update other values for NUCmer object
            nucmerObj.MaximumSeparation = 0;
            nucmerObj.MinimumScore      = 2;
            nucmerObj.SeparationFactor  = 0.12f;
            nucmerObj.BreakLength       = 2;
            nucmerObj.LengthOfMUM       = long.Parse(mumLength, null);
            nucmerObj.MinimumScore      = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                                         Constants.MinimumScoreNode), null);

            try
            {
                nucmerObj.Align(refSeqList, searchSeqList);
                Assert.Fail("Expected Exception: ArgumentException");
            }
            catch (ArgumentException)
            {
            }
        }
Example #7
0
        public void TestNUCmer3SingleCluster()
        {
            string reference = "AGAAAAGTTTTCA";
            string search    = "TTTTGAGATAAAATC";

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

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

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

            referenceSeqs = new List <ISequence>();
            referenceSeqs.Add(referenceSeq);

            searchSeqs = new List <ISequence>();
            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, "AG--AAAA");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "AGATAAAA");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "AGATAAAA");
            alignedSeq.Score          = -11;
            alignedSeq.FirstOffset    = 5;
            alignedSeq.SecondOffset   = 0;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            alignedSeq = new PairwiseAlignedSequence();
            alignedSeq.FirstSequence  = new Sequence(Alphabets.DNA, "TTTT");
            alignedSeq.SecondSequence = new Sequence(Alphabets.DNA, "TTTT");
            alignedSeq.Consensus      = new Sequence(Alphabets.DNA, "TTTT");
            alignedSeq.Score          = 12;
            alignedSeq.FirstOffset    = 0;
            alignedSeq.SecondOffset   = 7;
            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }
Example #8
0
        /// <summary>
        /// Validates the NUCmer align method for several test cases for the parameters passed.
        /// </summary>
        /// <param name="nodeName">Node name to be read from xml</param>
        void ValidateNUCmerAlignGeneralTestCases(string nodeName)
        {
            string mumLength = String.Empty;
            bool   exThrown  = false;

            string[]         referenceSequences = null;
            string[]         searchSequences    = null;
            List <ISequence> refSeqList         = new List <ISequence>();
            List <ISequence> searchSeqList      = new List <ISequence>();

            // Gets the reference & search sequences from the configurtion file
            referenceSequences = utilityObj.xmlUtil.GetTextValues(nodeName,
                                                                  Constants.ReferenceSequencesNode);
            searchSequences = utilityObj.xmlUtil.GetTextValues(nodeName,
                                                               Constants.SearchSequencesNode);

            IAlphabet seqAlphabet = Utility.GetAlphabet(utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                                        Constants.AlphabetNameNode));

            for (int i = 0; i < referenceSequences.Length; i++)
            {
                ISequence referSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(referenceSequences[i]));
                refSeqList.Add(referSeq);
            }

            for (int i = 0; i < searchSequences.Length; i++)
            {
                ISequence searchSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(searchSequences[i]));
                searchSeqList.Add(searchSeq);
            }

            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner();

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

            // Update other values for NUCmer object
            nucmerObj.MaximumSeparation = 0;
            nucmerObj.MinimumScore      = 2;
            nucmerObj.SeparationFactor  = 0.12f;
            nucmerObj.BreakLength       = 2;
            nucmerObj.LengthOfMUM       = long.Parse(mumLength, null);
            nucmerObj.MinimumScore      = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                                    Constants.MinimumScoreNode), (IFormatProvider)null);

            try
            {
                nucmerObj.Align(refSeqList, searchSeqList);
                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                exThrown = true;
                Assert.IsTrue(exThrown, String.Format((IFormatProvider)null,
                                                      "NUCmer P2: {0}", ex.Message));
            }
        }
Example #9
0
        public void NUCmerAlignGreaterMumLength()
        {
            string mumLength = String.Empty;

            string[]         referenceSequences = null;
            string[]         searchSequences    = null;
            List <ISequence> refSeqList         = new List <ISequence>();
            List <ISequence> searchSeqList      = new List <ISequence>();

            // Gets the reference & search sequences from the configurtion file
            referenceSequences = utilityObj.xmlUtil.GetTextValues(Constants.GreaterMumLengthSequence,
                                                                  Constants.ReferenceSequencesNode);
            searchSequences = utilityObj.xmlUtil.GetTextValues(Constants.GreaterMumLengthSequence,
                                                               Constants.SearchSequencesNode);

            IAlphabet seqAlphabet = Utility.GetAlphabet(utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence,
                                                                                        Constants.AlphabetNameNode));

            for (int i = 0; i < referenceSequences.Length; i++)
            {
                ISequence referSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(referenceSequences[i]));
                refSeqList.Add(referSeq);
            }

            for (int i = 0; i < searchSequences.Length; i++)
            {
                ISequence searchSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(searchSequences[i]));
                searchSeqList.Add(searchSeq);
            }

            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner();

            mumLength = utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence, Constants.MUMLengthNode);

            // Update other values for NUCmer object
            nucmerObj.MaximumSeparation = 0;
            nucmerObj.MinimumScore      = 2;
            nucmerObj.SeparationFactor  = 0.12f;
            nucmerObj.BreakLength       = 2;
            nucmerObj.LengthOfMUM       = long.Parse(mumLength, null);
            nucmerObj.MinimumScore      = int.Parse(utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence,
                                                                                    Constants.MinimumScoreNode), (IFormatProvider)null);


            IList <ISequenceAlignment> seqAlign = nucmerObj.Align(refSeqList, searchSeqList);

            if (seqAlign.Count == 0)
            {
                Console.WriteLine("NUCmer P2 : Successfully validated the invalid mumlength");
                ApplicationLog.WriteLine("NUCmer P2 : Successfully validated the invalid mumlength");
            }
            else
            {
                Assert.Fail();
            }
        }
Example #10
0
        public void NUCmerAlignSmallSizeAlignSequence()
        {
            // Gets the reference sequence from the FastA file
            string filePath = this.utilityObj.xmlUtil.GetTextValue(Constants.SmallSizeSequenceNodeName,
                                                                   Constants.FilePathNode);

            Assert.IsNotNull(filePath);

            FastAParser             parser     = new FastAParser();
            IEnumerable <ISequence> refSeqList = parser.Parse(filePath);

            // Gets the query sequence from the FastA file
            string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(Constants.SmallSizeSequenceNodeName,
                                                                        Constants.SearchSequenceFilePathNode);

            Assert.IsNotNull(queryFilePath);

            FastAParser             queryParser   = new FastAParser();
            IEnumerable <ISequence> searchSeqList = queryParser.Parse(queryFilePath);

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

            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner
            {
                MaximumSeparation = 0,
                MinimumScore      = 2,
                SeparationFactor  = 0.12f,
                BreakLength       = 2,
                LengthOfMUM       = long.Parse(mumLength, null)
            };

            IList <ISequenceAlignment> align = nucmerObj.Align(refSeqList.ElementAt(0), searchSeqList);

            string expectedSequences = this.utilityObj.xmlUtil.GetFileTextValue(Constants.SmallSizeSequenceNodeName,
                                                                                Constants.ExpectedSequencesNode);

            string[] expSeqArray = expectedSequences.Split(',');

            int j = 0;

            // Gets all the aligned sequences in comma separated format
            foreach (IPairwiseSequenceAlignment seqAlignment in align)
            {
                foreach (PairwiseAlignedSequence alignedSeq in seqAlignment)
                {
                    Assert.AreEqual(expSeqArray[j], alignedSeq.FirstSequence.ConvertToString());
                    ++j;
                    Assert.AreEqual(expSeqArray[j], alignedSeq.SecondSequence.ConvertToString());
                    j++;
                }
            }
        }
Example #11
0
        public void NUCmerAlignerProperties()
        {
            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner();

            Assert.AreEqual(Constants.NUCLength, nucmerObj.LengthOfMUM.ToString((IFormatProvider)null));
            Assert.AreEqual(200, nucmerObj.BreakLength);
            Assert.AreEqual(-8, nucmerObj.GapExtensionCost);
            Assert.AreEqual(-13, nucmerObj.GapOpenCost);
            Assert.AreEqual(Constants.NUCFixedSeperation, nucmerObj.FixedSeparation.ToString(CultureInfo.InvariantCulture));
            Assert.AreEqual(Constants.NUCMaximumSeparation, nucmerObj.MaximumSeparation.ToString(CultureInfo.InvariantCulture));
            Assert.AreEqual(Constants.NUCMinimumScore, nucmerObj.MinimumScore.ToString(CultureInfo.InvariantCulture));
            Assert.AreEqual(Constants.NUCSeparationFactor, nucmerObj.SeparationFactor.ToString(CultureInfo.InvariantCulture));
        }
Example #12
0
        /// <summary>
        ///     Validates the NUCmer align method for several test cases for the parameters passed.
        /// </summary>
        /// <param name="sequenceList">List of Input Sequences</param>
        private static void ValidateNUCmerEmptyAlignGeneralTestCases(IEnumerable <ISequence> sequenceList)
        {
            var nucmerObj = new NucmerPairwiseAligner();

            try
            {
                IList <ISequenceAlignment> result = nucmerObj.Align(sequenceList);
                ApplicationLog.WriteLine("NUCmer P2 : Exception not thrown");
                Assert.Fail("ArgumentNullException not thrown.");
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine("NUCmer P2: Successfully validated empty SequenceList");
            }
        }
Example #13
0
        /// <summary>
        ///     Validates the NUCmer align method for several test cases for the parameters passed.
        /// </summary>
        /// <param name="nodeName">Node name to be read from xml</param>
        private void ValidateNUCmerAlignSimpleGeneralTestCases(string nodeName)
        {
            // Gets the reference & search sequences from the configuration file
            string[] referenceSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode);
            string[] searchSequences    = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode);

            IAlphabet seqAlphabet   = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode));
            var       refSeqList    = referenceSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast <ISequence>().ToList();
            var       searchSeqList = searchSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast <ISequence>().ToList();

            // Gets the mum length from the xml
            string mumLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode);

            var nucmerObj = new NucmerPairwiseAligner
            {
                MaximumSeparation = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
                MinimumScore      = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
                SeparationFactor  = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
                BreakLength       = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null),
                LengthOfMUM       = long.Parse(mumLength, null)
            };

            IList <ISequence> seqList = refSeqList.ToList();

            foreach (ISequence seq in searchSeqList)
            {
                seqList.Add(seq);
            }

            IList <ISequenceAlignment> alignSimple = nucmerObj.AlignSimple(seqList);
            string expectedSequences = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequencesNode);

            string[] expSeqArray = expectedSequences.Split(',');

            int j = 0;

            // Gets all the aligned sequences in comma separated format
            foreach (PairwiseAlignedSequence alignedSeq in alignSimple.Cast <IPairwiseSequenceAlignment>().SelectMany(seqAlignment => seqAlignment))
            {
                Assert.AreEqual(expSeqArray[j], alignedSeq.FirstSequence.ConvertToString());
                ++j;
                Assert.AreEqual(expSeqArray[j], alignedSeq.SecondSequence.ConvertToString());
                j++;
            }

            ApplicationLog.WriteLine("NUCmer P2 : Successfully validated all the aligned sequences.");
        }
Example #14
0
        public void NUCmerAlignerProperties()
        {
            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner();

            Assert.AreEqual(Constants.NUCLength,
                            nucmerObj.LengthOfMUM.ToString((IFormatProvider)null));
            Assert.AreEqual(200, nucmerObj.BreakLength);
            Assert.AreEqual(-8, nucmerObj.GapExtensionCost);
            Assert.AreEqual(-13, nucmerObj.GapOpenCost);
            Assert.AreEqual(Constants.NUCFixedSeperation,
                            nucmerObj.FixedSeparation.ToString((IFormatProvider)null));
            Assert.AreEqual(Constants.NUCMaximumSeparation,
                            nucmerObj.MaximumSeparation.ToString((IFormatProvider)null));
            Assert.AreEqual(Constants.NUCMinimumScore,
                            nucmerObj.MinimumScore.ToString((IFormatProvider)null));
            Assert.AreEqual(Constants.NUCSeparationFactor,
                            nucmerObj.SeparationFactor.ToString((IFormatProvider)null));
            ApplicationLog.WriteLine("Successfully validated all the properties of NUCmer Aligner class.");
        }
Example #15
0
        public void NUCmerAlignGreaterMumLength()
        {
            // Gets the reference & search sequences from the configuration file
            string[]  referenceSequences = this.utilityObj.xmlUtil.GetTextValues(Constants.GreaterMumLengthSequence, Constants.ReferenceSequencesNode);
            string[]  searchSequences    = this.utilityObj.xmlUtil.GetTextValues(Constants.GreaterMumLengthSequence, Constants.SearchSequencesNode);
            IAlphabet seqAlphabet        = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence, Constants.AlphabetNameNode));

            var    refSeqList    = referenceSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast <ISequence>().ToList();
            var    searchSeqList = searchSequences.Select(t => new Sequence(seqAlphabet, Encoding.ASCII.GetBytes(t))).Cast <ISequence>().ToList();
            string mumLength     = this.utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence, Constants.MUMLengthNode);

            var nucmerObj = new NucmerPairwiseAligner
            {
                MaximumSeparation = 0,
                SeparationFactor  = 0.12f,
                BreakLength       = 2,
                LengthOfMUM       = long.Parse(mumLength, null),
                MinimumScore      = int.Parse(this.utilityObj.xmlUtil.GetTextValue(Constants.GreaterMumLengthSequence, Constants.MinimumScoreNode), null)
            };

            IList <ISequenceAlignment> seqAlign = nucmerObj.Align(refSeqList, searchSeqList);

            Assert.AreEqual(0, seqAlign.Count);
        }
Example #16
0
        void ValidateNUCmerAlignSimpleGeneralTestCases(string nodeName,
                                                       bool isAlignList)
        {
            string[]         referenceSequences = null;
            string[]         searchSequences    = null;
            List <ISequence> refSeqList         = new List <ISequence>();
            List <ISequence> searchSeqList      = new List <ISequence>();

            // Gets the reference & search sequences from the configurtion file
            referenceSequences = utilityObj.xmlUtil.GetTextValues(nodeName,
                                                                  Constants.ReferenceSequencesNode);
            searchSequences = utilityObj.xmlUtil.GetTextValues(nodeName,
                                                               Constants.SearchSequencesNode);

            IAlphabet seqAlphabet = Utility.GetAlphabet(
                utilityObj.xmlUtil.GetTextValue(nodeName,
                                                Constants.AlphabetNameNode));

            for (int i = 0; i < referenceSequences.Length; i++)
            {
                ISequence referSeq = new Sequence(seqAlphabet,
                                                  encodingObj.GetBytes(referenceSequences[i]));
                refSeqList.Add(referSeq);
            }

            for (int i = 0; i < searchSequences.Length; i++)
            {
                ISequence searchSeq = new Sequence(seqAlphabet,
                                                   encodingObj.GetBytes(searchSequences[i]));
                searchSeqList.Add(searchSeq);
            }

            // Gets the mum length from the xml
            string mumLength = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                               Constants.MUMAlignLengthNode);

            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner();

            // Update other values for NUCmer object
            nucmerObj.MaximumSeparation = int.Parse
                                              (utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), (IFormatProvider)null);
            nucmerObj.MinimumScore = int.Parse(
                utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), (IFormatProvider)null);
            nucmerObj.SeparationFactor = int.Parse(
                utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), (IFormatProvider)null);
            nucmerObj.BreakLength = int.Parse(
                utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), (IFormatProvider)null);
            nucmerObj.LengthOfMUM = long.Parse(mumLength, null);

            IList <ISequenceAlignment> alignSimple = null;

            if (isAlignList)
            {
                List <ISequence> listOfSeq = new List <ISequence>();
                listOfSeq.Add(refSeqList[0]);
                listOfSeq.Add(searchSeqList[0]);
                alignSimple = nucmerObj.AlignSimple(listOfSeq);
            }

            string expectedSequences = string.Empty;

            expectedSequences = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                Constants.ExpectedSequencesNode);

            string[] expSeqArray = expectedSequences.Split(',');

            int j = 0;

            // Gets all the aligned sequences in comma seperated format
            foreach (IPairwiseSequenceAlignment seqAlignment in alignSimple)
            {
                foreach (PairwiseAlignedSequence alignedSeq in seqAlignment)
                {
                    Assert.AreEqual(expSeqArray[j], new string(alignedSeq.FirstSequence.Select(a => (char)a).ToArray()));
                    ++j;
                    Assert.AreEqual(expSeqArray[j], new string(alignedSeq.SecondSequence.Select(a => (char)a).ToArray()));
                    j++;
                }
            }

            Console.WriteLine(
                "NUCmer BVT : Successfully validated all the aligned sequences.");
            ApplicationLog.WriteLine(
                "NUCmer BVT : Successfully validated all the aligned sequences.");
        }
Example #17
0
        void ValidateNUCmerAlignGeneralTestCases(string nodeName, bool isFilePath)
        {
            string[] referenceSequences           = null;
            string[] searchSequences              = null;
            IEnumerable <ISequence> refSeqList    = new List <ISequence>();
            IEnumerable <ISequence> searchSeqList = new List <ISequence>();

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

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

                FastAParser parser = new FastAParser(filePath);
                refSeqList = parser.Parse();

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

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

                FastAParser queryParser = new FastAParser(queryFilePath);

                searchSeqList = queryParser.Parse();
            }
            else
            {
                // Gets the reference & search sequences from the configurtion file
                referenceSequences = utilityObj.xmlUtil.GetTextValues(nodeName,
                                                                      Constants.ReferenceSequencesNode);
                searchSequences = utilityObj.xmlUtil.GetTextValues(nodeName,
                                                                   Constants.SearchSequencesNode);

                IAlphabet seqAlphabet = Utility.GetAlphabet(utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                                            Constants.AlphabetNameNode));

                IList <ISequence> tempRefSeqList = new List <ISequence>();
                for (int i = 0; i < referenceSequences.Length; i++)
                {
                    ISequence referSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(referenceSequences[i]));
                    referSeq.ID = "ref " + i;
                    tempRefSeqList.Add(referSeq);
                }
                refSeqList = (IEnumerable <ISequence>)tempRefSeqList;

                IList <ISequence> tempSearchSeqList = new List <ISequence>();
                for (int i = 0; i < searchSequences.Length; i++)
                {
                    ISequence searchSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(searchSequences[i]));
                    searchSeq.ID = "qry " + i;
                    tempSearchSeqList.Add(searchSeq);
                }
                searchSeqList = (IEnumerable <ISequence>)tempSearchSeqList;
            }

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

            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner();

            nucmerObj.MaximumSeparation = 0;
            nucmerObj.MinimumScore      = 2;
            nucmerObj.SeparationFactor  = 0.12f;
            nucmerObj.BreakLength       = 2;
            nucmerObj.LengthOfMUM       = long.Parse(mumLength, null);

            IList <ISequenceAlignment> align = nucmerObj.Align(refSeqList, searchSeqList);

            string expectedSequences = string.Empty;

            if (isFilePath)
            {
                expectedSequences = utilityObj.xmlUtil.GetFileTextValue(nodeName,
                                                                        Constants.ExpectedSequencesNode);
            }
            else
            {
                expectedSequences = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                    Constants.ExpectedSequencesNode);
            }

            string[] expSeqArray = expectedSequences.Split(',');



            // Gets all the aligned sequences in comma seperated format
            foreach (IPairwiseSequenceAlignment seqAlignment in align)
            {
                foreach (PairwiseAlignedSequence alignedSeq in seqAlignment)
                {
                    string actualStr = new string(alignedSeq.FirstSequence.Select(a => (char)a).ToArray());
                    Assert.IsTrue(expSeqArray.Contains(actualStr));

                    actualStr = new string(alignedSeq.SecondSequence.Select(a => (char)a).ToArray());
                    Assert.IsTrue(expSeqArray.Contains(actualStr));
                }
            }

            Console.WriteLine("NUCmer BVT : Successfully validated all the aligned sequences.");
            ApplicationLog.WriteLine("NUCmer BVT : Successfully validated all the aligned sequences.");
        }
Example #18
0
        public void NUCmerAlignSmallSizeAlignSequence()
        {
            IEnumerable <ISequence> refSeqList    = new List <ISequence>();
            IEnumerable <ISequence> searchSeqList = new List <ISequence>();

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

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

            FastAParser parser = new FastAParser(filePath);

            refSeqList = parser.Parse();

            // Gets the query sequence from the FastA file
            string queryFilePath = utilityObj.xmlUtil.GetTextValue(Constants.SmallSizeSequenceNodeName,
                                                                   Constants.SearchSequenceFilePathNode);

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

            FastAParser queryParser = new FastAParser(queryFilePath);

            searchSeqList = queryParser.Parse();

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

            NucmerPairwiseAligner nucmerObj = new NucmerPairwiseAligner();

            nucmerObj.MaximumSeparation = 0;
            nucmerObj.MinimumScore      = 2;
            nucmerObj.SeparationFactor  = 0.12f;
            nucmerObj.BreakLength       = 2;
            nucmerObj.LengthOfMUM       = long.Parse(mumLength, null);

            IList <ISequenceAlignment> align = nucmerObj.Align(refSeqList.ElementAt(0), searchSeqList);

            string expectedSequences = string.Empty;

            expectedSequences = utilityObj.xmlUtil.GetFileTextValue(Constants.SmallSizeSequenceNodeName,
                                                                    Constants.ExpectedSequencesNode);

            string[] expSeqArray = expectedSequences.Split(',');

            int j = 0;

            // Gets all the aligned sequences in comma seperated format
            foreach (IPairwiseSequenceAlignment seqAlignment in align)
            {
                foreach (PairwiseAlignedSequence alignedSeq in seqAlignment)
                {
                    Assert.AreEqual(expSeqArray[j], new string(alignedSeq.FirstSequence.Select(a => (char)a).ToArray()));
                    ++j;
                    Assert.AreEqual(expSeqArray[j], new string(alignedSeq.SecondSequence.Select(a => (char)a).ToArray()));
                    j++;
                }
            }

            Console.WriteLine("NUCmer BVT : Successfully validated all the aligned sequences.");
            ApplicationLog.WriteLine("NUCmer BVT : Successfully validated all the aligned sequences.");
        }
Example #19
0
        /// <summary>
        /// Validates the NUCmer align method for several test cases for the parameters passed.
        /// </summary>
        /// <param name="nodeName">Node name to be read from xml</param>
        /// <param name="isFilePath">Is Sequence saved in File</param>
        void ValidateNUCmerAlignGeneralTestCases(string nodeName, bool isFilePath)
        {
            IList <ISequence> refSeqList, searchSeqList;

            if (isFilePath)
            {
                // Gets the reference sequence from the FastA file
                string filePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
                Assert.IsNotNull(filePath);
                Assert.IsTrue(File.Exists(filePath));
                ApplicationLog.WriteLine(string.Format(null, "NUCmer BVT : Successfully validated the File Path '{0}'.", filePath));

                FastAParser parser = new FastAParser();
                refSeqList = parser.Parse(filePath).ToList();

                // Gets the query sequence from the FastA file
                string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode);
                Assert.IsNotNull(queryFilePath);
                Assert.IsTrue(File.Exists(queryFilePath));
                ApplicationLog.WriteLine(string.Format(null, "NUCmer BVT : Successfully validated the File Path '{0}'.", queryFilePath));

                searchSeqList = parser.Parse(queryFilePath).ToList();
            }
            else
            {
                // Gets the reference & search sequences from the configuration file
                IAlphabet seqAlphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode));

                string[] sequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode);
                refSeqList = sequences.Select((t, i) => new Sequence(seqAlphabet, this.encodingObj.GetBytes(t))
                {
                    ID = "ref " + i
                }).Cast <ISequence>().ToList();

                sequences     = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode);
                searchSeqList = sequences.Select((t, i) => new Sequence(seqAlphabet, this.encodingObj.GetBytes(t))
                {
                    ID = "qry " + i
                }).Cast <ISequence>().ToList();
            }

            var aligner = new NucmerPairwiseAligner
            {
                MaximumSeparation = 0,
                MinimumScore      = 2,
                SeparationFactor  = 0.12f,
                BreakLength       = 2,
                LengthOfMUM       = long.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode), null)
            };

            IList <ISequenceAlignment> align = aligner.Align(refSeqList, searchSeqList);

            string expectedSequences = isFilePath
                    ? this.utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.ExpectedSequencesNode)
                    : this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequencesNode);

            string[] expSeqArray = expectedSequences.Split(',');

            // Gets all the aligned sequences in comma separated format
            foreach (IPairwiseSequenceAlignment seqAlignment in align)
            {
                foreach (PairwiseAlignedSequence alignedSeq in seqAlignment)
                {
                    string actualStr = alignedSeq.FirstSequence.ConvertToString();
                    Assert.IsTrue(expSeqArray.Contains(actualStr));

                    actualStr = alignedSeq.SecondSequence.ConvertToString();
                    Assert.IsTrue(expSeqArray.Contains(actualStr));
                }
            }
        }
Example #20
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;
            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(CompareAlignment(result, expectedOutput));
        }
Example #21
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.");
        }
Example #22
0
 public NucmerAlignerProvider(ISequenceProvider provider, NucmerPairwiseAligner aligner)
 {
     _provider = provider;
     _aligner  = aligner;
 }
Example #23
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.");
        }