Exemple #1
0
        /// <summary>
        /// Validates most of the find matches suffix tree test cases with varying parameters.
        /// </summary>
        /// <param name="nodeName">Node name which needs to be read for execution.</param>
        /// <param name="isFilePath">Is File Path?</param>
        /// <param name="LISActionType">LIS action type enum</param>
        static void ValidateFindMatchSuffixGeneralTestCases(string nodeName, bool isFilePath,
                                                            LISParameters LISActionType)
        {
            ISequence referenceSeq      = null;
            ISequence querySeq          = null;
            string    referenceSequence = string.Empty;
            string    querySequence     = string.Empty;

            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();
                IList <ISequence> 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 seqAlp = Utility._xmlUtil.GetTextValue(nodeName,
                                                              Constants.AlphabetNameNode);

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

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

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

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

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

            // Builds the suffix for the reference sequence passed.
            ISuffixTreeBuilder suffixTreeBuilder = new KurtzSuffixTreeBuilder();
            SequenceSuffixTree suffixTree        = suffixTreeBuilder.BuildSuffixTree(referenceSeq);

            IList <MaxUniqueMatch> matches = suffixTreeBuilder.FindMatches(suffixTree, querySeq,
                                                                           long.Parse(mumLength, null));

            switch (LISActionType)
            {
            case LISParameters.FindUniqueMatches:
                // Validates the Unique Matches.
                ApplicationLog.WriteLine("MUMmer BVT : Validating the Unique Matches");
                Assert.IsTrue(ValidateUniqueMatches(matches, nodeName, LISActionType));
                break;

            case LISParameters.PerformLIS:
                // Validates the Unique Matches.
                ApplicationLog.WriteLine("MUMmer BVT : Validating the Unique Matches using LIS");
                LongestIncreasingSubsequence lisObj     = new LongestIncreasingSubsequence();
                IList <MaxUniqueMatch>       lisMatches = lisObj.GetLongestSequence(matches);
                Assert.IsTrue(ValidateUniqueMatches(lisMatches, nodeName, LISActionType));
                break;

            default:
                break;
            }

            Console.WriteLine(string.Format(null,
                                            "MUMmer BVT : Successfully validated the all the unique matches for the sequence '{0}' and '{1}'.",
                                            referenceSequence, querySequence));
            ApplicationLog.WriteLine(string.Format(null,
                                                   "MUMmer BVT : Successfully validated the all the unique matches for the sequence '{0}' and '{1}'.",
                                                   referenceSequence, querySequence));
        }
Exemple #2
0
        /// <summary>
        /// Validates the Unique Matches for the input provided.
        /// </summary>
        /// <param name="matches">Max Unique Match list</param>
        /// <param name="nodeName">Node name to be read from xml</param>
        /// <param name="LISActionType">Unique Match/Sub level LIS/LIS</param>
        /// <returns>True, if successfully validated</returns>
        static bool ValidateUniqueMatches(IList <MaxUniqueMatch> matches,
                                          string nodeName, LISParameters LISActionType)
        {
            // Gets all the unique matches properties to be validated as in xml.
            string[] firstSeqOrder  = null;
            string[] firstSeqStart  = null;
            string[] length         = null;
            string[] secondSeqOrder = null;
            string[] secondSeqStart = null;

            switch (LISActionType)
            {
            case LISParameters.PerformLIS:
                firstSeqOrder = Utility._xmlUtil.GetTextValue(nodeName,
                                                              Constants.LisFirstSequenceMumOrderNode).Split(',');
                firstSeqStart = Utility._xmlUtil.GetTextValue(nodeName,
                                                              Constants.LisFirstSequenceStartNode).Split(',');
                length         = Utility._xmlUtil.GetTextValue(nodeName, Constants.LisLengthNode).Split(',');
                secondSeqOrder = Utility._xmlUtil.GetTextValue(nodeName,
                                                               Constants.LisSecondSequenceMumOrderNode).Split(',');
                secondSeqStart = Utility._xmlUtil.GetTextValue(nodeName,
                                                               Constants.LisSecondSequenceStartNode).Split(',');
                break;

            case LISParameters.FindUniqueMatches:
                firstSeqOrder = Utility._xmlUtil.GetTextValue(nodeName,
                                                              Constants.FirstSequenceMumOrderNode).Split(',');
                firstSeqStart = Utility._xmlUtil.GetTextValue(nodeName,
                                                              Constants.FirstSequenceStartNode).Split(',');
                length         = Utility._xmlUtil.GetTextValue(nodeName, Constants.LengthNode).Split(',');
                secondSeqOrder = Utility._xmlUtil.GetTextValue(nodeName,
                                                               Constants.SecondSequenceMumOrderNode).Split(',');
                secondSeqStart = Utility._xmlUtil.GetTextValue(nodeName,
                                                               Constants.SecondSequenceStartNode).Split(',');
                break;

            default:
                break;
            }

            int i = 0;

            // Loops through all the matches and validates the same.
            foreach (MaxUniqueMatch match in matches)
            {
                if ((0 != string.Compare(firstSeqOrder[i],
                                         match.FirstSequenceMumOrder.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture)) ||
                    (0 != string.Compare(firstSeqStart[i],
                                         match.FirstSequenceStart.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture)) ||
                    (0 != string.Compare(length[i],
                                         match.Length.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture)) ||
                    (0 != string.Compare(secondSeqOrder[i],
                                         match.SecondSequenceMumOrder.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture)) ||
                    (0 != string.Compare(secondSeqStart[i],
                                         match.SecondSequenceStart.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture)))
                {
                    Console.WriteLine(string.Format(null,
                                                    "MUMmer BVT : Unique match not matching at index '{0}'", i.ToString()));
                    ApplicationLog.WriteLine(string.Format(null,
                                                           "MUMmer BVT : Unique match not matching at index '{0}'", i.ToString()));
                    return(false);
                }
                i++;
            }

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Validates the Unique Matches for the input provided.
        /// </summary>
        /// <param name="matches">Max Unique Match list</param>
        /// <param name="nodeName">Node name to be read from xml</param>
        /// <param name="lisActionType"></param>
        /// <returns>True, if successfully validated</returns>        
        bool ValidateUniqueMatches(IEnumerable<Match> matches, string nodeName, LISParameters lisActionType)
        {
            // Gets all the unique matches properties to be validated as in xml.
            string[] firstSeqStart = null;
            string[] length = null;
            string[] secondSeqStart = null;

            switch (lisActionType)
            {
                case LISParameters.PerformLIS:
                    firstSeqStart = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                        Constants.LisFirstSequenceStartNode).Split(',');
                    length = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.LisLengthNode).Split(',');
                    secondSeqStart = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                        Constants.LisSecondSequenceStartNode).Split(',');
                    break;
                case LISParameters.FindUniqueMatches:
                    firstSeqStart = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                        Constants.FirstSequenceStartNode).Split(',');
                    length = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.LengthNode).Split(',');
                    secondSeqStart = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                        Constants.SecondSequenceStartNode).Split(',');
                    break;
                default:
                    break;
            }

            int i = 0;
            // Loops through all the matches and validates the same.            
            foreach (Match match in matches)
            {
                if ((0 != string.Compare(firstSeqStart[i],
                    match.ReferenceSequenceOffset.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture))
                    || (0 != string.Compare(length[i],
                    match.Length.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture))
                    || (0 != string.Compare(secondSeqStart[i],
                    match.QuerySequenceOffset.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture)))
                {
                    ApplicationLog.WriteLine(string.Format("MUMmer BVT : Unique match not matching at index '{0}'", i.ToString((IFormatProvider)null)));
                    return false;
                }
                i++;
            }

            return true;
        }