33 #include <QThreadPool>
34 #include "../../exception/exceptioninterrupted.h"
35 #include "../../msfile/msfileaccessor.h"
36 #include "../../msrun/private/timsmsrunreaderms2.h"
37 #include "../../processing/filters/filterpseudocentroid.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 QRegExp parse_version(
"(.*) TANDEM ([A-Z,a-z, ]+) \\(([^ ,^\\)]*)(.*)");
173 qDebug() << parse_version;
177 if(parse_version.exactMatch(result.constData()))
179 version_return = QString(
"X!Tandem %1 %2")
180 .arg(parse_version.capturedTexts()[2])
181 .arg(parse_version.capturedTexts()[3]);
186 QObject::tr(
"This executable %1 may not be a valid X!Tandem software. "
187 "Please check your X!Tandem installation.")
188 .arg(tandem_bin_path));
191 QProcess::ExitStatus Status = xt_process->exitStatus();
197 QObject::tr(
"error executing X!Tandem Status != 0 : %1 %2\n%3")
198 .arg(tandem_bin_path)
199 .arg(arguments.join(
" ").arg(result.data())));
202 return version_return;
208 QString message(
m_xtProcess->readAllStandardOutput());
211 if(message.toLower().contains(
"error"))
222 QObject::tr(
"X!Tandem stopped by the user"));
236 QObject::tr(
"X!Tandem stopped by the user"));
242 const QString &tmp_tandem_output,
243 const QString &final_tandem_output,
244 const QString &original_msdata_file_name)
249 original_msdata_file_name);
262 QFile qfile(tmp_tandem_output);
263 QXmlInputSource xmlInputSource(&qfile);
264 QXmlSimpleReader simplereader;
265 simplereader.setContentHandler(&wrap_output);
266 simplereader.setErrorHandler(&wrap_output);
268 if(simplereader.parse(xmlInputSource))
274 QObject::tr(
"Error reading %1 X!Tandem output file :\n %2")
275 .arg(tmp_tandem_output)
287 QFile qfile(tandem_preset_file);
288 QXmlInputSource xmlInputSource(&qfile);
289 QXmlSimpleReader simplereader;
290 simplereader.setContentHandler(&preset_handler);
291 simplereader.setErrorHandler(&preset_handler);
293 if(simplereader.parse(xmlInputSource))
296 int ideal_number_of_thread = QThread::idealThreadCount();
298 qDebug() <<
" cpu_number=" << cpu_number;
300 if(cpu_number > ideal_number_of_thread)
302 cpu_number = ideal_number_of_thread;
308 QThreadPool::globalInstance()->setMaxThreadCount(cpu_number);
310 qDebug() <<
" maxThreadCount="
311 << QThreadPool::globalInstance()->maxThreadCount();
316 if(!ms2_filters_str.isEmpty())
319 std::make_shared<pappso::FilterSuiteString>(ms2_filters_str);
324 std::make_shared<pappso::FilterSuiteString>(
325 "chargeDeconvolution|0.02dalton mzExclusion|0.01dalton");
331 QObject::tr(
"Error reading %1 X!Tandem preset file :\n %2")
332 .arg(tandem_preset_file)
345 QString mzxml_data_file_name =
347 QString wrapped_tandem_input =
349 QString wrapped_tandem_output =
352 mzxml_data_file_name, wrapped_tandem_input, wrapped_tandem_output);
354 QFile qfile(tandem_input_file);
358 QObject::tr(
"Tandem input file %1 does not exists")
359 .arg(QFileInfo(tandem_input_file).absoluteFilePath()));
361 QXmlInputSource xmlInputSource(&qfile);
362 QXmlSimpleReader simplereader;
363 simplereader.setContentHandler(&wrap_input);
364 simplereader.setErrorHandler(&wrap_input);
366 if(simplereader.parse(xmlInputSource))
372 QObject::tr(
"Error reading %1 X!Tandem input file :\n %2")
373 .arg(tandem_input_file)
384 mzxml_data_file_name))
394 original_msdata_file_name);
405 const QString &target)
422 QObject::tr(
"Converting %1 to mzXML %2").arg(origin).arg(target));
429 if(tims2_reader !=
nullptr)
443 QFile output_file(target);
446 if(output_file.open(QIODevice::WriteOnly))
449 *
mp_monitor, QTextStream(&output_file).device());
455 p_mzxml_output->
write(p_reader.get());
457 p_mzxml_output->
close();
459 delete p_mzxml_output;
464 QObject::tr(
"unable to write into %1 mzXML output file")
480 const QString &tandem_input_file)
493 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
494 .arg(tandem_input_file));
497 QStringList arguments;
501 arguments << tandem_input_file;
508 &QProcess::readyReadStandardOutput,
512 &QProcess::readyReadStandardError,
524 QObject::tr(
"X!Tandem process failed to start"));
538 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
539 .arg(tandem_input_file));
543 QProcess::ExitStatus Status =
m_xtProcess->exitStatus();
546 if(Status != QProcess::ExitStatus::NormalExit)
550 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
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
QString errorString() const
int getNumberOfThreads() const
const QString getMs2FiltersOptions() 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