From 3d06aecd945a3f9449480f5c10a1d9437f368e1f Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Tue, 28 Mar 2017 12:07:19 +0200 Subject: [PATCH] count group and subgroups --- src/core/identificationgroup.cpp | 13 +++++++++++-- src/core/identificationgroup.h | 14 ++++++++++++-- src/grouping/groupinggroup.cpp | 4 +++- src/grouping/groupinggroup.h | 4 +++- src/gui/project_view/projectwindow.cpp | 3 +++ src/utils/groupstore.cpp | 18 ++++++++++++++++++ src/utils/groupstore.h | 3 +++ 7 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 059fc9d65..2aaf9e413 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -82,6 +82,15 @@ size_t IdentificationGroup::countValid()const { return i; } +std::size_t IdentificationGroup::countGroup()const { + return _group_store.countGroup(); +} + +std::size_t IdentificationGroup::countSubGroup()const { + return _group_store.countSubGroup(); +} + + void IdentificationGroup::startGrouping (const GroupingType & grouping_type) { if (_p_grp_experiment != nullptr) { delete _p_grp_experiment; @@ -92,9 +101,9 @@ void IdentificationGroup::startGrouping (const GroupingType & grouping_type) { } _p_grp_experiment->startGrouping(); - GroupStore group_store; + _group_store.clear(); for (auto & p_protein_match : _protein_match_list) { - p_protein_match->setGroupInstance(group_store); + p_protein_match->setGroupInstance(_group_store); } } diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index 4199d0515..9d27dd386 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.h @@ -49,11 +49,19 @@ public: /** @brief count valid proteins * */ - size_t countValid()const; + std::size_t countValid()const; /** @brief count valid and manually checked proteins * */ - size_t countValidAndChecked()const; + std::size_t countValidAndChecked()const; + + /** @brief count groups + * */ + std::size_t countGroup()const; + + /** @brief count subgroups + * */ + std::size_t countSubGroup()const; /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks @@ -67,6 +75,8 @@ private : GroupingExperiment * _p_grp_experiment= nullptr; Project * _p_project; + + GroupStore _group_store; std::vector<ProteinMatch *> _protein_match_list; diff --git a/src/grouping/groupinggroup.cpp b/src/grouping/groupinggroup.cpp index cd030733c..51806a76b 100644 --- a/src/grouping/groupinggroup.cpp +++ b/src/grouping/groupinggroup.cpp @@ -35,7 +35,9 @@ GroupingGroup::~GroupingGroup() { } - +unsigned int GroupingGroup::getNumberOfSubgroups() const { + return _number_of_subgroup; +} std::size_t GroupingGroup::countSpecificSpectrum(const ProteinMatch * p_protein_match) const { if (_number_of_subgroup == 1) { diff --git a/src/grouping/groupinggroup.h b/src/grouping/groupinggroup.h index 983996c7d..b8bb3befb 100644 --- a/src/grouping/groupinggroup.h +++ b/src/grouping/groupinggroup.h @@ -43,8 +43,10 @@ public: void add(const ProteinMatch * p_protein_match); std::size_t countSpecificSpectrum(const ProteinMatch * p_protein_match) const; std::size_t countSpecificSequence(const ProteinMatch * p_protein_match) const; + + unsigned int getNumberOfSubgroups() const; private : - unsigned int _number_of_subgroup=0; + unsigned int _number_of_subgroup=0; std::vector<std::pair<unsigned int, const PeptideMatch *>> _pair_sg_number_peptide_match_list; }; diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index bb33ac459..41160e470 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -168,6 +168,9 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { _project_sp = project_sp; vector< MsRunIdSp > ms_run_list = _project_sp.get()->getCurrentIdentificationGroupP()->getMsRunIdSpList(); ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); + + ui->group_number_display->setText(QString("%1").arg(_project_sp.get()->getCurrentIdentificationGroupP()->countGroup())); + ui->subgroup_number_display->setText(QString("%1").arg(_project_sp.get()->getCurrentIdentificationGroupP()->countSubGroup())); //_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP()); //_protein_list_window->show(); this->setEnabled(true); diff --git a/src/utils/groupstore.cpp b/src/utils/groupstore.cpp index 7f5f0ffa9..17c46e71f 100644 --- a/src/utils/groupstore.cpp +++ b/src/utils/groupstore.cpp @@ -40,6 +40,24 @@ GroupStore::~GroupStore() } +void GroupStore::clear() { + _map_group.clear(); +} + + +std::size_t GroupStore::countGroup() const { + return _map_group.size(); +} +std::size_t GroupStore::countSubGroup() const { + + unsigned int count = 0; + for (auto && pair_group :_map_group) { + count += pair_group.second->getNumberOfSubgroups(); + } + return count; +} + + GroupingGroupSp GroupStore::getInstance(unsigned int group_number) { GroupingGroupSp sp_group; diff --git a/src/utils/groupstore.h b/src/utils/groupstore.h index 051918cd4..7ed6182cf 100644 --- a/src/utils/groupstore.h +++ b/src/utils/groupstore.h @@ -41,6 +41,9 @@ public: GroupStore(); ~GroupStore(); GroupingGroupSp getInstance(unsigned int group_number); + void clear(); + std::size_t countGroup() const; + std::size_t countSubGroup() const; private : std::map<unsigned int, GroupingGroupSp> _map_group; }; -- GitLab