/// <summary> /// Concat all the sequences into one sequence with special character. /// </summary> /// <param name="sequences">List of reference sequence.</param> /// <returns>Concatenated sequence.</returns> protected static ISequence ConcatSequence(IEnumerable <ISequence> sequences) { if (sequences == null) { throw new ArgumentNullException("sequences"); } // Add the Concatenating symbol to every sequence in reference list // Note that, as of now protein sequence is being created out // of input sequence add concatenation character "X" to it to // simplify implementation. List <byte> referenceSequence = null; foreach (ISequence sequence in sequences) { if (null == referenceSequence) { referenceSequence = new List <byte>(sequence); } else { referenceSequence.AddRange(sequence); } // Add concatenating symbol. referenceSequence.Add((byte)'+'); } return(new Sequence(AlphabetExtensions.GetMummerAlphabet(sequences.ElementAt(0).Alphabet), referenceSequence.ToArray(), false)); }
void ValidateFindMatchSuffixGeneralTestCases(string nodeName, bool isFilePath, AdditionalParameters additionalParam) { ISequence referenceSeqs = null; string[] referenceSequences = null; string[] searchSequences = null; List <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)); using (FastAParser parser = new FastAParser(filePath)) { IEnumerable <ISequence> referenceSeqList = parser.Parse(); List <Byte> byteList = new List <Byte>(); foreach (ISequence seq in referenceSeqList) { byteList.AddRange(seq); byteList.Add((byte)'+'); } referenceSeqs = new Sequence(AlphabetExtensions.GetMummerAlphabet(referenceSeqList.ElementAt(0).Alphabet), byteList.ToArray()); // 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); IEnumerable <ISequence> querySeqList = queryParser.Parse(); foreach (ISequence seq in querySeqList) { searchSeqList.Add(seq); } } } 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)); List <ISequence> refSeqList = new List <ISequence>(); for (int i = 0; i < referenceSequences.Length; i++) { ISequence referSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(referenceSequences[i])); refSeqList.Add(referSeq); } List <Byte> byteListQuery = new List <Byte>(); foreach (ISequence seq in refSeqList) { byteListQuery.AddRange(seq); byteListQuery.Add((byte)'+'); } referenceSeqs = new Sequence(AlphabetExtensions.GetMummerAlphabet(refSeqList.ElementAt(0).Alphabet), byteListQuery.ToArray()); for (int i = 0; i < searchSequences.Length; i++) { ISequence searchSeq = new Sequence(seqAlphabet, encodingObj.GetBytes(searchSequences[i])); searchSeqList.Add(searchSeq); } } string mumLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMLengthNode); // Builds the suffix for the reference sequence passed. MultiWaySuffixTree suffixTreeBuilder = new MultiWaySuffixTree(referenceSeqs as Sequence); suffixTreeBuilder.MinLengthOfMatch = long.Parse(mumLength, null); Dictionary <ISequence, IEnumerable <Match> > matches = new Dictionary <ISequence, IEnumerable <Match> >(); for (int i = 0; i < searchSeqList.Count; i++) { matches.Add(searchSeqList[i], suffixTreeBuilder.SearchMatchesUniqueInReference(searchSeqList[i])); } List <Match> mums = new List <Match>(); foreach (var a in matches.Values) { mums.AddRange(a); } switch (additionalParam) { case AdditionalParameters.FindUniqueMatches: // Validates the Unique Matches. ApplicationLog.WriteLine("NUCmer BVT : Validating the Unique Matches"); Assert.IsTrue(ValidateUniqueMatches(mums, nodeName, additionalParam, isFilePath)); Console.WriteLine( "NUCmer BVT : Successfully validated the all the unique matches for the sequences."); break; case AdditionalParameters.PerformClusterBuilder: // Validates the Unique Matches. ApplicationLog.WriteLine( "NUCmer BVT : Validating the Unique Matches using Cluster Builder"); Assert.IsTrue(ValidateUniqueMatches(mums, nodeName, additionalParam, isFilePath)); Console.WriteLine( "NUCmer BVT : Successfully validated the all the cluster builder matches for the sequences."); break; default: break; } ApplicationLog.WriteLine( "NUCmer BVT : Successfully validated the all the unique matches for the sequences."); }