/// <summary>
        /// This method is called when the user wants to run BLAST on a sequence
        /// </summary>
        private void OnBlastSequence()
        {
            // Get the full sequence, or the selected fragment
            ISequence sequence = !string.IsNullOrEmpty(SelectedSequenceFragment)
                ? new Sequence(SelectedSequence.RawSequence.Alphabet, SelectedSequenceFragment)
                : SelectedSequence.RawSequence;

            IBlastServiceHandler blastServiceHandler = SelectedBlastAlgorithm;

            BlastParameters bp = new BlastParameters();

            bp.Add("Program", "blastn");
            bp.Add("Database", "nr");
            bp.Add("Expect", "10.0");

            blastServiceHandler.RequestCompleted += new EventHandler <BlastRequestCompletedEventArgs>(BlastServiceHandlerRequestCompleted);

            try
            {
                IsRunning = blastServiceHandler.SubmitRequest(sequence, bp);
                if (string.IsNullOrEmpty(IsRunning))
                {
                    ShowError("Failed to execute Blast", "No results returned", null);
                }
            }
            catch (Exception ex)
            {
                ShowError("Failed to execute Blast", "Error occurred", ex);
                ResultHits = null;
            }
        }
Beispiel #2
0
        public void ValidateEbiWebServiceProperties()
        {
            ConfigParameters configParams = new ConfigParameters();

            configParams.UseBrowserProxy = true;

            IBlastServiceHandler service = null;

            try
            {
                service = new EbiWuBlastHandler(configParams);

                // Validate EBI Web Service properties.
                Assert.AreEqual(Constants.EbiWebServiceDescription, service.Description);
                Assert.AreEqual(Constants.EbiWebServiceName, service.Name);

                ApplicationLog.WriteLine(
                    "EbiWebService : Successfully validated the Ebi WebService Properties");
                Console.WriteLine(
                    "EbiWebService : Successfully validated the Ebi WebService Properties");
            }
            catch (Exception ex) { Assert.Fail(ex.Message); }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #3
0
        public void InvalidateNcbiCancelRequest()
        {
            IBlastServiceHandler service = null;

            // Validate ServiceMeta ctor by passing null config.
            try
            {
                service = new NCBIBlastHandler();
                service.CancelRequest(null);
                Assert.Fail();
            }
            catch (Exception)
            {
                ApplicationLog.WriteLine(
                    "NcbiWebService P2 : Successfully validated the exception");
                Console.WriteLine(
                    "NcbiWebService P2 : Successfully validated the exception");
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #4
0
        public void InvalidateBlastResultsUsingConstructorPam()
        {
            // create Ncbi Blast service object.
            ConfigParameters     configParams = null;
            IBlastServiceHandler service      = null;

            // Validate NcbiWebService ctor by passing null parser.
            try
            {
                service = new NCBIBlastHandler(configParams);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine(
                    "NcbiWebService P2 : Successfully validated the Argument null exception");
                Console.WriteLine(
                    "NcbiWebService P2 : Successfully validated the Argument null exception");
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Get Request identifier for submitted job.
        /// </summary>
        /// <param name="blastParameters">Blast Input config parameters</param>
        /// <returns></returns>
        private TestCaseOutput GetRequestIdentifier(Dictionary <string, object> blastParameters)
        {
            // Get the input query string
            string   sequenceString = blastParameters[Constants.QuerySeqString] as string;
            Sequence sequence       = new Sequence(Alphabets.DNA, sequenceString);

            // Set NCBIHandler configuration services
            IBlastServiceHandler service = null;
            object reqId = null;

            try
            {
                service = new AzureBlastHandler();
                ConfigParameters configParams = new ConfigParameters();
                configParams.UseBrowserProxy = true;
                configParams.DefaultTimeout  = 5;
                configParams.Connection      = new Uri(Constants.AzureUri);
                service.Configuration        = configParams;

                BlastParameters blastSearchPams = blastParameters[Constants.BlastParmsConst]
                                                  as BlastParameters;

                // Get Request identifier from web service.
                reqId = service.SubmitRequest(sequence, blastSearchPams);
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }

            return(new TestCaseOutput(reqId, false));
        }
Beispiel #6
0
        /// <summary>
        /// Fetch results asynchronous
        /// </summary>
        /// <param name="blastParameters">Blast Input config parameters</param>
        /// <returns></returns>
        private TestCaseOutput FetchResultsAsync(Dictionary <string, object> blastParameters)
        {
            // Get the input query string
            string   sequenceString = blastParameters[Constants.QuerySeqString] as string;
            Sequence sequence       = new Sequence(Alphabets.DNA, sequenceString);

            // Set NCBIHandler configuration services
            IBlastServiceHandler service = null;
            object resultsObject         = null;

            try
            {
                service = new AzureBlastHandler();
                ConfigParameters configParams = new ConfigParameters();
                configParams.UseBrowserProxy = true;
                configParams.DefaultTimeout  = 5;
                configParams.Connection      = new Uri(Constants.AzureUri);
                service.Configuration        = configParams;

                BlastParameters blastSearchPams = blastParameters[Constants.BlastParmsConst]
                                                  as BlastParameters;

                // Get Request identifier from web service.
                string reqId = service.SubmitRequest(sequence, blastSearchPams);

                // Get request information for first time.
                ServiceRequestInformation info = service.GetRequestStatus(reqId);

                // Ping service until request staus is ready.
                int maxAttempts = 10;
                int attempt     = 1;

                while (attempt <= maxAttempts && info.Status != ServiceRequestStatus.Ready &&
                       info.Status != ServiceRequestStatus.Error)
                {
                    System.Threading.Thread.Sleep(2000);
                    ++attempt;
                    info = service.GetRequestStatus(reqId);
                }


                IBlastParser blastXmlParser = new BlastXmlParser();
                using (StringReader reader = new StringReader(service.GetResult(reqId, blastSearchPams)))
                {
                    resultsObject = blastXmlParser.Parse(reader);
                }
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }

            return(new TestCaseOutput(resultsObject, false));
        }
Beispiel #7
0
        /// <summary>
        /// This method renders the single line report for BLAST hits.
        /// </summary>
        /// <param name="results">BLAST hits</param>
        private void RenderSingleLineReport(IList <BlastResult> results, IBlastServiceHandler blastService, string databaseName)
        {
            this.lstSingleLineReport.ItemsSource = null;
            this.lstSingleLineReport.Items.Clear();
            this.blastResultCollator.Clear();
            this.Focus();
            foreach (BlastResult result in results)
            {
                foreach (BlastSearchRecord record in result.Records)
                {
                    if (null != record.Hits &&
                        0 < record.Hits.Count)
                    {
                        foreach (Hit hit in record.Hits)
                        {
                            if (null != hit.Hsps &&
                                0 < hit.Hsps.Count)
                            {
                                foreach (Hsp hsp in hit.Hsps)
                                {
                                    BlastResultCollator blast = new BlastResultCollator();
                                    blast.Uri           = BlastHitUrlResolver.ResolveUrl(hit.Id, blastService, databaseName);
                                    blast.Alignment     = hsp.AlignmentLength;
                                    blast.Bit           = hsp.BitScore;
                                    blast.EValue        = hsp.EValue;
                                    blast.Identity      = hsp.IdentitiesCount;
                                    blast.Length        = hit.Length;
                                    blast.QEnd          = hsp.QueryEnd;
                                    blast.QStart        = hsp.QueryStart;
                                    blast.QueryId       = record.IterationQueryId;
                                    blast.SEnd          = hsp.HitEnd;
                                    blast.SStart        = hsp.HitStart;
                                    blast.SubjectId     = hit.Id;
                                    blast.Positives     = hsp.PositivesCount;
                                    blast.QueryString   = hsp.QuerySequence;
                                    blast.SubjectString = hsp.HitSequence;
                                    blast.Accession     = hit.Accession;
                                    blast.Description   = hit.Def;
                                    blast.Gaps          = hsp.Gaps;
                                    this.blastResultCollator.Add(blast);
                                }
                            }
                        }
                    }
                }
            }

            this.lstSingleLineReport.ItemsSource = this.blastResultCollator;

            // Invoke the Silvermap
            if (this.blastResultCollator.Count > 0 || this.webServiceReportTab.SelectedIndex == 1)
            {
                this.silverMapControl.InvokeSilverMap(this.blastResultCollator);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Validate a Azure Blast Service constructor with invalid parameters.
        /// Input : Invalid service config parameters.
        /// Output : Invalidate Azure web service constructor.
        /// </summary>
        public void InvalidateAzureWebHandlerCtor()
        {
            ConfigParameters configParams = new ConfigParameters();

            configParams.UseBrowserProxy = true;
            configParams.DefaultTimeout  = 10;
            configParams.Connection      = new Uri(Constants.AzureUri);
            BlastXmlParser parser = new BlastXmlParser();

            // Validate AzureWebService ctor by passing null parser.
            IBlastServiceHandler service = null;

            try
            {
                service = new AzureBlastHandler(null, configParams);
                Assert.IsNotNull(service);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine(
                    "AzureWebService P2 : Successfully validated the Argument null exception");
                Console.WriteLine(
                    "AzureWebService P2 : Successfully validated the Argument null exception");
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }

            // Validate AzureWebService ctor by passing null configuration parameters.
            try
            {
                service = new AzureBlastHandler(parser, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine(
                    "AzureWebService P2 : Successfully validated the Argument null exception");
                Console.WriteLine(
                    "AzureWebService P2 : Successfully validated the Argument null exception");
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Validate Cancelling submitted Job.
        /// Input Data :Valid search query, Database value and program value.
        /// Output Data : Validation of Cancelling submitted Job.
        /// </summary>
        /// Invalidated the test case for the Bug 115
        public void ValidateCancelSubmittedJob()
        {
            // Gets the search query parameter and their values.
            string querySequence = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.QuerySequency);
            string queryDatabaseValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.DatabaseValue);
            string queryProgramValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.ProgramValue);
            string queryDatabaseParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.DatabaseParameter);
            string queryProgramParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.ProgramParameter);

            // Set Blast Parameters
            IBlastServiceHandler service = null;

            try
            {
                service = new AzureBlastHandler();
                BlastParameters queryParams = new BlastParameters();
                queryParams.Add(queryDatabaseParameter, queryDatabaseValue);
                queryParams.Add(queryProgramParameter, queryProgramValue);

                Dictionary <string, object> testCaseParms = new Dictionary <string, object>();
                testCaseParms.Add(Constants.BlastParmsConst, queryParams);
                testCaseParms.Add(Constants.QuerySeqString, querySequence);

                // Get request identifier
                TestCaseParameters parameters = new TestCaseParameters(
                    Constants.AzureWebServiceCancelSubmitRequestTest, null,
                    GetRequestIdentifier, testCaseParms);

                object resultsObject = _TestCaseSimulator.Simulate(parameters).Result;

                // Cancel subitted job.
                bool result = service.CancelRequest(resultsObject as string);

                // validate the cancelled job.
                Assert.IsTrue(result);

                Console.WriteLine(string.Format(null,
                                                "Azure Blast BVT : Submitted job cancelled was successfully.",
                                                queryProgramValue));
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// This method displays BLAST hits on the UI.
        /// </summary>
        /// <param name="results">BLAST hits</param>
        public void DisplayWebServiceOutput(IList <BlastResult> results, IBlastServiceHandler blastService, string databaseName)
        {
            if (results != null && results.Count >= 1)
            {
                this.RenderSingleLineReport(results, blastService, databaseName);
                this.blastResult = results[0];

                this.txtDate.Text         = DateTime.Now.Date.ToString(CultureInfo.CurrentCulture);
                this.txtDataBaseName.Text = this.blastResult.Metadata.Database;
                this.txtVersion.Text      = this.blastResult.Metadata.Version;
            }
        }
Beispiel #11
0
        /// <summary>
        /// This method is called when the user wants to run BLAST on a sequence
        /// </summary>
        private void OnBlastSequence()
        {
            // Get the full sequence, or the selected fragment
            ISequence sequence = !string.IsNullOrEmpty(SelectedSequenceFragment)
                ? new Sequence(SelectedSequence.RawSequence.Alphabet, SelectedSequenceFragment)
                : SelectedSequence.RawSequence;

            IBlastServiceHandler blastServiceHandler = SelectedBlastAlgorithm;

            BlastParameters bp = new BlastParameters();

            bp.Add("Program", "blastn");
            bp.Add("Database", "nr");
            bp.Add("Expect", "10.0");

            try
            {
                string resultKey = blastServiceHandler.SubmitRequest(sequence, bp);
                if (string.IsNullOrEmpty(resultKey))
                {
                    ShowError("Failed to execute Blast", "No results returned", null);
                }
                else
                {
                    IList <BlastResult> results =
                        blastServiceHandler.FetchResultsSync(resultKey, bp);
                    if (results == null || results.Count == 0)
                    {
                        MessageBox.Show("No Results returned.");
                        ResultHits = null;
                    }
                    else
                    {
                        ResultHits = results[0].Records[0].Hits;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError("Failed to execute Blast", "Error occurred", ex);
                ResultHits = null;
            }
        }
Beispiel #12
0
        /// <summary>
        /// Get the url for a blast hit
        /// </summary>
        /// <param name="hitID">Blast hit id</param>
        /// <param name="blastService">Instance of the blast service</param>
        /// <param name="databaseName">Database name used in the blast query</param>
        /// <returns>A url if resolved, else null</returns>
        public static string ResolveUrl(string hitID, IBlastServiceHandler blastService, string databaseName)
        {
            // NCBI
            if (blastService.Name == WebServices.NcbiBlast.Name)
            {
                string[] idSplit = hitID.Split('|');
                if (idSplit.Length < 2)
                {
                    return(null);
                }

                string id = idSplit[1];

                return(string.Format("http://www.ncbi.nlm.nih.gov/protein/{0}", id));
            }

            // EBI
            else if (blastService.Name == WebServices.EbiBlast.Name)
            {
                string[] idSplit = hitID.Split(':', ';');
                if (idSplit.Length < 2)
                {
                    return(null);
                }

                string id = idSplit[1];

                switch (databaseName)
                {
                case "em_rel":
                    return(string.Format("http://www.ebi.ac.uk/ena/data/view/{0}", id));

                case "uniprot":
                    return(string.Format("http://www.uniprot.org/uniprot/{0}.html", id));

                default:
                    return(null);
                }
            }

            // Return null if url was not resolved
            return(null);
        }
Beispiel #13
0
        /// <summary>
        /// Get BioHPC web service request status.
        /// </summary>
        /// <param name="blastParameters">Blast config parameters</param>
        /// <returns>BioHPC webservice request status</returns>
        private TestCaseOutput GetRequestStatus(Dictionary <string, object> blastParameters)
        {
            // Get the input query string
            string   sequenceString = blastParameters[Constants.QuerySeqString] as string;
            string   alphabetName   = blastParameters[Constants.AlphabetString] as string;
            string   email          = blastParameters[Constants.EmailString] as string;
            Sequence sequence       = new Sequence(Utility.GetAlphabet(alphabetName),
                                                   sequenceString);

            //Set BioHPC web service config parameters
            IBlastServiceHandler service = null;
            object serviceInfo           = null;

            try
            {
                service = new BioHPCBlastHandler();
                ConfigParameters configParameters = new ConfigParameters();
                configParameters.EmailAddress    = email;
                configParameters.Password        = String.Empty;
                configParameters.UseBrowserProxy = true;
                service.Configuration            = configParameters;

                BlastParameters blastSearchPams = blastParameters[Constants.BlastParmsConst]
                                                  as BlastParameters;

                // Submit request and get request identifier
                string reqId = service.SubmitRequest(sequence, blastSearchPams);

                // Get service request status.

                serviceInfo = service.GetRequestStatus(reqId);
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }

            return(new TestCaseOutput(serviceInfo, false));
        }
        /// <summary>
        /// This method is called when the user wants to run BLAST on a sequence
        /// </summary>
        private void OnBlastSequence()
        {
            // Get the full sequence, or the selected fragment
            ISequence sequence = !string.IsNullOrEmpty(SelectedSequenceFragment)
                ? new Sequence(SelectedSequence.RawSequence.Alphabet, SelectedSequenceFragment)
                : SelectedSequence.RawSequence;

            IBlastServiceHandler blastServiceHandler = SelectedBlastAlgorithm;

            BlastParameters bp = new BlastParameters();

            foreach (var item in BlastParameters.Where(kv => !string.IsNullOrEmpty(kv.Value)))
            {
                bp.Add(item.Key, item.Value);
            }

            if (!string.IsNullOrEmpty(Url))
            {
                blastServiceHandler.Configuration.Connection = new Uri(Url);
                if (Url.StartsWith("https"))
                {
                    blastServiceHandler.Configuration.UseHttps = true;
                }
            }
            blastServiceHandler.Configuration.UseBrowserProxy = UseBrowserProxy;

            blastServiceHandler.RequestCompleted += new EventHandler <BlastRequestCompletedEventArgs>(BlastServiceHandlerRequestCompleted);

            try
            {
                IsRunning = blastServiceHandler.SubmitRequest(sequence, bp);
                if (string.IsNullOrEmpty(IsRunning))
                {
                    ShowError("Failed to execute Blast", "No results returned", null);
                }
            }
            catch (Exception ex)
            {
                ShowError("Failed to execute Blast", "Error occurred", ex);
                ResultHits = null;
            }
        }
Beispiel #15
0
        /// <summary>
        /// Validate Request status of the submited request.
        /// </summary>
        /// <param name="blastParameters">Ebi blast service config parameters</param>
        /// <returns></returns>
        private TestCaseOutput GetRequestStatusTest(Dictionary <string, object> blastParameters)
        {
            // Get the input query string
            string   sequenceString = blastParameters[Constants.QuerySeqString] as string;
            string   alphabetName   = blastParameters[Constants.AlphabetString] as string;
            Sequence sequence       = new Sequence(Utility.GetAlphabet(alphabetName),
                                                   sequenceString);

            // create Ebi Blast service object.
            IBlastServiceHandler service = null;
            object reqInfoObject         = null;

            try
            {
                service = new EbiWuBlastHandler();
                ConfigParameters configParams = new ConfigParameters();
                configParams.UseBrowserProxy = true;
                service.Configuration        = configParams;

                BlastParameters blastSearchPams = blastParameters[Constants.BlastParmsConst]
                                                  as BlastParameters;

                // Create a request without passing sequence.
                string reqId = service.SubmitRequest(sequence, blastSearchPams);

                // validate request identifier.
                Assert.IsNotNull(reqId);

                // query the status
                reqInfoObject = service.GetRequestStatus(reqId);
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }

            return(new TestCaseOutput(reqInfoObject, false));
        }
Beispiel #16
0
        /// <summary>
        /// Fetch Asynchronous results
        /// </summary>
        /// <param name="blastParameters">Blast config parameters</param>
        /// <returns>BioHPC Web service results</returns>
        private TestCaseOutput FetchResultsASyncTest(Dictionary <string, object> blastParameters)
        {
            // Get the input query string
            string   sequenceString = blastParameters[Constants.QuerySeqString] as string;
            string   alphabetName   = blastParameters[Constants.AlphabetString] as string;
            string   email          = blastParameters[Constants.EmailString] as string;
            Sequence sequence       = new Sequence(Utility.GetAlphabet(alphabetName),
                                                   sequenceString);
            string maxAttempts = blastParameters[Constants.MaxAttemptString] as string;
            string waitTime    = blastParameters[Constants.WaitTimeString] as string;

            //Set BioHPC web service config parameters
            IBlastServiceHandler service = null;
            object responseResults       = null;

            try
            {
                service = new BioHPCBlastHandler();
                ConfigParameters configParameters = new ConfigParameters();
                configParameters.EmailAddress    = email;
                configParameters.Password        = String.Empty;
                configParameters.UseBrowserProxy = true;
                service.Configuration            = configParameters;

                BlastParameters blastSearchPams = blastParameters[Constants.BlastParmsConst]
                                                  as BlastParameters;

                // Submit request and get request identifier
                string reqId = service.SubmitRequest(sequence, blastSearchPams);

                // validate request identifier.
                Assert.IsNotNull(reqId);

                ServiceRequestInformation info = service.GetRequestStatus(reqId);
                if (info.Status != ServiceRequestStatus.Waiting &&
                    info.Status != ServiceRequestStatus.Ready &&
                    info.Status != ServiceRequestStatus.Queued)
                {
                    string err =
                        ApplicationLog.WriteLine("Unexpected status: '{0}'",
                                                 info.Status);
                    Assert.Fail(err);
                }

                // get async results, poll until ready
                int attempt = 1;
                while (attempt <= Int32.Parse(maxAttempts, (IFormatProvider)null) &&
                       info.Status != ServiceRequestStatus.Error &&
                       info.Status != ServiceRequestStatus.Ready)
                {
                    ++attempt;

                    info = service.GetRequestStatus(reqId);
                    Thread.Sleep(
                        info.Status == ServiceRequestStatus.Waiting ||
                        info.Status == ServiceRequestStatus.Queued
                      ? Int32.Parse(waitTime, (IFormatProvider)null) * attempt : 0);
                }

                IBlastParser blastXmlParser = new BlastXmlParser();

                using (StringReader reader = new StringReader(service.GetResult(reqId, blastSearchPams)))
                {
                    responseResults = blastXmlParser.Parse(reader);
                }
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }

            return(new TestCaseOutput(responseResults, false));
        }
Beispiel #17
0
        public void ValidateBioHPCCtor()
        {
            // Gets the search query parameter and their values.
            string alphabetName = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode,
                Constants.AlphabetNameNode);
            string querySequence = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode,
                Constants.QuerySequency);
            string queryDatabaseValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode,
                Constants.DatabaseValue);
            string email = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode,
                Constants.EmailAdress);
            string queryProgramValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode,
                Constants.ProgramValue);
            string queryDatabaseParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode,
                Constants.DatabaseParameter);
            string queryProgramParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode,
                Constants.ProgramParameter);
            string expect = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode, Constants.Expectparameter);
            string emailNotify = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode, Constants.EmailNotifyParameterNode);
            string jobName = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode, Constants.JobNameParameterNode);
            string expectValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode, Constants.ExpectNode);
            string emailNotifyValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode, Constants.EmailNotifyNode);
            string jobNameValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.BioHPCAsynchronousResultsNode, Constants.JobNameNode);

            // Set Blast Parameters
            BlastParameters      queryParams = new BlastParameters();
            IBlastServiceHandler service     = null;
            object resultsObject             = null;

            try
            {
                service = new BioHPCBlastHandler();
                ConfigParameters configParameters = new ConfigParameters();
                configParameters.EmailAddress    = email;
                configParameters.Password        = String.Empty;
                configParameters.UseBrowserProxy = true;
                service.Configuration            = configParameters;

                // Add mandatory parameter values to search query parameters.
                queryParams.Add(queryDatabaseParameter, queryDatabaseValue);
                queryParams.Add(queryProgramParameter, queryProgramValue);
                queryParams.Add(expect, expectValue);
                queryParams.Add(emailNotify, emailNotifyValue);
                queryParams.Add(jobName, jobNameValue);


                Dictionary <string, object> testCaseParms = new Dictionary <string, object>();
                testCaseParms.Add(Constants.BlastParmsConst, queryParams);
                testCaseParms.Add(Constants.QuerySeqString, querySequence);
                testCaseParms.Add(Constants.AlphabetString, alphabetName);
                testCaseParms.Add(Constants.EmailString, email);

                // Get request Identifier
                TestCaseParameters parameters = new TestCaseParameters(
                    Constants.BioHPCRequestIdentifierForDnaSeqTest,
                    null, GetRequestIdentifier, testCaseParms);
                resultsObject = _TestCaseSimulator.Simulate(parameters).Result;
                Assert.IsNotNull(resultsObject as string);
            }
            catch (WebException ex)
            {
                Assert.Fail();
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "BioHPC Blast Bvt : Connection not successful with error '{0}'",
                                                ex.Message));
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                       "BioHPC Blast Bvt : Connection not successful with error '{0}'",
                                                       ex.Message));
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #18
0
        public void ValidateEBIWuBlastManadatoryParams()
        {
            // Gets the search query parameter and their values.
            string querySequence = _utilityObj._xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.QuerySequency);
            string queryDatabaseValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.DatabaseValue);
            string queryProgramValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.ProgramValue);
            string queryDatabaseParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.DatabaseParameter);
            string queryProgramParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.ProgramParameter);
            string emailParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.Emailparameter);
            string email = _utilityObj._xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.EmailAdress);

            // Set Service confiruration parameters true.
            IBlastServiceHandler service = null;

            try
            {
                service = new EbiWuBlastHandler();
                ConfigParameters configParameters = new ConfigParameters();
                configParameters.UseBrowserProxy = true;
                service.Configuration            = configParameters;

                // Create search parameters object.
                BlastParameters ebiParams = new BlastParameters();

                // Add mandatory parameter values to search query parameters.
                //ebiParams.Add(querySequenceParameter, querySequence);
                ebiParams.Add(queryDatabaseParameter, queryDatabaseValue);
                ebiParams.Add(queryProgramParameter, queryProgramValue);
                ebiParams.Add(emailParameter, email);

                // Validate search query parameters.
                ParameterValidationResult validateParameters =
                    EbiWuBlastHandler.ValidateParameters(ebiParams);
                bool result = validateParameters.IsValid;

                Assert.IsTrue(result);
                // Assert.IsTrue(ebiParams.Settings.ContainsValue(querySequence));
                Assert.IsTrue(ebiParams.Settings.ContainsValue(queryDatabaseValue));
                Assert.IsTrue(ebiParams.Settings.ContainsValue(queryProgramValue));
                Assert.IsTrue(ebiParams.Settings.ContainsValue(email));
                Assert.AreEqual(ebiParams.Settings.Count, 3);

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "Ebi Blast BVT: Query Sequence{0} is as expected.", querySequence));
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "Ebi Blast BVT: DataBase Value{0} is as expected.", queryDatabaseValue));
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "Ebi Blast BVT: Program Value {0} is as expected.", queryProgramValue));
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// Validate Cancel submitted job by passing job id.
        /// <param name="nodeName">different alphabet node name</param>
        /// </summary>
        void ValidateCancelSubmittedJob(string nodeName)
        {
            // Gets the search query parameter and their values.
            string alphabetName = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.AlphabetNameNode);
            string querySequence = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.QuerySequency);
            string queryDatabaseValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.DatabaseValue);
            string emailParameter = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Emailparameter);
            string email = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EmailAdress);
            string queryProgramValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ProgramValue);
            string queryDatabaseParameter = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.DatabaseParameter);
            string queryProgramParameter = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ProgramParameter);

            Sequence seq = new Sequence(Utility.GetAlphabet(alphabetName),
                                        querySequence);

            // create Ebi Blast service object.
            IBlastServiceHandler service = null;

            try
            {
                service = new EbiWuBlastHandler();
                ConfigParameters configParams = new ConfigParameters();
                configParams.UseBrowserProxy = true;
                service.Configuration        = configParams;

                BlastParameters searchParams = new BlastParameters();

                // Set Request parameters.
                searchParams.Add(queryDatabaseParameter, queryDatabaseValue);
                searchParams.Add(queryProgramParameter, queryProgramValue);
                searchParams.Add(emailParameter, email);
                searchParams.Add("SequenceType",
                                 alphabetName.ToLower(CultureInfo.CurrentCulture).Replace("ambiguous", ""));

                // Create a request without passing sequence.
                string reqId = service.SubmitRequest(seq, searchParams);

                // Cancel subitted job.
                bool result = service.CancelRequest(reqId);

                // validate the cancelled job.
                Assert.IsTrue(result);

                Console.WriteLine(string.Concat(
                                      "EBI Blast P1 : Submitted job cancelled was successfully.",
                                      queryProgramValue));
            }
            catch (Exception ex) { Assert.Fail(ex.Message); }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// Validate Fetch results Asynchronous.
        /// </summary>
        /// <param name="blastParameters">Ebi blast service config parameters</param>
        /// <returns></returns>
        private TestCaseOutput FetchResultsSync(Dictionary <string, object> blastParameters)
        {
            // Get the input query string
            string   sequenceString = blastParameters[Constants.QuerySeqString] as string;
            string   alphabetName   = blastParameters[Constants.AlphabetString] as string;
            Sequence sequence       = new Sequence(Utility.GetAlphabet(alphabetName),
                                                   sequenceString);

            // create Ebi Blast service object.
            IBlastServiceHandler service          = null;
            IList <BlastResult>  syncBlastResults = null;

            try
            {
                service = new EbiWuBlastHandler();
                ConfigParameters configParams = new ConfigParameters();
                configParams.UseBrowserProxy = true;
                service.Configuration        = configParams;

                BlastParameters blastSearchPams = blastParameters[Constants.BlastParmsConst]
                                                  as BlastParameters;

                // Create a request without passing sequence.
                string reqId = service.SubmitRequest(sequence, blastSearchPams);

                // validate request identifier.
                Assert.IsNotNull(reqId);

                // query the status
                ServiceRequestInformation info = service.GetRequestStatus(reqId);
                if (info.Status != ServiceRequestStatus.Waiting &&
                    info.Status != ServiceRequestStatus.Ready)
                {
                    string err =
                        ApplicationLog.WriteLine("Unexpected status: '{0}'", info.Status);
                    Assert.Fail(err);
                }

                // get async results, poll until ready
                int maxAttempts = 3;
                int attempt     = 1;
                while (attempt <= maxAttempts &&
                       info.Status != ServiceRequestStatus.Error &&
                       info.Status != ServiceRequestStatus.Ready)
                {
                    info = service.GetRequestStatus(reqId);
                    Thread.Sleep(info.Status == ServiceRequestStatus.Waiting ||
                                 info.Status == ServiceRequestStatus.Queued
                        ? 20000 * attempt : 0);

                    ++attempt;
                }

                syncBlastResults =
                    service.FetchResultsSync(reqId, blastSearchPams) as List <BlastResult>;
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
            return(new TestCaseOutput(syncBlastResults, false));
        }
Beispiel #21
0
        /// <summary>
        /// Validate the Azure Blast Service Request status Queued.
        /// Input : Invalid request parameters.
        /// Output : Invalidate request status.
        /// </summary>
        public void InvalidateAzureWebServiceRequestStatus()
        {
            // Gets the search query parameter and their values.
            string queryProgramValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.ProgramValue);
            string queryDatabaseParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.DatabaseParameter);
            string queryDatabaseValue = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.DatabaseValue);
            string queryProgramParameter = _utilityObj._xmlUtil.GetTextValue(
                Constants.AzureBlastResultsNode, Constants.ProgramParameter);
            string reqId = string.Empty;

            ConfigParameters configParams = new ConfigParameters();

            configParams.UseBrowserProxy = true;
            configParams.DefaultTimeout  = 1;
            configParams.RetryInterval   = 10;
            configParams.RetryCount      = 1;
            configParams.Connection      = new Uri(Constants.AzureUri);

            // Create search parameters object.
            BlastParameters searchParams = new BlastParameters();

            // Add mandatory parameter values to search query parameters.
            searchParams.Add(queryProgramParameter, queryProgramValue);
            searchParams.Add(queryDatabaseParameter, queryDatabaseValue);

            IBlastServiceHandler service = null;

            try
            {
                service = new AzureBlastHandler(configParams);

                // Set Service confiruration parameters true.
                service.Configuration = configParams;

                // Get Request identifier from web service.
                //reqId = service.SubmitRequest(seq, searchParams);
            }
            catch (WebException ex)
            {
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                       "AzureWebService P2 : Connection Failed with the error '{0}'", ex.Message));
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "AzureWebService P2 : Connection Failed with the error '{0}'", ex.Message));
                Assert.Inconclusive("Test case ignored due to connection failure");
            }

            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
            try
            {
                object responseResults = service.FetchResultsSync(reqId, searchParams);
                Assert.IsNotNull(responseResults);
                Assert.Fail();
            }
            catch (WebException)
            {
                ApplicationLog.WriteLine("AzureWebService P2 : Successfully validated the exception");
                Console.WriteLine("AzureWebService P2 : Successfully validated the exception");
            }
        }
Beispiel #22
0
        public void ValidateEBIWuBlastManadatoryParams()
        {
            // Gets the search query parameter and their values.
            string querySequence = utilityObj.xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.QuerySequency);
            string queryDatabaseValue = utilityObj.xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.DatabaseValue);
            string queryProgramValue = utilityObj.xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.ProgramValue);
            string queryDatabaseParameter = utilityObj.xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.DatabaseParameter);
            string queryProgramParameter = utilityObj.xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.ProgramParameter);
            string emailParameter = utilityObj.xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.Emailparameter);
            string email = utilityObj.xmlUtil.GetTextValue(
                Constants.BlastParametersNode, Constants.EmailAdress);
            string alphabetName = utilityObj.xmlUtil.GetTextValue(
                Constants.EbiAsynchronousResultsNode, Constants.AlphabetNameNode);

            // Set Service confiruration parameters true.
            IBlastServiceHandler service = null;

            try
            {
                service = new EbiWuBlastHandler();
                ConfigParameters configParameters = new ConfigParameters();
                configParameters.UseBrowserProxy = true;
                service.Configuration            = configParameters;

                // Create search parameters object.
                BlastParameters ebiParams = new BlastParameters();

                // Add mandatory parameter values to search query parameters.
                //ebiParams.Add(querySequenceParameter, querySequence);
                ebiParams.Add(queryDatabaseParameter, queryDatabaseValue);
                ebiParams.Add(queryProgramParameter, queryProgramValue);
                ebiParams.Add(emailParameter, email);
                ebiParams.Add("SequenceType",
                              alphabetName.ToLower(CultureInfo.CurrentCulture).Replace("ambiguous", ""));

                // Validate search query parameters.
                ParameterValidationResult validateParameters =
                    EbiWuBlastHandler.ValidateParameters(ebiParams);
                bool result = validateParameters.IsValid;

                Assert.IsTrue(result);
                // Assert.IsTrue(ebiParams.Settings.ContainsValue(querySequence));
                Assert.IsTrue(ebiParams.Settings.ContainsValue(queryDatabaseValue));
                Assert.IsTrue(ebiParams.Settings.ContainsValue(queryProgramValue));
                Assert.IsTrue(ebiParams.Settings.ContainsValue(email));
                Assert.AreEqual(ebiParams.Settings.Count, 4);

                // Logs to the VSTest GUI (Console.Out) window
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "Ebi Blast BVT: Query Sequence{0} is as expected.", querySequence));
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "Ebi Blast BVT: DataBase Value{0} is as expected.", queryDatabaseValue));
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "Ebi Blast BVT: Program Value {0} is as expected.", queryProgramValue));
            }
            catch (Exception ex) { Assert.Fail(ex.Message); }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
        }