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

            if (isFilePath)
            {
                // Gets the reference sequence from the configuration file
                string filePath = this.utilityObj.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();
                switch (isAmbiguousCharacter)
                {
                    case PhaseOneAmbiguityParameters.Dna:
                        parser.Alphabet = AmbiguousDnaAlphabet.Instance;
                        break;
                    case PhaseOneAmbiguityParameters.Rna:
                        parser.Alphabet = AmbiguousRnaAlphabet.Instance;
                        break;
                    default:
                        break;
                }
                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(null, "MUMmer BVT : Successfully validated the Search File Path '{0}'.", queryFilePath));

                FastAParser queryParser = new FastAParser();
                switch (isAmbiguousCharacter)
                {
                    case PhaseOneAmbiguityParameters.Dna:
                        queryParser.Alphabet = AmbiguousDnaAlphabet.Instance;
                        break;
                    case PhaseOneAmbiguityParameters.Rna:
                        queryParser.Alphabet = AmbiguousRnaAlphabet.Instance;
                        break;
                    default:
                        break;
                }

                querySeqs = queryParser.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 referenceAlphabet = this.utilityObj.xmlUtil.GetTextValue(nodeName,
                    Constants.AlphabetNameNode);

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

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

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

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

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

            // Builds the suffix for the reference sequence passed.            
            MultiWaySuffixTree suffixTreeBuilder = new MultiWaySuffixTree(referenceSeq as Sequence);
            suffixTreeBuilder.MinLengthOfMatch = long.Parse(mumLength, null);
            IEnumerable<Match> matches = suffixTreeBuilder.SearchMatchesUniqueInReference(querySeq);

            // For multi sequence query file validate all the sequences with the reference sequence
            if (isMultiSequenceSearchFile)
            {
                matches = suffixTreeBuilder.SearchMatchesUniqueInReference(querySeqs.ElementAt(0));
                Assert.IsTrue(this.ValidateUniqueMatches(matches, nodeName));
                matches = suffixTreeBuilder.SearchMatchesUniqueInReference(querySeqs.ElementAt(1));
                Assert.IsTrue(this.ValidateUniqueMatches(matches, nodeName));
            }
            else
            {
                matches = suffixTreeBuilder.SearchMatchesUniqueInReference(querySeq);
                Assert.IsTrue(this.ValidateUniqueMatches(matches, nodeName));
            }

            ApplicationLog.WriteLine(string.Format(null, "MUMmer P1 : Successfully validated the all the unique matches for the sequence '{0}' and '{1}'.",
                referenceSequence, querySequence));
        }
Exemplo n.º 2
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="isAmbiguousCharacter"></param>
 void ValidateFindMatchSuffixGeneralTestCases(string nodeName,
     bool isFilePath, PhaseOneAmbiguityParameters isAmbiguousCharacter)
 {
     this.ValidateFindMatchSuffixGeneralTestCases(nodeName, isFilePath, false, isAmbiguousCharacter);
 }