Skip to content
Snippets Groups Projects
Commit cc48fd86 authored by Langella Olivier's avatar Langella Olivier
Browse files

WIP: show several peptide match if needed in ptm islands

parent 0ae79f22
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ PtmSampleScan::PtmSampleScan(const PeptideMatch * p_peptide_match) { ...@@ -40,7 +40,7 @@ PtmSampleScan::PtmSampleScan(const PeptideMatch * p_peptide_match) {
_peptide_match_list.push_back(p_peptide_match); _peptide_match_list.push_back(p_peptide_match);
} }
PtmSampleScan::PtmSampleScan(const PtmSampleScan& other){ PtmSampleScan::PtmSampleScan(const PtmSampleScan& other) {
} }
PtmSampleScan::~PtmSampleScan() { PtmSampleScan::~PtmSampleScan() {
...@@ -59,8 +59,8 @@ bool PtmSampleScan::add(const PeptideMatch * p_peptide_match) { ...@@ -59,8 +59,8 @@ bool PtmSampleScan::add(const PeptideMatch * p_peptide_match) {
return false; return false;
} }
_peptide_match_list.push_back(p_peptide_match); _peptide_match_list.push_back(p_peptide_match);
//sort list //sort list
std::sort(_peptide_match_list.begin(),_peptide_match_list.end(),[](const PeptideMatch * first, const PeptideMatch * second) { std::sort(_peptide_match_list.begin(),_peptide_match_list.end(),[](const PeptideMatch * first, const PeptideMatch * second) {
return (first->getEvalue() < second->getEvalue()) ; return (first->getEvalue() < second->getEvalue()) ;
}); });
...@@ -68,24 +68,24 @@ bool PtmSampleScan::add(const PeptideMatch * p_peptide_match) { ...@@ -68,24 +68,24 @@ bool PtmSampleScan::add(const PeptideMatch * p_peptide_match) {
return true; return true;
} }
std::vector<unsigned int> PtmSampleScan::getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const { std::vector<unsigned int> PtmSampleScan::getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const {
return p_ptm_grouping_experiment->getPtmPositions(getRepresentativePeptideMatch()); return p_ptm_grouping_experiment->getPtmPositions(getRepresentativePeptideMatch());
} }
std::vector<unsigned int> PtmSampleScan::getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const { std::vector<unsigned int> PtmSampleScan::getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const {
std::vector<unsigned int> position_list; std::vector<unsigned int> position_list;
for (const PeptideMatch * p_peptide_match: _peptide_match_list) { for (const PeptideMatch * p_peptide_match: _peptide_match_list) {
std::vector<unsigned int> positionb_list = p_ptm_grouping_experiment->getPtmPositions(p_peptide_match); std::vector<unsigned int> positionb_list = p_ptm_grouping_experiment->getPtmPositions(p_peptide_match);
for (unsigned int position: positionb_list) { for (unsigned int position: positionb_list) {
position_list.push_back(position); position_list.push_back(position);
}
} }
std::sort(position_list.begin(), position_list.end());
auto last = std::unique(position_list.begin(), position_list.end());
position_list.erase(last, position_list.end());
return position_list;
} }
std::sort(position_list.begin(), position_list.end());
auto last = std::unique(position_list.begin(), position_list.end());
position_list.erase(last, position_list.end());
return position_list;
}
const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const
{ {
...@@ -98,7 +98,7 @@ const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm ...@@ -98,7 +98,7 @@ const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm
bool nobest_bool[pep_size] = {false}; bool nobest_bool[pep_size] = {false};
double best_evalue = p_representative_peptide->getEvalue(); double best_evalue = p_representative_peptide->getEvalue();
for (auto & p_peptide_match : _peptide_match_list) { for (auto & p_peptide_match : _peptide_match_list) {
bool is_best= false; bool is_best= false;
if (p_peptide_match->getEvalue() == best_evalue) { if (p_peptide_match->getEvalue() == best_evalue) {
...@@ -121,17 +121,21 @@ const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm ...@@ -121,17 +121,21 @@ const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm
QString sequence_html; QString sequence_html;
for (unsigned int i=0; i < pep_size; i++) { for (unsigned int i=0; i < pep_size; i++) {
if (best_bool[i]) { if (best_bool[i]) {
sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_best.name())); sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_best.name()));
} }
else if (other_best_bool[i]) { else if (other_best_bool[i]) {
sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_other_best.name())); sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_other_best.name()));
} }
else if (nobest_bool[i]){ else if (nobest_bool[i]) {
sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_no_best.name())); sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_no_best.name()));
} }
else { else {
sequence_html.append(sequence[i]); sequence_html.append(sequence[i]);
} }
} }
return sequence_html; return sequence_html;
} }
const std::vector<const PeptideMatch *> & PtmSampleScan::getPeptideMatchList() const {
return _peptide_match_list;
}
...@@ -53,6 +53,7 @@ public: ...@@ -53,6 +53,7 @@ public:
std::vector<unsigned int> getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; std::vector<unsigned int> getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const;
std::vector<unsigned int> getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; std::vector<unsigned int> getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const;
const QString getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; const QString getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const;
const std::vector<const PeptideMatch *> & getPeptideMatchList() const;
private: private:
std::vector<const PeptideMatch *> _peptide_match_list; std::vector<const PeptideMatch *> _peptide_match_list;
......
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
#include "ui_ptm_peptide_list_view.h" #include "ui_ptm_peptide_list_view.h"
PtmPeptideListWindow::PtmPeptideListWindow(PtmIslandListWindow * parent):QMainWindow(parent), PtmPeptideListWindow::PtmPeptideListWindow(PtmIslandListWindow * parent):QMainWindow(parent),
ui(new Ui::PtmPeptideListWindow) { ui(new Ui::PtmPeptideListWindow) {
_p_ptm_island_list_window = parent; _p_ptm_island_list_window = parent;
......
...@@ -41,6 +41,7 @@ namespace Ui { ...@@ -41,6 +41,7 @@ namespace Ui {
class PtmPeptideListWindow; class PtmPeptideListWindow;
} }
class PtmPeptideListWindow: public QMainWindow { class PtmPeptideListWindow: public QMainWindow {
Q_OBJECT Q_OBJECT
public: public:
...@@ -49,12 +50,14 @@ public: ...@@ -49,12 +50,14 @@ public:
~PtmPeptideListWindow(); ~PtmPeptideListWindow();
void setPtmIsland(PtmIsland * p_ptm_island); void setPtmIsland(PtmIsland * p_ptm_island);
private: private:
PtmIsland * _p_ptm_island=nullptr; PtmIsland * _p_ptm_island=nullptr;
Ui::PtmPeptideListWindow *ui; Ui::PtmPeptideListWindow *ui;
PtmPeptideTableModel * _ptm_table_model_p = nullptr; PtmPeptideTableModel * _ptm_table_model_p = nullptr;
PtmPeptideTableProxyModel * _ptm_proxy_model_p = nullptr; PtmPeptideTableProxyModel * _ptm_proxy_model_p = nullptr;
PtmIslandListWindow * _p_ptm_island_list_window; PtmIslandListWindow * _p_ptm_island_list_window;
QMenu * _p_context_menu = nullptr;
}; };
......
...@@ -30,10 +30,35 @@ ...@@ -30,10 +30,35 @@
#include "ptmpeptidetablemodel.h" #include "ptmpeptidetablemodel.h"
#include "ptmpeptidelistwindow.h" #include "ptmpeptidelistwindow.h"
PtmPeptideMenuQaction::PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match):QAction(parent) {
this->setText(p_peptide_match->getPeptideXtpSp().get()->getSequence());
//evalue_action.setChecked(_display_evalue);
//connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
#if QT_VERSION >= 0x050000
// Qt5 code
/*
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad);
connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile);
*/
#else
// Qt4 code
connect (this, SIGNAL(toggled(bool)), this,SLOT(doToggled(bool)));
#endif
}
PtmPeptideMenuQaction::~PtmPeptideMenuQaction()
{
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
qDebug() << "PtmPeptideMenuQaction::~PtmPeptideMenuQaction begin ";
}
PtmPeptideTableProxyModel::PtmPeptideTableProxyModel(PtmPeptideListWindow * p_ptm_peptide_list_window, PtmPeptideTableModel* ptm_table_model_p) PtmPeptideTableProxyModel::PtmPeptideTableProxyModel(PtmPeptideListWindow * p_ptm_peptide_list_window, PtmPeptideTableModel* ptm_table_model_p)
{ {
_p_ptm_peptide_list_window = p_ptm_peptide_list_window; _p_ptm_peptide_list_window = p_ptm_peptide_list_window;
_p_ptm_table_model = ptm_table_model_p; _p_ptm_table_model = ptm_table_model_p;
} }
PtmPeptideTableProxyModel::~PtmPeptideTableProxyModel() PtmPeptideTableProxyModel::~PtmPeptideTableProxyModel()
...@@ -41,17 +66,36 @@ PtmPeptideTableProxyModel::~PtmPeptideTableProxyModel() ...@@ -41,17 +66,36 @@ PtmPeptideTableProxyModel::~PtmPeptideTableProxyModel()
} }
bool PtmPeptideTableProxyModel::lessThan(const QModelIndex &left, bool PtmPeptideTableProxyModel::lessThan(const QModelIndex &left,
const QModelIndex &right) const const QModelIndex &right) const
{ {
QVariant leftData = sourceModel()->data(left); QVariant leftData = sourceModel()->data(left);
QVariant rightData = sourceModel()->data(right); QVariant rightData = sourceModel()->data(right);
if (leftData.canConvert<PtmSampleScan *>()) { if (leftData.canConvert<PtmSampleScan *>()) {
PtmSampleScan * p_ptm_sample_scan_left = qvariant_cast<PtmSampleScan *>(leftData); PtmSampleScan * p_ptm_sample_scan_left = qvariant_cast<PtmSampleScan *>(leftData);
PtmSampleScan * p_ptm_sample_scan_right = qvariant_cast<PtmSampleScan *>(rightData); PtmSampleScan * p_ptm_sample_scan_right = qvariant_cast<PtmSampleScan *>(rightData);
return p_ptm_sample_scan_left->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->toAbsoluteString() < p_ptm_sample_scan_right->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->toAbsoluteString(); return p_ptm_sample_scan_left->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->toAbsoluteString() < p_ptm_sample_scan_right->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->toAbsoluteString();
} else { } else {
return QSortFilterProxyModel::lessThan(left, right); return QSortFilterProxyModel::lessThan(left, right);
} }
} }
void PtmPeptideTableProxyModel::showContextMenu(const QModelIndex &index) {
if (_p_context_menu == nullptr) {
_p_context_menu = new QMenu(tr("Context menu"));
QVariant index_data = sourceModel()->data(index);
if (index_data.canConvert<PtmSampleScan *>()) {
PtmSampleScan * p_ptm_sample = qvariant_cast<PtmSampleScan *>(index_data);
PtmPeptideMenuQaction * p_action;
for (auto p_peptide_match : p_ptm_sample->getPeptideMatchList()) {
p_action = new PtmPeptideMenuQaction(this, p_ptm_sample, p_peptide_match);
_p_context_menu->addAction(p_action);
}
}
//_p_context_menu->exec(mapToGlobal(pos));
}
_p_context_menu->show();
}
...@@ -31,11 +31,25 @@ ...@@ -31,11 +31,25 @@
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QMenu>
#include "../../grouping/ptm/ptmsamplescan.h"
class PtmPeptideListWindow; class PtmPeptideListWindow;
class PtmPeptideTableModel; class PtmPeptideTableModel;
class PtmPeptideTableProxyModel;
class PtmPeptideMenuQaction: public QAction {
Q_OBJECT
public:
explicit PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match);
~PtmPeptideMenuQaction();
private:
};
class PtmPeptideTableProxyModel: public QSortFilterProxyModel class PtmPeptideTableProxyModel: public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
...@@ -45,9 +59,11 @@ public: ...@@ -45,9 +59,11 @@ public:
protected: protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
void showContextMenu(const QModelIndex &index);
private: private:
PtmPeptideListWindow * _p_ptm_peptide_list_window; PtmPeptideListWindow * _p_ptm_peptide_list_window;
PtmPeptideTableModel* _p_ptm_table_model; PtmPeptideTableModel* _p_ptm_table_model;
QMenu * _p_context_menu = nullptr;
}; };
#endif // PTMPEPTIDETABLEPROXYMODEL_H #endif // PTMPEPTIDETABLEPROXYMODEL_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment