Commit 2d57610b authored by Edlira Nano's avatar Edlira Nano
Browse files

xicSelectionWidget working :)

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2244 e4b6dbb4-9209-464b-83f7-6257456c460c
parent 51ada734
......@@ -58,8 +58,8 @@ if (NOT CMAKE_INSTALL_PREFIX)
SET (CMAKE_INSTALL_PREFIX /usr/local)
endif (NOT CMAKE_INSTALL_PREFIX)
SET(CMAKE_BUILD_TYPE "Release")
#SET(CMAKE_BUILD_TYPE "RelWithDebInfo")
#SET(CMAKE_BUILD_TYPE "Release")
SET(CMAKE_BUILD_TYPE "RelWithDebInfo")
#SET( CMAKE_BUILD_TYPE "Debug")
IF(CMAKE_BUILD_TYPE MATCHES "Release")
......
......@@ -131,12 +131,14 @@ SET(GUI_SRCS
./gui/mainwindow.cpp
./gui/masschroq_gui.cpp
./gui/xicSelectionWidget.cpp
./gui/xicProfile.cpp
)
# another list, this time it includes all header files that should be treated with moc
SET(GUI_MOC_HDRS
./gui/mainwindow.h
./gui/xicSelectionWidget.h
./gui/xicProfile.h
)
set(CMAKE_MODULE_PATH ${masschroq_SOURCE_DIR}/modules)
......
......@@ -76,7 +76,7 @@ MainWindow::createActions() {
_aboutAct = new QAction(tr("&About"), this);
_aboutAct->setStatusTip(tr("About MassChroQ GUI"));
connect(_quitAct, SIGNAL(triggered()), this, SLOT(about()));
connect(_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}
......@@ -100,13 +100,12 @@ MainWindow::extractXicWidget() {
XicSelectionWidget * xic = new XicSelectionWidget(dock);
dock->setWidget(xic);
addDockWidget(Qt::LeftDockWidgetArea, dock);
connect(xic, SIGNAL(extract()), this, SLOT(extractXic(xic)));
connect(xic, SIGNAL(extract(XicSelectionWidget *)), this, SLOT(extractXic(XicSelectionWidget *)));
}
void
MainWindow::extractXic(XicSelectionWidget * xic) {
_masschroq_gui->extractXic(xic);
_masschroq_gui->extractXicProfile(_current_msrun_file, xic);
}
void
......@@ -115,9 +114,6 @@ MainWindow::filterXic() {
}
void MainWindow::about() {
QMessageBox::about(this, tr("About MassChroQ"),
tr("This is <b>MassChroQ GUI</b> version beta."));
......
......@@ -17,7 +17,7 @@ private slots:
void loadMsrun();
void extractXicWidget();
void extractXic(XicSelectionWidget *);
void extractXic(XicSelectionWidget * xic);
void filterXic();
void about();
......
......@@ -6,10 +6,15 @@
#include "masschroq_gui.h"
#include "../mcq_types.h"
#include "xicProfile.h"
#include "xicSelectionWidget.h"
#include "../lib/mcq_error.h"
#include "../lib/msrun/msrun_classic.h"
#include "../lib/msrun/msrun_sliced.h"
#include "../lib/xicExtractionMethods/xicExtractionMethodBase.h"
#include "../lib/quanti_items/quantiItemMzRt.h"
#include "../lib/xic/xic_base.h"
#include <math.h>
MasschroqGui::MasschroqGui() {
......@@ -71,15 +76,15 @@ MasschroqGui::setMsRun(const QString & filename) {
}
void
MasschroqGui::addMsRun(const QString & filename, const Msrun * msrun) {
MasschroqGui::addMsRun(const QString & filename, Msrun * msrun) {
_msrun_map[filename] = msrun;
}
Msrun *
MassChroq::getMsRun(const QString & filename) const {
MasschroqGui::getMsRun(const QString & filename) const {
std::map<QString, Msrun *>::const_iterator it;
it = _msrun_map.find(filename);
if (it == end()) {
if (it == _msrun_map.end()) {
return (NULL);
} else {
return (it->second);
......@@ -87,27 +92,44 @@ MassChroq::getMsRun(const QString & filename) const {
}
XicProfile *
MassChroq::extractXicProfile(XicSelectionWidget * xic) {
MasschroqGui::extractXicProfile(const QString & msrun_filename, XicSelectionWidget * xic) {
qDebug() << "Yo 1" << endl;
Msrun * msrun = getMsRun(msrun_filename);
if (msrun == NULL) {
throw mcqError(QObject::tr("The msrun with filename %1, does not exist").arg(msrun_filename));
}
qDebug() << "Yo 2" << endl;
if (xic == NULL)
qDebug() << "Null" << endl;
XicExtractionMethodBase * extraction_method = xic->getXicExtractionMethod();
qDebug() << "Yo 3" << endl;
mcq_xic_type xic_type = xic->getXicType();
mcq_double mz_value = xic->getMzToExtract();
mcq_double rt_value = xic->getRtToExtract();
qDebug() << "Yo 3" << endl;
extraction_method->setMz(mz_value);
qDebug() << "Yo 4" << endl;
QuantiItemBase * quanti_item;
if (rt_value != 0) {
quanti_item = new QuantiItemMzRt(*extraction_method, rt_value);
} else {
quanti_item = new QuantiItemBase(*extraction_method);
}
// extract XIC
_msrun->prepareSpectraForQuantification(extraction_method);
xicBase * current_xic = _msrun->extractXic(xic_type, quanti_item);
qDebug() << "Yo 3" << endl;
msrun->prepareSpectraForQuantification(extraction_method);
xicBase * current_xic = msrun->extractXic(xic_type, quanti_item);
qDebug() << "Yo 4" << endl;
if (current_xic == 0) {
qDebug() << "MsrunSelectionXic null xic ";
}
qDebug() << "Yo 5" << endl;
XicProfile * xic_profile = new XicProfile();
xic_profile->setRtVector(*(current_xic->getRetentionTimes()));
xic_profile->setIntensityVector(*(current_xic->getIntensities()));
qDebug() << "Yo 6" << endl;
delete (current_xic);
_msrun.doneWithSpectra();
msrun->doneWithSpectra();
return xic_profile;
......
......@@ -38,6 +38,9 @@
/* #include "peptides/protein.h" */
/* #include "peptides/isotope_label.h" */
class XicProfile;
class XicSelectionWidget;
/**
* \class MasschroqGui
* \brief The super API class in MassChroq GUI: it coordinates the main actions in the GUI
......@@ -53,11 +56,11 @@ class MasschroqGui {
/// creates and sets an msrun
void setMsRun(const QString & filename);
XicProfile * extractXicProfile(XicSelectionWidget xic);
XicProfile * extractXicProfile(const QString & msrun_filename, XicSelectionWidget * xic);
private :
void addMsRun(const QString & filename, const Msrun * msrun);
void addMsRun(const QString & filename, Msrun * msrun);
Msrun * getMsRun(const QString & filename) const;
std::map<QString, Msrun *> _msrun_map;
......
......@@ -18,8 +18,14 @@
*
*/
#ifndef _XICPLOT_H_
#define _XICPLOT_H_ 1
/**
* \file xicPlots.h
* \date November 08, 2011
* \author Edlira Nano
*/
#ifndef _XICPLOTS_H_
#define _XICPLOTS_H_ 1
class QwtPlotCurve;
......@@ -43,29 +49,32 @@ private:
QwtArray<double> d_y;
};
class XicPlot: public QwtPlot {
Q_OBJECT
public:
XicPlot(QWidget * parent = NULL);
virtual ~XicPlot();
void setXic(Msrun & ms_run,
const XicExtractionMethodBase * p_mz_extraction,
//const msRunHashGroup & group,
unsigned int median_window_length,
unsigned int min_max_window_length);
//void plotXicMinusBackground(const xic& the_data);
void appendData(double x, double y);
void appendData(double * x, double * y, int size);
void removeData();
class XicPlots: public QwtPlot {
Q_OBJECT
private:
void plotXic(const xicBase& the_data, QColor color, QString title);
public:
XicPlots(QWidget * parent = NULL);
virtual ~XicPlots();
void setXic(Msrun & ms_run,
const XicExtractionMethodBase * p_mz_extraction,
//const msRunHashGroup & group,
unsigned int median_window_length,
unsigned int min_max_window_length);
void appendData(double x, double y);
void appendData(double * x, double * y, int size);
void removeData();
private:
void plotXic(const xicBase& the_data, QColor color, QString title);
CurveData * d_data;
QwtPlotCurve * d_curve;
CurveData * d_data;
QwtPlotCurve * d_curve;
Zoomer * _zoomer;
};
#endif // _XICPLOT_H_
#endif // _XICPLOTS_H_
......@@ -5,6 +5,7 @@
*/
#include "xicProfile.h"
#include <iostream>
XicProfile::XicProfile() {
_rt_vector = new std::vector<mcq_double>;
......@@ -29,6 +30,7 @@ XicProfile::setRtVector(const std::vector<mcq_double> & rt_v) {
it_rt != rt_v.end();
++it_rt) {
_rt_vector->push_back(*it_rt);
std::cout << "rt : " << *it_rt << std::endl;
}
}
......@@ -39,5 +41,6 @@ XicProfile::setIntensityVector(const std::vector<mcq_double> & intensity_v) {
it_int != intensity_v.end();
++it_int) {
_intensity_vector->push_back(*it_int);
std::cout << "int : " << *it_int << std::endl;
}
}
......@@ -24,10 +24,13 @@
* \author Edlira Nano
*/
#ifndef XICPROFILE_H_
#define XICPROFILE_H_ 1
#ifndef XIC_PROFILE_H_
#define XIC_PROFILE_H_ 1
#include <vector>
#include "../mcq_types.h"
//class xicBase;
/**
* \class XicProfile
......@@ -46,24 +49,22 @@ class XicProfile {
virtual ~XicProfile();
protected :
void setRtVector(const std::vector<mcq_double> & rt_v);
void setIntensityVector(const std::vector<mcq_double> & intensity_v);
private :
/// XicProfile's retention times (x-axis)
std::vector<mcq_double> * _rt_vector;
/// XicProfile's intensities (y-axis)
std::vector<mcq_double> * _intensity_vector;
private :
/// The XIC this profile corresponds to
xicBase * _xic;
//xicBase * _xic;
};
#endif /* XICPROFILE_H_*/
#endif /* XIC_PROFILE_H_*/
......@@ -5,10 +5,14 @@
*/
#include <QtGui>
#include "../lib/mcq_error.h"
#include "xicSelectionWidget.h"
#include "../lib/xicExtractionMethods/xicExtractionMethodMzRange.h"
#include "../lib/xicExtractionMethods/xicExtractionMethodPpmRange.h"
XicSelectionWidget::XicSelectionWidget(QWidget * parent) : QWidget(parent) {
_xic_extraction_method = 0;
create_xic_type_group();
create_xic_range_group();
create_mz_group();
......@@ -19,6 +23,7 @@ XicSelectionWidget::XicSelectionWidget(QWidget * parent) : QWidget(parent) {
_button_box->addButton(extractButton, QDialogButtonBox::AcceptRole);
_button_box->addButton(QDialogButtonBox::Cancel);
connect(_button_box, SIGNAL(accepted()), this, SLOT(extractXic()));
connect(_button_box, SIGNAL(rejected()), this, SLOT(cancel()));
......@@ -29,7 +34,6 @@ XicSelectionWidget::XicSelectionWidget(QWidget * parent) : QWidget(parent) {
mainLayout->addWidget(_button_box);
setLayout(mainLayout);
setWindowTitle(tr("XIC extraction"));
}
XicSelectionWidget::~XicSelectionWidget() {
......@@ -67,7 +71,7 @@ XicSelectionWidget::create_xic_range_group() {
QCheckBox * ppm_range = new QCheckBox(tr("ppm range"));
ppm_range->setChecked(true);
XicExtractionMethodPpmRange extraction_method = new XicExtractionMethodPpmRange();
XicExtractionMethodPpmRange * extraction_method = new XicExtractionMethodPpmRange();
setXicExtractionMethod(extraction_method);
QCheckBox * mz_range = new QCheckBox(tr("mz range"));
......@@ -99,6 +103,8 @@ XicSelectionWidget::create_xic_range_group() {
_xic_range_group->setLayout(layout);
connect(xic_range_buttons, SIGNAL(buttonClicked(QAbstractButton * )),
this, SLOT(setXicExtractionMethod(QAbstractButton *)));
......@@ -114,11 +120,13 @@ XicSelectionWidget::create_mz_group() {
_mz_group = new QGroupBox(tr("m/z value selection"));
QFormLayout * layout = new QFormLayout;
QDoubleSpinBox * mz_value = new QDoubleSpinBox;
mz_value->setDecimals(4);
mz_value->setMaximum(5000.0000);
mz_value->setSingleStep(10.0000);
setMzToExtract(0);
QDoubleSpinBox * rt_value = new QDoubleSpinBox;
rt_value->setDecimals(4);
rt_value->setMaximum(5000.0000);
rt_value->setSingleStep(10.0000);
setRtToExtract(0);
......@@ -135,8 +143,8 @@ XicSelectionWidget::create_mz_group() {
void
XicSelectionWidget::setXicType(mcq_xic_type & type) {
if ( (type != MAX_XIC_TYPE) || (type != SUM_XIC_TYPE) ) {
XicSelectionWidget::setXicType(const mcq_xic_type & type) {
if ( (type != MAX_XIC_TYPE) && (type != SUM_XIC_TYPE) ) {
throw mcqError(QObject::tr("XicSelectionWidget::setXicType(mcq_xic_type) : invalid xic type"));
}
......@@ -186,30 +194,30 @@ XicSelectionWidget::setXicExtractionMethod(QAbstractButton * button) {
}
void
XicSelectionWidget::setMinRange(mcq_double min) {
XicSelectionWidget::setMinRange(double min) {
_min_range = min;
_xic_extraction_method->set_low_mz_range(_min_range);
_xic_extraction_method->set_min_range(_min_range);
}
void
XicSelectionWidget::setMaxRange(mcq_double max) {
XicSelectionWidget::setMaxRange(double max) {
_max_range = max;
_xic_extraction_method->set_high_mz_range(_max_range);
_xic_extraction_method->set_max_range(_max_range);
}
void
XicSelectionWidget::setMzToExtract(mcq_double mz) {
XicSelectionWidget::setMzToExtract(double mz) {
_mz_to_extract = mz;
}
void
XicSelectionWidget::setRtToExtract(mcq_double rt) {
XicSelectionWidget::setRtToExtract(double rt) {
_rt_to_extract = rt;
}
void
XicSelectionWidget::extractXic() {
emit extract();
emit extract(this);
}
void
......@@ -218,7 +226,7 @@ XicSelectionWidget::cancel() {
this->deleteLater();
}
const XicExtractionMethodBase *
XicExtractionMethodBase *
XicSelectionWidget::getXicExtractionMethod() const {
return _xic_extraction_method;
}
......
......@@ -28,10 +28,13 @@
#define XIC_SELECTION_WIDGET_H_ 1
#include <QDialog>
#include "../mcq_types.h"
class QButtonGroup;
class QGroupBox;
class QDialogButtonBox;
class QAbstractButton;
class XicExtractionMethodBase;
/**
......@@ -51,7 +54,7 @@ class XicSelectionWidget : public QWidget {
virtual ~XicSelectionWidget();
const XicExtractionMethodBase * getXicExtractionMethod() const;
XicExtractionMethodBase * getXicExtractionMethod() const;
const mcq_xic_type getXicType() const;
......@@ -63,17 +66,16 @@ class XicSelectionWidget : public QWidget {
void setXicType(QAbstractButton *);
void setXicExtractionMethod(QAbstractButton *);
void setMinRange(mcq_double min);
void setMaxRange(mcq_double max);
void setMzToExtract(mcq_double mz);
void setRtToExtract(mcq_double rt);
void setMinRange(double min);
void setMaxRange(double max);
void setMzToExtract(double mz);
void setRtToExtract(double rt);
void extractXic();
void cancel();
signals :
void extract();
void extract(XicSelectionWidget *);
protected :
......@@ -84,7 +86,7 @@ class XicSelectionWidget : public QWidget {
mcq_double _mz_to_extract;
mcq_double _rt_to_extract;
void setXicType(mcq_xic_type & type);
void setXicType(const mcq_xic_type & type);
void setXicExtractionMethod(XicExtractionMethodBase * extraction_method);
private :
......
......@@ -146,8 +146,8 @@ Slicer::closeCacheInSlices() {
const mcq_slice_index_id
Slicer::getSliceIdForMz(const QuantiItemBase * quanti_item) const {
const mcq_double high_mz = quanti_item->get_high_mz();
const mcq_double low_mz = quanti_item->get_low_mz();
const mcq_double high_mz = quanti_item->get_max_mz();
const mcq_double low_mz = quanti_item->get_min_mz();
std::vector<Slice * >::const_iterator it_slice;
for (it_slice = _slices.begin();
......
......@@ -56,8 +56,8 @@ xicPeak::print(std::ostream & out) const {
mcq_double aligned_rtime_max = this->get_aligned_max_rt();
out << "rtime max\tmax intensity\tarea\tmz_start\tmz_stop" << std::endl;
out << aligned_rtime_max << "\t" << _max_intensity << "\t" << _area << "\t"
<< _xic_quanti_item.get_low_mz() << "\t"
<< _xic_quanti_item.get_high_mz() << std::endl;
<< _xic_quanti_item.get_min_mz() << "\t"
<< _xic_quanti_item.get_max_mz() << std::endl;
}
void
......
......@@ -10,8 +10,8 @@
QuantiItemBase::QuantiItemBase(const XicExtractionMethodBase & extraction_method) {
_mz = extraction_method.get_mz();
_low_mz = extraction_method.get_low_mz();
_high_mz = extraction_method.get_high_mz();
_low_mz = extraction_method.get_min_mz();
_high_mz = extraction_method.get_max_mz();
this->setType();
}
......@@ -24,12 +24,12 @@ QuantiItemBase::get_mz() const {
}
mcq_double
QuantiItemBase::get_low_mz() const {
QuantiItemBase::get_min_mz() const {
return (_low_mz);
}
mcq_double
QuantiItemBase::get_high_mz() const {
QuantiItemBase::get_max_mz() const {
return (_high_mz);
}
......@@ -64,9 +64,9 @@ QuantiItemBase::getSimpleName(const Msrun * msrun) const {
QString name("mz_"), tmp;
tmp.setNum(get_mz());
name.append(tmp).append("_l_");
tmp.setNum(get_low_mz()).append("_");
tmp.setNum(get_min_mz()).append("_");
name.append(tmp).append("_h_");
tmp.setNum(get_high_mz());
tmp.setNum(get_max_mz());
name.append(tmp);
name = name.replace(".", "-");
//name.append(suffixName());
......
......@@ -55,9 +55,9 @@ class QuantiItemBase {
mcq_double get_mz() const;
mcq_double get_low_mz() const;
mcq_double get_min_mz() const;
mcq_double get_high_mz() const;
mcq_double get_max_mz() const;
virtual const unsigned int * getZ() const {
return (NULL);
......
......@@ -47,9 +47,9 @@ QuantiItemMzRt::getSimpleName(const Msrun * msrun) const {
name.append(tmp).append("_rt_");
tmp.setNum(_rt);
name.append(tmp).append("_l_");
tmp.setNum(get_low_mz());
tmp.setNum(get_min_mz());
name.append(tmp).append("_h_");
tmp.setNum(get_high_mz());
tmp.setNum(get_max_mz());
name.append(tmp);
name = name.replace(".", "-");
// name.append(suffixName());
......
......@@ -73,9 +73,9 @@ QuantiItemPeptide::getSimpleName(const Msrun * msrun) const {
name.append(tmp).append("_rt_");
tmp.setNum(getMatchingRt(msrun));
name.append(tmp).append("_l_");
tmp.setNum(get_low_mz());
tmp.setNum(get_min_mz());
name.append(tmp).append("_h_");
tmp.setNum(get_high_mz());
tmp.setNum(get_max_mz());
name.append(tmp).append("_z_");
tmp.setNum(_z);
name.append(tmp);
......
......@@ -16,8 +16,8 @@ xicBase::xicBase(const Msrun * p_ms_run,
_p_quanti_item(quanti_item),
_p_ms_run(p_ms_run)
{
_mz_start = _p_quanti_item->get_low_mz();
_mz_stop = _p_quanti_item->get_high_mz();
_mz_start = _p_quanti_item->get_min_mz();
_mz_stop = _p_quanti_item->get_max_mz();
_p_v_rt = new std::vector<mcq_double>;
_p_v_intensity = new std::vector<mcq_double>;
......