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

use peptide table model

parent d3991d7f
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,27 @@ ...@@ -29,6 +29,27 @@
#include "../../core/labeling/label.h" #include "../../core/labeling/label.h"
PeptideTableModel::columnMap PeptideTableModel::_column_assignment = {
(std::int8_t)PeptideListColumn::checked,
(std::int8_t)PeptideListColumn::peptide_grouping_id,
(std::int8_t)PeptideListColumn::sample,
(std::int8_t)PeptideListColumn::scan,
(std::int8_t)PeptideListColumn::rt,
(std::int8_t)PeptideListColumn::charge,
(std::int8_t)PeptideListColumn::sequence,
(std::int8_t)PeptideListColumn::modifs,
(std::int8_t)PeptideListColumn::label,
(std::int8_t)PeptideListColumn::start,
(std::int8_t)PeptideListColumn::length,
(std::int8_t)PeptideListColumn::used,
(std::int8_t)PeptideListColumn::subgroups,
(std::int8_t)PeptideListColumn::Evalue,
(std::int8_t)PeptideListColumn::theoretical_mhplus,
(std::int8_t)PeptideListColumn::delta_mhplus,
(std::int8_t)PeptideListColumn::hyperscore
};
PeptideTableModel::PeptideTableModel(QObject *parent) PeptideTableModel::PeptideTableModel(QObject *parent)
:QAbstractTableModel(parent) :QAbstractTableModel(parent)
{ {
...@@ -70,48 +91,18 @@ int PeptideTableModel::columnCount(const QModelIndex &parent ) const { ...@@ -70,48 +91,18 @@ int PeptideTableModel::columnCount(const QModelIndex &parent ) const {
} }
QVariant PeptideTableModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant PeptideTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{ {
if (role == Qt::DisplayRole) if (orientation == Qt::Horizontal) {
{ switch (role) {
if (orientation == Qt::Horizontal) { case Qt::DisplayRole :
switch (section) return QVariant(getTitle(_column_assignment [section]));
{ break;
case 0: case Qt::ToolTipRole :
return QString("checked"); return QVariant(getDescription(_column_assignment [section]));
case 1: break;
return QString("peptide ID");
case 2:
return QString("sample");
case 3:
return QString("scan");
case 4:
return QString("RT");
case 5:
return QString("charge");
case 6:
return QString("sequence");
case 7:
return QString("modifs");
case 8:
return QString("label");
case 9:
return QString("start");
case 10:
return QString("length");
case 11:
return QString("used");
case 12:
return QString("subgroups");
case 13:
return QString("Evalue");
case 14:
return QString("theoretical MH+");
case 15:
return QString("delta MH+");
case 16:
return QString("hyperscore");
}
} }
} }
//if (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() == nullptr) {
return QVariant(); return QVariant();
} }
QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const { QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
...@@ -144,73 +135,74 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const { ...@@ -144,73 +135,74 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
if (_p_protein_match == nullptr) { if (_p_protein_match == nullptr) {
} }
else { else {
pappso::GrpPeptide * p_grp_peptide;
if (col == 0) { const Label * p_label;
GroupingGroup * p_grp;
switch (_column_assignment[col]) {
case (std::int8_t)PeptideListColumn::checked:
return QVariant(); return QVariant();
} break;
if (col == 1) {
pappso::GrpPeptide * p_grp_peptide = _p_protein_match->getPeptideMatchList().at(row)->getGrpPeptideSp().get(); case (std::int8_t)PeptideListColumn::peptide_grouping_id:
p_grp_peptide = _p_protein_match->getPeptideMatchList().at(row)->getGrpPeptideSp().get();
if (p_grp_peptide != nullptr) return p_grp_peptide->getGroupingId(); if (p_grp_peptide != nullptr) return p_grp_peptide->getGroupingId();
return QVariant(); return QVariant();
} break;
if (col == 2) { case (std::int8_t)PeptideListColumn::sample:
return _p_protein_match->getPeptideMatchList().at(row)->getIdentificationDataSource()->getSampleName(); return _p_protein_match->getPeptideMatchList().at(row)->getIdentificationDataSource()->getSampleName();
} break;
if (col == 3) { case (std::int8_t)PeptideListColumn::scan:
return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row)->getScan()); return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row)->getScan());
} break;
if (col == 4) { case (std::int8_t)PeptideListColumn::rt:
return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row)->getRetentionTime()); return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row)->getRetentionTime());
} break;
if (col == 5) { case (std::int8_t)PeptideListColumn::charge:
return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row)->getCharge()); return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row)->getCharge());
} break;
if (col ==6) { case (std::int8_t)PeptideListColumn::sequence:
return _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getSequence(); return _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getSequence();
} break;
if (col ==7) { case (std::int8_t)PeptideListColumn::modifs:
return _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getModifString(); return _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getModifString();
} break;
if (col ==8) {//label case (std::int8_t)PeptideListColumn::label:
const Label * p_label = _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getLabel(); p_label = _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getLabel();
if (p_label != nullptr) { if (p_label != nullptr) {
return QVariant(p_label->getXmlId()); return QVariant(p_label->getXmlId());
} }
else { else {
return QVariant(); return QVariant();
} }
} break;
if (col ==9) { case (std::int8_t)PeptideListColumn::start:
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getStart()+1); return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getStart()+1);
} break;
if (col ==10) { case (std::int8_t)PeptideListColumn::length:
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->size()); return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->size());
} break;
if (col ==11) { case (std::int8_t)PeptideListColumn::used:
GroupingGroup * p_grp = _p_protein_match->getGroupingGroupSp().get(); p_grp = _p_protein_match->getGroupingGroupSp().get();
if (p_grp != nullptr) return QVariant((qreal) p_grp->countSubgroupPresence(_p_protein_match->getPeptideMatchList().at(row))); if (p_grp != nullptr) return QVariant((qreal) p_grp->countSubgroupPresence(_p_protein_match->getPeptideMatchList().at(row)));
return QVariant(); return QVariant();
} break;
if (col ==12) { case (std::int8_t)PeptideListColumn::subgroups:
GroupingGroup * p_grp = _p_protein_match->getGroupingGroupSp().get(); p_grp = _p_protein_match->getGroupingGroupSp().get();
if (p_grp != nullptr) return QVariant( p_grp->getSubgroupIdList(_p_protein_match->getPeptideMatchList().at(row)).join(" ")); if (p_grp != nullptr) return QVariant( p_grp->getSubgroupIdList(_p_protein_match->getPeptideMatchList().at(row)).join(" "));
return QVariant(); return QVariant();
} break;
if (col ==13) { case (std::int8_t)PeptideListColumn::Evalue:
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getEvalue()); return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getEvalue());
} break;
case (std::int8_t)PeptideListColumn::theoretical_mhplus:
if (col ==14) {
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getMz(1)); return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getMz(1));
break;
} case (std::int8_t)PeptideListColumn::delta_mhplus:
if (col ==15) {
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getDeltaMass()); return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getDeltaMass());
break;
} case (std::int8_t)PeptideListColumn::hyperscore:
if (col ==16) {
return _p_protein_match->getPeptideMatchList().at(row)->getParam(PeptideMatchParam::tandem_hyperscore); return _p_protein_match->getPeptideMatchList().at(row)->getParam(PeptideMatchParam::tandem_hyperscore);
break;
} }
} }
return QString("Row%1, Column%2") return QString("Row%1, Column%2")
...@@ -244,3 +236,136 @@ void PeptideTableModel::onPeptideDataChanged() { ...@@ -244,3 +236,136 @@ void PeptideTableModel::onPeptideDataChanged() {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
emit layoutChanged(); emit layoutChanged();
} }
const QString PeptideTableModel::getTitle(PeptideListColumn column) {
qDebug() << "PeptideTableModel::getTitle begin ";
return PeptideTableModel::getTitle((std::int8_t) column);
//qDebug() << "ProteinTableModel::getTitle end ";
}
const QString PeptideTableModel::getDescription(PeptideListColumn column) {
qDebug() << "PeptideTableModel::columnCount begin ";
return PeptideTableModel::getDescription((std::int8_t) column);
//qDebug() << "ProteinTableModel::columnCount end ";
}
const QString PeptideTableModel::getTitle(std::int8_t column) {
qDebug() << "PeptideTableModel::getTitle begin " << column;
switch (column) {
case (std::int8_t) PeptideListColumn::checked:
return "checked";
break;
case (std::int8_t) PeptideListColumn::peptide_grouping_id:
return "peptide ID";
break;
case (std::int8_t) PeptideListColumn::sample:
return "sample";
break;
case (std::int8_t) PeptideListColumn::scan:
return "scan";
break;
case (std::int8_t) PeptideListColumn::rt:
return "RT";
break;
case (std::int8_t) PeptideListColumn::charge:
return "charge";
break;
case (std::int8_t) PeptideListColumn::sequence:
return "sequence";
break;
case (std::int8_t) PeptideListColumn::modifs:
return "modifs";
break;
case (std::int8_t) PeptideListColumn::label:
return "label";
break;
case (std::int8_t) PeptideListColumn::start:
return "start";
break;
case (std::int8_t) PeptideListColumn::length:
return "length";
break;
case (std::int8_t) PeptideListColumn::used:
return "used";
break;
case (std::int8_t) PeptideListColumn::subgroups:
return "subgroups";
break;
case (std::int8_t) PeptideListColumn::Evalue:
return "Evalue";
break;
case (std::int8_t) PeptideListColumn::theoretical_mhplus:
return "theoretical MH+";
break;
case (std::int8_t) PeptideListColumn::delta_mhplus:
return "delta MH+";
break;
case (std::int8_t) PeptideListColumn::hyperscore:
return "hyperscore";
}
return "";
}
const QString PeptideTableModel::getDescription(std::int8_t column) {
qDebug() << "ProteinTableModel::getDescription begin " << column;
switch (column) {
case (std::int8_t) PeptideListColumn::checked:
return "manual protein check";
break;
case (std::int8_t) PeptideListColumn::peptide_grouping_id:
return "unique peptide identifier within this grouping experiment";
break;
case (std::int8_t) PeptideListColumn::sample:
return "MS sample name";
break;
case (std::int8_t) PeptideListColumn::scan:
return "scan number";
break;
case (std::int8_t) PeptideListColumn::rt:
return "retention time in seconds";
break;
case (std::int8_t) PeptideListColumn::charge:
return "peptide charge";
break;
case (std::int8_t) PeptideListColumn::sequence:
return "peptide sequence";
break;
case (std::int8_t) PeptideListColumn::modifs:
return "peptide modifications";
break;
case (std::int8_t) PeptideListColumn::label:
return "peptide label";
break;
case (std::int8_t) PeptideListColumn::start:
return "peptide start position on protein";
break;
case (std::int8_t) PeptideListColumn::length:
return "peptide length";
break;
case (std::int8_t) PeptideListColumn::used:
return "used";
break;
case (std::int8_t) PeptideListColumn::subgroups:
return "subgroups";
break;
case (std::int8_t) PeptideListColumn::Evalue:
return "peptide Evalue";
break;
case (std::int8_t) PeptideListColumn::theoretical_mhplus:
return "peptide theoretical MH+";
break;
case (std::int8_t) PeptideListColumn::delta_mhplus:
return "peptide mass difference betwenn observed mass and theoretical mass";
break;
case (std::int8_t) PeptideListColumn::hyperscore:
return "X!Tandem hyperscore";
}
return "";
}
...@@ -26,6 +26,31 @@ ...@@ -26,6 +26,31 @@
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include "../../core/project.h" #include "../../core/project.h"
/** \def PeptideListColumn list of available fields to display in peptide list
*
*/
enum class PeptideListColumn {
checked, ///< manual checked
peptide_grouping_id, ///< manual checked
sample,
scan,
rt,
charge,
sequence,
modifs,
label,
start,
length,
used,
subgroups,
Evalue,
theoretical_mhplus,
delta_mhplus,
hyperscore
};
class PeptideTableModel; class PeptideTableModel;
class PeptideTableModel: public QAbstractTableModel class PeptideTableModel: public QAbstractTableModel
...@@ -38,9 +63,12 @@ public: ...@@ -38,9 +63,12 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
static const QString getTitle(PeptideListColumn column);
static const QString getDescription(PeptideListColumn column);
void setProteinMatch(ProteinMatch * p_protein_match); void setProteinMatch(ProteinMatch * p_protein_match);
ProteinMatch * getProteinMatch(); ProteinMatch * getProteinMatch();
using columnMap = std::int8_t[30];
signals: signals:
void peptideMatchClicked(PeptideMatch * p_peptide_match); void peptideMatchClicked(PeptideMatch * p_peptide_match);
...@@ -49,8 +77,12 @@ public slots: ...@@ -49,8 +77,12 @@ public slots:
public slots: public slots:
void onTableClicked(const QModelIndex &index); void onTableClicked(const QModelIndex &index);
private :
static const QString getTitle(std::int8_t column);
static const QString getDescription(std::int8_t column);
private : private :
ProteinMatch * _p_protein_match= nullptr; ProteinMatch * _p_protein_match= nullptr;
static columnMap _column_assignment;
}; };
#endif // PEPTIDETABLEMODEL_H #endif // PEPTIDETABLEMODEL_H
...@@ -35,7 +35,7 @@ PeptideTableProxyModel::PeptideTableProxyModel(PeptideListWindow * p_peptide_lis ...@@ -35,7 +35,7 @@ PeptideTableProxyModel::PeptideTableProxyModel(PeptideListWindow * p_peptide_lis
} }
bool PeptideTableProxyModel::filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const { bool PeptideTableProxyModel::filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const {
if (source_column == 8) { if (source_column == (std::int8_t)PeptideListColumn::label) {
if (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() == nullptr) { if (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() == nullptr) {
return false; return false;
} }
...@@ -157,21 +157,10 @@ bool PeptideTableProxyModel::lessThan(const QModelIndex & left, const QModelInde ...@@ -157,21 +157,10 @@ bool PeptideTableProxyModel::lessThan(const QModelIndex & left, const QModelInde
QVariant PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
{ {
if (role == Qt::DisplayRole) int col = mapToSource(index(0,section)).column();
{
if (orientation == Qt::Horizontal) { return sourceModel()->headerData(col, orientation,
if (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() == nullptr) { role);
if (section > 7) {
section = section+1;
}
return sourceModel()->headerData(section, orientation, role);
}
else {
return sourceModel()->headerData(section, orientation, role);
}
}
}
return QVariant();
} }
void PeptideTableProxyModel::hideNotValid(bool hide) { void PeptideTableProxyModel::hideNotValid(bool hide) {
...@@ -193,3 +182,4 @@ void PeptideTableProxyModel::setSearchOn(QString search_on) { ...@@ -193,3 +182,4 @@ void PeptideTableProxyModel::setSearchOn(QString search_on) {
void PeptideTableProxyModel::setPeptideSearchString(QString peptide_search_string) { void PeptideTableProxyModel::setPeptideSearchString(QString peptide_search_string) {
_peptide_search_string = peptide_search_string; _peptide_search_string = peptide_search_string;
} }
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
void setIdentificationGroup(IdentificationGroup * p_identification_group); void setIdentificationGroup(IdentificationGroup * p_identification_group);
IdentificationGroup * getIdentificationGroup(); IdentificationGroup * getIdentificationGroup();
using columnMap = std::int8_t[20]; using columnMap = std::int8_t[30];
public slots: public slots:
void onProteinDataChanged(); void onProteinDataChanged();
......
...@@ -12,4 +12,5 @@ ...@@ -12,4 +12,5 @@
<mod at="Nter" value="36.0" acc="MOD:00638"/> <mod at="Nter" value="36.0" acc="MOD:00638"/>
<mod at="K" value="36.0" acc="MOD:00638"/> <mod at="K" value="36.0" acc="MOD:00638"/>
</isotope_label> </isotope_label>
</isotope_label_list>
</catalog> </catalog>
...@@ -54,7 +54,7 @@ IdentificationDataSourceSp IdentificationDataSourceStore::getInstance(const QStr ...@@ -54,7 +54,7 @@ IdentificationDataSourceSp IdentificationDataSourceStore::getInstance(const QStr
QFileInfo location_file(location); QFileInfo location_file(location);
QString ext = location_file.suffix(); QString ext = location_file.suffix();
//QString sample_name = location_file.baseName(); //QString sample_name = location_file.baseName();
IdentificationDataSourceSp p_identfile; IdentificationDataSourceSp p_identfile = nullptr;
if (ext.toLower() == "xml") { if (ext.toLower() == "xml") {
//X!Tandem result file //X!Tandem result file
p_identfile = std::make_shared<IdentificationXtandemFile>(location_file); p_identfile = std::make_shared<IdentificationXtandemFile>(location_file);
......
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