public void ClustalWParse() { string filepath = @"testdata\ClustalW\AlignmentData.aln"; Assert.IsTrue(File.Exists(filepath)); IList <Dictionary <string, string> > expectedOutput = new List <Dictionary <string, string> >(); Dictionary <string, string> expectedAlignment = new Dictionary <string, string>(); expectedAlignment["CYS1_DICDI"] = "-----MKVILLFVLAVFTVFVSS---------------RGIPPEEQ------------SQ" + "FLEFQDKFNKKY-SHEEYLERFEIFKSNLGKIEELNLIAINHKADTKFGVNKFADLSSDE" + "FKNYYLNNKEAIFTDDLPVADYLDDEFINSIPTAFDWRTRG-AVTPVKNQGQCGSCWSFS" + "TTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGEEACDEGCNGGLQPNAYNYIIKNG" + "GIQTESSYPYTAETGTQCNFNSANIGAKISNFTMIP-KNETVMAGYIVSTGPLAIAADAV" + "E-WQFYIGGVF-DIPCN--PNSLDHGILIVGYSAKNTIFRKNMPYWIVKNSWGADWGEQG" + "YIYLRRGKNTCGVSNFVSTSII--"; expectedAlignment["ALEU_HORVU"] = "MAHARVLLLALAVLATAAVAVASSSSFADSNPIRPVTDRAASTLESAVLGALGRTRHALR" + "FARFAVRYGKSYESAAEVRRRFRIFSESLEEVRSTN----RKGLPYRLGINRFSDMSWEE" + "FQATRL-GAAQTCSATLAGNHLMRDA--AALPETKDWREDG-IVSPVKNQAHCGSCWTFS" + "TTGALEAAYTQATGKNISLSEQQLVDCAGGFNNF--------GCNGGLPSQAFEYIKYNG" + "GIDTEESYPYKGVNGV-CHYKAENAAVQVLDSVNITLNAEDELKNAVGLVRPVSVAFQVI" + "DGFRQYKSGVYTSDHCGTTPDDVNHAVLAVGYGVENGV-----PYWLIKNSWGADWGDNG" + "YFKMEMGKNMCAIATCASYPVVAA"; expectedAlignment["CATH_HUMAN"] = "------MWATLPLLCAGAWLLGV--------PVCGAAELSVNSLEK------------FH" + "FKSWMSKHRKTY-STEEYHHRLQTFASNWRKINAHN----NGNHTFKMALNQFSDMSFAE" + "IKHKYLWSEPQNCSAT--KSNYLRGT--GPYPPSVDWRKKGNFVSPVKNQGACGSCWTFS" + "TTGALESAIAIATGKMLSLAEQQLVDCAQDFNNY--------GCQGGLPSQAFEYILYNK" + "GIMGEDTYPYQGKDGY-CKFQPGKAIGFVKDVANITIYDEEAMVEAVALYNPVSFAFEVT" + "QDFMMYRTGIYSSTSCHKTPDKVNHAVLAVGYGEKNGI-----PYWIVKNSWGPQWGMNG" + "YFLIERGKNMCGLAACASYPIPLV"; expectedOutput.Add(expectedAlignment); IList <ISequenceAlignment> actualOutput = null; ISequenceAlignmentParser parser = new ClustalWParser(); using (StreamReader reader = File.OpenText(filepath)) { actualOutput = parser.Parse(reader); } CompareOutput(actualOutput, expectedOutput); }
/// <summary> /// Parsers the ClustalW file for different test cases based /// on Additional parameter /// </summary> /// <param name="nodeName">Xml Node name</param> /// <param name="addParam">Additional parameter</param> private void ParserGeneralTestCases(string nodeName, AdditionalParameters addParam) { // Gets the Filename string filePath = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); Assert.IsFalse(string.IsNullOrEmpty(filePath)); ApplicationLog.WriteLine(string.Format(null, "ClustalW Parser BVT: Reading the File from location '{0}'", filePath)); // Get the rangelist after parsing. var parserObj = new ClustalWParser(); IList <ISequenceAlignment> sequenceAlignmentList = null; ISequenceAlignment sequenceAlignment = null; // Gets the SequenceAlignment list based on the parameters. switch (addParam) { case AdditionalParameters.Parse: sequenceAlignmentList = parserObj.Parse(filePath); break; case AdditionalParameters.ParseOne: sequenceAlignment = parserObj.ParseOne(filePath); break; case AdditionalParameters.ParseTextReader: using (var strRdrObj = new StreamReader(filePath)) { sequenceAlignmentList = parserObj.Parse(strRdrObj); } break; case AdditionalParameters.ParseOneTextReader: using (var strRdrObj = new StreamReader(filePath)) { sequenceAlignment = parserObj.ParseOne(strRdrObj); } break; default: break; } // Gets all the expected values from xml. IList <Dictionary <string, string> > expectedAlignmentList = new List <Dictionary <string, string> >(); var expectedAlignmentObj = new Dictionary <string, string>(); XElement expectedAlignmentNodes = utilityObj.xmlUtil.GetNode( nodeName, Constants.ExpectedAlignmentNode); IEnumerable <XNode> nodes = expectedAlignmentNodes.Nodes(); //Get all the values from the elements in the node. foreach (XElement node in nodes) { expectedAlignmentObj[node.Name.ToString()] = node.Value; } //Create a ISequenceAlignment List switch (addParam) { case AdditionalParameters.ParseOne: case AdditionalParameters.ParseOneTextReader: sequenceAlignmentList = new List <ISequenceAlignment>(); sequenceAlignmentList.Add(sequenceAlignment); break; default: break; } expectedAlignmentList.Add(expectedAlignmentObj); Assert.IsTrue(CompareOutput(sequenceAlignmentList, expectedAlignmentList)); ApplicationLog.WriteLine( "ClustalW Parser BVT: Successfully validated all the Alignment Sequences"); }
/// <summary> /// Parsers the ClustalW file for different test cases based /// on Additional parameter /// </summary> /// <param name="nodeName">Xml Node name</param> /// <param name="addParam">Additional parameter</param> void ParserGeneralTestCases(string nodeName, AdditionalParameters addParam) { // Gets the Filename string filePath = _utilityObj._xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); Assert.IsFalse(string.IsNullOrEmpty(filePath)); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "ClustalW Parser BVT: Reading the File from location '{0}'", filePath)); Console.WriteLine(string.Format((IFormatProvider)null, "ClustalW Parser BVT: Reading the File from location '{0}'", filePath)); // Get the rangelist after parsing. ClustalWParser parserObj = new ClustalWParser(); IList <ISequenceAlignment> sequenceAlignmentList = null; ISequenceAlignment sequenceAlignment = null; // Gets the SequenceAlignment list based on the parameters. switch (addParam) { case AdditionalParameters.Parse: sequenceAlignmentList = parserObj.Parse(filePath); break; case AdditionalParameters.ParseOne: sequenceAlignment = parserObj.ParseOne(filePath); break; case AdditionalParameters.ParseTextReader: using (StreamReader strRdrObj = new StreamReader(filePath)) { sequenceAlignmentList = parserObj.Parse(strRdrObj); } break; case AdditionalParameters.ParseOneTextReader: using (StreamReader strRdrObj = new StreamReader(filePath)) { sequenceAlignment = parserObj.ParseOne(strRdrObj); } break; case AdditionalParameters.ParseOneTextReaderReadOnly: using (StreamReader strRdrObj = new StreamReader(filePath)) { sequenceAlignment = parserObj.ParseOne(strRdrObj, false); } break; case AdditionalParameters.ParseTextReaderReadOnly: using (StreamReader strRdrObj = new StreamReader(filePath)) { sequenceAlignmentList = parserObj.Parse(strRdrObj, false); } break; case AdditionalParameters.ParseReadOnly: sequenceAlignmentList = parserObj.Parse(filePath, false); break; case AdditionalParameters.ParseOneReadOnly: sequenceAlignment = parserObj.ParseOne(filePath, false); break; default: break; } // Gets all the expected values from xml. IList <Dictionary <string, string> > expectedAlignmentList = new List <Dictionary <string, string> >(); Dictionary <string, string> expectedAlignmentObj = new Dictionary <string, string>(); XmlNode expectedAlignmentNodes = _utilityObj._xmlUtil.GetNode( nodeName, Constants.ExpectedAlignmentNode); XmlNodeList alignNodes = expectedAlignmentNodes.ChildNodes; // Create a ISequenceAlignment List switch (addParam) { case AdditionalParameters.ParseOne: case AdditionalParameters.ParseOneTextReader: case AdditionalParameters.ParseOneTextReaderReadOnly: case AdditionalParameters.ParseOneReadOnly: sequenceAlignmentList = new List <ISequenceAlignment>(); sequenceAlignmentList.Add(sequenceAlignment); break; default: break; } foreach (XmlNode expectedAlignment in alignNodes) { expectedAlignmentObj[expectedAlignment.Name] = expectedAlignment.InnerText; } expectedAlignmentList.Add(expectedAlignmentObj); Assert.IsTrue(CompareOutput(sequenceAlignmentList, expectedAlignmentList)); ApplicationLog.WriteLine( "ClustalW Parser BVT: Successfully validated all the Alignment Sequences"); Console.WriteLine( "ClustalW Parser BVT: Successfully validated all the Alignment Sequences"); }