diff --git a/src/gui/tandem_run_dialog/tandem_run_dialog.ui b/src/gui/tandem_run_dialog/tandem_run_dialog.ui index 336fae98917703eebb63464fd89b7245d68891b6..1f1639d9a3fc697b6e13fe9c573784be91089657 100644 --- a/src/gui/tandem_run_dialog/tandem_run_dialog.ui +++ b/src/gui/tandem_run_dialog/tandem_run_dialog.ui @@ -28,7 +28,45 @@ <property name="checked"> <bool>false</bool> </property> - <layout class="QHBoxLayout" name="horizontalLayout_6"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="tandem_bin_label"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>528</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButton_4"> + <property name="text"> + <string>change</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="tandem_version_label"> + <property name="text"> + <string>X!Tandem not found</string> + </property> + </widget> + </item> <item> <widget class="QWidget" name="exe_group_widget" native="true"> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -47,37 +85,6 @@ <property name="bottomMargin"> <number>0</number> </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="tandem_bin_label"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>528</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_4"> - <property name="text"> - <string>change</string> - </property> - </widget> - </item> - </layout> - </item> <item> <widget class="QGroupBox" name="use_htcondor_groupbox"> <property name="title"> diff --git a/src/gui/tandem_run_dialog/tandemrundialog.cpp b/src/gui/tandem_run_dialog/tandemrundialog.cpp index fd78ee5f5505609b54d45c0b988f65854686239d..def39f97edcd591e1a2db2217bc1c64874c3418d 100644 --- a/src/gui/tandem_run_dialog/tandemrundialog.cpp +++ b/src/gui/tandem_run_dialog/tandemrundialog.cpp @@ -37,6 +37,7 @@ #include <QStandardPaths> #include <pappsomspp/pappsoexception.h> #include "../../files/tandemparametersfile.h" +#include "../../utils/utils.h" // Q_DECLARE_METATYPE(QFileInfo) @@ -182,6 +183,11 @@ TandemRunDialog::reset() QString tandem_bin_path = settings.value("path/tandem_bin", "/usr/bin/tandem").toString(); + + ui->tandem_version_label->setText( + Utils::checkXtandemVersion(tandem_bin_path)); + + ui->output_directory_label->setText(default_output_location); ui->tandem_bin_label->setText(tandem_bin_path); diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 737282c2cb5e26271403a6501112f3c97eb68753..c236c399d669cc0dc544220e825766d83b5e7806 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -2,6 +2,8 @@ #include <pappsomspp/exception/exceptionnotfound.h> #include <pappsomspp/mass_range.h> #include <cmath> +#include <QProcess> +#include <QDebug> const QUrl Utils::getOlsUrl(QString psimod_accession) @@ -239,3 +241,61 @@ Utils::translateAaModificationFromUnimod(const QString &unimod_accession) << unimod_accession << " not found"; return nullptr; } + + +const QString +Utils::checkXtandemVersion(const QString &tandem_bin_path) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + QString version_return; + QStringList arguments; + + arguments << "-v"; + + QProcess *xt_process = new QProcess(); + // hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath()); + + xt_process->start(tandem_bin_path, arguments); + + if(!xt_process->waitForStarted()) + { + throw pappso::PappsoException( + QObject::tr("X!Tandem process failed to start")); + } + + while(xt_process->waitForReadyRead(1000)) + { + } + /* + if (!xt_process->waitForFinished(_max_xt_time_ms)) { + throw pappso::PappsoException(QObject::tr("can't wait for X!Tandem process + to finish : timeout at %1").arg(_max_xt_time_ms)); + } + */ + QByteArray result = xt_process->readAll(); + + + qDebug() << result.constData(); + + QRegExp parse_version("X! TANDEM ([A-Z]+) \\((.*)\\)"); + // Pattern patt = Pattern.compile("X! TANDEM [A-Z]+ \\((.*)\\)", + // Pattern.CASE_INSENSITIVE); + + if(parse_version.exactMatch(result.constData())) + { + version_return = parse_version.capturedTexts().join(" "); + } + + QProcess::ExitStatus Status = xt_process->exitStatus(); + delete xt_process; + if(Status != 0) + { + // != QProcess::NormalExit + throw pappso::PappsoException( + QObject::tr("error executing X!Tandem Status != 0 : %1 %2\n%3") + .arg(tandem_bin_path) + .arg(arguments.join(" ").arg(result.data()))); + } + return version_return; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; +} diff --git a/src/utils/utils.h b/src/utils/utils.h index 13de1f6169748a673452fe735defab0ec9cd733f..52ecc77f5263f6d2228a5bcc1e49bc0096692cb2 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -36,6 +36,7 @@ class Utils static const QString getIdentificationEngineName(IdentificationEngine engine); static const QString getDatabaseName(ExternalDatabase database); static const QString getXmlDouble(pappso::pappso_double number); + static const QString checkXtandemVersion(const QString &tandem_bin_path); static pappso::AaModificationP guessAaModificationPbyMonoisotopicMassDelta(pappso::mz mass); static pappso::AaModificationP