libpappsomspp
Library for mass spectrometry
tandemwrapperrun.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/processing/tandemwrapper/tandemwrapperrun.h
3  * \date 25/01/2020
4  * \author Olivier Langella
5  * \brief actually does really run tandem directly on Bruker's data
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2020 Olivier Langella <Olivier.Langella@u-psud.fr>.
10  *
11  * This file is part of PAPPSOms-tools.
12  *
13  * PAPPSOms-tools is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms-tools is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25  *
26  ******************************************************************************/
27 
28 #pragma once
29 
30 #include <QDebug>
31 #include <QObject>
32 #include <QProcess>
33 #include <QTemporaryDir>
34 #include <QMutex>
35 
36 #include "../../exportinmportconfig.h"
37 #include "../../processing/filters/filtersuitestring.h"
38 #include "../uimonitor/uimonitorinterface.h"
39 #include "../../pappsoexception.h"
40 #include "../../types.h"
41 
42 /**
43  * @todo write docs
44  */
45 namespace pappso
46 {
48 {
49  public:
50  XtandemError(const QString &message) throw() : PappsoException(message)
51  {
52  }
53 
54  virtual QException *
55  clone() const override
56  {
57  return new XtandemError(*this);
58  }
59 };
60 
61 class PMSPP_LIB_DECL TandemWrapperRun : public QObject
62 {
63  Q_OBJECT
64  public:
65  /** @brief prepare a tandem run
66  * @param tandem_binary file path to tandem.exe if not set, a default value is
67  * given in QSettings
68  * @param tmp_dir temporary directory, where to write mzXML file conversion if
69  * not set, a default value is given in QSettings
70  */
71  TandemWrapperRun(const QString &tandem_binary, const QString &tmp_dir);
72 
73  /** @brief run a tandem job
74  *
75  * The tandem input file *should* contain an additional input parameter called
76  * "spectrum, timstof MS2 filters". The value of this parameters *must*
77  * contain a string describing the FilterSuiteString to apply on TimsTOF MS2.
78  * A default value of "chargeDeconvolution|0.02dalton" is recommended for this
79  * additional tandem input parameter
80  *
81  * @param monitor user interface monitor
82  * @param tandem_input_file tandem xml input file
83  */
84  void run(UiMonitorInterface &monitor, const QString &tandem_input_file);
85 
86  void readTandemPresetFile(const QString &tandem_preset_file);
87 
88  /** @brief gets the list of filters used on MS2 spectrum
89  *
90  * @return string describing filters and associated parameters
91  */
92  QString getMs2FilterSuiteString() const;
93 
94  /**
95  * Destructor
96  */
98 
99  signals:
100  void tandemProgressMessage(QString message);
101 
102 
103  private:
104  void setTandemBinaryPath(const QString &tandem_binary_path);
105  const QString checkXtandemVersion(const QString &tandem_bin_path);
106  void wrapTandemInputFile(const QString &tandem_input_file);
107 
108  bool convertOrginalMsData2mzXmlData(const QString &origin,
109  const QString &target);
110 
111 
112  /** @brief run a tandem job
113  * @param tandem_input_file tandem xml input file
114  */
115  void runTandem(const QString &tandem_input_file);
116 
117  /** @brief tandem output modification
118  * tandem output is modified to contain the Bruker's file as input and
119  * centroidization parameters
120  * @param tmp_tandem_output raw tandem output filename
121  * @param final_tandem_output final destination file for modified tandem
122  * output
123  */
124  void writeFinalTandemOutput(const QString &tmp_tandem_output,
125  const QString &final_tandem_output,
126  const QString &original_msdata_file_name);
127 
128 
129  private slots:
130  void readyReadStandardOutput();
131  void readyReadStandardError();
132 
133  private:
135  QString m_tandemBinary;
137  QString m_tmpDir;
138  int m_maxTandemRunTimeMs =
139  1000; // If msecs is -1, this function will not time out.
140  QProcess *m_xtProcess = nullptr;
141 
142  std::shared_ptr<FilterSuiteString> msp_ms2FilterSuiteString = nullptr;
143 
144  QTemporaryDir *mpa_temporaryDirectory = nullptr;
145 
146  bool m_convertMzDataUsingSpectrumIndex = false;
147 
149 
150  qint64 m_conversionTime=0;
151 };
152 } // namespace pappso
PappsoException(const QString &message)
UiMonitorInterface * mp_monitor
void tandemProgressMessage(QString message)
XtandemError(const QString &message)
virtual QException * clone() const override
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
MzFormat
Definition: types.h:108
@ unknown
unknown format