OpenMS  3.0.0
MascotRemoteQuery.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2022.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Andreas Bertsch, Daniel Jameson, Chris Bielow, Timo Sachsenberg $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 #include <QtCore/QObject>
39 #include <QtCore/QString>
40 #include <QtNetwork/QNetworkAccessManager>
41 #include <QTimer>
42 #include <QNetworkReply>
43 
44 
45 namespace OpenMS
46 {
57  public QObject,
58  public DefaultParamHandler
59  {
60  Q_OBJECT
61 
62 public:
63 
67  OPENMS_DLLAPI MascotRemoteQuery(QObject* parent = 0);
69 
71  OPENMS_DLLAPI ~MascotRemoteQuery() override ;
73 
75  OPENMS_DLLAPI void setQuerySpectra(const String& exp);
76 
78  OPENMS_DLLAPI const QByteArray& getMascotXMLResponse() const;
79 
81  OPENMS_DLLAPI bool hasError() const;
82 
84  OPENMS_DLLAPI const String& getErrorMessage() const;
85 
87  OPENMS_DLLAPI String getSearchIdentifier() const;
88 
90  OPENMS_DLLAPI void setExportDecoys(const bool b);
91 
93  OPENMS_DLLAPI const QByteArray& getMascotXMLDecoyResponse() const;
94 protected:
95 
96  OPENMS_DLLAPI void updateMembers_() override ;
97 
98 public slots:
99 
100  OPENMS_DLLAPI void run();
101 
102 private slots:
103 
105  OPENMS_DLLAPI void timedOut() const;
106 
108  OPENMS_DLLAPI void readResponse(QNetworkReply* reply);
109 
111  OPENMS_DLLAPI void downloadProgress(qint64 bytes_read, qint64 bytes_total);
112 
114  OPENMS_DLLAPI void uploadProgress(qint64 bytes_read, qint64 bytes_total);
115 
117  OPENMS_DLLAPI void followRedirect(QNetworkReply * reply);
118 
119 signals:
120 
122  OPENMS_DLLAPI void gotRedirect(QNetworkReply * reply);
123 
125  OPENMS_DLLAPI void done();
126 
127 private:
128 
130  void login();
131 
133  void execQuery();
134 
136  void getResults(QString results_path);
137 
139  OPENMS_DLLAPI MascotRemoteQuery& operator=(const MascotRemoteQuery& rhs);
140 
142  OPENMS_DLLAPI MascotRemoteQuery(const MascotRemoteQuery& rhs);
143 
145  OPENMS_DLLAPI void endRun_();
146 
152  void removeHostName_(QString& url);
153 
155  QUrl buildUrl_(std::string path);
156 
158  OPENMS_DLLAPI void logHeader_(const QNetworkRequest header, const String& what);
159 
161  OPENMS_DLLAPI void logHeader_(const QNetworkReply* header, const String& what);
162 
163  OPENMS_DLLAPI String getSearchIdentifierFromFilePath(const String& path) const;
164 
166  OPENMS_DLLAPI void readResponseHeader(const QNetworkReply* reply);
167 
168  QNetworkAccessManager* manager_;
169 
170  // Input / Output data
172  QByteArray mascot_xml_;
173  QByteArray mascot_decoy_xml_;
174 
175  // Internal data structures
176  QString cookie_;
178  QTimer timeout_;
180 
188  bool use_ssl_;
193 
194  bool export_decoys_ = false;
195  };
196 
197 }
198 
DefaultParamHandler.h
OpenMS::MascotRemoteQuery
Class which handles the communication between OpenMS and the Mascot server.
Definition: MascotRemoteQuery.h:56
QObject
OpenMS::MascotRemoteQuery::cookie_
QString cookie_
Definition: MascotRemoteQuery.h:176
OpenMS::MascotRemoteQuery::endRun_
void endRun_()
finish a run and emit "done"
OpenMS::MascotRemoteQuery::operator=
MascotRemoteQuery & operator=(const MascotRemoteQuery &rhs)
assignment operator
OpenMS::MascotRemoteQuery::requires_login_
bool requires_login_
Login required.
Definition: MascotRemoteQuery.h:186
OpenMS::MascotRemoteQuery::setQuerySpectra
void setQuerySpectra(const String &exp)
sets the query spectra, given in MGF file format
OpenMS::MascotRemoteQuery::run
void run()
OpenMS::MascotRemoteQuery::removeHostName_
void removeHostName_(QString &url)
Remove host name information from an url, e.g., "http://www.google.de/search" -> "search".
OpenMS::MascotRemoteQuery::MascotRemoteQuery
MascotRemoteQuery(QObject *parent=0)
default constructor
OpenMS::MascotRemoteQuery::export_decoys_
bool export_decoys_
Definition: MascotRemoteQuery.h:194
OpenMS::MascotRemoteQuery::to_
Int to_
Timeout after these many seconds.
Definition: MascotRemoteQuery.h:192
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::MascotRemoteQuery::login
void login()
login to Mascot server
OpenMS::MascotRemoteQuery::downloadProgress
void downloadProgress(qint64 bytes_read, qint64 bytes_total)
slot connected to signal downloadProgress
OpenMS::MascotRemoteQuery::getSearchIdentifierFromFilePath
String getSearchIdentifierFromFilePath(const String &path) const
OpenMS::MascotRemoteQuery::boundary_
String boundary_
boundary string that will be embedded into the HTTP requests
Definition: MascotRemoteQuery.h:190
OpenMS::MascotRemoteQuery::getSearchIdentifier
String getSearchIdentifier() const
returns the search number
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
OpenMS::MascotRemoteQuery::timedOut
void timedOut() const
slot connected to QTimer (timeout_)
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS::MascotRemoteQuery::use_ssl_
bool use_ssl_
Use SSL connection.
Definition: MascotRemoteQuery.h:188
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::MascotRemoteQuery::readResponseHeader
void readResponseHeader(const QNetworkReply *reply)
parse new response header
OpenMS::MascotRemoteQuery::timeout_
QTimer timeout_
Definition: MascotRemoteQuery.h:178
OpenMS::MascotRemoteQuery::buildUrl_
QUrl buildUrl_(std::string path)
helper function to build URL
OpenMS::MascotRemoteQuery::done
void done()
signal when class is done and results can be collected
OpenMS::MascotRemoteQuery::getErrorMessage
const String & getErrorMessage() const
returns the error message, if hasError can be used to check whether an error has occurred
OpenMS::MascotRemoteQuery::~MascotRemoteQuery
~MascotRemoteQuery() override
destructor
OpenMS::MascotRemoteQuery::setExportDecoys
void setExportDecoys(const bool b)
request export of decoy summary and decoys (note: internal decoy search must be enabled in the MGF fi...
OpenMS::MascotRemoteQuery::hasError
bool hasError() const
predicate which returns true if an error occurred during the query
OpenMS::MascotRemoteQuery::mascot_xml_
QByteArray mascot_xml_
Definition: MascotRemoteQuery.h:172
OpenMS::MascotRemoteQuery::logHeader_
void logHeader_(const QNetworkRequest header, const String &what)
Write HTTP header to error stream (for debugging)
OpenMS::MascotRemoteQuery::followRedirect
void followRedirect(QNetworkReply *reply)
slot connected to signal gotRedirect
OpenMS::MascotRemoteQuery::updateMembers_
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
OpenMS::MascotRemoteQuery::getMascotXMLResponse
const QByteArray & getMascotXMLResponse() const
returns the Mascot XML response which contains the identifications
OpenMS::MascotRemoteQuery::host_name_
String host_name_
Hostname of the mascot server.
Definition: MascotRemoteQuery.h:184
OpenMS::MascotRemoteQuery::search_identifier_
String search_identifier_
Definition: MascotRemoteQuery.h:179
OpenMS::MascotRemoteQuery::query_spectra_
String query_spectra_
Definition: MascotRemoteQuery.h:171
OpenMS::MascotRemoteQuery::getMascotXMLDecoyResponse
const QByteArray & getMascotXMLDecoyResponse() const
returns the Mascot XML response which contains the decoy identifications (note: setExportDecoys must ...
OpenMS::MascotRemoteQuery::execQuery
void execQuery()
execute query (upload file)
OpenMS::MascotRemoteQuery::error_message_
String error_message_
Definition: MascotRemoteQuery.h:177
OpenMS::MascotRemoteQuery::mascot_decoy_xml_
QByteArray mascot_decoy_xml_
Definition: MascotRemoteQuery.h:173
OpenMS::MascotRemoteQuery::server_path_
String server_path_
Path on mascot server.
Definition: MascotRemoteQuery.h:182
OpenMS::MascotRemoteQuery::getResults
void getResults(QString results_path)
download result file
OpenMS::MascotRemoteQuery::gotRedirect
void gotRedirect(QNetworkReply *reply)
signal when class got a redirect
OpenMS::MascotRemoteQuery::uploadProgress
void uploadProgress(qint64 bytes_read, qint64 bytes_total)
slot connected to signal uploadProgress
OpenMS::MascotRemoteQuery::readResponse
void readResponse(QNetworkReply *reply)
slot connected to the QNetworkAccessManager::finished signal
OpenMS::MascotRemoteQuery::manager_
QNetworkAccessManager * manager_
Definition: MascotRemoteQuery.h:168