/// <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 = string.Empty; // Validate the Parameter ParameterValidationResult valid = ValidateParameters(parameters); if (!valid.IsValid) { throw new Exception(valid.ValidationErrors); } // Submit the job to server inputParams blastRequest = GetRequestParameter( sequence, parameters); blastRequest.appxml = APPXMLYES; blastRequest.async = true; data[] mydata = new data[1]; mydata[0] = new data(); mydata[0].type = SEQUENCETYPE; mydata[0].content = sequence.ToString(); requestIdentifier = _blastClient.runWUBlast(blastRequest, mydata); // 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); }
/// <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 inputParams GetRequestParameter( ISequence sequence, BlastParameters parameters) { inputParams blastParameter = new inputParams(); // check required parameters: blastParameter.database = parameters.Settings[PARAMETERDATABASE]; // force program to uppercase, per EBI docs (though the service seems // to work fine regardless of the case of this parameter) blastParameter.program = parameters.Settings[PARAMETERPROGRAM].ToUpper(); // note: query is not part of the inputParams class, so the caller will // need to handle it separately. blastParameter.email = parameters.Settings[PARAMETEREMAIL]; // apply any addition validation logic and set remaining supported parameters: // validate filters here, since QBLAST uses a different set: if (parameters.Settings.ContainsKey(PARAMETERFILTER)) { blastParameter.filter = parameters.Settings[PARAMETERFILTER]; } if (parameters.Settings.ContainsKey(PARAMETERALIGNMENTS)) { blastParameter.numal = (int?)int.Parse(parameters.Settings[PARAMETERALIGNMENTS]); } if (parameters.Settings.ContainsKey(PARAMETERMATRIXNAME)) { blastParameter.matrix = parameters.Settings[PARAMETERMATRIXNAME]; } if (parameters.Settings.ContainsKey(PARAMETEREXPECT)) { blastParameter.exp = (float?)float.Parse(parameters.Settings[PARAMETEREXPECT]); } return(blastParameter); }
/// <summary> /// Get the blast service request object with all the request parameter set /// </summary> /// <param name="parameters">Blast parameters</param> /// <returns>Blast service request object</returns> private static inputParams GetRequestParameter( BlastParameters parameters) { inputParams blastParameter = new inputParams(); // check required parameters: blastParameter.database = parameters.Settings[ParameterDatabase]; // force program to uppercase, per EBI docs (though the service seems // to work fine regardless of the case of this parameter) blastParameter.program = parameters.Settings[ParameterProgram].ToUpperInvariant(); // note: query is not part of the inputParams class, so the caller will // need to handle it separately. blastParameter.email = parameters.Settings[ParameterEmail]; // apply any addition validation logic and set remaining supported parameters: // validate filters here, since QBLAST uses a different set: if (parameters.Settings.ContainsKey(ParameterFilter)) { blastParameter.filter = parameters.Settings[ParameterFilter]; } if (parameters.Settings.ContainsKey(ParameterAlignments)) { blastParameter.numal = (int?)int.Parse(parameters.Settings[ParameterAlignments], CultureInfo.InvariantCulture); } if (parameters.Settings.ContainsKey(ParameterMatrixName)) { blastParameter.matrix = parameters.Settings[ParameterMatrixName]; } if (parameters.Settings.ContainsKey(ParameterExpect)) { blastParameter.exp = (float?)float.Parse(parameters.Settings[ParameterExpect], CultureInfo.InvariantCulture); } return(blastParameter); }
/// <summary> /// Submit the search request with the user supplied configuration parameters /// and sequence. Implementation should make use of the MBF.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"); } if (!string.IsNullOrEmpty(Configuration.EmailAddress)) { if (!parameters.Settings.ContainsKey(ParameterEmail)) { parameters.Add(ParameterEmail, Configuration.EmailAddress); } } string requestIdentifier = string.Empty; // Validate the Parameter ParameterValidationResult valid = ValidateParameters(parameters); if (!valid.IsValid) { throw new Exception(valid.ValidationErrors); } // Submit the job to server inputParams blastRequest = GetRequestParameter(parameters); blastRequest.appxml = AppXmlYes; blastRequest.async = true; data[] mydata = new data[1]; mydata[0] = new data(); mydata[0].type = SequenceType; FastaFormatter formatter = new FastaFormatter(); mydata[0].content = formatter.FormatString(sequence); requestIdentifier = _blastClient.runWUBlast(blastRequest, mydata); // 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); }