// Test wiggle variable step private static WiggleAnnotation TestParserVariableStep(string filename) { WiggleParser p = new WiggleParser(); WiggleAnnotation an = p.Parse(filename).First(); Assert.IsTrue(an.Chromosome == "chr19"); Assert.IsTrue(an.Step == 0); Assert.IsTrue(an.BasePosition == 0); Assert.IsTrue(an.Span == 150); Assert.IsTrue(an.Metadata["type"] == "wiggle_0"); Assert.IsTrue(an.Metadata["name"] == "ArrayExpt1"); Assert.IsTrue(an.Metadata["description"] == "20 degrees, 2 hr"); var x = an.GetEnumerator(); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59304701); Assert.IsTrue(x.Current.Value == 10.0); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59304901); Assert.IsTrue(x.Current.Value == 12.5); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59305401); Assert.IsTrue(x.Current.Value == 15.0); x.MoveNext(); x.MoveNext(); x.MoveNext(); x.MoveNext(); x.MoveNext(); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59307871); Assert.IsTrue(x.Current.Value == 10.0); return(an); }
// Test wiggle fixed step private static WiggleAnnotation TestParserFixedStep(string filename) { WiggleParser p = new WiggleParser(); WiggleAnnotation an = p.Parse(filename).First(); Assert.IsTrue(an.Chromosome == "chr19"); Assert.IsTrue(an.BasePosition == 59307401); Assert.IsTrue(an.Step == 300); Assert.IsTrue(an.Span == 200); Assert.IsTrue(an.Metadata["type"] == "wiggle_0"); Assert.IsTrue(an.Metadata["name"] == "ArrayExpt1"); Assert.IsTrue(an.Metadata["description"] == "20 degrees, 2 hr"); float[] values = an.GetValueArray(0, 3); Assert.IsTrue(values[0] == 1000); Assert.IsTrue(values[1] == 900); Assert.IsTrue(values[2] == 800); values = an.GetValueArray(7, 3); Assert.IsTrue(values[0] == 300); Assert.IsTrue(values[1] == 200); Assert.IsTrue(values[2] == 100); return(an); }
public void ValidateWiggleParserPublicProperties() { // Gets the filepath from the Xml string filePath = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.FilePathNode); Assert.IsTrue(File.Exists(filePath)); // Logs information to the log file ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Wiggle Parser BVT: File Exists in the Path '{0}'.", filePath)); //Get the expected values from configuration file. string expectedDescription = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.ParserDescriptionNode); string expectedName = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.NameNode); string expectedFileType = this.utilityObj.xmlUtil.GetTextValue(Constants. SimpleWiggleWithFixedStepNodeName, Constants.FileTypesNode); WiggleParser parser = new WiggleParser(); //Parse the file var annotation = parser.Parse(filePath); Assert.IsNotNull(annotation); Assert.AreEqual(expectedDescription, parser.Description); Assert.AreEqual(expectedName, parser.Name); Assert.AreEqual(expectedFileType, parser.SupportedFileTypes); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "Wiggle Parser BVT: Validation of all public properties is successful")); }
public void TestWiggleFormatter() { string filepathTmp = Path.GetTempFileName(); using (WiggleFormatter formatter = new WiggleFormatter(filepathTmp)) { formatter.Write(CreateDummyAnnotation()); } WiggleParser parser = new WiggleParser(); VerifyDummyAnnotation(parser.Parse(filepathTmp)); }
public void TestWiggleFormatter() { string filepathTmp = Path.GetTempFileName(); WiggleFormatter formatter = new WiggleFormatter(); using (formatter.Open(filepathTmp)) { formatter.Format(CreateDummyAnnotation()); } WiggleParser parser = new WiggleParser(); VerifyDummyAnnotation(parser.Parse(filepathTmp).First()); }
// Test wiggle variable step private static WiggleAnnotation TestParserVariableStep(string filename) { WiggleParser p = new WiggleParser(); WiggleAnnotation an = p.Parse(filename).First(); Assert.IsTrue(an.Chromosome == "chr19"); Assert.IsTrue(an.Step == 0); Assert.IsTrue(an.BasePosition == 0); Assert.IsTrue(an.Span == 150); Assert.IsTrue(an.Metadata["type"] == "wiggle_0"); Assert.IsTrue(an.Metadata["name"] == "ArrayExpt1"); Assert.IsTrue(an.Metadata["description"] == "20 degrees, 2 hr"); var x = an.GetEnumerator(); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59304701); Assert.IsTrue(x.Current.Value == 10.0); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59304901); Assert.IsTrue(x.Current.Value == 12.5); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59305401); Assert.IsTrue(x.Current.Value == 15.0); x.MoveNext(); x.MoveNext(); x.MoveNext(); x.MoveNext(); x.MoveNext(); x.MoveNext(); Assert.IsTrue(x.Current.Key == 59307871); Assert.IsTrue(x.Current.Value == 10.0); return an; }
// Test wiggle fixed step private static WiggleAnnotation TestParserFixedStep(string filename) { WiggleParser p = new WiggleParser(); WiggleAnnotation an = p.Parse(filename).First(); Assert.IsTrue(an.Chromosome == "chr19"); Assert.IsTrue(an.BasePosition == 59307401); Assert.IsTrue(an.Step == 300); Assert.IsTrue(an.Span == 200); Assert.IsTrue(an.Metadata["type"] == "wiggle_0"); Assert.IsTrue(an.Metadata["name"] == "ArrayExpt1"); Assert.IsTrue(an.Metadata["description"] == "20 degrees, 2 hr"); float[] values = an.GetValueArray(0, 3); Assert.IsTrue(values[0] == 1000); Assert.IsTrue(values[1] == 900); Assert.IsTrue(values[2] == 800); values = an.GetValueArray(7, 3); Assert.IsTrue(values[0] == 300); Assert.IsTrue(values[1] == 200); Assert.IsTrue(values[2] == 100); return an; }
/// <summary> /// Validate Exceptions from Wiggle Parser with invalid metadata. /// </summary> /// <param name="nodeName">Node containing the invalid file name.</param> public void ValidateFormatException(string nodeName) { // Gets the filepath. String filePath = this.utilityObj.xmlUtil.GetTextValue(Constants. InValidFileNamesNode, nodeName); Assert.IsTrue(File.Exists(filePath)); WiggleParser parser=new WiggleParser(); try { parser.Parse(filePath); } catch (FormatException exception) { ApplicationLog.WriteLine( "Wiggle P2 test cases : Successfully validated Format exception:", exception.Message); } }