Used for submitting searches to a Mascot server and retrieving search results using HTTP(S). More...
#include <ms_http_client_search.hpp>
Public Types | |
enum | DownloadOption { DO_NORMAL = 0 , DO_WITH_IONS = 1 } |
Definitions for downloading results. More... | |
enum | ReportTopSpecialValues { RT_auto = 0 , RT_file = -1 } |
Definitions for special 'report top' values when requesting results in XML format. More... | |
enum | SearchStatusCode { SS_UNKNOWN , SS_ASSIGNED , SS_QUEUED , SS_RUNNING , SS_COMPLETE , SS_ERROR , SS_SEARCH_CONTROL_ERROR } |
Definitions for the various states possible when querying about a running Mascot search. More... | |
enum | UploadResponseCode { UR_SUCCESS , UR_ACCESS_DENIED , UR_INVALID_TASKID , UR_NO_RESULT_FILENAME , UR_NO_RESULT_FILE , UR_FILE_ALREADY_EXISTS , UR_ERROR } |
Definitions for the various responses possible when uploading data to Mascot. More... | |
Public Member Functions | |
ms_http_client_search (const ms_http_client_search &src) | |
ms_http_client_search (ms_http_client_session &session, const std::string &searchTaskId) | |
Access previously run search results. | |
virtual | ~ms_http_client_search () |
Destructor;. | |
void | appendErrors (const ms_errors &src) |
Copies all errors from another instance and appends them at the end of own list. | |
void | clearAllErrors () |
Remove all errors from the current list of errors. | |
void | copyFrom (const ms_errors *right) |
Use this member to make a copy of another instance. | |
void | copyFrom (const ms_http_client_search *right) |
bool | downloadDaemonResultsFile (std::string filename, ms_http_helper_progress &progress) |
Download the summary results of a search in the format used by Mascot Daemon. | |
bool | downloadPercolatorFile (std::string filename, ms_http_helper_progress &progress) |
Download the Percolator input and output files for the associated search. | |
bool | downloadResultsFile (std::string filename, ms_http_helper_progress &progress, DownloadOption options=DO_WITH_IONS) |
Download the results in dat28 (MIME) format. | |
bool | downloadResultsFileMSR (std::string filename, ms_http_helper_progress &progress, DownloadOption options=DO_WITH_IONS) |
Download the results in Mascot Search Results (MSR) format. | |
bool | downloadXmlResultsFile (std::string filename, ms_http_helper_progress &progress, int reportTop=RT_auto) |
Download the results of the search in XML format. | |
const ms_errs * | getErrorHandler () const |
Retrive the error object using this function to get access to all errors and error parameters. | |
int | getLastError () const |
Return the error description of the last error that occurred. | |
std::string | getLastErrorString () const |
Return the error description of the last error that occurred. | |
bool | getResultsFileName (std::string &returnFileName) |
Return the path to the result file on the server (usually relative to the cgi directory). | |
std::string | getSearchTaskID () const |
Get the task ID of the associated Mascot search. | |
std::string | getSessionID () const |
Get the associated session ID. | |
bool | getStage (std::string &stage, int &step) |
Return the current stage and step of the search (Mascot 2.8.1 or later required). | |
bool | getStatus (SearchStatusCode &returnCode, int &statusValue) |
Return the current status of the search. | |
bool | isValid () const |
Call this function to determine if there have been any errors. | |
ms_http_client_search & | operator= (const ms_http_client_search &right) |
std::string | sessionId () const |
Get the associated session ID. | |
bool | uploadDistillerXmlResultsFile (std::string filename, UploadResponseCode &responseCode, std::string &responseText) |
Upload a Mascot Distiller quantitation XML file to the server. | |
Used for submitting searches to a Mascot server and retrieving search results using HTTP(S).
Use ms_http_client_search to follow the progress of a new search as it runs on the Mascot server and to retrieve the results from both new searches and old searches stored on the server.
The Mascot search must be run on the server within a Mascot session created by ms_http_client_session.
A previous search can be accessed by constructing a ms_http_client_search with a task identifier.
enum DownloadOption |
Definitions for downloading results.
See Using enumerated values and static const ints in Perl, Java, Python and C#.
Definitions for special 'report top' values when requesting results in XML format.
Otherwise can use a small positive integer (eg 1..50) See Using enumerated values and static const ints in Perl, Java, Python and C#.
Enumerator | |
---|---|
RT_auto | Automatically determine the number of protein hits included in the report. |
RT_file | Honour the number of hits specified when the search was submitted. |
enum SearchStatusCode |
Definitions for the various states possible when querying about a running Mascot search.
See Using enumerated values and static const ints in Perl, Java, Python and C#.
Enumerator | |
---|---|
SS_UNKNOWN | The search task ID was not recognised as a recent Mascot task. |
SS_ASSIGNED | The search task has been assigned but no search has been submitted. |
SS_QUEUED | The search has been submitted, but it has been queued by the server. |
SS_RUNNING | The search has started. The approximate percentage that has been completed is available. |
SS_COMPLETE | The search has completed. |
SS_ERROR | An error occurred when running the search. The Mascot error number is available from the getStatus call. |
SS_SEARCH_CONTROL_ERROR | An error has occurred in the Mascot server application trying to get the search status. The error code is available and is documented in the Mascot Installation and Setup Manual (For example, ERR_TASKID_FAILOPEN = 1) |
enum UploadResponseCode |
Definitions for the various responses possible when uploading data to Mascot.
See Using enumerated values and static const ints in Perl, Java, Python and C#.
ms_http_client_search | ( | ms_http_client_session & | session, |
const std::string & | searchTaskId | ||
) |
Access previously run search results.
This constructor does not validate the searchTaskId or session and does not call any scripts on the Mascot Server. It is recommended that getStatus() is called before calling other functions so that the searchTaskId and session can be validated.
session | The associated session object. |
searchTaskId | The Mascot task identifier used for the associated search. |
|
virtual |
Destructor;.
Called automatically.
ms_http_client_search | ( | const ms_http_client_search & | src | ) |
src | is the source to initialise from |
|
inherited |
Copies all errors from another instance and appends them at the end of own list.
src | The object to copy the errors across from. See Maintaining object references: two rules of thumb. |
|
inherited |
Remove all errors from the current list of errors.
The list of 'errors' can include fatal errors, warning messages, information messages and different levels of debugging messages.
All messages are accumulated into a list in this object, until clearAllErrors() is called.
See Error Handling.
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
void copyFrom | ( | const ms_http_client_search * | right | ) |
The session object is copied, it is not created anew, cf the other constructors
right | is the source to initialise from |
bool downloadDaemonResultsFile | ( | std::string | filename, |
ms_http_helper_progress & | progress | ||
) |
Download the summary results of a search in the format used by Mascot Daemon.
filename | The name of the local file for the results to be written to. |
progress | The progress information is maintained as the data is downloaded from the server. The download may be aborted by calling setAbort. See Maintaining object references: two rules of thumb. |
bool downloadPercolatorFile | ( | std::string | filename, |
ms_http_helper_progress & | progress | ||
) |
Download the Percolator input and output files for the associated search.
filename | The name of the local file for the results to be written to. |
progress | The progress information is maintained as the data is downloaded from the server. The download may be aborted by calling setAbort. See Maintaining object references: two rules of thumb. |
bool downloadResultsFile | ( | std::string | filename, |
ms_http_helper_progress & | progress, | ||
DownloadOption | options = DO_WITH_IONS |
||
) |
Download the results in dat28 (MIME) format.
It is safest to call getStatus() before calling this function to validate the searchTaskId, because this function has more limited error reporting.
The results data is downloaded as dat28 (MIME) format file. This is the F1234.dat format created by Mascot Server 2.8 and earlier. See ms_http_client_search::downloadResultsFileMSR() for downloading the data in the Mascot Search Results (MSR) format, introduced in Mascot Server 3.0.
Downloading can fail if the task ID doesn't exist or there is some other server-side problem. These are reported as "problem=" lines by Mascot. In this case, downloadResultsFile() saves the text in filename and returns true (not false!) because the HTTP(S) transfer did succeed.
The caller should always check the file contents: 1) If it's a gzipped file, uncompress it; 2) if it starts with "problem=", report the error string; and 3) finally, use ms_mascotresfilebase::resfileType() to detect the file type.
Error conditions for HTTP(S) transfer:
filename | The name of the local file for the results to be written to. |
progress | The progress information is maintained as the data is downloaded from the server. The download may be aborted by calling setAbort. See Maintaining object references: two rules of thumb. |
options | This contains the bit flags that controls how the file will be downloaded. It should be DO_NORMAL or a bitwise accumulation (boolean OR) of the other flags. |
bool downloadResultsFileMSR | ( | std::string | filename, |
ms_http_helper_progress & | progress, | ||
DownloadOption | options = DO_WITH_IONS |
||
) |
Download the results in Mascot Search Results (MSR) format.
It is safest to call getStatus() before calling this function to validate the searchTaskId. This function has more limited error reporting.
The results data is saved as Mascot Search Results (MSR) file. This is an SQLite database, introduced in Mascot Server 3.0. See ms_http_client_search::downloadResultsFile() for downloading the data in the traditional, dat28 (MIME) format.
The data sent by the server is an SQL dump, which is saved in a temporary file in the same location as filename. If download succeeds, the MSR file is restored from the SQL dump and saved as filename. The temporary file is removed in both cases.
Downloading the results as MSR may fail if 1) the server is Mascot Server 2.8 or earlier or 2) if creating MSR files has been disabled by a configuration option. In this case, try ms_http_client_search::downloadResultsFile(), which should always succeed.
Downloading can fail if the task ID doesn't exist or there is some other server-side problem. These are reported as "problem=" lines by Mascot. In this case, downloadResultsFileMSR() reports the problem string as a fatal error and returns false. Note: This behaviour is different from downloadResultsFile(), which saves string in the output file and returns true if there is a "problem=" line.
The caller should always check the file contents using ms_mascotresfilebase::resfileType() to confirm it is an MSR file.
Error conditions for HTTP(S) transfer:
Error conditions for restoring the file from the SQL dump:
filename | The name of the local file for the results to be written to. |
progress | Progress information for the data downloaded from the server. The download and post-processing may be aborted by calling setAbort. See Maintaining object references: two rules of thumb. |
options | This contains the bit flags that controls how the file will be downloaded. It should be DO_NORMAL or a bitwise accumulation (boolean OR) of the other flags. |
bool downloadXmlResultsFile | ( | std::string | filename, |
ms_http_helper_progress & | progress, | ||
int | reportTop = RT_auto |
||
) |
Download the results of the search in XML format.
Use of this function is deprecated. Use downloadResultsFile instead.
filename | The name of the local file for the results to be written to. |
progress | The progress information is maintained as the data is downloaded from the server. The download may be aborted by calling setAbort. See Maintaining object references: two rules of thumb. |
reportTop | The number of protein hits to include in the results. |
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
bool getResultsFileName | ( | std::string & | returnFileName | ) |
Return the path to the result file on the server (usually relative to the cgi directory).
The function is implemented by calling ms_http_helper::httpGetString with the command:
client.pl?result_file_name&task_id=searchTaskId
If the function fails because an invalid searchTaskId has been set, then the function will return false, returnFileName will be empty and the ms_errs::ERR_MSP_HTTP_GETRESULTSFILENAME error will be set.
It is safest to call getStatus() before calling this function to validate the searchTaskId etc. because this function has more limited error reporting.
See Multiple return values in Perl, Java, Python and C#.
[out] | returnFileName | Returns the path to the result file on the server (usually relative to the cgi directory). |
std::string getSearchTaskID | ( | ) | const |
Get the task ID of the associated Mascot search.
std::string getSessionID | ( | ) | const |
Get the associated session ID.
bool getStage | ( | std::string & | stage, |
int & | step | ||
) |
Return the current stage and step of the search (Mascot 2.8.1 or later required).
Can be called regularly while a submitted search is runing in order to determine search stage.
The function is implemented by calling ms_http_helper::httpGetString with the command:
client.pl?status_current_stage&task_id=searchTaskId
If the function fails because an invalid searchTaskId has been set, or if the Mascot Server version is earlier than 2.8.1 then the function will return false, stage will be empty and step set to -1 and the ms_errs::ERR_MSP_HTTP_GETSEARCHSTAGE error will be set.
It is safest to call getStatus() before calling this function to validate the searchTaskId etc. because this function has more limited error reporting.
See Multiple return values in Perl, Java, Python and C#.
[out] | stage | Returns the search stage text |
[out] | step | Returns the search stage step |
bool getStatus | ( | SearchStatusCode & | returnCode, |
int & | statusValue | ||
) |
Return the current status of the search.
Can be called regularly while a submitted search is runing in order to determine status.
The function is implemented by calling ms_http_helper::httpGetString with the command:
client.pl?status&task_id=searchTaskId
The value returned in statusValue depends on the returnCode:
See Multiple return values in Perl, Java, Python and C#.
[out] | returnCode | Returns the current status code of the search task. |
[out] | statusValue | Returns an optional value depending on the returnCode. |
|
inherited |
Call this function to determine if there have been any errors.
This will return true unless there have been any fatal errors.
See Error Handling.
ms_http_client_search & operator= | ( | const ms_http_client_search & | right | ) |
right | is the source to initialise from |
|
inline |
bool uploadDistillerXmlResultsFile | ( | std::string | filename, |
ms_http_client_search::UploadResponseCode & | responseCode, | ||
std::string & | responseText | ||
) |
Upload a Mascot Distiller quantitation XML file to the server.
Uploads a Mascot Distiller quantitation XML file to the Mascot Server.
See Multiple return values in Perl, Java, Python and C#.
[in] | filename | The path of the file to be uploaded. |
[out] | responseCode | If the return value is true then this should be checked to see if the upload was accepted as valid. |
[out] | responseText | The response from the Mascot server. |