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 "../../processing/filters/filterchargedeconvolution.h"
40 #include "../../msrun/output/mzxmloutput.h"
48 const QString &tmp_dir)
53 if(!tmp_dir.isEmpty())
65 QObject::tr(
"ERROR: unable to create temporary directory %1\n Please "
66 "check file system permissions")
89 settings.value(
"path/tandem_binary",
"/usr/bin/tandem").toString();
104 QFileInfo tandem_exe(tandem_bin_path);
105 if(!tandem_exe.exists())
110 "X!Tandem software not found at %1.\nPlease check the X!Tandem "
111 "installation on your computer and set tandem.exe path.")
112 .arg(tandem_exe.absoluteFilePath()));
114 if(!tandem_exe.isReadable())
118 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
119 "(file not readable).")
120 .arg(tandem_exe.absoluteFilePath()));
122 if(!tandem_exe.isExecutable())
126 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
127 "(file not executable).")
128 .arg(tandem_exe.absoluteFilePath()));
132 QString version_return;
133 QStringList arguments;
137 QProcess *xt_process =
new QProcess();
140 xt_process->start(tandem_bin_path, arguments);
142 if(!xt_process->waitForStarted())
145 QObject::tr(
"X!Tandem %1 process failed to start")
149 while(xt_process->waitForReadyRead(1000))
158 QByteArray result = xt_process->readAll();
161 qDebug() << result.constData();
165 QRegExp parse_version(
"(.*) TANDEM ([A-Z,a-z, ]+) \\(([^ ,^\\)]*)(.*)");
166 qDebug() << parse_version;
170 if(parse_version.exactMatch(result.constData()))
172 version_return = QString(
"X!Tandem %1 %2")
173 .arg(parse_version.capturedTexts()[2])
174 .arg(parse_version.capturedTexts()[3]);
179 QObject::tr(
"This executable %1 may not be a valid X!Tandem software. "
180 "Please check your X!Tandem installation.")
181 .arg(tandem_bin_path));
184 QProcess::ExitStatus Status = xt_process->exitStatus();
190 QObject::tr(
"error executing X!Tandem Status != 0 : %1 %2\n%3")
191 .arg(tandem_bin_path)
192 .arg(arguments.join(
" ").arg(result.data())));
195 return version_return;
222 const QString &tmp_tandem_output,
223 const QString &final_tandem_output,
224 const QString &original_msdata_file_name)
228 original_msdata_file_name);
233 QFile qfile(tmp_tandem_output);
234 QXmlInputSource xmlInputSource(&qfile);
235 QXmlSimpleReader simplereader;
236 simplereader.setContentHandler(&wrap_output);
237 simplereader.setErrorHandler(&wrap_output);
239 if(simplereader.parse(xmlInputSource))
245 QObject::tr(
"Error reading %1 X!Tandem output file :\n %2")
246 .arg(tmp_tandem_output)
258 QFile qfile(tandem_preset_file);
259 QXmlInputSource xmlInputSource(&qfile);
260 QXmlSimpleReader simplereader;
261 simplereader.setContentHandler(&preset_handler);
262 simplereader.setErrorHandler(&preset_handler);
264 if(simplereader.parse(xmlInputSource))
267 int ideal_number_of_thread = QThread::idealThreadCount();
269 qDebug() <<
" cpu_number=" << cpu_number;
271 if(cpu_number > ideal_number_of_thread)
273 cpu_number = ideal_number_of_thread;
279 QThreadPool::globalInstance()->setMaxThreadCount(cpu_number);
281 qDebug() <<
" maxThreadCount="
282 << QThreadPool::globalInstance()->maxThreadCount();
288 std::make_shared<pappso::FilterSuiteString>(ms2_filters_str);
293 QObject::tr(
"Error reading %1 X!Tandem preset file :\n %2")
294 .arg(tandem_preset_file)
307 QString mzxml_data_file_name =
309 QString wrapped_tandem_input =
311 QString wrapped_tandem_output =
314 mzxml_data_file_name, wrapped_tandem_input, wrapped_tandem_output);
316 QFile qfile(tandem_input_file);
317 QXmlInputSource xmlInputSource(&qfile);
318 QXmlSimpleReader simplereader;
319 simplereader.setContentHandler(&wrap_input);
320 simplereader.setErrorHandler(&wrap_input);
322 if(simplereader.parse(xmlInputSource))
328 QObject::tr(
"Error reading %1 X!Tandem input file :\n %2")
329 .arg(tandem_input_file)
340 mzxml_data_file_name);
349 original_msdata_file_name);
354 const QString &target)
const
367 if(tims2_reader !=
nullptr)
381 QFile output_file(target);
384 if(output_file.open(QIODevice::WriteOnly))
393 p_mzxml_output->
write(p_reader.get());
395 p_mzxml_output->
close();
400 tr(
"unable to write into %1 mzXML output file").arg(target));
408 QTextStream &output_stream,
409 QTextStream &error_stream)
423 QStringList arguments;
427 arguments << tandem_input_file;
434 &QProcess::readyReadStandardOutput,
438 &QProcess::readyReadStandardError,
448 QObject::tr(
"X!Tandem process failed to start"));
462 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
463 .arg(tandem_input_file));
467 QProcess::ExitStatus Status =
m_xtProcess->exitStatus();
474 QObject::tr(
"error executing X!Tandem Status != 0 : %1")