33 #include <QThreadPool>
34 #include "../../pappsoexception.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 "../../msrun/output/mzxmloutput.h"
47 const QString &tmp_dir,
48 const QString ¢roid_options)
57 if(!tmp_dir.isEmpty())
86 settings.value(
"path/tandem_binary",
"/usr/bin/tandem").toString();
101 QFileInfo tandem_exe(tandem_bin_path);
102 if(!tandem_exe.exists())
107 "X!Tandem software not found at %1.\nPlease check the X!Tandem "
108 "installation on your computer and set tandem.exe path.")
109 .arg(tandem_exe.absoluteFilePath()));
111 if(!tandem_exe.isReadable())
115 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
116 "(file not readable).")
117 .arg(tandem_exe.absoluteFilePath()));
119 if(!tandem_exe.isExecutable())
123 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
124 "(file not executable).")
125 .arg(tandem_exe.absoluteFilePath()));
129 QString version_return;
130 QStringList arguments;
134 QProcess *xt_process =
new QProcess();
137 xt_process->start(tandem_bin_path, arguments);
139 if(!xt_process->waitForStarted())
142 QObject::tr(
"X!Tandem %1 process failed to start")
146 while(xt_process->waitForReadyRead(1000))
155 QByteArray result = xt_process->readAll();
158 qDebug() << result.constData();
162 QRegExp parse_version(
"(.*) TANDEM ([A-Z,a-z, ]+) \\(([^ ,^\\)]*)(.*)");
163 qDebug() << parse_version;
167 if(parse_version.exactMatch(result.constData()))
169 version_return = QString(
"X!Tandem %1 %2")
170 .arg(parse_version.capturedTexts()[2])
171 .arg(parse_version.capturedTexts()[3]);
176 QObject::tr(
"This executable %1 may not be a valid X!Tandem software. "
177 "Please check your X!Tandem installation.")
178 .arg(tandem_bin_path));
181 QProcess::ExitStatus Status = xt_process->exitStatus();
187 QObject::tr(
"error executing X!Tandem Status != 0 : %1 %2\n%3")
188 .arg(tandem_bin_path)
189 .arg(arguments.join(
" ").arg(result.data())));
192 return version_return;
219 const QString &tmp_tandem_output,
220 const QString &final_tandem_output,
221 const QString &original_msdata_file_name)
225 original_msdata_file_name);
230 QFile qfile(tmp_tandem_output);
231 QXmlInputSource xmlInputSource(&qfile);
232 QXmlSimpleReader simplereader;
233 simplereader.setContentHandler(&wrap_output);
234 simplereader.setErrorHandler(&wrap_output);
236 if(simplereader.parse(xmlInputSource))
242 QObject::tr(
"Error reading %1 X!Tandem output file :\n %2")
243 .arg(tmp_tandem_output)
255 QFile qfile(tandem_preset_file);
256 QXmlInputSource xmlInputSource(&qfile);
257 QXmlSimpleReader simplereader;
258 simplereader.setContentHandler(&preset_handler);
259 simplereader.setErrorHandler(&preset_handler);
261 if(simplereader.parse(xmlInputSource))
264 int ideal_number_of_thread = QThread::idealThreadCount();
266 qDebug() <<
" cpu_number=" << cpu_number;
268 if(cpu_number > ideal_number_of_thread)
270 cpu_number = ideal_number_of_thread;
276 QThreadPool::globalInstance()->setMaxThreadCount(cpu_number);
278 qDebug() <<
" maxThreadCount="
279 << QThreadPool::globalInstance()->maxThreadCount();
291 QObject::tr(
"Error reading %1 X!Tandem preset file :\n %2")
292 .arg(tandem_preset_file)
305 QString mzxml_data_file_name =
307 QString wrapped_tandem_input =
309 QString wrapped_tandem_output =
312 mzxml_data_file_name, wrapped_tandem_input, wrapped_tandem_output);
314 QFile qfile(tandem_input_file);
315 QXmlInputSource xmlInputSource(&qfile);
316 QXmlSimpleReader simplereader;
317 simplereader.setContentHandler(&wrap_input);
318 simplereader.setErrorHandler(&wrap_input);
320 if(simplereader.parse(xmlInputSource))
326 QObject::tr(
"Error reading %1 X!Tandem input file :\n %2")
327 .arg(tandem_input_file)
339 mzxml_data_file_name);
348 original_msdata_file_name);
353 const QString &target)
const
367 if(tims2_reader !=
nullptr)
372 std::shared_ptr<pappso::FilterPseudoCentroid> ms2filter =
373 std::make_shared<pappso::FilterPseudoCentroid>(
374 option_list.at(0).toDouble(),
375 option_list.at(1).toDouble(),
376 option_list.at(2).toDouble(),
377 option_list.at(3).toDouble());
394 QFile output_file(target);
397 if(output_file.open(QIODevice::WriteOnly))
406 p_mzxml_output->
write(p_reader.get());
408 p_mzxml_output->
close();
413 tr(
"unable to write into %1 mzXML output file").arg(target));
421 QTextStream &output_stream,
422 QTextStream &error_stream)
437 QStringList arguments;
441 arguments << tandem_input_file;
448 &QProcess::readyReadStandardOutput,
452 &QProcess::readyReadStandardError,
462 QObject::tr(
"X!Tandem process failed to start"));
476 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
477 .arg(tandem_input_file));
481 QProcess::ExitStatus Status =
m_xtProcess->exitStatus();
488 QObject::tr(
"error executing X!Tandem Status != 0 : %1")