public void ClustalWParserValidatePublicProperties() { string description = utilityObj.xmlUtil.GetTextValue( Constants.ClustalWDescriptionsNode, Constants.DescriptionNode); string name = utilityObj.xmlUtil.GetTextValue( Constants.ClustalWDescriptionsNode, Constants.NameNode); string supportedFileTypes = utilityObj.xmlUtil.GetTextValue( Constants.ClustalWDescriptionsNode, Constants.SupportedFileTypesNode); // Get the rangelist after parsing. var parserObj = new ClustalWParser(); //Validate Description for ClustalW Parser. Assert.AreEqual(description, parserObj.Description); ApplicationLog.WriteLine(string.Format(null, "ClustalW Parser BVT: Successfully validated description")); //Validate Name for Clustal W parser. Assert.AreEqual(name, parserObj.Name); ApplicationLog.WriteLine(string.Format(null, "ClustalW Parser BVT: Successfully validated Name")); //Validate supported file types for Clustal W parser. Assert.AreEqual(supportedFileTypes, parserObj.SupportedFileTypes); ApplicationLog.WriteLine(string.Format(null, "ClustalW Parser BVT: Successfully validated Supported File types.")); }
/// <summary> /// Validate Submit Job and Fetch ResultSync() using multiple input sequences /// </summary> /// <param name="nodeName">xml node name</param> void ValidateFetchResultSync(string nodeName) { // Read input from config file string filepath = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); string emailId = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.EmailIDNode); string clusterOption = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.ClusterOptionNode); string actionAlign = utilityObj.xmlUtil.GetTextValue( nodeName, Constants.ActionAlignNode); // Initialize with parser and config params ConfigParameters configparams = new ConfigParameters(); ClustalWParser clustalparser = new ClustalWParser(); configparams.UseBrowserProxy = true; TestIClustalWServiceHandler handler = new TestIClustalWServiceHandler(clustalparser, configparams); ClustalWParameters parameters = new ClustalWParameters(); parameters.Values[ClustalWParameters.Email] = emailId; parameters.Values[ClustalWParameters.ClusterOption] = clusterOption; parameters.Values[ClustalWParameters.ActionAlign] = actionAlign; IEnumerable <ISequence> sequence = null; // Get the input sequences using (FastAParser parser = new FastAParser(filepath)) { sequence = parser.Parse(); // Submit job and validate it returned valid job id and control id ServiceParameters svcparameters = handler.SubmitRequest(sequence.ToList(), parameters); Assert.IsFalse(string.IsNullOrEmpty(svcparameters.JobId)); ApplicationLog.WriteLine(string.Concat("JobId", svcparameters.JobId)); foreach (string key in svcparameters.Parameters.Keys) { Assert.IsFalse(string.IsNullOrEmpty(svcparameters.Parameters[key].ToString())); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "{0}:{1}", key, svcparameters.Parameters[key].ToString())); } // Get the results and validate it is not null. ClustalWResult result = handler.FetchResultsSync(svcparameters); Assert.IsNotNull(result); Assert.IsNotNull(result.SequenceAlignment); foreach (IAlignedSequence alignSeq in result.SequenceAlignment.AlignedSequences) { ApplicationLog.WriteLine("Aligned Sequence Sequences :"); foreach (ISequence seq in alignSeq.Sequences) { ApplicationLog.WriteLine(string.Concat("Sequence:", seq.ToString())); } } } ApplicationLog.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is successfully completed using FetchResultSync()"); }
/// <summary> /// Validate if the connection is successful /// </summary> /// <returns>True, if connection is successful</returns> static bool ValidateWebServiceConnection() { // Read input from config file string filepath = Utility._xmlUtil.GetTextValue( Constants.DefaultOptionNode, Constants.FilePathNode); string emailId = Utility._xmlUtil.GetTextValue( Constants.DefaultOptionNode, Constants.EmailIDNode); string clusterOption = Utility._xmlUtil.GetTextValue( Constants.DefaultOptionNode, Constants.ClusterOptionNode); string actionAlign = Utility._xmlUtil.GetTextValue( Constants.DefaultOptionNode, Constants.ActionAlignNode); // Initialize with parser and config params ConfigParameters configparams = new ConfigParameters(); ClustalWParser clustalparser = new ClustalWParser(); configparams.UseBrowserProxy = true; TestIClustalWServiceHandler handler = new TestIClustalWServiceHandler(clustalparser, configparams); ClustalWParameters parameters = new ClustalWParameters(); parameters.Values[ClustalWParameters.Email] = emailId; parameters.Values[ClustalWParameters.ClusterOption] = clusterOption; parameters.Values[ClustalWParameters.ActionAlign] = actionAlign; // Get the input sequences FastaParser parser = new FastaParser(); IList <ISequence> sequence = parser.Parse(filepath); try { // Submit job and validate it returned valid job id and control id ServiceParameters svcparameters = handler.SubmitRequest(sequence, parameters); if (string.IsNullOrEmpty(svcparameters.JobId)) { Console.WriteLine( "ClustalW BVT : Connection not successful with no Job ID"); ApplicationLog.WriteLine( "ClustalW BVT : Connection not successful with no Job ID"); return(false); } handler.FetchResultsSync(svcparameters); } catch (Exception ex) { Console.WriteLine(string.Format( "ClustalW BVT : Connection not successful with error '{0}'", ex.Message)); ApplicationLog.WriteLine(string.Format( "ClustalW BVT : Connection not successful with error '{0}'", ex.Message)); return(false); } Console.WriteLine("ClustalW BVT : Connection Successful"); return(true); }
/// <summary> /// Validate the CancelRequest() /// </summary> /// <param name="nodeName">xml node name</param> void ValidateCancelRequest(string nodeName) { // Read input from config file string filepath = _utilityObj._xmlUtil.GetTextValue(nodeName, Constants.FilePathNode); string emailId = _utilityObj._xmlUtil.GetTextValue(nodeName, Constants.EmailIDNode); string clusterOption = _utilityObj._xmlUtil.GetTextValue(nodeName, Constants.ClusterOptionNode); string actionAlign = _utilityObj._xmlUtil.GetTextValue(nodeName, Constants.ActionAlignNode); ClustalWParameters parameters = new ClustalWParameters(); parameters.Values[ClustalWParameters.Email] = emailId; parameters.Values[ClustalWParameters.ClusterOption] = clusterOption; parameters.Values[ClustalWParameters.ActionAlign] = actionAlign; IList <ISequence> sequence = null; // Get the input sequences using (FastaParser parser = new FastaParser()) { sequence = parser.Parse(filepath); } // Submit job and cancel job // Validate cancel job is working as expected ConfigParameters configparams = new ConfigParameters(); ClustalWParser clustalparser = new ClustalWParser(); configparams.UseBrowserProxy = true; TestIClustalWServiceHandler handler = new TestIClustalWServiceHandler(clustalparser, configparams); ServiceParameters svcparams = handler.SubmitRequest(sequence, parameters); bool result = handler.CancelRequest(svcparams); Assert.IsTrue(result); Console.WriteLine(string.Concat("JobId:", svcparams.JobId)); ApplicationLog.WriteLine(string.Concat("JobId:", svcparams.JobId)); Assert.IsTrue(string.IsNullOrEmpty(svcparams.JobId)); foreach (string key in svcparams.Parameters.Keys) { Assert.IsTrue(string.IsNullOrEmpty(svcparams.Parameters[key].ToString())); Console.WriteLine(string.Format((IFormatProvider)null, "{0} : {1}", key, svcparams.Parameters[key].ToString())); ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "{0} : {1}", key, svcparams.Parameters[key].ToString())); } Console.WriteLine( "ClustalWServiceHandler BVT : Cancel job is submitted as expected"); ApplicationLog.WriteLine( "ClustalWServiceHandler BVT : Cancel job is submitted as expected"); }
/// <summary> /// Validate submit job and Get Results using event handler /// </summary> /// <param name="nodeName">xml node name</param> void ValidateFetchResultsUsingEvent(string nodeName) { // Read input from config file string filepath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode); string emailId = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.EmailIDNode); string clusterOption = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ClusterOptionNode); string actionAlign = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ActionAlignNode); ClustalWParameters parameters = new ClustalWParameters(); parameters.Values[ClustalWParameters.Email] = emailId; parameters.Values[ClustalWParameters.ClusterOption] = clusterOption; parameters.Values[ClustalWParameters.ActionAlign] = actionAlign; IEnumerable <ISequence> sequence = null; // Get the input sequences using (FastAParser parser = new FastAParser(filepath)) { sequence = parser.Parse(); // Register event and submit request ConfigParameters configparams = new ConfigParameters(); ClustalWParser clustalparser = new ClustalWParser(); configparams.UseBrowserProxy = true; TestIClustalWServiceHandler handler = new TestIClustalWServiceHandler(clustalparser, configparams); handler.RequestCompleted += new EventHandler <ClustalWCompletedEventArgs>(handler_RequestCompleted); ServiceParameters svcparams = handler.SubmitRequest(sequence.ToList(), parameters); WaitHandle[] aryHandler = new WaitHandle[1]; aryHandler[0] = _resetEvent; WaitHandle.WaitAny(aryHandler); // Validate the submit job results Assert.IsFalse(string.IsNullOrEmpty(svcparams.JobId)); Console.WriteLine("JobId:" + svcparams.JobId); foreach (string key in svcparams.Parameters.Keys) { Assert.IsFalse(string.IsNullOrEmpty(svcparams.Parameters[key].ToString())); Console.WriteLine(string.Format((IFormatProvider)null, "{0} : {1}", key, svcparams.Parameters[key].ToString())); } aryHandler = null; _resetEvent.Close(); _resetEvent.Dispose(); } }
public void ClustalWParseOne() { 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); List <ISequenceAlignment> actualOutput = new List <ISequenceAlignment>(); ISequenceAlignment actualAlignment = null; ISequenceAlignmentParser parser = new ClustalWParser(); using (StreamReader reader = File.OpenText(filepath)) { actualAlignment = parser.ParseOne(reader); } actualOutput.Add(actualAlignment); CompareOutput(actualOutput, expectedOutput); }
/// <summary> /// Validate submit job and FetchResultAsync() using multiple input sequences /// </summary> /// <param name="nodeName">xml node name</param> void ValidateFetchResultAsync(string nodeName) { // Read input from config file string filepath = _utilityObj._xmlUtil.GetTextValue( nodeName, Constants.FilePathNode); string emailId = _utilityObj._xmlUtil.GetTextValue( nodeName, Constants.EmailIDNode); string clusterOption = _utilityObj._xmlUtil.GetTextValue( nodeName, Constants.ClusterOptionNode); string actionAlign = _utilityObj._xmlUtil.GetTextValue( nodeName, Constants.ActionAlignNode); ConfigParameters configparams = new ConfigParameters(); ClustalWParser clustalparser = new ClustalWParser(); configparams.UseBrowserProxy = true; TestIClustalWServiceHandler handler = new TestIClustalWServiceHandler(clustalparser, configparams); ClustalWParameters parameters = new ClustalWParameters(); parameters.Values[ClustalWParameters.Email] = emailId; parameters.Values[ClustalWParameters.ClusterOption] = clusterOption; parameters.Values[ClustalWParameters.ActionAlign] = actionAlign; IList <ISequence> sequence = null; // Get input sequences using (FastaParser parser = new FastaParser()) { sequence = parser.Parse(filepath); } // Submit job and validate it returned valid job id and control id ServiceParameters svcparameters = handler.SubmitRequest(sequence, parameters); Assert.IsTrue(string.IsNullOrEmpty(svcparameters.JobId)); Console.WriteLine(string.Concat("JobId:", svcparameters.JobId)); foreach (string key in svcparameters.Parameters.Keys) { Assert.IsTrue(string.IsNullOrEmpty(svcparameters.Parameters[key].ToString())); Console.WriteLine(string.Format((IFormatProvider)null, "{0}:{1}", key, svcparameters.Parameters[key].ToString())); } // Get the results and validate it is not null. ClustalWResult result = null; int retrycount = 0; ServiceRequestInformation info; do { info = handler.GetRequestStatus(svcparameters); if (info.Status == ServiceRequestStatus.Ready) { break; } Thread.Sleep( info.Status == ServiceRequestStatus.Waiting || info.Status == ServiceRequestStatus.Queued ? Constants.ClusterRetryInterval * retrycount : 0); retrycount++; }while (retrycount < 10); if (info.Status == ServiceRequestStatus.Ready) { result = handler.FetchResultsAsync(svcparameters); } Assert.IsNotNull(result); Assert.IsNotNull(result.SequenceAlignment); foreach (IAlignedSequence alignSeq in result.SequenceAlignment.AlignedSequences) { Console.WriteLine("Aligned Sequence Sequences : "); ApplicationLog.WriteLine("Aligned Sequence Sequences : "); foreach (ISequence seq in alignSeq.Sequences) { Console.WriteLine(string.Concat("Sequence:", seq.ToString())); ApplicationLog.WriteLine(string.Concat("Sequence:", seq.ToString())); } } Console.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is successfully completed using FetchResultAsync()"); ApplicationLog.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is successfully completed using FetchResultAsync()"); }
/// <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"); }