/// <summary> /// Submit the search request with the user supplied configuration parameters /// and sequence. Implementation should make use of the Bio.IO formatters /// to convert the sequence into the web interface compliant sequence format. /// This method performs parameter validation and throw Exception on invalid input. /// </summary> /// <remarks>An exception is thrown if the request does not succeed.</remarks> /// <param name="sequence">The sequence to search with</param> /// <param name="parameters">Blast input parameters</param> /// <returns>Request Identifier</returns> public string SubmitRequest(ISequence sequence, BlastParameters parameters) { if (null == sequence) { throw new ArgumentNullException("sequence"); } if (null == parameters) { throw new ArgumentNullException("parameters"); } string requestIdentifier; // Create blast client object if not created already or if connection string has changed. if (blastClient == null || blastClient.Endpoint.Address.Uri != configuration.Connection) { InitializeBlastClient(); } // Validate the Parameter ParameterValidationResult valid = ValidateParameters(parameters); if (!valid.IsValid) { throw new Exception(valid.ValidationErrors); } // Submit the job to server BlastSerivceRequest blastRequest = GetRequestParameter( sequence, parameters); try { requestIdentifier = blastClient.SubmitJob(blastRequest).ToString(); } catch (FaultException <BlastFault> fault) { throw new Exception(fault.Message); } // Only if the event is registered, invoke the thread if (null != RequestCompleted) { BlastThreadParameter threadParameter = new BlastThreadParameter( requestIdentifier, sequence, parameters); // Start the BackGroundThread to check the status of job workerThread = new BackgroundWorker(); workerThread.WorkerSupportsCancellation = true; workerThread.DoWork += new DoWorkEventHandler(ProcessRequestThread); workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedRequestThread); workerThread.RunWorkerAsync(threadParameter); } return(requestIdentifier); }
/// <summary> /// Get the blast service request object with all the request parameter set /// </summary> /// <param name="sequence">Input sequece</param> /// <param name="parameters">Blast parameters</param> /// <returns>Blast service request object</returns> private static BlastSerivceRequest GetRequestParameter( ISequence sequence, BlastParameters parameters) { BlastSerivceRequest blastParameter = new BlastSerivceRequest(); // Sets the format of output expected from Azure Blast service blastParameter.OptionM = OPTIONMVALUE; // Sets the name of Job owner blastParameter.Owner = Resources.OWNERVALUE; blastParameter.ParitionNumber = PARTITIONVALUE; // Convert string to byte ISequenceFormatter formatter = new FastaFormatter(); string inputContent = formatter.FormatString(sequence); ASCIIEncoding asciiEncoding = new ASCIIEncoding(); blastParameter.InputContent = asciiEncoding.GetBytes(inputContent); // Other parameters // Set the Title of Job blastParameter.Title = sequence.ID; // Name of the database to be searched in blastParameter.DatabaseName = parameters.Settings[PARAMETERDATABASE]; // Type of search program to be executed blastParameter.ProgramName = parameters.Settings[PARAMETERPROGRAM]; return(blastParameter); }
/// <summary> /// Submit the search request with the user supplied configuration parameters /// and sequence. Implementation should make use of the Bio.IO formatters /// to convert the sequence into the web interface compliant sequence format. /// This method performs parameter validation and throw Exception on invalid input. /// </summary> /// <remarks>An exception is thrown if the request does not succeed.</remarks> /// <param name="sequence">The sequence to search with</param> /// <param name="parameters">Blast input parameters</param> /// <returns>Request Identifier</returns> public string SubmitRequest(ISequence sequence, BlastParameters parameters) { if (null == sequence) { throw new ArgumentNullException("sequence"); } if (null == parameters) { throw new ArgumentNullException("parameters"); } string requestIdentifier; // Validate the Parameter ParameterValidationResult valid = ValidateParameters(parameters); if (!valid.IsValid) { throw new Exception(valid.ValidationErrors); } // Submit the job to server BlastSerivceRequest blastRequest = GetRequestParameter( sequence, parameters); try { requestIdentifier = _blastClient.SubmitJob(blastRequest).ToString(); } catch (FaultException <BlastFault> fault) { throw new Exception(fault.Detail.Detail); } // Only if the event is registered, invoke the thread if (null != RequestCompleted) { ThreadParameter threadParameter = new ThreadParameter( requestIdentifier, sequence, parameters); // Start the BackGroundThread to check the status of job _workerThread = new BackgroundWorker(); _workerThread.WorkerSupportsCancellation = true; _workerThread.DoWork += new DoWorkEventHandler(ProcessRequestThread); _workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedRequestThread); _workerThread.RunWorkerAsync(threadParameter); } return(requestIdentifier); }