34#include <QRegularExpression>
35#include "../../exception/exceptioninterrupted.h"
36#include "../../msfile/msfileaccessor.h"
37#include "../../msrun/private/timsmsrunreaderms2.h"
38#include "../../processing/filters/filtertriangle.h"
39#include "../../processing/filters/filterchargedeconvolution.h"
40#include "../../msrun/output/mzxmloutput.h"
50 const QString &tmp_dir)
55 if(!tmp_dir.isEmpty())
67 QObject::tr(
"ERROR: unable to create temporary directory %1\n Please "
68 "check file system permissions")
96 settings.value(
"path/tandem_binary",
"/usr/bin/tandem").toString();
111 QFileInfo tandem_exe(tandem_bin_path);
112 if(!tandem_exe.exists())
117 "X!Tandem software not found at %1.\nPlease check the X!Tandem "
118 "installation on your computer and set tandem.exe path.")
119 .arg(tandem_exe.absoluteFilePath()));
121 if(!tandem_exe.isReadable())
125 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
126 "(file not readable).")
127 .arg(tandem_exe.absoluteFilePath()));
129 if(!tandem_exe.isExecutable())
133 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
134 "(file not executable).")
135 .arg(tandem_exe.absoluteFilePath()));
139 QString version_return;
140 QStringList arguments;
144 QProcess *xt_process =
new QProcess();
147 xt_process->start(tandem_bin_path, arguments);
149 if(!xt_process->waitForStarted())
152 QObject::tr(
"X!Tandem %1 process failed to start")
156 while(xt_process->waitForReadyRead(1000))
165 QByteArray result = xt_process->readAll();
168 qDebug() << result.constData();
172 QRegularExpression parse_version(
173 "(.*) TANDEM ([A-Z,a-z, ]+) \\(([^ ,^\\)]*)(.*)");
174 qDebug() << parse_version;
177 QRegularExpressionMatch match_parse_version =
178 parse_version.match(result.constData());
179 if(match_parse_version.hasMatch())
181 version_return = QString(
"X!Tandem %1 %2")
182 .arg(match_parse_version.captured(2))
183 .arg(match_parse_version.captured(3));
188 QObject::tr(
"This executable %1 may not be a valid X!Tandem software. "
189 "Please check your X!Tandem installation.")
190 .arg(tandem_bin_path));
193 QProcess::ExitStatus Status = xt_process->exitStatus();
199 QObject::tr(
"error executing X!Tandem Status != 0 : %1 %2\n%3")
200 .arg(tandem_bin_path)
201 .arg(arguments.join(
" ").arg(result.data())));
204 return version_return;
210 QString message(
m_xtProcess->readAllStandardOutput());
213 if(message.toLower().contains(
"error"))
224 QObject::tr(
"X!Tandem stopped by the user"));
238 QObject::tr(
"X!Tandem stopped by the user"));
244 const QString &tmp_tandem_output,
245 const QString &final_tandem_output,
246 const QString &original_msdata_file_name)
268 "timing, tandemwrapper conversion time (sec)",
272 if(wrap_output.
readFile(tmp_tandem_output))
278 QObject::tr(
"Error reading %1 X!Tandem output file :\n %2")
279 .arg(tmp_tandem_output)
292 if(preset_handler.
readFile(tandem_preset_file))
295 int ideal_number_of_thread = QThread::idealThreadCount();
297 qDebug() <<
" cpu_number=" << cpu_number;
299 if(cpu_number > ideal_number_of_thread)
301 cpu_number = ideal_number_of_thread;
307 QThreadPool::globalInstance()->setMaxThreadCount(cpu_number);
309 qDebug() <<
" maxThreadCount="
310 << QThreadPool::globalInstance()->maxThreadCount();
315 if(!ms2_filters_str.isEmpty())
318 std::make_shared<pappso::FilterSuiteString>(ms2_filters_str);
323 std::make_shared<pappso::FilterSuiteString>(
324 "chargeDeconvolution|0.02dalton mzExclusion|0.01dalton");
330 QObject::tr(
"Error reading %1 X!Tandem preset file :\n %2")
331 .arg(tandem_preset_file)
346 QString mzxml_data_file_name =
348 QString wrapped_tandem_input =
350 QString wrapped_tandem_output =
354 mzxml_data_file_name, wrapped_tandem_input, wrapped_tandem_output);
357 if(wrap_tandem_input.
readFile(tandem_input_file))
363 QObject::tr(
"Error reading %1 X!Tandem input file :\n %2")
364 .arg(tandem_input_file)
410 QString original_msdata_file_name =
413 mzxml_data_file_name))
422 wrapped_tandem_output,
424 original_msdata_file_name);
436 const QString &target)
447 QObject::tr(
"%1 file format not known").arg(origin));
459 QObject::tr(
"Converting %1 to mzXML %2").arg(origin).arg(target));
466 if(tims2_reader !=
nullptr)
480 QFile output_file(target);
483 if(output_file.open(QIODevice::WriteOnly))
489 *
mp_monitor, QTextStream(&output_file).device());
495 p_mzxml_output->
write(p_reader.get());
497 p_mzxml_output->
close();
499 delete p_mzxml_output;
508 QObject::tr(
"unable to write into %1 mzXML output file")
524 const QString &tandem_input_file)
537 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
538 .arg(tandem_input_file));
541 QStringList arguments;
545 arguments << tandem_input_file;
552 &QProcess::readyReadStandardOutput,
556 &QProcess::readyReadStandardError,
568 QObject::tr(
"X!Tandem process failed to start"));
582 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
583 .arg(tandem_input_file));
587 QProcess::ExitStatus Status =
m_xtProcess->exitStatus();
590 if(Status != QProcess::ExitStatus::NormalExit)
594 QObject::tr(
"error executing X!Tandem Status != 0 : %1")
MsRunReaderSPtr msRunReaderSPtr(MsRunIdCstSPtr ms_run_id)
void setPreferredFileReaderType(MsDataFormat format, FileReaderType reader_type)
given an mz format, explicitly set the preferred reader
MsDataFormat getFileFormat() const
get the raw format of mz data
std::vector< MsRunIdCstSPtr > getMsRunIds()
void setReadAhead(bool read_ahead)
void write(MsRunReader *p_msrunreader)
void maskMs1(bool mask_ms1)
QTemporaryDir * mpa_temporaryDirectory
void run(UiMonitorInterface &monitor, const QString &tandem_input_file)
run a tandem job
void setTandemBinaryPath(const QString &tandem_binary_path)
void readyReadStandardError()
bool m_convertMzDataUsingSpectrumIndex
UiMonitorInterface * mp_monitor
void readyReadStandardOutput()
pappso::MsDataFormat m_mzFormat
bool convertOrginalMsData2mzXmlData(const QString &origin, const QString &target)
void readTandemPresetFile(const QString &tandem_preset_file)
std::shared_ptr< FilterSuiteString > msp_ms2FilterSuiteString
void wrapTandemInputFile(const QString &tandem_input_file)
void writeFinalTandemOutput(const QString &tmp_tandem_output, const QString &final_tandem_output, const QString &original_msdata_file_name)
tandem output modification tandem output is modified to contain the Bruker's file as input and centro...
TandemWrapperRun(const QString &tandem_binary, const QString &tmp_dir)
prepare a tandem run
QString getMs2FilterSuiteString() const
gets the list of filters used on MS2 spectrum
void runTandem(const QString &tandem_input_file)
run a tandem job
const QString checkXtandemVersion(const QString &tandem_bin_path)
void setMs2FilterCstSPtr(pappso::FilterInterfaceCstSPtr filter)
void setMs2BuiltinCentroid(bool centroid)
enable or disable simple centroid filter on raw tims data for MS2
virtual void setStatus(const QString &status)=0
current status of the process
virtual void appendText(const QString &text)=0
append a text to a long report
virtual bool shouldIstop()=0
should the procces be stopped ? If true, then cancel process Use this function at strategic point of ...
void setInputParameters(const QString &label_name_attribute, const QString &input_value)
QString errorString() const
virtual bool readFile(const QString &fileName)
const QString getMs2FiltersOptions() const
int getNumberOfThreads() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< MsRunReader > MsRunReaderSPtr
actually does really run tandem directly on Bruker's data
rewrites tandem xml output file with temporary files
read tandem preset file to get centroid parameters and number of threads