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 
35 #include "../../exportinmportconfig.h"
36 #include "../../processing/filters/filtersuitestring.h"
37 
38 /**
39  * @todo write docs
40  */
41 namespace pappso
42 {
43 class PMSPP_LIB_DECL TandemWrapperRun : public QObject
44 {
45  Q_OBJECT
46  public:
47  /** @brief prepare a tandem run
48  * @param tandem_binary file path to tandem.exe if not set, a default value is
49  * given in QSettings
50  * @param tmp_dir temporary directory, where to write mzXML file conversion if
51  * not set, a default value is given in QSettings
52  */
53  TandemWrapperRun(const QString &tandem_binary, const QString &tmp_dir);
54 
55  /** @brief run a tandem job
56  *
57  * The tandem input file *should* contain an additional input parameter called
58  * "spectrum, timstof MS2 filters". The value of this parameters *must*
59  * contain a string describing the FilterSuiteString to apply on TimsTOF MS2.
60  * A default value of "chargeDeconvolution|0.02dalton" is recommended for this
61  * additional tandem input parameter
62  *
63  * @param tandem_input_file tandem xml input file
64  * @param output_stream standard output where to write tandem stdout
65  * @param error_stream standard error where to write tandem stderr
66  */
67  void run(const QString &tandem_input_file,
68  QTextStream &output_stream,
69  QTextStream &error_stream);
70 
71  void readTandemPresetFile(const QString &tandem_preset_file);
72 
73  /** @brief gets the list of filters used on MS2 spectrum
74  *
75  * @return string describing filters and associated parameters
76  */
77  QString getMs2FilterSuiteString() const;
78 
79  /**
80  * Destructor
81  */
83 
84  private:
85  void setTandemBinaryPath(const QString &tandem_binary_path);
86  bool shouldIstop();
87  const QString checkXtandemVersion(const QString &tandem_bin_path);
88  void wrapTandemInputFile(const QString &tandem_input_file);
89 
90  void convertOrginalMsData2mzXmlData(const QString &origin,
91  const QString &target) const;
92 
93 
94  /** @brief run a tandem job
95  * @param tandem_input_file tandem xml input file
96  */
97  void runTandem(const QString &tandem_input_file);
98 
99  /** @brief tandem output modification
100  * tandem output is modified to contain the Bruker's file as input and
101  * centroidization parameters
102  * @param tmp_tandem_output raw tandem output filename
103  * @param final_tandem_output final destination file for modified tandem
104  * output
105  */
106  void writeFinalTandemOutput(const QString &tmp_tandem_output,
107  const QString &final_tandem_output,
108  const QString &original_msdata_file_name);
109 
110 
111  private slots:
112  void readyReadStandardOutput();
113  void readyReadStandardError();
114 
115  private:
116  QString m_tandemBinary;
118  QString m_tmpDir;
119  int m_maxTandemRunTimeMs = (60000 * 60 * 24); // 1 day
120  QProcess *m_xtProcess = nullptr;
121 
122  std::shared_ptr<FilterSuiteString> msp_ms2FilterSuiteString =
123  std::make_shared<pappso::FilterSuiteString>(
124  "chargeDeconvolution|0.02dalton");
125 
126  QTextStream *mp_outputStream = nullptr;
127  QTextStream *mp_errorStream = nullptr;
128 
129  QTemporaryDir *mpa_temporaryDirectory = nullptr;
130 };
131 } // namespace pappso
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition: exportinmportconfig.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
pappso::TandemWrapperRun::m_tandemVersion
QString m_tandemVersion
Definition: tandemwrapperrun.h:117
pappso::TandemWrapperRun
Definition: tandemwrapperrun.h:44
pappso::TandemWrapperRun::m_tmpDir
QString m_tmpDir
Definition: tandemwrapperrun.h:118
pappso::TandemWrapperRun::m_tandemBinary
QString m_tandemBinary
Definition: tandemwrapperrun.h:116