From 4efc081002828034f231390a95598838df9a67bd Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Fri, 7 Apr 2017 19:28:23 +0200 Subject: [PATCH] FDR computation OK --- src/core/identificationgroup.cpp | 21 +++++++++++++++++ src/core/identificationgroup.h | 8 ++++++- src/core/peptidematch.cpp | 11 +++++++++ src/core/peptidematch.h | 2 ++ src/core/proteinmatch.cpp | 31 +++++++++++++++++++++----- src/core/proteinmatch.h | 3 +++ src/gui/project_view/projectwindow.cpp | 6 +++-- src/utils/types.h | 1 + 8 files changed, 75 insertions(+), 8 deletions(-) diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index a2c3f253a..df013590e 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -42,6 +42,17 @@ IdentificationGroup::~IdentificationGroup() } +unsigned int IdentificationGroup::countDecoyPeptideMatch(ValidationState state) const { + unsigned int i=0; + for (auto & p_protein_match : _protein_match_list) { + if (p_protein_match->getValidationState() == state) { + if (p_protein_match->getProteinXtpSp().get()->isDecoy()) { + i+=p_protein_match->countPeptideMatch(state); + } + } + } + return i; +} unsigned int IdentificationGroup::countDecoyProtein(ValidationState state) const { unsigned int i=0; for (auto & p_protein_match : _protein_match_list) { @@ -67,6 +78,16 @@ unsigned int IdentificationGroup::countDecoyProtein(ValidationState state) const return i; } +unsigned int IdentificationGroup::countPeptideMatch(ValidationState state) const { + unsigned int i=0; + for (auto & p_protein_match : _protein_match_list) { + if (p_protein_match->getValidationState() == state) { + i+=p_protein_match->countPeptideMatch(state); + } + } + return i; +} + unsigned int IdentificationGroup::countProtein(ValidationState state) const { unsigned int i=0; if (state == ValidationState::grouped) { diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index 767f8cc25..3eaf8565c 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.h @@ -74,7 +74,13 @@ public: unsigned int countProtein(ValidationState state) const; /** @brief count decoy proteins * */ - unsigned int countDecoyProtein(ValidationState state) const; + unsigned int countDecoyProtein(ValidationState state) const; + /** @brief count peptide match + * */ + unsigned int countPeptideMatch(ValidationState state) const; + /** @brief count decoy peptide match + * */ + unsigned int countDecoyPeptideMatch(ValidationState state) const; /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp index c95a4d48e..81706face 100644 --- a/src/core/peptidematch.cpp +++ b/src/core/peptidematch.cpp @@ -69,6 +69,17 @@ void PeptideMatch::setChecked(bool arg1) { _checked = arg1; } +ValidationState PeptideMatch::getValidationState() const { + if (isValid()) { + return ValidationState::valid; + } else if (isValidAndChecked()) { + return ValidationState::validAndChecked; + } else if (isGrouped()) { + return ValidationState::grouped; + } + return ValidationState::notValid; +} + bool PeptideMatch::isValid() const { return _proxy_valid; } diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h index bd150ed5c..a9f67e112 100644 --- a/src/core/peptidematch.h +++ b/src/core/peptidematch.h @@ -75,6 +75,8 @@ public : /** @brief get delta between theoretical mhplus mass and mhplus experimental mass */ pappso::mz getDeltaMass() const; + + ValidationState getValidationState() const; private : MsRun * _msrunid_sp; diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index 0df923cc2..792634523 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -43,7 +43,16 @@ ProteinMatch::~ProteinMatch() it++; } } - +ValidationState ProteinMatch::getValidationState() const { + if (isValid()) { + return ValidationState::valid; + } else if (isValidAndChecked()) { + return ValidationState::validAndChecked; + } else if (isGrouped()) { + return ValidationState::grouped; + } + return ValidationState::notValid; +} bool ProteinMatch::contains(PeptideMatch * peptide_match) const { if (peptide_match == nullptr) return false; for (auto & p_peptide_match : _peptide_match_list) { @@ -166,6 +175,18 @@ const pappso::GrpProteinSp & ProteinMatch::getGrpProteinSp() const { return _sp_grp_protein; } + +unsigned int ProteinMatch::countPeptideMatch(ValidationState state) const { + return std::count_if (_peptide_match_list.begin(), _peptide_match_list.end(), [state](const PeptideMatch * p_peptide_match) { + if (p_peptide_match->getValidationState() == state) { + return true; + } + else { + return false; + } + }); +} + size_t ProteinMatch::countValidSpectrum()const { return std::count_if (_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch * p_peptide_match) { return (p_peptide_match->isValid()); @@ -312,7 +333,7 @@ const QString ProteinMatch::getHtmlSequence(PeptideMatch * peptide_match_to_loca } else { sequence_html.append(QString("</span>")); - i--; + i--; break; } } @@ -323,9 +344,9 @@ const QString ProteinMatch::getHtmlSequence(PeptideMatch * peptide_match_to_loca i++; for (; i < prot_size; i++) { if (highlight_bool[i]) { - i--; - break; - } + i--; + break; + } if(cover_bool[i]) { sequence_html.append(sequence[i]); } diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index 3044d8d70..b2501074d 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.h @@ -75,6 +75,9 @@ public: bool isValidAndChecked() const; bool isGrouped() const; + ValidationState getValidationState() const; + unsigned int countPeptideMatch(ValidationState state) const; + /** @brief count valid spectrums * */ size_t countValidSpectrum()const; diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index f2a57aa78..f9c63fed0 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -151,9 +151,11 @@ void ProjectWindow::computeFdr(ValidationState state) { pappso::pappso_double total_peptide=0; pappso::pappso_double false_peptide=0; for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) { - //total_peptide += identification_group->countPeptideMatch(state); - //false_peptide += identification_group->countDecoyPeptideMatch(state); + total_peptide += identification_group->countPeptideMatch(state); + false_peptide += identification_group->countDecoyPeptideMatch(state); } + qDebug() << "ProjectWindow::computeFdr false_peptide=" <<false_peptide; + qDebug() << "ProjectWindow::computeFdr total_peptide=" <<total_peptide; ui->peptide_fdr_label->setText(QString("%1 %").arg(false_peptide/total_peptide)); } diff --git a/src/utils/types.h b/src/utils/types.h index e3cbf9b1c..c87465c67 100644 --- a/src/utils/types.h +++ b/src/utils/types.h @@ -51,6 +51,7 @@ enum class MzFormat { */ enum class ValidationState { + notValid,///< notValid : automatic filter validation failed valid, ///< valid : automatic filter validation passed validAndChecked, ///< validAndChecked : automatic filter validation passed + manual checking grouped, ///< grouped : automatic filter validation passed + manual checking + grouped -- GitLab