Commit 9b8a6069 authored by Renne Thomas's avatar Renne Thomas
Browse files

Add Ms Identification list window with run ID and file ID

parent a5f265a0
......@@ -181,6 +181,9 @@ SET(XTPCPP_SRCS
./gui/export/export_masschroq_dialog/masschroqfileparameters.cpp
./gui/export/export_spreadsheet_dialog/exportspreadsheetdialog.cpp
./gui/load_results_dialog/loadresultsdialog.cpp
./gui/lists/ms_identification_run_list_view/msidentificationlistwindow.cpp
./gui/lists/ms_identification_run_list_view/msidentificationtablemodel.cpp
./gui/lists/ms_identification_run_list_view/msidentificationtableproxymodel.cpp
./gui/mainwindow.cpp
./gui/peptide_detail_view/peptidewindow.cpp
./gui/peptide_list_view/peptidelistwindow.cpp
......@@ -224,6 +227,7 @@ SET (GUI_UIS
./gui/edit/edit_tandem_preset_dialog/edit_tandem_preset_dialog.ui
./gui/export/export_masschroq_dialog/export_masschroq_dialog.ui
./gui/export/export_spreadsheet_dialog/export_spreadsheet_dialog.ui
./gui/lists/ms_identification_run_list_view/ms_identification_run_view.ui
./gui/load_results_dialog/load_results_dialog.ui
./gui/main.ui
./gui/peptide_detail_view/peptide_detail_view.ui
......
......@@ -111,6 +111,7 @@ class Project
LabelingMethodSp _labeling_method_sp;
ProjectMode _project_mode = ProjectMode::combined;
std::vector<IdentificationGroup *> _identification_goup_list;
std::vector<IdentificationDataSourceSp> m_identificationDataSourceSpList;
IdentificationGroup *_p_current_identification_group = nullptr;
AutomaticFilterParameters _automatic_filter_parameters;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MsIdentificationView</class>
<widget class="QMainWindow" name="MsIdentificationView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>826</width>
<height>404</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="windowTitle">
<string>Protein list</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableView" name="tableView">
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>826</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuExport">
<property name="title">
<string>e&amp;xport</string>
</property>
<addaction name="actionAs_ODS_file"/>
</widget>
<addaction name="menuExport"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionAs_ODS_file">
<property name="text">
<string>&amp;as ODS file</string>
</property>
</action>
<action name="actionValid_proteins">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;valid proteins</string>
</property>
</action>
<action name="actionChecked_proteins">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;checked proteins</string>
</property>
</action>
<action name="actionGrouped_proteins">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;grouped proteins</string>
</property>
</action>
</widget>
<resources/>
<connections>
<connection>
<sender>actionAs_ODS_file</sender>
<signal>triggered()</signal>
<receiver>MsIdentificationView</receiver>
<slot>doExportAsOdsFile()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>412</x>
<y>201</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>doNotValidHide(bool)</slot>
<slot>doNotCheckedHide(bool)</slot>
<slot>doNotGroupedHide(bool)</slot>
<slot>onProteinSearchEdit(QString)</slot>
<slot>doSearchOn(QString)</slot>
<slot>doMsrunFileSearch(QString)</slot>
<slot>doScanNumberSearch(int)</slot>
<slot>doModificationSearch(QString)</slot>
<slot>doExportAsOdsFile()</slot>
</slots>
</ui>
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and
*implementation
******************************************************************************/
#include "ui_ms_identification_run_view.h"
#include "msidentificationlistwindow.h"
#include "../../mainwindow.h"
#include <QSettings>
#include <odsstream/odsdocwriter.h>
#include <odsstream/qtablewriter.h>
MsIdentificationListQactionColumn::MsIdentificationListQactionColumn(MsIdentificationListWindow *parent,
msIdentificationListColumn column)
: QAction(parent)
{
this->setText(MsIdentificationTableModel::getTitle(column));
this->setCheckable(true);
// evalue_action.setChecked(_display_evalue);
// connect(p_action, SIGNAL(toggled(bool)), this,
// SLOT(showEvalueColumn(bool)));
m_column = column;
m_msid_list_window = parent;
#if QT_VERSION >= 0x050000
// Qt5 code
connect(this,
&MsIdentificationListQactionColumn::toggled,
this,
&MsIdentificationListQactionColumn::doToggled);
#else
// Qt4 code
connect(this, SIGNAL(toggled(bool)), this, SLOT(doToggled(bool)));
#endif
}
MsIdentificationListQactionColumn::~MsIdentificationListQactionColumn()
{
// if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
qDebug() << "MsIdentificationListQactionColumn::~MsIdentificationListQactionColumn begin ";
}
void
MsIdentificationListQactionColumn::doToggled(bool toggled)
{
qDebug() << "MsIdentificationListQactionColumn::doToggled begin " << toggled;
setChecked(toggled);
m_msid_list_window->setMsIdentificationListColumnDisplay(m_column, toggled);
qDebug() << "MsIdentificationListQactionColumn::doToggled end";
}
MsIdentificationListWindow::MsIdentificationListWindow(ProjectWindow *parent)
: QMainWindow(parent), ui(new Ui::MsIdentificationView)
{
m_project_window = parent;
ui->setupUi(this);
setWindowIcon(QIcon(":/xtpcpp_icon/resources/xtandempipeline_icon.svg"));
m_msid_table_model_p = new MsIdentificationTableModel(this);
m_proxy_model = new MsIdentificationTableProxyModel(this, m_msid_table_model_p);
m_proxy_model->setSourceModel(m_msid_table_model_p);
m_proxy_model->setDynamicSortFilter(true);
ui->tableView->setModel(m_proxy_model);
ui->tableView->setSortingEnabled(true);
ui->tableView->setAlternatingRowColors(true);
connect(ui->centralwidget,
&QWidget::customContextMenuRequested,
this,
&MsIdentificationListWindow::showContextMenu);
}
void
MsIdentificationListWindow::showContextMenu(const QPoint &pos)
{
if(_p_context_menu == nullptr)
{
_p_context_menu = new QMenu(tr("Context menu"), this);
MsIdentificationListQactionColumn *p_action;
for(unsigned int i = 0; i < m_msid_table_model_p->columnCount(); i++)
{
p_action = new MsIdentificationListQactionColumn(
this, MsIdentificationTableModel::getMsIdentificationListColumn(i));
_p_context_menu->addAction(p_action);
}
_p_context_menu->exec(mapToGlobal(pos));
}
_p_context_menu->move(mapToGlobal(pos));
_p_context_menu->show();
}
void
MsIdentificationListWindow::resizeColumnsToContents()
{
ui->tableView->resizeColumnsToContents();
}
MsIdentificationListWindow::~MsIdentificationListWindow()
{
// if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
// delete ui;
// if(_p_context_menu != nullptr)
// {
// delete _p_context_menu;
// }
}
void
MsIdentificationListWindow::setIdentificationDataSourceSpList(std::vector<IdentificationDataSourceSp>& identificationDataSourceSpList)
{
qDebug() << "MsIdentificationListWindow::setIdentificationGroup begin ";
m_msid_table_model_p->setIdentificationDataSourceSpList(identificationDataSourceSpList);
qDebug() << "MsIdentificationListWindow::setIdentificationGroup end";
}
void
MsIdentificationListWindow::setMsIdentificationListColumnDisplay(msIdentificationListColumn column,
bool toggled)
{
m_proxy_model->setMsIdentificationListColumnDisplay(column, toggled);
}
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and
*implementation
******************************************************************************/
#pragma once
#include <QMainWindow>
#include <QAction>
#include <QMenu>
#include "msidentificationtablemodel.h"
#include "msidentificationtableproxymodel.h"
#include "ui_ms_identification_run_view.h"
class ProjectWindow;
// http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html
namespace Ui
{
class MsIdentificationView;
}
class MsIdentificationListWindow;
class MsIdentificationListQactionColumn : public QAction
{
Q_OBJECT
public:
explicit MsIdentificationListQactionColumn(MsIdentificationListWindow *parent,
msIdentificationListColumn column);
~MsIdentificationListQactionColumn();
public slots:
void doToggled(bool toggled);
private:
MsIdentificationListWindow *m_msid_list_window;
msIdentificationListColumn m_column;
};
class MsIdentificationListWindow : public QMainWindow
{
friend class MsIdentificationTableModel;
friend class MsIdentificationTableProxyModel;
Q_OBJECT
public:
explicit MsIdentificationListWindow(ProjectWindow *parent = 0);
~MsIdentificationListWindow();
void setIdentificationDataSourceSpList(std::vector<IdentificationDataSourceSp>& identificationDataSourceSpList);
void setMsIdentificationListColumnDisplay(msIdentificationListColumn column, bool toggled);
void resizeColumnsToContents();
protected slots:
void showContextMenu(const QPoint &);
private:
Ui::MsIdentificationView *ui;
MsIdentificationTableModel *m_msid_table_model_p = nullptr;
MsIdentificationTableProxyModel *m_proxy_model = nullptr;
ProjectWindow *m_project_window;
QMenu *_p_context_menu = nullptr;
bool _display_evalue = true;
bool _display_accession = true;
};
/*******************************************************************************
* 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 "msidentificationtablemodel.h"
#include <QDebug>
#include <pappsomspp/pappsoexception.h>
#include "msidentificationlistwindow.h"
#include "../../../utils/identificationdatasourcestore.h"
MsIdentificationTableModel::MsIdentificationTableModel(MsIdentificationListWindow *ms_id_list_window)
: QAbstractTableModel(ms_id_list_window)
{
m_ms_id_list_window = ms_id_list_window;
}
void
MsIdentificationTableModel::setIdentificationDataSourceSpList(
std::vector<IdentificationDataSourceSp>& identificationDataSourceSpList)
{
qDebug() << " identificationDataSourceSpList.size()=" << identificationDataSourceSpList.size();
beginResetModel();
m_identificationDataSourceSpList = identificationDataSourceSpList;
// emit headerDataChanged(Qt::Horizontal, 0,11);
// refresh();
qDebug() ;
endResetModel();
m_ms_id_list_window->resizeColumnsToContents();
}
int
MsIdentificationTableModel::rowCount(const QModelIndex &parent) const
{
// qDebug() << "MsIdentificationTableModel::rowCount begin ";
if(m_identificationDataSourceSpList.size() != 0)
{
// qDebug() << "MsIdentificationTableModel::rowCount(const QModelIndex &parent ) "
// << _p_identification_group->getProteinMatchList().size();
return (int)m_identificationDataSourceSpList.size();
}
return 0;
}
int
MsIdentificationTableModel::columnCount(const QModelIndex &parent) const
{
return (std::int8_t)msIdentificationListColumn::last;
}
const QString
MsIdentificationTableModel::getTitle(msIdentificationListColumn column)
{
qDebug() << "MsIdentificationTableModel::getTitle begin ";
return MsIdentificationTableModel::getTitle((std::int8_t)column);
// qDebug() << "MsIdentificationTableModel::getTitle end ";
}
const QString
MsIdentificationTableModel::getDescription(msIdentificationListColumn column)
{
qDebug() << "MsIdentificationTableModel::columnCount begin ";
return MsIdentificationTableModel::getDescription((std::int8_t)column);
// qDebug() << "MsIdentificationTableModel::columnCount end ";
}
const QString
MsIdentificationTableModel::getTitle(std::int8_t column)
{
qDebug() << "MsIdentificationTableModel::getTitle begin " << column;
switch(column)
{
case(std::int8_t)msIdentificationListColumn::run_id:
return "Run ID";
break;
case(std::int8_t)msIdentificationListColumn::id_file:
return "File ID";
break;
case(std::int8_t)msIdentificationListColumn::mzML:
return "mzML";
break;
// case(std::int8_t)msIdentificationListColumn::test:
// return "Test";
// break;
}
return "";
}
const QString
MsIdentificationTableModel::getDescription(std::int8_t column)
{
qDebug() << "MsIdentificationTableModel::getDescription begin " << column;
switch(column)
{
case(std::int8_t)msIdentificationListColumn::run_id:
return "Run ID";
break;
case(std::int8_t)msIdentificationListColumn::id_file:
return "File ID pathway";
break;
case(std::int8_t)msIdentificationListColumn::mzML:
return "mzML file pathway";
break;
}
return "";
}
QVariant
MsIdentificationTableModel::headerData(int section,
Qt::Orientation orientation,
int role) const
{
if(orientation == Qt::Horizontal)
{
switch(role)
{
case Qt::DisplayRole:
qDebug() << section;
return QVariant(getTitle(section));
break;
case Qt::ToolTipRole:
return QVariant(getDescription(section));
break;
case Qt::SizeHintRole:
qDebug() << section;
return QSize(getColumnWidth(section),40);
break;
}
}
return QVariant();
}
int
MsIdentificationTableModel::getColumnWidth(int column)
{
qDebug() << "Test " << column;
switch(column)
{
case(int)msIdentificationListColumn::run_id:
return 300;
break;
case(int)msIdentificationListColumn::id_file:
return 300;
break;
case(int)msIdentificationListColumn::mzML:
return 300;
break;
}
return 300;
}
msIdentificationListColumn
MsIdentificationTableModel::getMsIdentificationListColumn(std::int8_t column)
{
return static_cast<msIdentificationListColumn>(column);
}
QVariant
MsIdentificationTableModel::data(const QModelIndex &index, int role) const
{
int row = index.row();
int col = index.column();
switch(role)
{
case Qt::SizeHintRole:
qDebug() << MsIdentificationTableModel::getColumnWidth(col);
return QSize(MsIdentificationTableModel::getColumnWidth(col), 30);
break;
case Qt::DisplayRole:
switch(col)
{
case(std::int8_t)msIdentificationListColumn::run_id:
return QVariant(m_identificationDataSourceSpList
.at(row)
->getSampleName());
}
if(col == (std::int8_t)msIdentificationListColumn::id_file)
{
return QVariant(m_identificationDataSourceSpList