diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index d0334bb2833091f28e0f6325d80854b737537dd3..3e98431bd4cc4cd858d78d97e218064620c10bc8 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -42,17 +42,40 @@ IdentificationGroup::~IdentificationGroup() } - const GroupStore & IdentificationGroup::getGroupStore() const { - return _group_store; +const GroupStore & IdentificationGroup::getGroupStore() const { + return _group_store; +} + +unsigned int IdentificationGroup::countPeptideMassSample(ValidationState state) const { + std::vector<std::size_t> count_peptide_mass_sample; + for (auto & p_protein_match : _protein_match_list) { + p_protein_match->countPeptideMassSample(count_peptide_mass_sample, state); + } + std::sort(count_peptide_mass_sample.begin(), count_peptide_mass_sample.end()); + auto last = std::unique(count_peptide_mass_sample.begin(),count_peptide_mass_sample.end()); + return std::distance(count_peptide_mass_sample.begin(),last); +} + +unsigned int IdentificationGroup::countDecoyPeptideMassSample(ValidationState state) const { + std::vector<std::size_t> count_peptide_mass_sample; + for (auto & p_protein_match : _protein_match_list) { + if (p_protein_match->getProteinXtpSp().get()->isDecoy()) { + p_protein_match->countPeptideMassSample(count_peptide_mass_sample, state); + } } + std::sort(count_peptide_mass_sample.begin(), count_peptide_mass_sample.end()); + auto last = std::unique(count_peptide_mass_sample.begin(),count_peptide_mass_sample.end()); + return std::distance(count_peptide_mass_sample.begin(),last); +} + 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); - } + if (p_protein_match->getProteinXtpSp().get()->isDecoy()) { + i+=p_protein_match->countPeptideMatch(state); + } //} } return i; @@ -72,7 +95,7 @@ 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); + i+=p_protein_match->countPeptideMatch(state); //} } return i; diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index ee430508a3e6c68a6438b55699ec369de9255020..e8393d41de6cc1fcb0c858c0a6e6fffc2a59d665 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.h @@ -50,54 +50,60 @@ public: std::vector<ProteinMatch *> & getProteinMatchList(); void addMsRunSp(MsRunSp ms_run_sp); - /** @brief count groups - * */ + /** @brief count groups + * */ std::size_t countGroup()const; - /** @brief count subgroups - * */ + /** @brief count subgroups + * */ std::size_t countSubGroup()const; - + /** @brief count proteins - * */ + * */ unsigned int countProteinMatch(ValidationState state) const; /** @brief count decoy proteins - * */ - unsigned int countDecoyProteinMatch(ValidationState state) const; - /** @brief count peptide match - * */ + * */ + unsigned int countDecoyProteinMatch(ValidationState state) const; + /** @brief count peptide match (peptide spectrum match + protein match) + * */ unsigned int countPeptideMatch(ValidationState state) const; /** @brief count decoy peptide match - * */ + * */ unsigned int countDecoyPeptideMatch(ValidationState state) const; + /** @brief count peptide (peptide+mass+sample) + * */ + unsigned int countPeptideMassSample(ValidationState state) const; + /** @brief count peptide (peptide+mass+sample) included by decoy proteins + * */ + unsigned int countDecoyPeptideMassSample(ValidationState state) const; /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks * */ void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); - + void startGrouping (const GroupingType & grouping_type); - - const std::vector<MsRunSp> & getMsRunSpList() const; - + + const std::vector<MsRunSp> & getMsRunSpList() const; + /** @brief get tab name for qtabwidget - * */ + * */ const QString getTabName() const; - + bool contains (const MsRun * p_msrun) const; - + void collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const; private : GroupingExperiment * _p_grp_experiment= nullptr; Project * _p_project; - + GroupStore _group_store; std::vector<ProteinMatch *> _protein_match_list; std::vector<MsRunSp> _ms_run_list; - + std::map<QString, ProteinMatch *> _cache_accession_protein_match; }; diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp index 5761314c310df3d6906d622e75ea35b57df35153..05085bd33dfbb535f72a726d22f922b48b2cc7d5 100644 --- a/src/core/peptidematch.cpp +++ b/src/core/peptidematch.cpp @@ -47,6 +47,10 @@ void PeptideMatch::setEvalue(pappso::pappso_double evalue) { } +std::size_t PeptideMatch::getHashPeptideMassSample() const { + return PeptideMatch::_hash_fn (QString("%1 %2").arg(_peptide_sp.get()->getLiAbsoluteString()).arg(_msrunid_sp->getXmlId()).toStdString()); +} + std::size_t PeptideMatch::getHashSampleScan() const { return _hash_sample_scan; } diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h index 6d885f71557ef321e9054b469430d788279fb7f2..42bcbabfe2e6bfb41b8e380d45a69182ed32956d 100644 --- a/src/core/peptidematch.h +++ b/src/core/peptidematch.h @@ -36,6 +36,7 @@ class PeptideMatch public : PeptideMatch(MsRun * msrunid_sp, unsigned int scan); std::size_t getHashSampleScan() const; + std::size_t getHashPeptideMassSample() const; void setRetentionTime(pappso::pappso_double rt); void setEvalue(pappso::pappso_double evalue); diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index d44f1fe72868028860c843dcb1b262773609fcec..07c97cf886cc5053302cbb09a4dc4d2e3adb67a8 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -176,6 +176,15 @@ const pappso::GrpProteinSp & ProteinMatch::getGrpProteinSp() const { } +void ProteinMatch::countPeptideMassSample(std::vector<size_t> & count_peptide_mass_sample, ValidationState state) const { + for (auto & p_peptide_match : _peptide_match_list) { + if (p_peptide_match->getValidationState() >= state) { + count_peptide_mass_sample.push_back(p_peptide_match->getHashPeptideMassSample()); + } + } +} + + 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) { diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index fb125d15d1fcdc4e9d892941207b6c91f5208334..c1cf0687690db207fa854ee8703d6d6e62b8f4a8 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.h @@ -77,6 +77,10 @@ public: ValidationState getValidationState() const; unsigned int countPeptideMatch(ValidationState state) const; + + /** @brief count peptide (peptide+mass+sample) + */ + void countPeptideMassSample(std::vector<size_t> & count_peptide_mass_sample, ValidationState state) const; /** @brief count unique identified sequences (from valid and cheked spectrums) * */ diff --git a/src/gui/project_view/project_view.ui b/src/gui/project_view/project_view.ui index f45e0bde2451651437545c2180993d9429b147f1..9313cbdae54eb8c04782d3ad1b690db62eb3e731 100644 --- a/src/gui/project_view/project_view.ui +++ b/src/gui/project_view/project_view.ui @@ -24,7 +24,7 @@ <string/> </property> <property name="currentIndex"> - <number>2</number> + <number>0</number> </property> <widget class="QWidget" name="identifications"> <attribute name="title"> @@ -52,6 +52,9 @@ <string>Contaminants</string> </property> <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <widget class="QListView" name="contaminant_database_listview"/> + </item> <item> <widget class="QLineEdit" name="contaminant_protein_regexp_line_edit"> <property name="placeholderText"> diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 780eaa948f8675af91794363fb6dadc998630835..29e125688e690b92a7842e7206f3bb6c3b7566e4 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -45,6 +45,7 @@ ProjectWindow::ProjectWindow(MainWindow *parent): _p_fasta_str_li = new QStandardItemModel(); ui->decoy_database_listview->setModel(_p_fasta_str_li); + ui->contaminant_database_listview->setModel(_p_fasta_str_li); _p_automatic_filter_widget = new AutomaticFilterWidget(this); ui->filter_parameter_layout->addWidget(_p_automatic_filter_widget); @@ -153,8 +154,10 @@ void ProjectWindow::computeFdr() { for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) { total_prot += identification_group->countProteinMatch(state); false_prot += identification_group->countDecoyProteinMatch(state); - total_peptide += identification_group->countPeptideMatch(state); - false_peptide += identification_group->countDecoyPeptideMatch(state); + //total_peptide += identification_group->countPeptideMatch(state); + //false_peptide += identification_group->countDecoyPeptideMatch(state); + total_peptide += identification_group->countPeptideMassSample(state); + false_peptide += identification_group->countDecoyPeptideMassSample(state); } ui->protein_fdr_label->setText(QString("%1 %").arg(QString::number((false_prot/total_prot)*100.0,'f',10))); ui->peptide_fdr_label->setText(QString("%1 %").arg(QString::number((false_peptide/total_peptide)*100.0,'f',10))); @@ -353,7 +356,6 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { qDebug() << "ProjectWindow::setProjectSp begin " << _project_sp.get()->getFastaFileStore().getFastaFileList().size() ; _fastafile_list = _project_sp.get()->getFastaFileStore().getFastaFileList(); - for (FastaFileSp fasta_file : _fastafile_list ) { QStandardItem *item;