Ejemplo n.º 1
0
        /// <summary>
        /// Validate general fetching results.by passing 
        /// differnt parameters for BioHPC Blast web service.
        /// <param name="nodeName">xml node name.</param>
        /// <param name="isFetchSynchronous">Is Fetch Synchronous?</param>
        /// </summary>
        void ValidateBioHPCBlastResultsFetch(
            string nodeName, bool isFetchSynchronous)
        {
            // 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 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);
            string expectedHitId = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.HitID);
            string expectedAccession = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.HitAccession);
            string expectedResultCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ResultsCount);
            string expectedHitsCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.HitsCount);
            string expectedEntropyStatistics =
                utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EntropyStatistics);
            string expectedKappaStatistics = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.KappaStatistics);
            string expectedLambdaStatistics = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LambdaStatistics);
            string expectedLength = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Length);
            int maxAttempts = int.Parse(utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.MaxAttemptsNode), (IFormatProvider)null);
            int waitingTime = int.Parse(utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.WaitTimeNode), (IFormatProvider)null);
            string expect = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Expectparameter);
            string emailNotify = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EmailNotifyParameterNode);
            string jobName = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.JobNameParameterNode);
            string expectValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectNode);
            string emailNotifyValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EmailNotifyNode);
            string jobNameValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.JobNameNode);

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

            // create BioHPC Blast Web Service object.
            IBlastServiceHandler service = new BioHPCBlastHandler();
            ConfigParameters configPams = new ConfigParameters();
            configPams.EmailAddress = email;
            configPams.Password = String.Empty;
            configPams.UseBrowserProxy = true;
            service.Configuration = configPams;

            BlastParameters searchParams = new BlastParameters();

            // Set Request parameters.
            searchParams.Add(queryDatabaseParameter, queryDatabaseValue);
            searchParams.Add(queryProgramParameter, queryProgramValue);
            searchParams.Add(expect, expectValue);
            searchParams.Add(emailNotify, emailNotifyValue);
            searchParams.Add(jobName, jobNameValue);

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

            // 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 <= maxAttempts
                    && info.Status != ServiceRequestStatus.Error
                    && info.Status != ServiceRequestStatus.Ready)
            {
                ++attempt;
                if (isFetchSynchronous)
                {
                    info = service.GetRequestStatus(reqId);
                    Thread.Sleep(
                        info.Status == ServiceRequestStatus.Waiting
                        || info.Status == ServiceRequestStatus.Queued
                        ? waitingTime * attempt : 0);
                }
                else
                {
                    Thread.Sleep(
                        info.Status == ServiceRequestStatus.Waiting
                        || info.Status == ServiceRequestStatus.Queued ?
                        waitingTime * attempt : 0);
                    info = service.GetRequestStatus(reqId);
                }

            }

            IBlastParser blastXmlParser = new BlastXmlParser();
            responseResults = blastXmlParser.Parse(
                    new StringReader(service.GetResult(reqId, searchParams)));


            Assert.IsNotNull(responseResults);
            List<BlastResult> eBlastResults =
                responseResults as List<BlastResult>;
            Assert.IsNotNull(eBlastResults);
            Assert.AreEqual(eBlastResults.Count.ToString(
                (IFormatProvider)null), expectedResultCount);
            Assert.AreEqual(eBlastResults[0].Records.Count.ToString((
                IFormatProvider)null), expectedResultCount);
            BlastSearchRecord record = eBlastResults[0].Records[0];
            Assert.AreEqual(record.Statistics.Kappa.ToString(
                (IFormatProvider)null), expectedKappaStatistics);
            Assert.AreEqual(record.Statistics.Lambda.ToString(
                (IFormatProvider)null), expectedLambdaStatistics);
            Assert.AreEqual(record.Statistics.Entropy.ToString(
                (IFormatProvider)null), expectedEntropyStatistics);
            Assert.AreEqual(record.Hits.Count.ToString(
                (IFormatProvider)null), expectedHitsCount);
            Hit hit = record.Hits[0];
            Assert.AreEqual(hit.Accession, expectedAccession);
            Assert.AreEqual(hit.Length.ToString((IFormatProvider)null),
                expectedLength);
            Assert.AreEqual(hit.Id.ToString((IFormatProvider)null),
                expectedHitId);
            Assert.AreEqual(hit.Hsps.Count.ToString((IFormatProvider)null),
                expectedResultCount);
            Console.WriteLine(string.Format((IFormatProvider)null,
               "BioHPC Blast BVT : Hits count '{0}'.", eBlastResults.Count));
            Console.WriteLine(string.Format((IFormatProvider)null,
                "BioHPC Blast BVT : Accession '{0}'.", hit.Accession));
            Console.WriteLine(string.Format((IFormatProvider)null,
                "BioHPC Blast BVT : Hit Id '{0}'.", hit.Id));
            Console.WriteLine(string.Format((IFormatProvider)null,
                "BioHPC Blast BVT : Hits Count '{0}'.", hit.Hsps.Count));
            // Validate the results Synchronously with the results got earlier.
            if (isFetchSynchronous)
            {
                IList<BlastResult> syncBlastResults =
                    service.FetchResultsSync(reqId, searchParams) as List<BlastResult>;
                Assert.IsNotNull(syncBlastResults);
                if (null != eBlastResults[0].Records[0].Hits
                    && 0 < eBlastResults[0].Records[0].Hits.Count
                    && null != eBlastResults[0].Records[0].Hits[0].Hsps
                    && 0 < eBlastResults[0].Records[0].Hits[0].Hsps.Count)
                {
                    Assert.AreEqual(
                        eBlastResults[0].Records[0].Hits[0].Hsps[0].QuerySequence,
                        syncBlastResults[0].Records[0].Hits[0].Hsps[0].QuerySequence);
                }
                else
                {
                    ApplicationLog.WriteLine(
                        "No significant hits found with the these parameters.");
                    Console.WriteLine(
                        "No significant hits found with the these parameters.");
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fetch synchronous results
        /// </summary>
        /// <param name="blastParameters">Blast config parameters</param>
        /// <returns>BioHPC Web service results</returns>
        private TestCaseOutput FetchResultsSyncTest(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;
            IList <BlastResult>  syncBlastResults = 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);
                }

                syncBlastResults =
                    service.FetchResultsSync(reqId, blastSearchPams) as List <BlastResult>;
            }
            finally
            {
                if (service != null)
                {
                    ((IDisposable)service).Dispose();
                }
            }
            return(new TestCaseOutput(syncBlastResults, false));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Validate general fetching results.by passing
        /// differnt parameters for BioHPC Blast web service.
        /// <param name="nodeName">xml node name.</param>
        /// <param name="isFetchSynchronous">Is Fetch Synchronous?</param>
        /// </summary>
        void ValidateBioHPCBlastResultsFetch(
            string nodeName, bool isFetchSynchronous)
        {
            // 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 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);
            string expectedHitId = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.HitID);
            string expectedAccession = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.HitAccession);
            string expectedResultCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ResultsCount);
            string expectedHitsCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.HitsCount);
            string expectedEntropyStatistics =
                utilityObj.xmlUtil.GetTextValue(
                    nodeName, Constants.EntropyStatistics);
            string expectedKappaStatistics = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.KappaStatistics);
            string expectedLambdaStatistics = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.LambdaStatistics);
            string expectedLength = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Length);
            int maxAttempts = int.Parse(utilityObj.xmlUtil.GetTextValue(
                                            nodeName, Constants.MaxAttemptsNode), (IFormatProvider)null);
            int waitingTime = int.Parse(utilityObj.xmlUtil.GetTextValue(
                                            nodeName, Constants.WaitTimeNode), (IFormatProvider)null);
            string expect = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.Expectparameter);
            string emailNotify = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EmailNotifyParameterNode);
            string jobName = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.JobNameParameterNode);
            string expectValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectNode);
            string emailNotifyValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EmailNotifyNode);
            string jobNameValue = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.JobNameNode);

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

            // create BioHPC Blast Web Service object.
            IBlastServiceHandler service    = new BioHPCBlastHandler();
            ConfigParameters     configPams = new ConfigParameters();

            configPams.EmailAddress    = email;
            configPams.Password        = String.Empty;
            configPams.UseBrowserProxy = true;
            service.Configuration      = configPams;

            BlastParameters searchParams = new BlastParameters();

            // Set Request parameters.
            searchParams.Add(queryDatabaseParameter, queryDatabaseValue);
            searchParams.Add(queryProgramParameter, queryProgramValue);
            searchParams.Add(expect, expectValue);
            searchParams.Add(emailNotify, emailNotifyValue);
            searchParams.Add(jobName, jobNameValue);

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

            // 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 <= maxAttempts &&
                   info.Status != ServiceRequestStatus.Error &&
                   info.Status != ServiceRequestStatus.Ready)
            {
                ++attempt;
                if (isFetchSynchronous)
                {
                    info = service.GetRequestStatus(reqId);
                    Thread.Sleep(
                        info.Status == ServiceRequestStatus.Waiting ||
                        info.Status == ServiceRequestStatus.Queued
                        ? waitingTime * attempt : 0);
                }
                else
                {
                    Thread.Sleep(
                        info.Status == ServiceRequestStatus.Waiting ||
                        info.Status == ServiceRequestStatus.Queued ?
                        waitingTime * attempt : 0);
                    info = service.GetRequestStatus(reqId);
                }
            }

            IBlastParser blastXmlParser = new BlastXmlParser();

            responseResults = blastXmlParser.Parse(
                new StringReader(service.GetResult(reqId, searchParams)));


            Assert.IsNotNull(responseResults);
            List <BlastResult> eBlastResults =
                responseResults as List <BlastResult>;

            Assert.IsNotNull(eBlastResults);
            Assert.AreEqual(eBlastResults.Count.ToString(
                                (IFormatProvider)null), expectedResultCount);
            Assert.AreEqual(eBlastResults[0].Records.Count.ToString((
                                                                        IFormatProvider)null), expectedResultCount);
            BlastSearchRecord record = eBlastResults[0].Records[0];

            Assert.AreEqual(record.Statistics.Kappa.ToString(
                                (IFormatProvider)null), expectedKappaStatistics);
            Assert.AreEqual(record.Statistics.Lambda.ToString(
                                (IFormatProvider)null), expectedLambdaStatistics);
            Assert.AreEqual(record.Statistics.Entropy.ToString(
                                (IFormatProvider)null), expectedEntropyStatistics);
            Assert.AreEqual(record.Hits.Count.ToString(
                                (IFormatProvider)null), expectedHitsCount);
            Hit hit = record.Hits[0];

            Assert.AreEqual(hit.Accession, expectedAccession);
            Assert.AreEqual(hit.Length.ToString((IFormatProvider)null),
                            expectedLength);
            Assert.AreEqual(hit.Id.ToString((IFormatProvider)null),
                            expectedHitId);
            Assert.AreEqual(hit.Hsps.Count.ToString((IFormatProvider)null),
                            expectedResultCount);
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "BioHPC Blast BVT : Hits count '{0}'.", eBlastResults.Count));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "BioHPC Blast BVT : Accession '{0}'.", hit.Accession));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "BioHPC Blast BVT : Hit Id '{0}'.", hit.Id));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "BioHPC Blast BVT : Hits Count '{0}'.", hit.Hsps.Count));
            // Validate the results Synchronously with the results got earlier.
            if (isFetchSynchronous)
            {
                IList <BlastResult> syncBlastResults =
                    service.FetchResultsSync(reqId, searchParams) as List <BlastResult>;
                Assert.IsNotNull(syncBlastResults);
                if (null != eBlastResults[0].Records[0].Hits &&
                    0 < eBlastResults[0].Records[0].Hits.Count &&
                    null != eBlastResults[0].Records[0].Hits[0].Hsps &&
                    0 < eBlastResults[0].Records[0].Hits[0].Hsps.Count)
                {
                    Assert.AreEqual(
                        eBlastResults[0].Records[0].Hits[0].Hsps[0].QuerySequence,
                        syncBlastResults[0].Records[0].Hits[0].Hsps[0].QuerySequence);
                }
                else
                {
                    ApplicationLog.WriteLine(
                        "No significant hits found with the these parameters.");
                    Console.WriteLine(
                        "No significant hits found with the these parameters.");
                }
            }
        }