Exemplo n.º 1
0
        void ValidateMUMsGeneralTestCases(string nodeName, bool isFilePath)
        {
            ISequence referenceSeq = null;
            ISequence querySeq = null;
            IEnumerable<ISequence> querySeqs = null;
            string referenceSequence = string.Empty;
            string querySequence = string.Empty;
            IEnumerable<ISequence> referenceSeqs = null;

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

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

                FastAParser parser = new FastAParser();
                parser.Alphabet = Alphabets.DNA;
                referenceSeqs = parser.Parse(filePath);
                referenceSeq = referenceSeqs.ElementAt(0);
                referenceSequence = new string(referenceSeq.Select(a => (char)a).ToArray());

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

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

                querySeqs = parser.Parse(queryFilePath);
                querySeq = querySeqs.ElementAt(0);
                querySequence = new string(querySeq.Select(a => (char)a).ToArray());
            }
            else
            {
                // Gets the reference sequence from the configurtion file
                referenceSequence = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.SequenceNode);

                string referenceSeqAlphabet = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.AlphabetNameNode);

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

                querySequence = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.SearchSequenceNode);

                referenceSeqAlphabet = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.SearchSequenceAlphabetNode);

                querySeq = new Sequence(Utility.GetAlphabet(referenceSeqAlphabet),
                    this.encodingObj.GetBytes(querySequence));

                querySeqs = new List<ISequence>() { querySeq };
            }

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

            Bio.Algorithms.MUMmer.MUMmer mum = new Bio.Algorithms.MUMmer.MUMmer(referenceSeq as Sequence);
            mum.LengthOfMUM = long.Parse(mumLength, null);
            IEnumerable<Match> actualResult = null;
            actualResult = mum.GetMatchesUniqueInReference(querySeqs.ElementAt(0));

            // Validate MUMs output.
            Assert.IsTrue(this.ValidateMums(nodeName, actualResult));

            ApplicationLog.WriteLine("MUMmer BVT : Successfully validated the Mumms.");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Validates Longest Increasing sequences.
        /// </summary>
        /// <param name="nodeName">Node name which needs to be read for execution.</param>
        /// <param name="isFilePath">Is File Path?</param>
        void ValidateLongestIncreasingSubsequenceTestCases(string nodeName, bool isFilePath)
        {
            ISequence referenceSeq = null;
            ISequence querySeq = null;
            string referenceSequence = string.Empty;
            string querySequence = string.Empty;
            IEnumerable<ISequence> referenceSeqs = null;

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

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

                FastAParser parser = new FastAParser();
                referenceSeqs = parser.Parse(filePath);
                referenceSeq = referenceSeqs.ElementAt(0);
                referenceSequence = new string(referenceSeq.Select(a => (char)a).ToArray());

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

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

                IEnumerable<ISequence> querySeqs = null;
                querySeqs = parser.Parse(queryFilePath);
                querySeq = querySeqs.ElementAt(0);
                querySequence = new string(querySeq.Select(a => (char)a).ToArray());
            }
            else
            {
                // Gets the reference sequence from the configuration file
                referenceSequence = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.SequenceNode);

                string seqAlp = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.AlphabetNameNode);

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

                querySequence = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.SearchSequenceNode);

                seqAlp = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.SearchSequenceAlphabetNode);

                querySeq = new Sequence(Utility.GetAlphabet(seqAlp),
                    querySequence);
            }

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

            IEnumerable<Match> matches;
            Bio.Algorithms.MUMmer.MUMmer mum = new Bio.Algorithms.MUMmer.MUMmer(referenceSeq as Sequence);
            mum.LengthOfMUM = long.Parse(mumLength);
            matches = mum.GetMatchesUniqueInReference(querySeq);

            // Validates the Unique Matches.
            ApplicationLog.WriteLine("MUMmer BVT : Validating the Unique Matches using LIS");
            LongestIncreasingSubsequence lisObj = new LongestIncreasingSubsequence();

            List<Match> listMatch = new List<Match>();

            foreach (Match mtch in matches)
            {
                listMatch.Add(mtch);
            }

            IList<Match> lisSorted = null, actualLis = null;
            lisSorted = lisObj.SortMum(listMatch);
            actualLis = lisObj.GetLongestSequence(lisSorted);
            Assert.IsTrue(this.ValidateUniqueMatches(actualLis, nodeName, LISParameters.PerformLIS));

            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                "MUMmer BVT : Successfully validated the all the unique matches for the sequence '{0}' and '{1}'.",
                referenceSequence, querySequence));
        }
Exemplo n.º 3
0
        public void ValidateGetMumsWithMaxMatchWithOneLineSequence()
        {
            // Gets the reference sequence from the configurtion file
            string referenceSequence = this.utilityObj.xmlUtil.GetTextValue(Constants.OneLineSequenceNodeName,
                    Constants.SequenceNode);

            string referenceSeqAlphabet = this.utilityObj.xmlUtil.GetTextValue(Constants.OneLineSequenceNodeName,
                Constants.AlphabetNameNode);

            ISequence referenceSeq = new Sequence(Utility.GetAlphabet(referenceSeqAlphabet),
                this.encodingObj.GetBytes(referenceSequence));

            string querySequence = this.utilityObj.xmlUtil.GetTextValue(Constants.OneLineSequenceNodeName,
                Constants.SearchSequenceNode);

            referenceSeqAlphabet = this.utilityObj.xmlUtil.GetTextValue(Constants.OneLineSequenceNodeName,
                Constants.SearchSequenceAlphabetNode);

            ISequence querySeq = new Sequence(Utility.GetAlphabet(referenceSeqAlphabet),
                 this.encodingObj.GetBytes(querySequence));

            string mumLength = this.utilityObj.xmlUtil.GetTextValue(Constants.OneLineSequenceNodeName, Constants.MUMLengthNode);

            Bio.Algorithms.MUMmer.MUMmer mum = new Bio.Algorithms.MUMmer.MUMmer(referenceSeq as Sequence);
            mum.LengthOfMUM = long.Parse(mumLength, null);
            IEnumerable<Match> actualResult = null;
            actualResult = mum.GetMatches(querySeq);

            // Validate MUMs output.
            Assert.IsTrue(this.ValidateMums(Constants.OneLineSequenceNodeName, actualResult));

            ApplicationLog.WriteLine("MUMmer BVT : Successfully validated the Mumms.");
        }