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 "../../exportinmportconfig.h"
35 
36 /**
37  * @todo write docs
38  */
39 namespace pappso
40 {
41 class PMSPP_LIB_DECL TandemWrapperRun : public QObject
42 {
43  Q_OBJECT
44  public:
45  /** @brief prepare a tandem run
46  * @param tandem_binary file path to tandem.exe if not set, a default value is
47  * given in QSettings
48  * @param tmp_dir temporary directory, where to write mzXML file conversion if
49  * not set, a default value is given in QSettings
50  * @param centroid_options controls the way MS2 spectrum are centroided from
51  * raw bruker's data if not set, a default value is given in QSettings
52  */
53  TandemWrapperRun(const QString &tandem_binary,
54  const QString &tmp_dir,
55  const QString &centroid_options);
56 
57  /** @brief run a tandem job
58  * @param tandem_input_file tandem xml input file
59  * @param output_stream standard output where to write tandem stdout
60  * @param error_stream standard error where to write tandem stderr
61  */
62  void run(const QString &tandem_input_file,
63  QTextStream &output_stream,
64  QTextStream &error_stream);
65 
66  void readTandemPresetFile(const QString &tandem_preset_file);
67  /**
68  * Destructor
69  */
71 
72  private:
73  void setTandemBinaryPath(const QString &tandem_binary_path);
74  bool shouldIstop();
75  const QString checkXtandemVersion(const QString &tandem_bin_path);
76  void wrapTandemInputFile(const QString &tandem_input_file);
77 
78  void convertOrginalMsData2mzXmlData(const QString &origin,
79  const QString &target) const;
80 
81 
82  /** @brief run a tandem job
83  * @param tandem_input_file tandem xml input file
84  */
85  void runTandem(const QString &tandem_input_file);
86 
87  /** @brief tandem output modification
88  * tandem output is modified to contain the Bruker's file as input and
89  * centroidization parameters
90  * @param tmp_tandem_output raw tandem output filename
91  * @param final_tandem_output final destination file for modified tandem
92  * output
93  */
94  void writeFinalTandemOutput(const QString &tmp_tandem_output,
95  const QString &final_tandem_output,
96  const QString &original_msdata_file_name);
97 
98 
99  private slots:
100  void readyReadStandardOutput();
101  void readyReadStandardError();
102 
103  private:
104  QString m_tandemBinary;
106  QString m_tmpDir;
108  int m_maxTandemRunTimeMs = (60000 * 60 * 24); // 1 day
109  QProcess *m_xtProcess = nullptr;
110 
111  QTextStream *mp_outputStream = nullptr;
112  QTextStream *mp_errorStream = nullptr;
113 
114  QTemporaryDir *mpa_temporaryDirectory = nullptr;
115 };
116 } // 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
Definition: aa.cpp:39
pappso::TandemWrapperRun::m_tandemVersion
QString m_tandemVersion
Definition: tandemwrapperrun.h:105
pappso::TandemWrapperRun::m_centroidOptions
QString m_centroidOptions
Definition: tandemwrapperrun.h:107
pappso::TandemWrapperRun
Definition: tandemwrapperrun.h:42
pappso::TandemWrapperRun::m_tmpDir
QString m_tmpDir
Definition: tandemwrapperrun.h:106
pappso::TandemWrapperRun::m_tandemBinary
QString m_tandemBinary
Definition: tandemwrapperrun.h:104