public void TestClusterWithCross() { // Create a list of Mum classes. List <MaxUniqueMatch> matches = new List <MaxUniqueMatch>(); MaxUniqueMatch match = null; match = new MaxUniqueMatch(); match.FirstSequenceStart = 0; match.Length = 4; match.SecondSequenceStart = 4; matches.Add(match); match = new MaxUniqueMatch(); match.FirstSequenceStart = 4; match.Length = 3; match.SecondSequenceStart = 0; matches.Add(match); match = new MaxUniqueMatch(); match.FirstSequenceStart = 10; match.Length = 3; match.SecondSequenceStart = 10; matches.Add(match); IClusterBuilder clusterBuilder = new ClusterBuilder(); clusterBuilder.MinimumScore = 2; clusterBuilder.FixedSeparation = 0; IList <Cluster> actualOutput = clusterBuilder.BuildClusters(matches); IList <Cluster> expectedOutput = new List <Cluster>(); IList <MaxUniqueMatchExtension> clusterMatches = new List <MaxUniqueMatchExtension>(); match = new MaxUniqueMatch(); match.FirstSequenceStart = 0; match.Length = 4; match.SecondSequenceStart = 4; clusterMatches.Add(new MaxUniqueMatchExtension(match)); expectedOutput.Add(new Cluster(clusterMatches)); clusterMatches = new List <MaxUniqueMatchExtension>(); match = new MaxUniqueMatch(); match.FirstSequenceStart = 4; match.Length = 3; match.SecondSequenceStart = 0; clusterMatches.Add(new MaxUniqueMatchExtension(match)); expectedOutput.Add(new Cluster(clusterMatches)); clusterMatches = new List <MaxUniqueMatchExtension>(); match = new MaxUniqueMatch(); match.FirstSequenceStart = 10; match.Length = 3; match.SecondSequenceStart = 10; clusterMatches.Add(new MaxUniqueMatchExtension(match)); expectedOutput.Add(new Cluster(clusterMatches)); Assert.IsTrue(this.CompareMumList(actualOutput, expectedOutput)); }
bool ValidateUniqueMatches(IList <Match> matches, string nodeName, AdditionalParameters additionalParam, bool isFilePath) { switch (additionalParam) { case AdditionalParameters.PerformClusterBuilder: // Validates the Cluster builder MUMs string firstSeqOrderExpected = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustFirstSequenceStartNode); string lengthExpected = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustLengthNode); string secondSeqOrderExpected = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClustSecondSequenceStartNode); StringBuilder firstSeqOrderActual = new StringBuilder(); StringBuilder lengthActual = new StringBuilder(); StringBuilder secondSeqOrderActual = new StringBuilder(); ClusterBuilder cb = new ClusterBuilder(); cb.MinimumScore = 0; List <MatchExtension> meObj = new List <MatchExtension>(); foreach (Match m in matches) { meObj.Add(new MatchExtension(m)); } // Order the mum list with query sequence order and // Assign query sequence to the MUM's for (int index = 0; index < meObj.Count(); index++) { meObj.ElementAt(index).ReferenceSequenceMumOrder = index + 1; meObj.ElementAt(index).QuerySequenceMumOrder = index + 1; } List <Cluster> clusts = cb.BuildClusters(meObj); foreach (Cluster clust in clusts) { foreach (MatchExtension maxMatchExtension in clust.Matches) { firstSeqOrderActual.Append(maxMatchExtension.ReferenceSequenceMumOrder); secondSeqOrderActual.Append(maxMatchExtension.QuerySequenceMumOrder); lengthActual.Append(maxMatchExtension.Length); } } if ((0 != string.Compare(firstSeqOrderExpected.Replace(",", ""), firstSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture)) || (0 != string.Compare(lengthExpected.Replace(",", ""), lengthActual.ToString(), true, CultureInfo.CurrentCulture)) || (0 != string.Compare(secondSeqOrderExpected.Replace(",", ""), secondSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture))) { Console.WriteLine("NUCmer BVT : Unique match not matching"); ApplicationLog.WriteLine("NUCmer BVT : Unique match not matching"); return(false); } break; case AdditionalParameters.FindUniqueMatches: // Gets all the unique matches properties to be validated as in xml. string[] firstSeqOrder = null; string[] length = null; string[] secondSeqOrder = null; if (isFilePath) { firstSeqOrder = utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.FirstSequenceMumOrderNode).Split(','); length = utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.LengthNode).Split(','); secondSeqOrder = utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.SecondSequenceMumOrderNode).Split(','); } else { firstSeqOrder = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FirstSequenceMumOrderNode).Split(','); length = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.LengthNode).Split(','); secondSeqOrder = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SecondSequenceMumOrderNode).Split(','); } int i = 0; IList <MatchExtension> meNewObj = new List <MatchExtension>(); foreach (Match m in matches) { meNewObj.Add(new MatchExtension(m)); } // Order the mum list with query sequence order and // Assign query sequence to the MUM's for (int index = 0; index < meNewObj.Count(); index++) { meNewObj.ElementAt(index).ReferenceSequenceMumOrder = index + 1; meNewObj.ElementAt(index).QuerySequenceMumOrder = index + 1; } // Loops through all the matches and validates the same. foreach (MatchExtension match in meNewObj) { if ((0 != string.Compare(firstSeqOrder[i], match.ReferenceSequenceMumOrder.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.QuerySequenceMumOrder.ToString((IFormatProvider)null), true, CultureInfo.CurrentCulture))) { Console.WriteLine(string.Format((IFormatProvider)null, "NUCmer BVT : Unique match not matching at index '{0}'", i.ToString((IFormatProvider)null))); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "NUCmer BVT : Unique match not matching at index '{0}'", i.ToString((IFormatProvider)null))); return(false); } i++; } break; default: break; } return(true); }
/// <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="additionalParam">Unique Match/Sub level LIS/LIS</param> /// <param name="isFilePath">Nodes to be read from Text file?</param> /// <returns>True, if successfully validated</returns> static bool ValidateUniqueMatches(IList <MaxUniqueMatch> matches, string nodeName, AdditionalParameters additionalParam, bool isFilePath) { switch (additionalParam) { case AdditionalParameters.PerformClusterBuilder: // Validates the Cluster builder MUMs string firstSeqOrderExpected = Utility._xmlUtil.GetTextValue(nodeName, Constants.ClustFirstSequenceMumOrderNode); string firstSeqStartExpected = Utility._xmlUtil.GetTextValue(nodeName, Constants.ClustFirstSequenceStartNode); string lengthExpected = Utility._xmlUtil.GetTextValue(nodeName, Constants.ClustLengthNode); string secondSeqOrderExpected = Utility._xmlUtil.GetTextValue(nodeName, Constants.ClustSecondSequenceMumOrderNode); string secondSeqStartExpected = Utility._xmlUtil.GetTextValue(nodeName, Constants.ClustSecondSequenceStartNode); StringBuilder firstSeqOrderActual = new StringBuilder(); StringBuilder firstSeqStartActual = new StringBuilder(); StringBuilder lengthActual = new StringBuilder(); StringBuilder secondSeqOrderActual = new StringBuilder(); StringBuilder secondSeqStartActual = new StringBuilder(); ClusterBuilder cb = new ClusterBuilder(); cb.MinimumScore = 0; IList <Cluster> clusts = cb.BuildClusters(matches); foreach (Cluster clust in clusts) { foreach (MaxUniqueMatchExtension maxMatchExtension in clust.Matches) { firstSeqOrderActual.Append(maxMatchExtension.FirstSequenceMumOrder); secondSeqOrderActual.Append(maxMatchExtension.SecondSequenceMumOrder); secondSeqStartActual.Append(maxMatchExtension.SecondSequenceStart); firstSeqStartActual.Append(maxMatchExtension.FirstSequenceStart); lengthActual.Append(maxMatchExtension.Length); } } if ((0 != string.Compare(firstSeqOrderExpected.Replace(",", ""), firstSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture)) || (0 != string.Compare(firstSeqStartExpected.Replace(",", ""), firstSeqStartActual.ToString(), true, CultureInfo.CurrentCulture)) || (0 != string.Compare(lengthExpected.Replace(",", ""), lengthActual.ToString(), true, CultureInfo.CurrentCulture)) || (0 != string.Compare(secondSeqOrderExpected.Replace(",", ""), secondSeqOrderActual.ToString(), true, CultureInfo.CurrentCulture)) || (0 != string.Compare(secondSeqStartExpected.Replace(",", ""), secondSeqStartActual.ToString(), true, CultureInfo.CurrentCulture))) { Console.WriteLine("NUCmer BVT : Unique match not matching"); ApplicationLog.WriteLine("NUCmer BVT : Unique match not matching"); return(false); } break; case AdditionalParameters.FindUniqueMatches: // 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; if (isFilePath) { firstSeqOrder = Utility._xmlUtil.GetFileTextValue(nodeName, Constants.FirstSequenceMumOrderNode).Split(','); firstSeqStart = Utility._xmlUtil.GetFileTextValue(nodeName, Constants.FirstSequenceStartNode).Split(','); length = Utility._xmlUtil.GetFileTextValue(nodeName, Constants.LengthNode).Split(','); secondSeqOrder = Utility._xmlUtil.GetFileTextValue(nodeName, Constants.SecondSequenceMumOrderNode).Split(','); secondSeqStart = Utility._xmlUtil.GetFileTextValue(nodeName, Constants.SecondSequenceStartNode).Split(','); } else { 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(','); } 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, "NUCmer BVT : Unique match not matching at index '{0}'", i.ToString())); ApplicationLog.WriteLine(string.Format(null, "NUCmer BVT : Unique match not matching at index '{0}'", i.ToString())); return(false); } i++; } break; default: break; } return(true); }