/// <summary> /// Create a SequenceRangeGrouping by passing RangeID,Start and End Index. /// and validate created SequenceRange. /// </summary> /// <param name="nodeName">Xml Node name for different inputs.</param> static void CreateSequenceRangeGrouping(string nodeName) { // Get values from xml. string expectedRangeIDs = Utility._xmlUtil.GetTextValue( nodeName, Constants.IDNode); string expectedStartIndex = Utility._xmlUtil.GetTextValue( nodeName, Constants.StartNode); string expectedEndIndex = Utility._xmlUtil.GetTextValue( nodeName, Constants.EndNode); string expectedSequenceRangeCount = Utility._xmlUtil.GetTextValue( nodeName, Constants.SequenceRangeCountNode); string actualRangeStarts = string.Empty; string actualRangeEnds = string.Empty; string actualRangeIDs = string.Empty; string[] rangeIDs = expectedRangeIDs.Split(','); string[] rangeStarts = expectedStartIndex.Split(','); string[] rangeEnds = expectedEndIndex.Split(','); SequenceRangeGrouping seqRangeGrouping = new SequenceRangeGrouping(); List <ISequenceRange> rangeList = null; // Create a SequenceRange and add to SequenceRangeList. for (int i = 0; i < rangeIDs.Length; i++) { SequenceRange seqRange = new SequenceRange(rangeIDs[i], long.Parse(rangeStarts[i]), long.Parse(rangeEnds[i])); seqRangeGrouping.Add(seqRange); } IEnumerable <string> rangeGroupIds = seqRangeGrouping.GroupIDs; string rangeID = string.Empty; foreach (string groupID in rangeGroupIds) { rangeID = groupID; // Get SequenceRangeIds. rangeList = seqRangeGrouping.GetGroup(rangeID); // Validate created SequenceRanges. foreach (ISequenceRange seqRange in rangeList) { actualRangeIDs = string.Concat(actualRangeIDs, seqRange.ID.ToString(), ","); actualRangeStarts = string.Concat(actualRangeStarts, seqRange.Start.ToString(), ","); actualRangeEnds = string.Concat(actualRangeEnds, seqRange.End.ToString(), ","); } } Assert.AreEqual(expectedSequenceRangeCount, rangeList.Count.ToString()); Assert.AreEqual(expectedRangeIDs, actualRangeIDs.Substring(0, actualRangeIDs.Length - 1)); Assert.AreEqual(expectedStartIndex, actualRangeStarts.Substring(0, actualRangeStarts.Length - 1)); Assert.AreEqual(expectedEndIndex, actualRangeEnds.Substring(0, actualRangeEnds.Length - 1)); Console.WriteLine( "SequenceRange BVT : Successfully validated the SequenceStart, SequenceID and SequenceEnd."); }
public void ValidateFlatten() { // Get values from xml. string expectedRangeIDs = utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.IDNode); string expectedStartIndex = utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.StartNode); string expectedEndIndex = utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.EndNode); string expectedSequenceRangeCount = utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.SequenceRangeCountNode); string[] rangeIDs = expectedRangeIDs.Split(','); string[] rangeStarts = expectedStartIndex.Split(','); string[] rangeEnds = expectedEndIndex.Split(','); SequenceRangeGrouping seqRangeGrouping = new SequenceRangeGrouping(); List <ISequenceRange> rangeList = null; // Create a SequenceRange and add to SequenceRangeList. for (int i = 0; i < rangeIDs.Length; i++) { SequenceRange seqRange = new SequenceRange(rangeIDs[i], long.Parse(rangeStarts[i], (IFormatProvider)null), long.Parse(rangeEnds[i], (IFormatProvider)null)); seqRangeGrouping.Add(seqRange); } //Convert SequenceRangeGroup to SequenceRangeList. rangeList = seqRangeGrouping.Flatten(); int j = 0; // Validate created SequenceRanges. foreach (ISequenceRange seqRange in rangeList) { Assert.AreEqual(rangeStarts[j], seqRange.Start.ToString((IFormatProvider)null)); Assert.AreEqual(rangeEnds[j], seqRange.End.ToString((IFormatProvider)null)); Assert.AreEqual(rangeIDs[j], seqRange.ID.ToString((IFormatProvider)null)); j++; } Assert.AreEqual(expectedSequenceRangeCount, rangeList.Count.ToString((IFormatProvider)null)); Console.WriteLine( "SequenceRange BVT : Successfully validated the SequenceStart,SequenceID and SequenceEnd."); }
/// <summary> /// Formats the Range/RangeGroup for different test cases based /// on Additional parameter /// </summary> /// <param name="nodeName">Xml Node name</param> /// <param name="addParam">Additional parameter</param> private void FormatterGeneralTestCases(string nodeName, AdditionalParameters addParam) { IList <ISequenceRange> rangeList = new List <ISequenceRange>(); var rangeGroup = new SequenceRangeGrouping(); // Gets the file name. string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode).TestDir(); // Condition to check if Parse() happens before Format() switch (addParam) { case AdditionalParameters.ParseRangeGroup: var initialParserGroupObj = new BedParser(); rangeGroup = initialParserGroupObj.ParseRangeGrouping(filePath); break; case AdditionalParameters.ParseRange: var initialParserObj = new BedParser(); rangeList = initialParserObj.ParseRange(filePath); break; default: // Gets all the expected values from xml. string expectedID = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.IDNode); string expectedStart = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.StartNode); string expectedEnd = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.EndNode); string[] expectedIDs = expectedID.Split(','); string[] expectedStarts = expectedStart.Split(','); string[] expectedEnds = expectedEnd.Split(','); // Gets the Range Group or Range based on the additional parameter switch (addParam) { case AdditionalParameters.RangeGroupTextWriter: case AdditionalParameters.RangeGroupFileName: for (int i = 0; i < expectedIDs.Length; i++) { var rangeObj1 = new SequenceRange(expectedIDs[i], long.Parse(expectedStarts[i], null), long.Parse(expectedEnds[i], null)); rangeGroup.Add(rangeObj1); } break; default: for (int i = 0; i < expectedIDs.Length; i++) { var rangeObj2 = new SequenceRange(expectedIDs[i], long.Parse(expectedStarts[i], null), long.Parse(expectedEnds[i], null)); rangeList.Add(rangeObj2); } break; } break; } var formatterObj = new BedFormatter(); // Gets the Range list/Range Group based on the parameters. switch (addParam) { case AdditionalParameters.RangeFileName: case AdditionalParameters.ParseRange: formatterObj.Format(rangeList, Constants.BedTempFileName); break; case AdditionalParameters.RangeTextWriter: using (var txtWriter = File.Create(Constants.BedTempFileName)) { formatterObj.Format(txtWriter, rangeList); } break; case AdditionalParameters.RangeGroupFileName: case AdditionalParameters.ParseRangeGroup: formatterObj.Format(rangeGroup, Constants.BedTempFileName); break; case AdditionalParameters.RangeGroupTextWriter: using (var txtWriter = File.Create(Constants.BedTempFileName)) { formatterObj.Format(txtWriter, rangeGroup); } break; default: break; } // Reparse to validate the results var parserObj = new BedParser(); IList <ISequenceRange> newRangeList = parserObj.ParseRange(Constants.BedTempFileName); // Validation of all the properties. for (int i = 0; i < rangeList.Count; i++) { Assert.AreEqual(rangeList[i].ID, newRangeList[i].ID); Assert.AreEqual(rangeList[i].Start, newRangeList[i].Start); Assert.AreEqual(rangeList[i].End, newRangeList[i].End); // Validation of all metadata information. if (rangeList[i].Metadata.Count > 0) { if (rangeList[i].Metadata.ContainsKey("Name")) { Assert.AreEqual(rangeList[i].Metadata["Name"], newRangeList[i].Metadata["Name"]); } if (rangeList[i].Metadata.ContainsKey("Score")) { Assert.AreEqual(rangeList[i].Metadata["Score"], newRangeList[i].Metadata["Score"]); } if (rangeList[i].Metadata.ContainsKey("Strand")) { Assert.AreEqual(rangeList[i].Metadata["Strand"], newRangeList[i].Metadata["Strand"]); } if (rangeList[i].Metadata.ContainsKey("ThickStart")) { Assert.AreEqual(rangeList[i].Metadata["ThickStart"], newRangeList[i].Metadata["ThickStart"]); } if (rangeList[i].Metadata.ContainsKey("ThickEnd")) { Assert.AreEqual(rangeList[i].Metadata["ThickEnd"], newRangeList[i].Metadata["ThickEnd"]); } if (rangeList[i].Metadata.ContainsKey("ItemRGB")) { Assert.AreEqual(rangeList[i].Metadata["ItemRGB"], newRangeList[i].Metadata["ItemRGB"]); } if (rangeList[i].Metadata.ContainsKey("BlockCount")) { Assert.AreEqual(rangeList[i].Metadata["BlockCount"], newRangeList[i].Metadata["BlockCount"]); } if (rangeList[i].Metadata.ContainsKey("BlockSizes")) { Assert.AreEqual(rangeList[i].Metadata["BlockSizes"], newRangeList[i].Metadata["BlockSizes"]); } if (rangeList[i].Metadata.ContainsKey("BlockStarts")) { Assert.AreEqual(rangeList[i].Metadata["BlockStarts"], newRangeList[i].Metadata["BlockStarts"]); } ApplicationLog.WriteLine( "Bed Formatter BVT: Successfully validated all the metadata information"); } } ApplicationLog.WriteLine( "Bed Formatter BVT: Successfully validated the ID, Start and End Ranges"); // Cleanup the file. if (File.Exists(Constants.BedTempFileName)) { File.Delete(Constants.BedTempFileName); } }
/// <summary> /// Formats the Range/RangeGroup for different test cases based /// on Additional parameter /// </summary> /// <param name="nodeName">Xml Node name</param> /// <param name="addParam">Additional parameter</param> void FormatterGeneralTestCases(string nodeName, AdditionalParameters addParam) { IList <ISequenceRange> rangeList = new List <ISequenceRange>(); SequenceRangeGrouping rangeGroup = new SequenceRangeGrouping(); // Gets the file name. string filePath = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); // Condition to check if Parse() happens before Format() switch (addParam) { case AdditionalParameters.ParseRangeGroup: case AdditionalParameters.ParseRangeGroupTextWriter: BedParser initialParserGroupObj = new BedParser(); rangeGroup = initialParserGroupObj.ParseRangeGrouping(filePath); break; case AdditionalParameters.ParseRange: case AdditionalParameters.ParseRangeTextWriter: BedParser initialParserObj = new BedParser(); rangeList = initialParserObj.ParseRange(filePath); break; default: // Gets all the expected values from xml. string expectedID = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.IDNode); string expectedStart = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.StartNode); string expectedEnd = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.EndNode); string[] expectedIDs = expectedID.Split(','); string[] expectedStarts = expectedStart.Split(','); string[] expectedEnds = expectedEnd.Split(','); // Gets the Range Group or Range based on the additional parameter switch (addParam) { case AdditionalParameters.RangeGroupTextWriter: case AdditionalParameters.RangeGroupFileName: for (int i = 0; i < expectedIDs.Length; i++) { SequenceRange rangeObj1 = new SequenceRange(expectedIDs[i], long.Parse(expectedStarts[i], (IFormatProvider)null), long.Parse(expectedEnds[i], (IFormatProvider)null)); rangeGroup.Add(rangeObj1); } break; default: for (int i = 0; i < expectedIDs.Length; i++) { SequenceRange rangeObj2 = new SequenceRange(expectedIDs[i], long.Parse(expectedStarts[i], (IFormatProvider)null), long.Parse(expectedEnds[i], (IFormatProvider)null)); rangeList.Add(rangeObj2); } break; } break; } BedFormatter formatterObj = new BedFormatter(); // Gets the Range list/Range Group based on the parameters. switch (addParam) { case AdditionalParameters.RangeFileName: case AdditionalParameters.ParseRange: formatterObj.Format(rangeList, Constants.BedTempFileName); break; case AdditionalParameters.RangeTextWriter: case AdditionalParameters.ParseRangeTextWriter: using (TextWriter txtWriter = new StreamWriter(Constants.BedTempFileName)) { formatterObj.Format(rangeList, txtWriter); } break; case AdditionalParameters.RangeGroupFileName: case AdditionalParameters.ParseRangeGroup: formatterObj.Format(rangeGroup, Constants.BedTempFileName); break; case AdditionalParameters.RangeGroupTextWriter: case AdditionalParameters.ParseRangeGroupTextWriter: using (TextWriter txtWriter = new StreamWriter(Constants.BedTempFileName)) { formatterObj.Format(rangeGroup, txtWriter); } break; default: break; } // Reparse to validate the results BedParser parserObj = new BedParser(); IList <ISequenceRange> newRangeList = parserObj.ParseRange(Constants.BedTempFileName); // Validation of all the properties. for (int i = 0; i < rangeList.Count; i++) { Assert.AreEqual(rangeList[0].ID, newRangeList[0].ID); Assert.AreEqual(rangeList[0].Start, newRangeList[0].Start); Assert.AreEqual(rangeList[0].End, newRangeList[0].End); } ApplicationLog.WriteLine( "Bed Formatter P1: Successfully validated the ID, Start and End Ranges"); Console.WriteLine( "Bed Formatter P1: Successfully validated the ID, Start and End Ranges"); // Cleanup the file. if (File.Exists(Constants.BedTempFileName)) { File.Delete(Constants.BedTempFileName); } }
/// <summary> /// Formats the Range/RangeGroup for different test cases based /// on Additional parameter /// </summary> /// <param name="nodeName">Xml Node name</param> /// <param name="addParam">Additional parameter</param> private void FormatterGeneralTestCases(string nodeName, AdditionalParameters addParam) { IList<ISequenceRange> rangeList = new List<ISequenceRange>(); var rangeGroup = new SequenceRangeGrouping(); // Gets the file name. string filePath = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); // Condition to check if Parse() happens before Format() switch (addParam) { case AdditionalParameters.ParseRangeGroup: case AdditionalParameters.ParseRangeGroupTextWriter: var initialParserGroupObj = new BedParser(); rangeGroup = initialParserGroupObj.ParseRangeGrouping(filePath); break; case AdditionalParameters.ParseRange: case AdditionalParameters.ParseRangeTextWriter: var initialParserObj = new BedParser(); rangeList = initialParserObj.ParseRange(filePath); break; default: // Gets all the expected values from xml. string expectedID = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.IDNode); string expectedStart = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.StartNode); string expectedEnd = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.EndNode); string[] expectedIDs = expectedID.Split(','); string[] expectedStarts = expectedStart.Split(','); string[] expectedEnds = expectedEnd.Split(','); // Gets the Range Group or Range based on the additional parameter switch (addParam) { case AdditionalParameters.RangeGroupTextWriter: case AdditionalParameters.RangeGroupFileName: for (int i = 0; i < expectedIDs.Length; i++) { var rangeObj1 = new SequenceRange(expectedIDs[i], long.Parse(expectedStarts[i], null), long.Parse(expectedEnds[i], null)); rangeGroup.Add(rangeObj1); } break; default: for (int i = 0; i < expectedIDs.Length; i++) { var rangeObj2 = new SequenceRange(expectedIDs[i], long.Parse(expectedStarts[i], null), long.Parse(expectedEnds[i], null)); rangeList.Add(rangeObj2); } break; } break; } var formatterObj = new BedFormatter(); // Gets the Range list/Range Group based on the parameters. switch (addParam) { case AdditionalParameters.RangeFileName: case AdditionalParameters.ParseRange: formatterObj.Format(rangeList, Constants.BedTempFileName); break; case AdditionalParameters.RangeTextWriter: case AdditionalParameters.ParseRangeTextWriter: using (var txtWriter = File.Create(Constants.BedTempFileName)) { formatterObj.Format(txtWriter, rangeList); } break; case AdditionalParameters.RangeGroupFileName: case AdditionalParameters.ParseRangeGroup: formatterObj.Format(rangeGroup, Constants.BedTempFileName); break; case AdditionalParameters.RangeGroupTextWriter: case AdditionalParameters.ParseRangeGroupTextWriter: using (var txtWriter = File.Create(Constants.BedTempFileName)) { formatterObj.Format(txtWriter, rangeGroup); } break; default: break; } // Reparse to validate the results var parserObj = new BedParser(); IList<ISequenceRange> newRangeList = parserObj.ParseRange(Constants.BedTempFileName); // Validation of all the properties. for (int i = 0; i < rangeList.Count; i++) { Assert.AreEqual(rangeList[0].ID, newRangeList[0].ID); Assert.AreEqual(rangeList[0].Start, newRangeList[0].Start); Assert.AreEqual(rangeList[0].End, newRangeList[0].End); } ApplicationLog.WriteLine( "Bed Formatter P1: Successfully validated the ID, Start and End Ranges"); // Cleanup the file. if (File.Exists(Constants.BedTempFileName)) File.Delete(Constants.BedTempFileName); }
/// <summary> /// Create a SequenceRangeGrouping by passing RangeID,Start and End Index. /// and validate created SequenceRange. /// </summary> /// <param name="nodeName">Xml Node name for different inputs.</param> private void CreateSequenceRangeGrouping(string nodeName) { // Get values from xml. string expectedRangeIDs = this.utilityObj.xmlUtil.GetTextValue( nodeName, Constants.IDNode); string expectedStartIndex = this.utilityObj.xmlUtil.GetTextValue( nodeName, Constants.StartNode); string expectedEndIndex = this.utilityObj.xmlUtil.GetTextValue( nodeName, Constants.EndNode); string expectedSequenceRangeCount = this.utilityObj.xmlUtil.GetTextValue( nodeName, Constants.SequenceRangeCountNode); string[] rangeIDs = expectedRangeIDs.Split(','); string[] rangeStarts = expectedStartIndex.Split(','); string[] rangeEnds = expectedEndIndex.Split(','); var seqRangeGrouping = new SequenceRangeGrouping(); List<ISequenceRange> rangeList = null; // Create a SequenceRange and add to SequenceRangeList. for (int i = 0; i < rangeIDs.Length; i++) { var seqRange = new SequenceRange(rangeIDs[i], long.Parse(rangeStarts[i], null), long.Parse(rangeEnds[i], null)); seqRangeGrouping.Add(seqRange); } IEnumerable<string> rangeGroupIds = seqRangeGrouping.GroupIDs; string rangeID = string.Empty; int j = 0; foreach (string groupID in rangeGroupIds) { rangeID = groupID; // Get SequenceRangeIds. rangeList = seqRangeGrouping.GetGroup(rangeID); // Validate created SequenceRanges. foreach (ISequenceRange seqRange in rangeList) { Assert.AreEqual(rangeStarts[j], seqRange.Start.ToString((IFormatProvider) null)); Assert.AreEqual(rangeEnds[j], seqRange.End.ToString((IFormatProvider) null)); Assert.AreEqual(rangeIDs[j], seqRange.ID.ToString(null)); j++; } } Assert.AreEqual(expectedSequenceRangeCount, rangeList.Count.ToString((IFormatProvider) null)); ApplicationLog.WriteLine( "SequenceRange BVT : Successfully validated the SequenceStart, SequenceID and SequenceEnd."); }
public void ValidateFlatten() { // Get values from xml. string expectedRangeIDs = this.utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.IDNode); string expectedStartIndex = this.utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.StartNode); string expectedEndIndex = this.utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.EndNode); string expectedSequenceRangeCount = this.utilityObj.xmlUtil.GetTextValue( Constants.SmallSizeBedNodeName, Constants.SequenceRangeCountNode); string[] rangeIDs = expectedRangeIDs.Split(','); string[] rangeStarts = expectedStartIndex.Split(','); string[] rangeEnds = expectedEndIndex.Split(','); var seqRangeGrouping = new SequenceRangeGrouping(); List<ISequenceRange> rangeList = null; // Create a SequenceRange and add to SequenceRangeList. for (int i = 0; i < rangeIDs.Length; i++) { var seqRange = new SequenceRange(rangeIDs[i], long.Parse(rangeStarts[i], null), long.Parse(rangeEnds[i], null)); seqRangeGrouping.Add(seqRange); } //Convert SequenceRangeGroup to SequenceRangeList. rangeList = seqRangeGrouping.Flatten(); int j = 0; // Validate created SequenceRanges. foreach (ISequenceRange seqRange in rangeList) { Assert.AreEqual(rangeStarts[j], seqRange.Start.ToString((IFormatProvider) null)); Assert.AreEqual(rangeEnds[j], seqRange.End.ToString((IFormatProvider) null)); Assert.AreEqual(rangeIDs[j], seqRange.ID.ToString(null)); j++; } Assert.AreEqual(expectedSequenceRangeCount, rangeList.Count.ToString((IFormatProvider) null)); ApplicationLog.WriteLine("SequenceRange BVT : Successfully validated the SequenceStart,SequenceID and SequenceEnd."); }