/// <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="additionalParam">LIS action type enum</param> void ValidateFindMatchSuffixGeneralTestCases(string nodeName, bool isFilePath, AdditionalParameters additionalParam) { ISequence referenceSeqs; var searchSeqList = new List<ISequence>(); if (isFilePath) { // Gets the reference sequence from the FastA file string filePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode); Assert.IsNotNull(filePath); FastAParser parser = new FastAParser(); IEnumerable<ISequence> referenceSeqList = parser.Parse(filePath); List<Byte> byteList = new List<Byte>(); foreach (ISequence seq in referenceSeqList) { byteList.AddRange(seq); byteList.Add((byte)'+'); } referenceSeqs = new Sequence(referenceSeqList.First().Alphabet.GetMummerAlphabet(), byteList.ToArray()); // Gets the query sequence from the FastA file string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode); Assert.IsNotNull(queryFilePath); IEnumerable<ISequence> querySeqList = parser.Parse(queryFilePath); searchSeqList.AddRange(querySeqList); } else { // 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)); List<ISequence> refSeqList = referenceSequences.Select(t => new Sequence(seqAlphabet, this.encodingObj.GetBytes(t))).Cast<ISequence>().ToList(); List<Byte> byteListQuery = new List<Byte>(); foreach (ISequence seq in refSeqList) { byteListQuery.AddRange(seq); byteListQuery.Add((byte)'+'); } referenceSeqs = new Sequence(refSeqList.First().Alphabet.GetMummerAlphabet(), byteListQuery.ToArray()); searchSeqList.AddRange(searchSequences.Select(t => new Sequence(seqAlphabet, this.encodingObj.GetBytes(t))).Cast<ISequence>()); } string mumLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMLengthNode); // Builds the suffix for the reference sequence passed. MultiWaySuffixTree suffixTreeBuilder = new MultiWaySuffixTree(referenceSeqs as Sequence) { MinLengthOfMatch = long.Parse(mumLength, null) }; var matches = new Dictionary<ISequence, IEnumerable<Match>>(); foreach (ISequence sequence in searchSeqList) { matches.Add(sequence, suffixTreeBuilder.SearchMatchesUniqueInReference(sequence)); } List<Match> mums = new List<Match>(); foreach (var a in matches.Values) { mums.AddRange(a); } switch (additionalParam) { case AdditionalParameters.FindUniqueMatches: // Validates the Unique Matches. Assert.IsTrue(this.ValidateUniqueMatches(mums, nodeName, additionalParam, isFilePath)); break; case AdditionalParameters.PerformClusterBuilder: // Validates the Unique Matches. Assert.IsTrue(this.ValidateUniqueMatches(mums, nodeName, additionalParam, isFilePath)); break; default: break; } }
void ValidateFindMatchSimpleSuffixGeneralTestCases(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 configurtion 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), this.encodingObj.GetBytes(referenceSequence)); querySequence = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceNode); seqAlp = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceAlphabetNode); querySeq = new Sequence(Utility.GetAlphabet(seqAlp), 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 = null; matches = suffixTreeBuilder.SearchMatchesUniqueInReference(querySeq); // Validates the Unique Matches. ApplicationLog.WriteLine("MUMmer BVT : Validating the Unique Matches"); Assert.IsTrue(this.ValidateUniqueMatches(matches, nodeName, LISParameters.FindUniqueMatches)); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "MUMmer BVT : Successfully validated the all the unique matches for the sequence '{0}' and '{1}'.", referenceSequence, querySequence)); }
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)); }