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

FDR computation OK

parent 3dc2d538
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,58 @@ IdentificationGroup::~IdentificationGroup() ...@@ -41,6 +41,58 @@ IdentificationGroup::~IdentificationGroup()
} }
} }
unsigned int IdentificationGroup::countDecoyProtein(ValidationState state) const {
unsigned int i=0;
for (auto & p_protein_match : _protein_match_list) {
if (!p_protein_match->getProteinXtpSp().get()->isDecoy()) continue;
if (state == ValidationState::grouped) {
if (p_protein_match->isGrouped()) {
i++;
}
}
else if(state == ValidationState::valid) {
if (p_protein_match->isValid()) {
i++;
}
}
else if (state == ValidationState::validAndChecked) {
if (p_protein_match->isValidAndChecked()) {
i++;
}
}
}
return i;
}
unsigned int IdentificationGroup::countProtein(ValidationState state) const {
unsigned int i=0;
if (state == ValidationState::grouped) {
for (auto & p_protein_match : _protein_match_list) {
if (p_protein_match->isGrouped()) {
i++;
}
}
}
else if(state == ValidationState::valid) {
for (auto & p_protein_match : _protein_match_list) {
if (p_protein_match->isValid()) {
i++;
}
}
}
else if (state == ValidationState::validAndChecked) {
for (auto & p_protein_match : _protein_match_list) {
if (p_protein_match->isValidAndChecked()) {
i++;
}
}
}
return i;
}
void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
for (auto & p_protein_match : _protein_match_list) { for (auto & p_protein_match : _protein_match_list) {
p_protein_match->updateAutomaticFilters(automatic_filter_parameters); p_protein_match->updateAutomaticFilters(automatic_filter_parameters);
......
...@@ -68,6 +68,13 @@ public: ...@@ -68,6 +68,13 @@ public:
/** @brief count subgroups /** @brief count subgroups
* */ * */
std::size_t countSubGroup()const; std::size_t countSubGroup()const;
/** @brief count proteins
* */
unsigned int countProtein(ValidationState state) const;
/** @brief count decoy proteins
* */
unsigned int countDecoyProtein(ValidationState state) const;
/** @brief validate or invalidate peptides and proteins based automatic filters and manual checks /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>445</width> <width>465</width>
<height>392</height> <height>493</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -53,7 +53,121 @@ ...@@ -53,7 +53,121 @@
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout2"> <layout class="QGridLayout" name="gridLayout2">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QFormLayout" name="formLayout_2"/> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>FDR</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>FDR on peptides</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="peptide_fdr_label">
<property name="text">
<string>0 %</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>FDR on proteins</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="protein_fdr_label">
<property name="text">
<string>0 %</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Decoy database files</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="decoy_database_list_widget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>add</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Decoy protein regular expression</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLineEdit" name="decoy_protein_regexp_line_edit">
<property name="placeholderText">
<string>.*\\|reversed$</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
...@@ -76,13 +190,33 @@ ...@@ -76,13 +190,33 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>445</width> <width>465</width>
<height>23</height> <height>25</height>
</rect> </rect>
</property> </property>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections>
<connection>
<sender>pushButton_2</sender>
<signal>clicked()</signal>
<receiver>ProjectView</receiver>
<slot>doFdrChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>403</x>
<y>329</y>
</hint>
<hint type="destinationlabel">
<x>484</x>
<y>334</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>doFdrChanged()</slot>
</slots>
</ui> </ui>
...@@ -45,7 +45,7 @@ ProjectWindow::ProjectWindow(MainWindow *parent): ...@@ -45,7 +45,7 @@ ProjectWindow::ProjectWindow(MainWindow *parent):
_p_automatic_filter_widget = new AutomaticFilterWidget(this); _p_automatic_filter_widget = new AutomaticFilterWidget(this);
ui->filter_parameter_layout->addWidget(_p_automatic_filter_widget); ui->filter_parameter_layout->addWidget(_p_automatic_filter_widget);
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
// Qt5 code // Qt5 code
...@@ -58,7 +58,7 @@ ProjectWindow::ProjectWindow(MainWindow *parent): ...@@ -58,7 +58,7 @@ ProjectWindow::ProjectWindow(MainWindow *parent):
// Qt4 code // Qt4 code
//connect (_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this //,SLOT(doProteinMatchClicked(ProteinMatch *))); //connect (_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this //,SLOT(doProteinMatchClicked(ProteinMatch *)));
connect (_p_automatic_filter_widget, SIGNAL(automaticFilterParametersChanged(AutomaticFilterParameters)), this,SLOT(doAutomaticFilterParametersChanged(AutomaticFilterParameters))); connect (_p_automatic_filter_widget, SIGNAL(automaticFilterParametersChanged(AutomaticFilterParameters)), this,SLOT(doAutomaticFilterParametersChanged(AutomaticFilterParameters)));
#endif #endif
/* /*
*/ */
...@@ -138,7 +138,29 @@ void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) { ...@@ -138,7 +138,29 @@ void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) {
qDebug() << "ProjectWindow::refreshGroup end"; qDebug() << "ProjectWindow::refreshGroup end";
} }
void ProjectWindow::computeFdr() {
pappso::pappso_double total_prot=0;
pappso::pappso_double false_prot=0;
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
total_prot += identification_group->countProtein(ValidationState::grouped);
false_prot += identification_group->countDecoyProtein(ValidationState::grouped);
}
ui->protein_fdr_label->setText(QString("%1 %").arg(false_prot/total_prot));
}
void ProjectWindow::doFdrChanged() {
qDebug() << "ProjectWindow::doFdrChanged begin ";
_project_sp.get()->getProteinStore().setRegexpDecoyPattern(ui->decoy_protein_regexp_line_edit->text());
_project_sp.get()->updateAutomaticFilters(_project_sp.get()->getAutomaticFilterParameters());
//re group
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
doIdentificationGroupEdited(identification_group);
}
computeFdr();
qDebug() << "ProjectWindow::doFdrChanged end ";
}
void ProjectWindow::doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters) { void ProjectWindow::doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters) {
qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged begin "; qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged begin ";
_project_sp.get()->updateAutomaticFilters(parameters); _project_sp.get()->updateAutomaticFilters(parameters);
...@@ -312,5 +334,8 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { ...@@ -312,5 +334,8 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) {
_p_automatic_filter_widget->setAutomaticFilterParameters(params); _p_automatic_filter_widget->setAutomaticFilterParameters(params);
//_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP()); //_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP());
//_protein_list_window->show(); //_protein_list_window->show();
ui->decoy_protein_regexp_line_edit->setText(_project_sp.get()->getProteinStore().getRegexpDecoy().pattern());
computeFdr();
this->setEnabled(true); this->setEnabled(true);
} }
...@@ -55,6 +55,7 @@ public slots: ...@@ -55,6 +55,7 @@ public slots:
void doViewProteinList(IdentificationGroup* p_identification_group =nullptr); void doViewProteinList(IdentificationGroup* p_identification_group =nullptr);
void setDefaultProteinListWindow(ProteinListWindow* p_protein_list_window); void setDefaultProteinListWindow(ProteinListWindow* p_protein_list_window);
void doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters); void doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters);
void doFdrChanged();
// void setColor(const QColor &color); // void setColor(const QColor &color);
// void setShape(Shape shape); // void setShape(Shape shape);
signals: signals:
...@@ -67,6 +68,7 @@ protected : ...@@ -67,6 +68,7 @@ protected :
void doViewPeptideDetail(PeptideMatch * peptide_match); void doViewPeptideDetail(PeptideMatch * peptide_match);
void doViewProteinDetail(ProteinMatch * protein_match); void doViewProteinDetail(ProteinMatch * protein_match);
void doIdentificationGroupEdited(IdentificationGroup * p_identification_group); void doIdentificationGroupEdited(IdentificationGroup * p_identification_group);
void computeFdr();
private : private :
void connectNewProteinListWindow(); void connectNewProteinListWindow();
......
...@@ -42,6 +42,16 @@ ProteinStore::~ProteinStore() ...@@ -42,6 +42,16 @@ ProteinStore::~ProteinStore()
{ {
} }
QRegExp ProteinStore::getRegexpDecoy() const {
return (_regexp_decoy);
}
void ProteinStore::setRegexpDecoyPattern(const QString & pattern) {
_regexp_decoy.setPattern(pattern);
for (std::pair<const QString, ProteinXtpSp> & acc_protein :_map_accession_protein_list) {
setProteinInformations(acc_protein.second);
}
}
ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & peptide_in) { ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & peptide_in) {
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define PROTEINSTORE_H #define PROTEINSTORE_H
#include "../core/proteinxtp.h" #include "../core/proteinxtp.h"
#include "types.h"
#include <QString> #include <QString>
#include <QRegExp> #include <QRegExp>
#include <map> #include <map>
...@@ -44,6 +45,10 @@ public: ...@@ -44,6 +45,10 @@ public:
~ProteinStore(); ~ProteinStore();
ProteinXtpSp & getInstance(ProteinXtpSp & protein_in); ProteinXtpSp & getInstance(ProteinXtpSp & protein_in);
void setRegexpDecoyPattern(const QString & pattern);
QRegExp getRegexpDecoy() const;
private : private :
void setProteinInformations(ProteinXtpSp & protein_in); void setProteinInformations(ProteinXtpSp & protein_in);
......
...@@ -46,6 +46,17 @@ enum class MzFormat { ...@@ -46,6 +46,17 @@ enum class MzFormat {
mzXML, ///< mzXML mzXML, ///< mzXML
}; };
/** \def ValidationState
*
*/
enum class ValidationState {
valid, ///< valid : automatic filter validation passed
validAndChecked, ///< validAndChecked : automatic filter validation passed + manual checking
grouped, ///< grouped : automatic filter validation passed + manual checking + grouped
};
/** \def ProteinListColumn list of available fields to display in protein list /** \def ProteinListColumn list of available fields to display in protein list
* *
*/ */
......
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