33 #include <QThreadPool>
34 #include "../../exception/exceptioninterrupted.h"
35 #include "../../msfile/msfileaccessor.h"
36 #include "../../msrun/private/timsmsrunreaderms2.h"
37 #include "../../processing/filters/filtertriangle.h"
38 #include "../../processing/filters/filterchargedeconvolution.h"
39 #include "../../msrun/output/mzxmloutput.h"
49 const QString &tmp_dir)
54 if(!tmp_dir.isEmpty())
66 QObject::tr(
"ERROR: unable to create temporary directory %1\n Please "
67 "check file system permissions")
95 settings.value(
"path/tandem_binary",
"/usr/bin/tandem").toString();
110 QFileInfo tandem_exe(tandem_bin_path);
111 if(!tandem_exe.exists())
116 "X!Tandem software not found at %1.\nPlease check the X!Tandem "
117 "installation on your computer and set tandem.exe path.")
118 .arg(tandem_exe.absoluteFilePath()));
120 if(!tandem_exe.isReadable())
124 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
125 "(file not readable).")
126 .arg(tandem_exe.absoluteFilePath()));
128 if(!tandem_exe.isExecutable())
132 QObject::tr(
"Please check permissions on X!Tandem software found at %1 "
133 "(file not executable).")
134 .arg(tandem_exe.absoluteFilePath()));
138 QString version_return;
139 QStringList arguments;
143 QProcess *xt_process =
new QProcess();
146 xt_process->start(tandem_bin_path, arguments);
148 if(!xt_process->waitForStarted())
151 QObject::tr(
"X!Tandem %1 process failed to start")
155 while(xt_process->waitForReadyRead(1000))
164 QByteArray result = xt_process->readAll();
167 qDebug() << result.constData();
171 QRegExp parse_version(
"(.*) TANDEM ([A-Z,a-z, ]+) \\(([^ ,^\\)]*)(.*)");
172 qDebug() << parse_version;
176 if(parse_version.exactMatch(result.constData()))
178 version_return = QString(
"X!Tandem %1 %2")
179 .arg(parse_version.capturedTexts()[2])
180 .arg(parse_version.capturedTexts()[3]);
185 QObject::tr(
"This executable %1 may not be a valid X!Tandem software. "
186 "Please check your X!Tandem installation.")
187 .arg(tandem_bin_path));
190 QProcess::ExitStatus Status = xt_process->exitStatus();
196 QObject::tr(
"error executing X!Tandem Status != 0 : %1 %2\n%3")
197 .arg(tandem_bin_path)
198 .arg(arguments.join(
" ").arg(result.data())));
201 return version_return;
207 QString message(
m_xtProcess->readAllStandardOutput());
210 if(message.toLower().contains(
"error"))
221 QObject::tr(
"X!Tandem stopped by the user"));
235 QObject::tr(
"X!Tandem stopped by the user"));
241 const QString &tmp_tandem_output,
242 const QString &final_tandem_output,
243 const QString &original_msdata_file_name)
265 "timing, tandemwrapper conversion time (sec)",
269 if(wrap_output.
readFile(tmp_tandem_output))
275 QObject::tr(
"Error reading %1 X!Tandem output file :\n %2")
276 .arg(tmp_tandem_output)
289 if(preset_handler.
readFile(tandem_preset_file))
292 int ideal_number_of_thread = QThread::idealThreadCount();
294 qDebug() <<
" cpu_number=" << cpu_number;
296 if(cpu_number > ideal_number_of_thread)
298 cpu_number = ideal_number_of_thread;
304 QThreadPool::globalInstance()->setMaxThreadCount(cpu_number);
306 qDebug() <<
" maxThreadCount="
307 << QThreadPool::globalInstance()->maxThreadCount();
312 if(!ms2_filters_str.isEmpty())
315 std::make_shared<pappso::FilterSuiteString>(ms2_filters_str);
320 std::make_shared<pappso::FilterSuiteString>(
321 "chargeDeconvolution|0.02dalton mzExclusion|0.01dalton");
327 QObject::tr(
"Error reading %1 X!Tandem preset file :\n %2")
328 .arg(tandem_preset_file)
343 QString mzxml_data_file_name =
345 QString wrapped_tandem_input =
347 QString wrapped_tandem_output =
351 mzxml_data_file_name, wrapped_tandem_input, wrapped_tandem_output);
354 if(wrap_tandem_input.
readFile(tandem_input_file))
360 QObject::tr(
"Error reading %1 X!Tandem input file :\n %2")
361 .arg(tandem_input_file)
398 QString original_msdata_file_name =
401 mzxml_data_file_name))
410 wrapped_tandem_output,
412 original_msdata_file_name);
423 const QString &target)
441 QObject::tr(
"Converting %1 to mzXML %2").arg(origin).arg(target));
448 if(tims2_reader !=
nullptr)
462 QFile output_file(target);
465 if(output_file.open(QIODevice::WriteOnly))
471 *
mp_monitor, QTextStream(&output_file).device());
477 p_mzxml_output->
write(p_reader.get());
479 p_mzxml_output->
close();
481 delete p_mzxml_output;
490 QObject::tr(
"unable to write into %1 mzXML output file")
506 const QString &tandem_input_file)
519 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
520 .arg(tandem_input_file));
523 QStringList arguments;
527 arguments << tandem_input_file;
534 &QProcess::readyReadStandardOutput,
538 &QProcess::readyReadStandardError,
550 QObject::tr(
"X!Tandem process failed to start"));
564 QObject::tr(
"X!Tandem stopped by the user processing on file %1")
565 .arg(tandem_input_file));
569 QProcess::ExitStatus Status =
m_xtProcess->exitStatus();
572 if(Status != QProcess::ExitStatus::NormalExit)
576 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