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);
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)
253 XtandemPresetSaxHandler preset_handler;
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();
265 int cpu_number = preset_handler.getNumberOfThreads();
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();
286 QObject::tr(
"Error reading %1 X!Tandem preset file :\n %2")
287 .arg(tandem_preset_file)
288 .arg(preset_handler.errorString()));
300 QString mzxml_data_file_name =
302 QString wrapped_tandem_input =
304 QString wrapped_tandem_output =
306 XtandemInputSaxHandler wrap_input(
307 mzxml_data_file_name, wrapped_tandem_input, wrapped_tandem_output);
309 QFile qfile(tandem_input_file);
310 QXmlInputSource xmlInputSource(&qfile);
311 QXmlSimpleReader simplereader;
312 simplereader.setContentHandler(&wrap_input);
313 simplereader.setErrorHandler(&wrap_input);
315 if(simplereader.parse(xmlInputSource))
321 QObject::tr(
"Error reading %1 X!Tandem input file :\n %2")
322 .arg(tandem_input_file)
323 .arg(wrap_input.errorString()));
331 QString original_msdata_file_name = wrap_input.getOriginalMsDataFileName();
332 qDebug() <<
"DDDDDDDDDDD" << original_msdata_file_name
333 << wrap_input.getOriginalTandemOutputFileName();
335 mzxml_data_file_name);
343 wrap_input.getOriginalTandemOutputFileName(),
344 original_msdata_file_name);
349 const QString &target)
const
355 origin_access.getMsRunIds();
358 p_reader = origin_access.msRunReaderSp(origin_access.getMsRunIds().front());
362 if(tims2_reader !=
nullptr)
372 std::shared_ptr<FilterSuite> ms2filter =
373 std::make_shared<FilterSuite>();
375 ms2filter.get()->push_back(
376 std::make_shared<FilterChargeDeconvolution>(
386 QFile output_file(target);
389 if(output_file.open(QIODevice::WriteOnly))
398 p_mzxml_output->
write(p_reader.get());
400 p_mzxml_output->
close();
405 tr(
"unable to write into %1 mzXML output file").arg(target));
413 QTextStream &output_stream,
414 QTextStream &error_stream)
428 QStringList arguments;
432 arguments << tandem_input_file;
439 &QProcess::readyReadStandardOutput,
443 &QProcess::readyReadStandardError,
453 QObject::tr(
"X!Tandem process failed to start"));
467 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
468 .arg(tandem_input_file));
472 QProcess::ExitStatus Status =
m_xtProcess->exitStatus();
479 QObject::tr(
"error executing X!Tandem Status != 0 : %1")
487 const std::shared_ptr<FilterSuite> ms2filter)
492 std::shared_ptr<FilterSuite>