diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index ae009c04d43bbf8c599b0da93e16db8a83694463..9df856540f0dde85e4eccabacc999f1b8603d4f9 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -162,6 +162,36 @@ size_t ProteinMatch::countUniqueSequence()const { return sequence_list.size(); } +unsigned int ProteinMatch::countValidAndCheckedPeptideMassCharge(const pappso::MsRunIdSp & sp_msrun_id) const { + std::set<QString> sequence_list; + for (auto & p_peptide_match : _peptide_match_list) { + if (p_peptide_match->isValidAndChecked()) { + if(sp_msrun_id.get() != nullptr) { + //within sample + if (p_peptide_match->getMsRunIdSp().get() == sp_msrun_id.get()) { + sequence_list.insert(QString("%1-%2").arg(p_peptide_match->getPeptideXtpSp().get()->toAbsoluteString()).arg(p_peptide_match->getCharge())); + } + } + else { + //overall samples + sequence_list.insert(QString("%1-%2").arg(p_peptide_match->getPeptideXtpSp().get()->toAbsoluteString()).arg(p_peptide_match->getCharge())); + } + } + } + return sequence_list.size(); +} + + +pappso::pappso_double ProteinMatch::getPAI() const { + pappso::MsRunIdSp sp_msrun_id; + return getPAI(sp_msrun_id); +} + +pappso::pappso_double ProteinMatch::getPAI(const pappso::MsRunIdSp & sp_msrun_id) const { + pappso::pappso_double PAI = (pappso::pappso_double) countValidAndCheckedPeptideMassCharge(sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->countTrypticPeptidesForPAI(); + return PAI; +} + pappso::pappso_double ProteinMatch::getCoverage() const { size_t prot_size = _protein_sp.get()->size(); //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); @@ -186,7 +216,7 @@ pappso::pappso_double ProteinMatch::getCoverage() const { return (((pappso::pappso_double)count)/ ((pappso::pappso_double)prot_size)); } const GroupingGroupSp & ProteinMatch::getGroupingGroupSp() const { - return _sp_group; + return _sp_group; } void ProteinMatch::setGroupInstance(GroupStore & group_store) { diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index b473d43e6ec0dc4965b7ee1e9cc38912cedd0c10..d649e35533d39a7f5bd19c29829c4defb5877473 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.h @@ -46,6 +46,17 @@ public: void setEvalue(pappso::pappso_double evalue); pappso::pappso_double getEvalue() const; pappso::pappso_double getCoverage() const; + + /** @brief compute Protein Abundance Index (PAI) + * overall sample PAI computation (Rappsilber et al. 2002) + * */ + pappso::pappso_double getPAI() const; + + /** @brief compute Protein Abundance Index (PAI) within sample + * PAI computation (Rappsilber et al. 2002) + * */ + pappso::pappso_double getPAI(const pappso::MsRunIdSp & sp_msrun_id) const; + void setProteinXtpSp(ProteinXtpSp protein_sp); void addPeptideMatch(PeptideMatch * peptide_match); std::vector<PeptideMatch *> & getPeptideMatchList(); @@ -95,6 +106,7 @@ private: /** @brief automatic filter result (false by default) */ bool _proxy_valid = false; + unsigned int countValidAndCheckedPeptideMassCharge(const pappso::MsRunIdSp & sp_msrun_id) const; }; diff --git a/src/core/proteinxtp.cpp b/src/core/proteinxtp.cpp index 432318eb218e10e138978341cce5ec29a6cec60e..f08e97e2091ff5652ec667db2be480bd19580a0f 100644 --- a/src/core/proteinxtp.cpp +++ b/src/core/proteinxtp.cpp @@ -22,6 +22,7 @@ ******************************************************************************/ #include "proteinxtp.h" +#include <pappsomspp/protein/enzyme.h> ProteinXtp::ProteinXtp():pappso::Protein() { @@ -62,3 +63,32 @@ bool ProteinXtp::isContaminant() const { bool ProteinXtp::isDecoy() const { return _is_decoy; } + +class DigestionHandler: public pappso::EnzymeProductInterface { +public: + void setPeptide(std::int8_t sequence_database_id, const pappso::ProteinSp & protein_sp, bool is_decoy, const QString& peptide, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme) override { + _peptide_list.append(peptide); + }; + + QStringList _peptide_list; +}; + +unsigned int ProteinXtp::countTrypticPeptidesForPAI() const { + qDebug() << "ProteinXtp::countTrypticPeptidesForPAI begin"; + pappso::Enzyme kinase; + kinase.setMiscleavage(0); + DigestionHandler digestion; + kinase.eat(0,this->makeProteinSp(),false,digestion); + + unsigned int count = 0; + for (const QString & peptide_str: digestion._peptide_list) { + pappso::Peptide peptide(peptide_str); + pappso::mz mass= peptide.getMass(); + if ((mass > 800) && (mass < 2500)) { + count ++; + } + } + + return count; + qDebug() << "ProteinXtp::countTrypticPeptidesForPAI end"; +} diff --git a/src/core/proteinxtp.h b/src/core/proteinxtp.h index 764266d3e3d866e469c7a8136d588144463c76a4..0dfa8ff7a33e700a8a293f4ebe074c49517af537 100644 --- a/src/core/proteinxtp.h +++ b/src/core/proteinxtp.h @@ -48,6 +48,7 @@ public: void setIsDecoy(bool conta); bool isContaminant() const; bool isDecoy() const; + unsigned int countTrypticPeptidesForPAI() const; private: SequenceDatabase * _p_sequence_database; diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 96f0793d7572ef1785b5e04be7068e37eeb24d5e..c5700f620e37883bf70e5dbad5d92bdb698f23ef 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -167,17 +167,17 @@ void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_grou void ProjectWindow::setProjectSp(ProjectSp project_sp) { for (auto && p_window :_peptide_list_window_collection) { - delete p_window; + delete p_window; } _peptide_list_window_collection.clear(); _p_current_peptide_list_window = nullptr; - - for (auto && p_window :_protein_list_window_collection) { - delete p_window; + + for (auto && p_window :_protein_list_window_collection) { + delete p_window; } _protein_list_window_collection.clear(); _p_current_protein_list_window = nullptr; - + _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())); diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index eb74f3cdcb47768da2cce5c813606d0839acc2a2..3a64371f67c4e3245ea4066e62f944f427fb641d 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -147,7 +147,7 @@ int ProteinTableModel::rowCount(const QModelIndex &parent ) const { return 0; } int ProteinTableModel::columnCount(const QModelIndex &parent ) const { - return 10; + return 11; } QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -176,6 +176,8 @@ QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, return QString("specific sequence"); case 9: return QString("coverage"); + case 10: + return QString("PAI"); } } } @@ -264,6 +266,9 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { if (col == 9) { return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getCoverage()); } + if (col == 10) { + return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getPAI()); + } return QVariant(); }