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/filtersuite.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  * @param tandem_input_file tandem xml input file
57  * @param output_stream standard output where to write tandem stdout
58  * @param error_stream standard error where to write tandem stderr
59  */
60  void run(const QString &tandem_input_file,
61  QTextStream &output_stream,
62  QTextStream &error_stream);
63 
64  void readTandemPresetFile(const QString &tandem_preset_file);
65 
66  /** @brief sets optional filters to use on MS2 spectrum
67  *
68  * @param ms2filter vector of filters applied on MS2 spectrums
69  */
70  void setMs2FilterSuite(const std::shared_ptr<FilterSuite> ms2filter);
71 
72 
73  /** @brief gets the list of filters used on MS2 spectrum
74  *
75  * @return vector of filters applied on MS2 spectrums
76  */
77  std::shared_ptr<FilterSuite> getMs2FilterSuite() 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;
117  QString m_tandemVersion;
118  QString m_tmpDir;
119  int m_maxTandemRunTimeMs = (60000 * 60 * 24); // 1 day
120  QProcess *m_xtProcess = nullptr;
121 
122  std::shared_ptr<FilterSuite> msp_ms2FilterSuite =
123  std::make_shared<FilterSuite>();
124 
125  QTextStream *mp_outputStream = nullptr;
126  QTextStream *mp_errorStream = nullptr;
127 
128  QTemporaryDir *mpa_temporaryDirectory = nullptr;
129 };
130 } // 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
Definition: tandemwrapperrun.h:62