Commit 85e8017d authored by Langella Olivier's avatar Langella Olivier
Browse files

control param

parent 5a04980c
......@@ -30,6 +30,7 @@
#include "tandemparameters.h"
#include <QDebug>
#include <pappsomspp/exception/exceptionnotfound.h>
#include <pappsomspp/exception/exceptionnotpossible.h>
TandemParameters::TandemParameters() {
}
......@@ -55,7 +56,7 @@ const QString TandemParameters::getLabelCategory(const QString & value) const {
const QString & TandemParameters::getValue(const QString & label) const {
QMap<QString,QString>::const_iterator it = _map_label_value.constFind(label);
if (it == _map_label_value.end()) {
throw pappso::ExceptionNotFound(QObject::tr("X!Tandem preset label %1 not found in method %2").arg(label).arg(_method_name));
throw pappso::ExceptionNotFound(QObject::tr("X!Tandem preset label %1 not found in method %2").arg(label).arg(_method_name));
}
return it.value();
}
......@@ -70,6 +71,24 @@ void TandemParameters::setParamLabelValue(const QString & label, const QString &
return;
}
if (label == "spectrum, parent monoisotopic mass error units") {
if ((value != "Daltons") && (value != "ppm")) {
throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be Daltons or ppm (not %2)").arg(label).arg(value));
}
}
if (label == "spectrum, parent monoisotopic mass isotope error") {
if ((value != "yes") && (value != "no")) {
throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be yes or no (not %2)").arg(label).arg(value));
}
}
if ((label == "spectrum, parent monoisotopic mass error minus") || (label == "spectrum, parent monoisotopic mass error plus")) {
bool ok;
value.toDouble(&ok);
if (!ok) {// not an integer
throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be a number (not %2)").arg(label).arg(value));
}
}
_map_label_value.insert(label, value);
}
void TandemParameters::setMethodName(const QString & method) {
......
......@@ -132,8 +132,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1125</width>
<height>289</height>
<width>971</width>
<height>198</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
......@@ -143,7 +143,7 @@
<widget class="QComboBox" name="parent_ion_window_unit_combo_box">
<item>
<property name="text">
<string>dalton</string>
<string>Daltons</string>
</property>
</item>
<item>
......@@ -292,8 +292,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1125</width>
<height>289</height>
<width>98</width>
<height>72</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
......
......@@ -35,6 +35,7 @@
#include <QSettings>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
EditTandemPresetDialog::EditTandemPresetDialog(QWidget * parent):
......@@ -64,14 +65,14 @@ EditTandemPresetDialog::~EditTandemPresetDialog()
}
void EditTandemPresetDialog::setTandemParametersFiles(const TandemParametersFile & tandem_preset_file) {
if (tandem_preset_file.exists()) {
_p_tandem_preset_file = new TandemParametersFile( tandem_preset_file);
} else {
_p_tandem_preset_file = new TandemParametersFile(":/tandem/ressources/model/QExactive_analysis_FDR_nosemi.xml");
_p_tandem_preset_file = new TandemParametersFile(":/tandem/ressources/model/QExactive_analysis_FDR_nosemi.xml");
}
_tandem_params = _p_tandem_preset_file->getTandemParameters();
fillPresetComboBox();
populate();
}
......@@ -80,7 +81,7 @@ void EditTandemPresetDialog::doCopy() {
ui->method_name_line_edit->setText("untitled");
readUi();
if (_p_tandem_preset_file == nullptr) {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
else {
......@@ -88,7 +89,7 @@ void EditTandemPresetDialog::doCopy() {
}
QSettings settings;
QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString();
_p_tandem_preset_file = new TandemParametersFile(QString("%1/untitled.xml").arg(default_preset_location));
_p_tandem_preset_file = new TandemParametersFile(QString("%1/untitled.xml").arg(default_preset_location));
}
......@@ -114,7 +115,7 @@ void EditTandemPresetDialog::doSelectDir() {
void EditTandemPresetDialog::doSave() {
readUi();
if (_p_tandem_preset_file == nullptr) {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
_p_tandem_preset_file->setTandemParameters(_tandem_params);
......@@ -125,20 +126,20 @@ void EditTandemPresetDialog::doSave() {
void EditTandemPresetDialog::doLoad() {
int index = ui->preset_combo_box->currentIndex();
if ( index != -1 ) { // -1 for not found
if (_p_tandem_preset_file == nullptr) {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
else {
delete _p_tandem_preset_file;
}
QSettings settings;
QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString();
_p_tandem_preset_file = new TandemParametersFile(
ui->preset_combo_box->itemData(index).value<QString>());
_tandem_params = _p_tandem_preset_file->getTandemParameters();
populate();
if (_p_tandem_preset_file == nullptr) {
throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr"));
}
else {
delete _p_tandem_preset_file;
}
QSettings settings;
QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString();
_p_tandem_preset_file = new TandemParametersFile(
ui->preset_combo_box->itemData(index).value<QString>());
_tandem_params = _p_tandem_preset_file->getTandemParameters();
populate();
}
}
......@@ -190,17 +191,24 @@ void EditTandemPresetDialog::doHelp() {
}
void EditTandemPresetDialog::readUi() {
_tandem_params.setMethodName(ui->method_name_line_edit->text());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error units", ui->parent_ion_window_unit_combo_box->itemData(ui->parent_ion_window_unit_combo_box->currentIndex()).toString());
try {
_tandem_params.setMethodName(ui->method_name_line_edit->text());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error units", ui->parent_ion_window_unit_combo_box->currentText());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error minus", ui->parent_ion_lower_window_edit->text());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error minus", ui->parent_ion_lower_window_edit->text());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error plus", ui->parent_ion_upper_window_edit->text());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error plus", ui->parent_ion_upper_window_edit->text());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass isotope error", ui->anticipate_carbon_combo_box->itemData(ui->anticipate_carbon_combo_box->currentIndex()).toString());
_tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass isotope error", ui->anticipate_carbon_combo_box->currentText());
}
catch (pappso::PappsoException & error) {
QMessageBox::warning(this,tr("Error in parameters :"), error.qwhat());
}
}
void EditTandemPresetDialog::populate() {
qDebug() << "EditTandemPresetDialog::populate begin";
ui->method_name_line_edit->setText(_tandem_params.getMethodName());
/*
* <note type="input" label="spectrum, parent monoisotopic mass error units">ppm</note>
......@@ -209,6 +217,9 @@ void EditTandemPresetDialog::populate() {
if ( index != -1 ) { // -1 for not found
ui->parent_ion_window_unit_combo_box->setCurrentIndex(index);
}
else {
qDebug() << "EditTandemPresetDialog::populate " << index;
}
//<note type="input" label="spectrum, parent monoisotopic mass error minus">10</note>
ui->parent_ion_lower_window_edit->setText(_tandem_params.getValue("spectrum, parent monoisotopic mass error minus"));
//<note type="input" label="spectrum, parent monoisotopic mass error plus">10</note>
......@@ -218,4 +229,5 @@ void EditTandemPresetDialog::populate() {
if ( index != -1 ) { // -1 for not found
ui->anticipate_carbon_combo_box->setCurrentIndex(index);
}
qDebug() << "EditTandemPresetDialog::populate end";
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment