diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index a2c3f253a20e4a960cbf65d675249ef6b1bbac11..df013590e923439ba2a8d63112f149e4f37d2730 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 767f8cc25ff258593a97409a8530e5292a00c0ff..3eaf8565c3d30eb615d1dceff0f3a94f931d308f 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 c95a4d48e31f568243172e2d6336caf5b1a105bc..81706facecd72cd126d2f2a660daeb7f5383a5fd 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 bd150ed5cd59c70137e9e72fceacec4704cf9a8a..a9f67e11253738b2dde03aca67fb36daec8ca6ae 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 0df923cc2980f86fba9cb8beb926b83bd0219410..792634523eba9025bdad1dedd669f870461d1f22 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 3044d8d706033f32c32a22b0499da6a7a611bc09..b2501074db9e4aecda17ddaac2f4578633f791a9 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 f2a57aa78fc958bea9e092a805a2e9ed303208db..f9c63fed086f588e9a87eae0a681660611413397 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 e3cbf9b1c642371f7897e8ce478094b35b9e8ca9..c87465c675df83f7c3a28f1b2a6b5cc6ebe8e357 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