OpenMS
MascotRemoteQuery.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Andreas Bertsch, Daniel Jameson, Chris Bielow, Timo Sachsenberg $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 #include <QtCore/QObject>
13 #include <QtCore/QString>
14 #include <QtNetwork/QNetworkAccessManager>
15 #include <QTimer>
16 #include <QNetworkReply>
17 
18 
19 namespace OpenMS
20 {
31  public QObject,
32  public DefaultParamHandler
33  {
34  Q_OBJECT
35 
36 public:
37 
42  OPENMS_DLLAPI MascotRemoteQuery(QObject* parent = 0);
43 
45  OPENMS_DLLAPI MascotRemoteQuery& operator=(const MascotRemoteQuery& rhs) = delete;
46 
48  OPENMS_DLLAPI MascotRemoteQuery(const MascotRemoteQuery& rhs) = delete;
49 
51  OPENMS_DLLAPI ~MascotRemoteQuery() override;
53 
55  OPENMS_DLLAPI void setQuerySpectra(const String& exp);
56 
58  OPENMS_DLLAPI const QByteArray& getMascotXMLResponse() const;
59 
61  OPENMS_DLLAPI const QByteArray& getMascotXMLDecoyResponse() const;
62 
64  OPENMS_DLLAPI bool hasError() const;
65 
67  OPENMS_DLLAPI const String& getErrorMessage() const;
68 
70  OPENMS_DLLAPI String getSearchIdentifier() const;
71 
73  OPENMS_DLLAPI void setExportDecoys(const bool b);
74 
75 protected:
76 
77  OPENMS_DLLAPI void updateMembers_() override;
78 
79 public slots:
80 
81  OPENMS_DLLAPI void run();
82 
83 private slots:
84 
86  OPENMS_DLLAPI void timedOut() const;
87 
89  OPENMS_DLLAPI void readResponse(QNetworkReply* reply);
90 
92  OPENMS_DLLAPI void downloadProgress(qint64 bytes_read, qint64 bytes_total);
93 
95  OPENMS_DLLAPI void uploadProgress(qint64 bytes_read, qint64 bytes_total);
96 
98  OPENMS_DLLAPI void followRedirect(QNetworkReply * reply);
99 
100 signals:
101 
103  OPENMS_DLLAPI void gotRedirect(QNetworkReply * reply);
104 
106  OPENMS_DLLAPI void done();
107 
108 private:
109 
111  void login();
112 
114  void execQuery();
115 
117  void getResults(const QString& results_path);
118 
120  OPENMS_DLLAPI void endRun_();
121 
127  void removeHostName_(QString& url);
128 
130  QUrl buildUrl_(const std::string& path);
131 
133  OPENMS_DLLAPI void logHeader_(const QNetworkRequest& header, const String& what);
134 
136  OPENMS_DLLAPI void logHeader_(const QNetworkReply* header, const String& what);
137 
138  OPENMS_DLLAPI String getSearchIdentifierFromFilePath(const String& path) const;
139 
141  OPENMS_DLLAPI void readResponseHeader(const QNetworkReply* reply);
142 
143  QNetworkAccessManager* manager_;
144 
145  // Input / Output data
147  QByteArray mascot_xml_;
148  QByteArray mascot_decoy_xml_;
149 
150  // Internal data structures
151  QString cookie_;
153  QTimer timeout_;
155 
163  bool use_ssl_;
168 
169  bool export_decoys_ = false;
170  };
171 
172 }
173 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Class which handles the communication between OpenMS and the Mascot server.
Definition: MascotRemoteQuery.h:33
void gotRedirect(QNetworkReply *reply)
signal when class got a redirect
void execQuery()
execute query (upload file)
void followRedirect(QNetworkReply *reply)
slot connected to signal gotRedirect
void readResponse(QNetworkReply *reply)
slot connected to the QNetworkAccessManager::finished signal
bool export_decoys_
Definition: MascotRemoteQuery.h:169
String getSearchIdentifier() const
returns the search number
String query_spectra_
Definition: MascotRemoteQuery.h:146
String search_identifier_
Definition: MascotRemoteQuery.h:154
QNetworkAccessManager * manager_
Definition: MascotRemoteQuery.h:143
void logHeader_(const QNetworkReply *header, const String &what)
Write HTTP header to error stream (for debugging)
const String & getErrorMessage() const
returns the error message, if hasError can be used to check whether an error has occurred
String boundary_
boundary string that will be embedded into the HTTP requests
Definition: MascotRemoteQuery.h:165
String server_path_
Path on mascot server.
Definition: MascotRemoteQuery.h:157
void readResponseHeader(const QNetworkReply *reply)
parse new response header
String error_message_
Definition: MascotRemoteQuery.h:152
QTimer timeout_
Definition: MascotRemoteQuery.h:153
QByteArray mascot_decoy_xml_
Definition: MascotRemoteQuery.h:148
const QByteArray & getMascotXMLResponse() const
returns the Mascot XML response which contains the identifications
void uploadProgress(qint64 bytes_read, qint64 bytes_total)
slot connected to signal uploadProgress
MascotRemoteQuery & operator=(const MascotRemoteQuery &rhs)=delete
assignment operator
const QByteArray & getMascotXMLDecoyResponse() const
returns the Mascot XML response which contains the decoy identifications (note: setExportDecoys must ...
bool hasError() const
predicate which returns true if an error occurred during the query
void getResults(const QString &results_path)
download result file
void logHeader_(const QNetworkRequest &header, const String &what)
Write HTTP header to error stream (for debugging)
void endRun_()
finish a run and emit "done"
void setQuerySpectra(const String &exp)
sets the query spectra, given in MGF file format
String getSearchIdentifierFromFilePath(const String &path) const
Int to_
Timeout after these many seconds.
Definition: MascotRemoteQuery.h:167
MascotRemoteQuery(QObject *parent=0)
default constructor
void done()
signal when class is done and results can be collected
void timedOut() const
slot connected to QTimer (timeout_)
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
~MascotRemoteQuery() override
destructor
QByteArray mascot_xml_
Definition: MascotRemoteQuery.h:147
bool use_ssl_
Use SSL connection.
Definition: MascotRemoteQuery.h:163
bool requires_login_
Login required.
Definition: MascotRemoteQuery.h:161
QUrl buildUrl_(const std::string &path)
helper function to build URL
void downloadProgress(qint64 bytes_read, qint64 bytes_total)
slot connected to signal downloadProgress
void setExportDecoys(const bool b)
request export of decoy summary and decoys (note: internal decoy search must be enabled in the MGF fi...
void removeHostName_(QString &url)
Remove host name information from an url, e.g., "http://www.google.de/search" -> "search".
String host_name_
Hostname of the mascot server.
Definition: MascotRemoteQuery.h:159
void login()
login to Mascot server
QString cookie_
Definition: MascotRemoteQuery.h:151
MascotRemoteQuery(const MascotRemoteQuery &rhs)=delete
copy constructor
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:76
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22