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

peptide list work

parent 7240cdcb
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,7 @@ SET(XTPCPP_SRCS
./gui/mainwindow.cpp
./gui/peptide_list_view/peptidelistwindow.cpp
./gui/peptide_list_view/peptidetablemodel.cpp
./gui/peptide_list_view/peptidetableproxymodel.cpp
./gui/project_view/projectwindow.cpp
./gui/protein_view/proteinwindow.cpp
./gui/protein_list_view/proteinlistwindow.cpp
......@@ -105,6 +106,7 @@ SET(XTPCPP_MOC_HDRS
./gui/mainwindow.h
./gui/peptide_list_view/peptidelistwindow.h
./gui/peptide_list_view/peptidetablemodel.h
./gui/peptide_list_view/peptidetableproxymodel.h
./gui/project_view/projectwindow.h
./gui/protein_list_view/proteinlistwindow.h
./gui/protein_list_view/proteintablemodel.h
......
......@@ -21,17 +21,32 @@
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include <QSettings>
#include "peptidelistwindow.h"
#include "../project_view/projectwindow.h"
#include "ui_peptide_view.h"
PeptideListWindow::PeptideListWindow(QWidget *parent):
PeptideListWindow::PeptideListWindow(ProjectWindow *parent):
QMainWindow(parent),
ui(new Ui::PeptideView)
{
_project_window = parent;
ui->setupUi(this);
_peptide_table_model_p = new PeptideTableModel(0);
_p_proxy_model = new PeptideTableProxyModel(this, _peptide_table_model_p);
_p_proxy_model->setSourceModel(_peptide_table_model_p);
_p_proxy_model->setDynamicSortFilter(true);
ui->tableView->setModel( _p_proxy_model );
ui->tableView->setSortingEnabled(true);
//connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &)));
#if QT_VERSION >= 0x050000
// Qt5 code
/*
......@@ -41,6 +56,7 @@ PeptideListWindow::PeptideListWindow(QWidget *parent):
*/
#else
// Qt4 code
connect (this, SIGNAL(peptideDataChanged()), _peptide_table_model_p, SLOT(onPeptideDataChanged()));
/*
connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString)));
......@@ -50,16 +66,6 @@ PeptideListWindow::PeptideListWindow(QWidget *parent):
/*
*/
_peptide_table_model_p = new PeptideTableModel(0);
_p_proxy_model = new PeptideTableProxyModel(this, _peptide_table_model_p);
_p_proxy_model->setSourceModel(_peptide_table_model_p);
_p_proxy_model->setDynamicSortFilter(true);
ui->tableView->setModel( _p_proxy_model );
ui->tableView->setSortingEnabled(true);
//connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &)));
}
PeptideListWindow::~PeptideListWindow()
......@@ -83,3 +89,51 @@ void PeptideListWindow::setProteinMatch(Project * p_project, ProteinMatch * p_pr
}
void PeptideListWindow::edited() {
qDebug() << "PeptideListWindow::edited begin";
//emit dataChanged(index, index);
_project_window->doIdentificationGroupEdited(_p_identification_group);
//updateStatusBar();
qDebug() << "PeptideListWindow::edited end";
}
void PeptideListWindow::doNotValidHide(bool hide) {
qDebug() << "PeptideListWindow::doNotValidHide begin";
_p_proxy_model->hideNotValid(hide);
QSettings settings;
settings.setValue("peptidelistview/hidenotvalid", QString("%1").arg(hide));
emit peptideDataChanged();
qDebug() << "PeptideListWindow::doNotValidHide end";
}
void PeptideListWindow::doNotCheckedHide(bool hide) {
qDebug() << "PeptideListWindow::doNotCheckedHide begin";
_p_proxy_model->hideNotChecked(hide);
QSettings settings;
settings.setValue("peptidelistview/hidenotchecked", QString("%1").arg(hide));
emit peptideDataChanged();
qDebug() << "PeptideListWindow::doNotCheckedHide end";
}
void PeptideListWindow::doNotGroupedHide(bool hide) {
qDebug() << "PeptideListWindow::doNotGroupedHide begin";
_p_proxy_model->hideNotGrouped(hide);
QSettings settings;
settings.setValue("peptidelistview/hidenotgrouped", QString("%1").arg(hide));
emit peptideDataChanged();
qDebug() << "PeptideListWindow::doNotGroupedHide end";
}
void PeptideListWindow::onPeptideSearchEdit(QString protein_search_string) {
qDebug() << "PeptideListWindow::onProteinSearchEdit begin " << protein_search_string;
_p_proxy_model->setPeptideSearchString( protein_search_string);
emit peptideDataChanged();
}
void PeptideListWindow::askPeptideDetailView(PeptideMatch * p_peptide_match) {
qDebug() << "PeptideListWindow::askPeptideDetailView begin";
_project_window->doViewPeptideDetail(p_peptide_match);
qDebug() << "PeptideListWindow::askPeptideDetailView end";
//updateStatusBar();
}
......@@ -26,9 +26,11 @@
#include <QMainWindow>
#include "peptidetablemodel.h"
#include "peptidetableproxymodel.h"
#include "../../core/proteinmatch.h"
#include "../../core/project.h"
class ProjectWindow;
//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html
namespace Ui {
class PeptideView;
......@@ -37,11 +39,15 @@ class PeptideView;
class PeptideListWindow: public QMainWindow {
Q_OBJECT
friend class PeptideTableModel;
friend class PeptideTableProxyModel;
public:
explicit PeptideListWindow(QWidget * parent = 0);
explicit PeptideListWindow(ProjectWindow * parent = 0);
~PeptideListWindow();
void setProteinMatch(Project * p_project, ProteinMatch * p_protein_match);
void edited();
public slots:
//void peptideEdited(QString peptideStr);
......@@ -50,13 +56,26 @@ public slots:
void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group);
signals:
void identificationGroupEdited(IdentificationGroup * p_identification_group);
void peptideDataChanged();
//void peptideChanged(pappso::PeptideSp peptide);
protected :
void askPeptideDetailView(PeptideMatch * p_peptide_match);
protected slots:
void doNotValidHide(bool hide);
void doNotCheckedHide(bool hide);
void doNotGroupedHide(bool hide);
void onPeptideSearchEdit(QString protein_search_string);
private:
Ui::PeptideView *ui;
PeptideTableModel * _peptide_table_model_p = nullptr;
PeptideTableProxyModel * _p_proxy_model = nullptr;
ProteinMatch* _p_protein_match;
ProjectWindow * _project_window;
IdentificationGroup * _p_identification_group=nullptr;
};
......
......@@ -28,45 +28,6 @@
#include <pappsomspp/grouping/grppeptide.h>
PeptideTableProxyModel::PeptideTableProxyModel(QObject *parent,PeptideTableModel* peptide_table_model_p): QSortFilterProxyModel(parent)
{
_peptide_table_model_p = peptide_table_model_p;
}
bool PeptideTableProxyModel::filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const {
return _peptide_table_model_p->acceptRow(source_row);
//return true;
}
void PeptideTableProxyModel::onTableClicked(const QModelIndex &index)
{
qDebug() << "PeptideTableProxyModel::onTableClicked begin " << index.row();
qDebug() << "PeptideTableProxyModel::onTableClicked begin " << this->mapToSource(index).row();
_peptide_table_model_p->onTableClicked(this->mapToSource(index));
}
bool PeptideTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const {
QVariant leftData = sourceModel()->data(left);
QVariant rightData = sourceModel()->data(right);
if (leftData.type() == QVariant::UInt) {
return leftData.toUInt() < rightData.toUInt();
}
if (leftData.type() == QVariant::UInt) {
return leftData.toUInt() < rightData.toUInt();
}
if (leftData.type() == QVariant::Double) {
return leftData.toDouble() < rightData.toDouble();
}
return leftData.toString() < rightData.toString();
}
QVariant PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation,
int role) const {
return sourceModel()->headerData(section, orientation,
role);
}
PeptideTableModel::PeptideTableModel(QObject *parent)
:QAbstractTableModel(parent)
{
......@@ -90,6 +51,9 @@ void PeptideTableModel::setProteinMatch(Project * p_project, ProteinMatch * p_pr
qDebug() << "PeptideTableModel::setProteinMatch end " ;
}
ProteinMatch * PeptideTableModel::getProteinMatch() {
return _p_protein_match;
}
int PeptideTableModel::rowCount(const QModelIndex &parent ) const {
if (_p_protein_match != nullptr) {
//qDebug() << "PeptideTableModel::rowCount(const QModelIndex &parent ) " << _p_protein_match->getPeptideMatchList().size();
......@@ -162,7 +126,7 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
}
}
break;
case Qt::BackgroundRole:
case Qt::BackgroundRole:
if (_p_protein_match->getPeptideMatchList().at(row)->isValid() == false)
{
return QVariant(QColor("grey"));
......@@ -172,7 +136,7 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
if (_p_protein_match == nullptr) {
}
else {
if (col == 0) {
return QVariant();
}
......@@ -210,23 +174,23 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
if (p_grp != nullptr) return QVariant((qreal) p_grp->countSubgroupPresence(_p_protein_match->getPeptideMatchList().at(row)));
return QVariant();
}
if (col ==11) {
if (col ==11) {
GroupingGroup * p_grp = _p_protein_match->getGroupingGroupSp().get();
if (p_grp != nullptr) return QVariant( p_grp->getSubgroupIdList(_p_protein_match->getPeptideMatchList().at(row)).join(" "));
return QVariant();
}
if (col ==12) {
if (col ==12) {
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getEvalue());
}
if (col ==13) {
if (col ==13) {
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getMz(1));
}
if (col ==14) {
}
if (col ==14) {
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getDeltaMass());
}
}
}
return QString("Row%1, Column%2")
.arg(index.row() + 1)
......@@ -254,9 +218,8 @@ void PeptideTableModel::onTableClicked(const QModelIndex &index)
}
}
bool PeptideTableModel::acceptRow(int source_row) {
if (_p_protein_match->getPeptideMatchList().at(source_row)->isValid()) {
return true;
}
return true;
void PeptideTableModel::onPeptideDataChanged() {
qDebug() << "PeptideTableModel::onPeptideDataChanged begin " << rowCount();
emit layoutAboutToBeChanged();
emit layoutChanged();
}
......@@ -24,26 +24,9 @@
#define PEPTIDETABLEMODEL_H
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include "../../core/project.h"
class PeptideTableModel;
class PeptideTableProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
PeptideTableProxyModel(QObject* parent,PeptideTableModel* peptide_table_model_p);
bool filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role) const override;
bool lessThan(const QModelIndex & left, const QModelIndex & right) const override;
public slots:
void onTableClicked(const QModelIndex &index);
private:
PeptideTableModel* _peptide_table_model_p;
};
class PeptideTableModel: public QAbstractTableModel
{
......@@ -57,10 +40,12 @@ public:
void setProteinMatch(Project * p_project, ProteinMatch * p_protein_match);
bool acceptRow(int source_row);
ProteinMatch * getProteinMatch();
signals:
void peptideMatchClicked(PeptideMatch * p_peptide_match);
public slots:
void onPeptideDataChanged();
public slots:
void onTableClicked(const QModelIndex &index);
......
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include <QDebug>
#include <pappsomspp/pappsoexception.h>
#include "peptidetableproxymodel.h"
#include "peptidetablemodel.h"
#include "peptidelistwindow.h"
PeptideTableProxyModel::PeptideTableProxyModel(PeptideListWindow * p_peptide_list_window, PeptideTableModel * peptide_table_model_p): QSortFilterProxyModel(peptide_table_model_p)
{
_peptide_table_model_p = peptide_table_model_p;
_p_peptide_list_window = p_peptide_list_window;
}
bool PeptideTableProxyModel::filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const {
try {
qDebug() << "PeptideTableProxyModel::filterAcceptsRow begin " << source_row;
PeptideMatch * peptide_match = _peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(source_row);
qDebug() << "PeptideTableProxyModel::filterAcceptsRow protein_match " << source_row;
if (!_peptide_search_string.isEmpty()) {
if (!peptide_match->getPeptideXtpSp().get()->getSequence().contains(_peptide_search_string)) {
return false;
}
}
qDebug() << "PeptideTableProxyModel::filterAcceptsRow valid ";
if (_hide_not_valid) {
if (! peptide_match->isValid()) {
return false;
}
}
qDebug() << "PeptideTableProxyModel::filterAcceptsRow checked ";
if (_hide_not_checked) {
if (! peptide_match->isChecked()) {
return false;
}
}
qDebug() << "PeptideTableProxyModel::filterAcceptsRow grouped ";
if (_hide_not_grouped) {
if (! peptide_match->isGrouped()) {
return false;
}
}
}
catch (pappso::PappsoException exception_pappso) {
//QMessageBox::warning(this,
// tr("Error in ProteinTableModel::acceptRow :"), exception_pappso.qwhat());
qDebug() << "Error in PeptideTableProxyModel::acceptRow :" << exception_pappso.qwhat();
}
catch (std::exception exception_std) {
//QMessageBox::warning(this,
// tr("Error in ProteinTableModel::acceptRow :"), exception_std.what());
qDebug() << "Error in PeptideTableProxyModel::acceptRow :" << exception_std.what();
}
return true;
//return true;
}
void PeptideTableProxyModel::onTableClicked(const QModelIndex &index)
{
qDebug() << "PeptideTableProxyModel::onTableClicked begin " << index.row();
qDebug() << "PeptideTableProxyModel::onTableClicked begin " << this->mapToSource(index).row();
//_protein_table_model_p->onTableClicked(this->mapToSource(index));
QModelIndex source_index(this->mapToSource(index));
int row = source_index.row();
int col = source_index.column();
PeptideMatch * peptide_match = _peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(row);
if (col == 0) //add a checkbox to cell(1,0)
{
if ( peptide_match->isChecked()) {
peptide_match->setChecked(false);
}
else {
peptide_match->setChecked(true);
}
_p_peptide_list_window->edited();
}
else {
_p_peptide_list_window->askPeptideDetailView(peptide_match);
}
qDebug() << "PeptideTableProxyModel::onTableClicked end " << index.row();
}
bool PeptideTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const {
QVariant leftData = sourceModel()->data(left);
QVariant rightData = sourceModel()->data(right);
if (leftData.type() == QVariant::UInt) {
return leftData.toUInt() < rightData.toUInt();
}
if (leftData.type() == QVariant::UInt) {
return leftData.toUInt() < rightData.toUInt();
}
if (leftData.type() == QVariant::Double) {
return leftData.toDouble() < rightData.toDouble();
}
return leftData.toString() < rightData.toString();
}
QVariant PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation,
int role) const {
return sourceModel()->headerData(section, orientation,
role);
}
void PeptideTableProxyModel::hideNotValid(bool hide) {
_hide_not_valid = hide;
}
void PeptideTableProxyModel::hideNotChecked(bool hide) {
qDebug() << "PeptideTableProxyModel::hideNotChecked begin ";
_hide_not_checked = hide;
qDebug() << "PeptideTableProxyModel::hideNotChecked end ";
}
void PeptideTableProxyModel::hideNotGrouped(bool hide) {
_hide_not_grouped = hide;
}
void PeptideTableProxyModel::setPeptideSearchString(QString peptide_search_string) {
_peptide_search_string = peptide_search_string;
}
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#ifndef PEPTIDETABLEPROXYMODEL_H
#define PEPTIDETABLEPROXYMODEL_H
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include "../../core/project.h"
class PeptideListWindow;
class PeptideTableModel;
class PeptideTableProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
PeptideTableProxyModel(PeptideListWindow * p_peptide_list_window, PeptideTableModel* peptide_table_model_p);
bool filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role) const override;
bool lessThan(const QModelIndex & left, const QModelIndex & right) const override;
void hideNotValid(bool hide);
void hideNotChecked(bool hide);
void hideNotGrouped(bool hide);
void setPeptideSearchString(QString peptide_search_string);
public slots:
void onTableClicked(const QModelIndex &index);
private:
PeptideTableModel* _peptide_table_model_p;
PeptideListWindow * _p_peptide_list_window;
QString _peptide_search_string;
bool _hide_not_valid = true;
bool _hide_not_checked = true;
bool _hide_not_grouped = true;
};
#endif // PEPTIDETABLEPROXYMODEL_H
......@@ -177,6 +177,9 @@ void ProjectWindow::doViewPeptideList(ProteinMatch * protein_match) {
qDebug() << "ProjectWindow::doViewPeptideList end";
}
void ProjectWindow::doViewPeptideDetail(PeptideMatch * peptide_match) {
}
void ProjectWindow::doViewProteinDetail(ProteinMatch * protein_match) {
......@@ -198,7 +201,7 @@ void ProjectWindow::doViewProteinDetail(ProteinMatch * protein_match) {
void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_group) {
qDebug() << "ProjectWindow::doViewProteinList begin " << p_identification_group;
//if (p_identification_group == nullptr) {
p_identification_group = _project_sp.get()->getCurrentIdentificationGroupP();
p_identification_group = _project_sp.get()->getCurrentIdentificationGroupP();
//}
if (_protein_list_window_collection.size() == 0) {
connectNewProteinListWindow();
......@@ -213,7 +216,7 @@ void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_grou
qDebug() << "ProjectWindow::doViewProteinList end " << p_identification_group;
_p_current_protein_list_window->setIdentificationGroup(p_identification_group);
emit identificationGroupGrouped(p_identification_group);
qDebug() << "ProjectWindow::doViewProteinList end";
}
......
......@@ -41,6 +41,7 @@ class ProjectWindow: public QMainWindow {
Q_OBJECT
friend class ProteinListWindow;
friend class PeptideListWindow;
public:
explicit ProjectWindow(MainWindow * parent = 0);
......@@ -59,6 +60,7 @@ signals:
protected :
void doViewPeptideList(ProteinMatch * protein_match);
void doViewProteinDetail(ProteinMatch * protein_match);
void doViewPeptideDetail(PeptideMatch * peptide_match);
void doIdentificationGroupEdited(IdentificationGroup * p_identification_group);
private :
......
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