33 #include <QThreadPool>
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)
401 QString original_msdata_file_name =
404 mzxml_data_file_name))
413 wrapped_tandem_output,
415 original_msdata_file_name);
426 const QString &target)
437 QObject::tr(
"%1 file format not known").arg(origin));
449 QObject::tr(
"Converting %1 to mzXML %2").arg(origin).arg(target));
456 if(tims2_reader !=
nullptr)
470 QFile output_file(target);
473 if(output_file.open(QIODevice::WriteOnly))
479 *
mp_monitor, QTextStream(&output_file).device());
485 p_mzxml_output->
write(p_reader.get());
487 p_mzxml_output->
close();
489 delete p_mzxml_output;
498 QObject::tr(
"unable to write into %1 mzXML output file")
514 const QString &tandem_input_file)
527 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
528 .arg(tandem_input_file));
531 QStringList arguments;
535 arguments << tandem_input_file;
542 &QProcess::readyReadStandardOutput,
546 &QProcess::readyReadStandardError,
558 QObject::tr(
"X!Tandem process failed to start"));
572 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
573 .arg(tandem_input_file));
577 QProcess::ExitStatus Status =
m_xtProcess->exitStatus();
580 if(Status != QProcess::ExitStatus::NormalExit)
584 QObject::tr(
"error executing X!Tandem Status != 0 : %1")
MzFormat getFileFormat() const
get the raw format of mz data
MsRunReaderSPtr msRunReaderSp(MsRunIdCstSPtr ms_run_id)
void setPreferedFileReaderType(MzFormat format, FileReaderType reader_type)
given an mz format, explicitly set the prefered reader
std::vector< MsRunIdCstSPtr > getMsRunIds()
void setReadAhead(bool read_ahead)
void write(MsRunReader *p_msrunreader)
void maskMs1(bool mask_ms1)
QTemporaryDir * mpa_temporaryDirectory
pappso::MzFormat m_mzFormat
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()
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