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 
41 /**
42  * @todo write docs
43  */
44 namespace pappso
45 {
47 {
48  public:
49  XtandemError(const QString &message) throw() : PappsoException(message)
50  {
51  }
52 
53  virtual QException *
54  clone() const override
55  {
56  return new XtandemError(*this);
57  }
58 };
59 
60 class PMSPP_LIB_DECL TandemWrapperRun : public QObject
61 {
62  Q_OBJECT
63  public:
64  /** @brief prepare a tandem run
65  * @param tandem_binary file path to tandem.exe if not set, a default value is
66  * given in QSettings
67  * @param tmp_dir temporary directory, where to write mzXML file conversion if
68  * not set, a default value is given in QSettings
69  */
70  TandemWrapperRun(const QString &tandem_binary, const QString &tmp_dir);
71 
72  /** @brief run a tandem job
73  *
74  * The tandem input file *should* contain an additional input parameter called
75  * "spectrum, timstof MS2 filters". The value of this parameters *must*
76  * contain a string describing the FilterSuiteString to apply on TimsTOF MS2.
77  * A default value of "chargeDeconvolution|0.02dalton" is recommended for this
78  * additional tandem input parameter
79  *
80  * @param monitor user interface monitor
81  * @param tandem_input_file tandem xml input file
82  */
83  void run(UiMonitorInterface &monitor, const QString &tandem_input_file);
84 
85  void readTandemPresetFile(const QString &tandem_preset_file);
86 
87  /** @brief gets the list of filters used on MS2 spectrum
88  *
89  * @return string describing filters and associated parameters
90  */
91  QString getMs2FilterSuiteString() const;
92 
93  /**
94  * Destructor
95  */
97 
98  signals:
99  void tandemProgressMessage(QString message);
100 
101 
102  private:
103  void setTandemBinaryPath(const QString &tandem_binary_path);
104  const QString checkXtandemVersion(const QString &tandem_bin_path);
105  void wrapTandemInputFile(const QString &tandem_input_file);
106 
107  bool convertOrginalMsData2mzXmlData(const QString &origin,
108  const QString &target);
109 
110 
111  /** @brief run a tandem job
112  * @param tandem_input_file tandem xml input file
113  */
114  void runTandem(const QString &tandem_input_file);
115 
116  /** @brief tandem output modification
117  * tandem output is modified to contain the Bruker's file as input and
118  * centroidization parameters
119  * @param tmp_tandem_output raw tandem output filename
120  * @param final_tandem_output final destination file for modified tandem
121  * output
122  */
123  void writeFinalTandemOutput(const QString &tmp_tandem_output,
124  const QString &final_tandem_output,
125  const QString &original_msdata_file_name);
126 
127 
128  private slots:
129  void readyReadStandardOutput();
130  void readyReadStandardError();
131 
132  private:
134  QString m_tandemBinary;
136  QString m_tmpDir;
137  int m_maxTandemRunTimeMs =
138  1000; // If msecs is -1, this function will not time out.
139  QProcess *m_xtProcess = nullptr;
140 
141  std::shared_ptr<FilterSuiteString> msp_ms2FilterSuiteString = nullptr;
142 
143  QTemporaryDir *mpa_temporaryDirectory = nullptr;
144 
145  bool m_convertMzDataUsingSpectrumIndex = false;
146 };
147 } // 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