diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 4b3c3e3b7fec64f60a5c26a96e8c74261aa7b4f5..36ed21580d10cdc21d0da720c8fe8f2757c27f22 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -128,6 +128,9 @@ unsigned int IdentificationGroup::countProteinMatch(ValidationState state) const void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { qDebug() << "IdentificationGroup::updateAutomaticFilters begin" ; + for (IdentificationDataSource * p_identification_source_list:_id_source_list) { + p_identification_source_list->getPeptideEvidenceStore().updateAutomaticFilters(automatic_filter_parameters); + } for (auto & p_protein_match : _protein_match_list) { p_protein_match->updateAutomaticFilters(automatic_filter_parameters); } diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp index 4f600217148e06263f02c09b9daba427c1651eea..c4a57c3a850f88d1108ac782f19171b18b67169b 100644 --- a/src/core/peptidematch.cpp +++ b/src/core/peptidematch.cpp @@ -33,6 +33,12 @@ PeptideMatch::PeptideMatch(const PeptideMatch & other) { _p_peptide_evidence = other._p_peptide_evidence; } +bool PeptideMatch::operator==(const PeptideMatch & other) const { + if ((_p_peptide_evidence == other._p_peptide_evidence) && (_start == other._start)) { + return true; + } + return false; +} void PeptideMatch::setPeptideEvidenceSp(PeptideEvidenceSp sp_peptide_evidence) { _p_peptide_evidence = sp_peptide_evidence.get(); } diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h index 1794efc211c2adf75b0789f1b07a91a4a9ad678b..4f18084ca68850346541f24114d6d41dc3622882 100644 --- a/src/core/peptidematch.h +++ b/src/core/peptidematch.h @@ -31,6 +31,8 @@ class PeptideMatch public : PeptideMatch(); PeptideMatch(const PeptideMatch & other); + + bool operator==(const PeptideMatch & other) const; /** @brief set start position of this peptide inside the protein sequence diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index 37795b3f75c9c79644ff626689f9ea716533f076..0d2680d86f54317bddfba4ab00c1e90503f82f1e 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -51,13 +51,6 @@ ValidationState ProteinMatch::getValidationState() const { } return ValidationState::notValid; } -bool ProteinMatch::contains(PeptideMatch * peptide_match) const { - if (peptide_match == nullptr) return false; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match == peptide_match) return true; - } - return false; -} void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { //qDebug() <<"ProteinMatch::updateAutomaticFilters begin " ; @@ -66,17 +59,13 @@ void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & auto bool cross_sample = automatic_filter_parameters.getFilterCrossSamplePeptideNumber(); if (cross_sample) { - for (auto & p_peptide_match : _peptide_match_list) { - p_peptide_match->updateAutomaticFilters(automatic_filter_parameters); - } number_of_valid_peptides= countSequenceLi(ValidationState::validAndChecked,nullptr); } else { std::set<const MsRun *> msrun_set; for (auto & p_peptide_match : _peptide_match_list) { - p_peptide_match->updateAutomaticFilters(automatic_filter_parameters); - if (p_peptide_match->isValidAndChecked()) { - msrun_set.insert(p_peptide_match->getMsRunP()); + if (p_peptide_match.getPeptideEvidence()->isValidAndChecked()) { + msrun_set.insert(p_peptide_match.getPeptideEvidence()->getMsRunP()); } } for (const MsRun * p_msrun : msrun_set) { @@ -137,16 +126,17 @@ bool ProteinMatch::isGrouped() const { void ProteinMatch::setChecked(bool arg1) { _checked = arg1; } -void ProteinMatch::addPeptideMatchSp(PeptideMatchSp peptide_match) { - _peptide_match_list.push_back(peptide_match.get()); + +void ProteinMatch::addPeptideMatch(const PeptideMatch & peptide_match) { + _peptide_match_list.push_back(peptide_match); } -std::vector<PeptideMatch *> & ProteinMatch::getPeptideMatchList() { +std::vector<PeptideMatch> & ProteinMatch::getPeptideMatchList() { return _peptide_match_list; } -const std::vector<PeptideMatch *> & ProteinMatch::getPeptideMatchList() const { +const std::vector<PeptideMatch> & ProteinMatch::getPeptideMatchList() const { return _peptide_match_list; } @@ -156,9 +146,9 @@ void ProteinMatch::setGroupingExperiment(GroupingExperiment * p_grp_experiment) _sp_grp_protein = p_grp_experiment->getGrpProteinSp(this); for (auto & p_peptide_match : _peptide_match_list) { - p_peptide_match->setGrpPeptideSp(nullptr); - if (p_peptide_match->isValidAndChecked()) { - p_peptide_match->setGrpPeptideSp(p_grp_experiment->setGrpPeptide(_sp_grp_protein, p_peptide_match)); + p_peptide_match.getPeptideEvidence()->setGrpPeptideSp(nullptr); + if (p_peptide_match.getPeptideEvidence()->isValidAndChecked()) { + p_peptide_match.getPeptideEvidence()->setGrpPeptideSp(p_grp_experiment->setGrpPeptide(_sp_grp_protein, p_peptide_match.getPeptideEvidence())); } } @@ -177,24 +167,24 @@ const pappso::GrpProteinSp & ProteinMatch::getGrpProteinSp() const { void ProteinMatch::countPeptideMass(std::vector<pappso::GrpPeptide *> & count_peptide_mass, ValidationState state) const { for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->getValidationState() >= state) { - count_peptide_mass.push_back(p_peptide_match->getGrpPeptideSp().get()); + if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { + count_peptide_mass.push_back(p_peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()); } } } 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()); + if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { + count_peptide_mass_sample.push_back(p_peptide_match.getPeptideEvidence()->getHashPeptideMassSample()); } } } -std::vector<PeptideMatch *> ProteinMatch::getPeptideMatchList(ValidationState state) const { - std::vector<PeptideMatch *> peptide_match_list; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->getValidationState() >= state) { - peptide_match_list.push_back(p_peptide_match); +std::vector<PeptideMatch> ProteinMatch::getPeptideMatchList(ValidationState state) const { + std::vector<PeptideMatch> peptide_match_list; + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { + peptide_match_list.push_back(peptide_match); } } return peptide_match_list; @@ -202,14 +192,15 @@ std::vector<PeptideMatch *> ProteinMatch::getPeptideMatchList(ValidationState st unsigned int ProteinMatch::countSampleScan(ValidationState state, const MsRun * p_msrun_id) const { std::vector<std::size_t> count_sample_scan; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->getValidationState() >= state) { + for (auto & peptide_match : _peptide_match_list) { + const PeptideEvidence * p_peptide_evidence = peptide_match.getPeptideEvidence(); + if (p_peptide_evidence->getValidationState() >= state) { if(p_msrun_id == nullptr) { - count_sample_scan.push_back(p_peptide_match->getHashSampleScan()); + count_sample_scan.push_back(p_peptide_evidence->getHashSampleScan()); } else { - if (p_peptide_match->getMsRunP() == p_msrun_id) { - count_sample_scan.push_back(p_peptide_match->getHashSampleScan()); + if (p_peptide_evidence->getMsRunP() == p_msrun_id) { + count_sample_scan.push_back(p_peptide_evidence->getHashSampleScan()); } } } @@ -220,8 +211,8 @@ unsigned int ProteinMatch::countSampleScan(ValidationState state, const MsRun * } 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 std::count_if (_peptide_match_list.begin(), _peptide_match_list.end(), [state](const PeptideMatch & peptide_match) { + if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { return true; } else { @@ -232,17 +223,17 @@ unsigned int ProteinMatch::countPeptideMatch(ValidationState state) const { size_t ProteinMatch::countSequenceLi(ValidationState state, const MsRun * p_msrun_id) const { std::set<QString> sequence_list; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->getValidationState() >= state) { + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { if(p_msrun_id != nullptr) { //within sample - if (p_peptide_match->getMsRunP() == p_msrun_id) { - sequence_list.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi()); + if (peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) { + sequence_list.insert(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); } } else { //overall samples - sequence_list.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi()); + sequence_list.insert(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); } } } @@ -252,9 +243,9 @@ size_t ProteinMatch::countSequenceLi(ValidationState state, const MsRun * p_msru unsigned int ProteinMatch::countDistinctMsSamples(ValidationState state) const { std::set<QString> sequence_list; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->getValidationState() >= state) { - sequence_list.insert(QString("%1").arg(p_peptide_match->getMsRunP()->getXmlId())); + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { + sequence_list.insert(QString("%1").arg(peptide_match.getPeptideEvidence()->getMsRunP()->getXmlId())); } } return sequence_list.size(); @@ -262,17 +253,17 @@ unsigned int ProteinMatch::countDistinctMsSamples(ValidationState state) const { unsigned int ProteinMatch::countPeptideMassCharge(ValidationState state, const MsRun * sp_msrun_id) const { std::set<QString> sequence_list; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->getValidationState() >= state) { + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { if(sp_msrun_id != nullptr) { //within sample - if (p_peptide_match->getMsRunP() == sp_msrun_id) { - sequence_list.insert(QString("%1-%2-%3").arg(p_peptide_match->getPeptideXtpSp().get()->getNativePeptideP()->getSequenceLi()).arg(p_peptide_match->getPeptideXtpSp().get()->getNativePeptideP()->getMass()).arg(p_peptide_match->getCharge())); + if (peptide_match.getPeptideEvidence()->getMsRunP() == sp_msrun_id) { + sequence_list.insert(QString("%1-%2-%3").arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getSequenceLi()).arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getMass()).arg(peptide_match.getPeptideEvidence()->getCharge())); } } else { //overall samples - sequence_list.insert(QString("%1-%2-%3").arg(p_peptide_match->getPeptideXtpSp().get()->getNativePeptideP()->getSequenceLi()).arg(p_peptide_match->getPeptideXtpSp().get()->getNativePeptideP()->getMass()).arg(p_peptide_match->getCharge())); + sequence_list.insert(QString("%1-%2-%3").arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getSequenceLi()).arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getMass()).arg(peptide_match.getPeptideEvidence()->getCharge())); } } } @@ -285,13 +276,13 @@ pappso::pappso_double ProteinMatch::getEvalue(const MsRun * sp_msrun_id) const { pappso::pappso_double ProteinMatch::getLogEvalue(const MsRun * sp_msrun_id) const { std::map<QString, pappso::pappso_double> map_sequence_evalue; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->isValidAndChecked()) { - QString sequence(p_peptide_match->getPeptideXtpSp().get()->getSequence()); - pappso::pappso_double evalue = p_peptide_match->getEvalue(); + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { + QString sequence(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()); + pappso::pappso_double evalue = peptide_match.getPeptideEvidence()->getEvalue(); if(sp_msrun_id != nullptr) { //within sample - if (p_peptide_match->getMsRunP() == sp_msrun_id) { + if (peptide_match.getPeptideEvidence()->getMsRunP() == sp_msrun_id) { auto ret = map_sequence_evalue.insert(std::pair<QString, pappso::pappso_double>(sequence, evalue)); if (ret.second == false) { if (ret.first->second > evalue) {//get best evalue for sequence @@ -341,27 +332,29 @@ pappso::pappso_double ProteinMatch::getEmPAI(const MsRun * sp_msrun_id) const { return value; } -const QString ProteinMatch::getHtmlSequence(PeptideMatch * peptide_match_to_locate) const +const QString ProteinMatch::getHtmlSequence(PeptideEvidence * peptide_evidence_to_locate) const { size_t prot_size = _protein_sp.get()->size(); //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); if (prot_size == 0) return 0; bool cover_bool[prot_size] = {false}; bool highlight_bool[prot_size] = {false}; - if (this->contains(peptide_match_to_locate)) { - size_t size = peptide_match_to_locate->getPeptideXtpSp().get()->size(); - size_t offset = peptide_match_to_locate->getStart(); - if (offset >= 0) { - for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { - highlight_bool[offset] = true; + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence() == peptide_evidence_to_locate) { + size_t size = peptide_evidence_to_locate->getPeptideXtpSp().get()->size(); + size_t offset = peptide_match.getStart(); + if (offset >= 0) { + for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { + highlight_bool[offset] = true; + } } } } - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->isValidAndChecked()) { - size_t size = p_peptide_match->getPeptideXtpSp().get()->size(); - size_t offset = p_peptide_match->getStart(); + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { + size_t size = peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->size(); + size_t offset = peptide_match.getPeptideEvidence()->getStart(); if (offset >= 0) { for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { cover_bool[offset] = true; @@ -417,10 +410,10 @@ pappso::pappso_double ProteinMatch::getCoverage() const { //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); if (prot_size == 0) return 0; bool cover_bool[prot_size] = {false}; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->isValidAndChecked()) { - size_t size = p_peptide_match->getPeptideXtpSp().get()->size(); - size_t offset = p_peptide_match->getStart(); + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { + size_t size = peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->size(); + size_t offset = peptide_match.getStart(); if (offset >= 0) { for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { cover_bool[offset] = true; @@ -452,14 +445,14 @@ void ProteinMatch::setGroupInstance(GroupStore & group_store) { void ProteinMatch::collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const { - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->getValidationState() >= state) { - pappso::pappso_double diff = p_peptide_match->getDeltaMass(); + for (auto & peptide_match : _peptide_match_list) { + if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { + pappso::pappso_double diff = peptide_match.getPeptideEvidence()->getDeltaMass(); if (unit == pappso::PrecisionUnit::ppm) { while (diff < -0.5) { diff = diff + pappso::DIFFC12C13; } - diff = (diff / p_peptide_match->getPeptideXtpSp().get()->getMz(1)) * pappso::ONEMILLION; + diff = (diff / peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getMz(1)) * pappso::ONEMILLION; } delta_list.push_back(diff); } diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index 4652c3edcbd02a97c07d2d8228b031a4d4ac33b8..e397ea51ada4e7317a505e8c3c8af765ead68686 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.h @@ -61,7 +61,7 @@ public: /** @brief get coverage sequence (html representation) * @param peptide_match_to_locate pointer to optional peptide match to locate on protein sequence **/ - const QString getHtmlSequence(PeptideMatch * peptide_match_to_locate = nullptr) const; + const QString getHtmlSequence(PeptideEvidence * peptide_evidence_to_locate = nullptr) const; /** @brief compute Protein Abundance Index (PAI) within sample * PAI computation (Rappsilber et al. 2002) @@ -75,12 +75,12 @@ public: void setProteinXtpSp(ProteinXtpSp protein_sp); void addPeptideMatch(const PeptideMatch & peptide_match); - std::vector<PeptideMatch *> & getPeptideMatchList(); - const std::vector<PeptideMatch *> & getPeptideMatchList() const; + std::vector<PeptideMatch> & getPeptideMatchList(); + const std::vector<PeptideMatch> & getPeptideMatchList() const; /** @brief get peptide match sublist with required validation state * */ - std::vector<PeptideMatch *> getPeptideMatchList(ValidationState state) const; + std::vector<PeptideMatch> getPeptideMatchList(ValidationState state) const; void setChecked(bool arg1); bool isChecked() const; @@ -113,10 +113,6 @@ public: * */ void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); - /** @brief tells if this protein match contains this peptides - */ - bool contains(PeptideMatch * peptide_match) const; - void collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const; /** @brief count distinct sequence taking into account equivalence between Leucine and Isoleucine @@ -152,7 +148,7 @@ private: pappso::GrpProteinSp _sp_grp_protein; GroupingGroupSp _sp_group; - std::vector<PeptideMatch *> _peptide_match_list; + std::vector<PeptideMatch> _peptide_match_list; ProteinXtpSp _protein_sp = nullptr; /** @brief manually checked by user (true by default) */ diff --git a/src/grouping/groupingexperiment.h b/src/grouping/groupingexperiment.h index bd974b4a7f3aed15296d849d2d401feea33af763..0910407c3bcce9cd02cfcfc0b030911b9fd22f6e 100644 --- a/src/grouping/groupingexperiment.h +++ b/src/grouping/groupingexperiment.h @@ -30,7 +30,7 @@ #define GROUPINGEXPERIMENT_H class ProteinMatch; -class PeptideMatch; +class PeptideEvidence; class GroupingExperiment { @@ -41,7 +41,7 @@ public: static GroupingExperiment * newInstance(const GroupingType & grouping_type, WorkMonitorInterface * p_work_monitor); virtual pappso::GrpProteinSp & getGrpProteinSp(ProteinMatch* p_protein_match) = 0; - virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideMatch* p_peptide_match) = 0; + virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideEvidence * p_peptide_evidence) = 0; virtual void addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) = 0; virtual void startGrouping()= 0; diff --git a/src/grouping/groupinggroup.cpp b/src/grouping/groupinggroup.cpp index 806902120b70e40534d152ec2b511de9b6dcd49a..e3d85a0950dc72fbb9a6e17b64dea39c70570701 100644 --- a/src/grouping/groupinggroup.cpp +++ b/src/grouping/groupinggroup.cpp @@ -38,8 +38,8 @@ GroupingGroup::~GroupingGroup() } -const std::vector<std::pair<unsigned int, const PeptideMatch *>> & GroupingGroup::getPairSgNumberPeptideMatchList() const { - return _pair_sg_number_peptide_match_list; +const std::vector<std::pair<unsigned int, const PeptideEvidence *>> & GroupingGroup::getPairSgNumberPeptideEvidenceList() const { + return _pair_sg_number_peptide_evidence_list; } unsigned int GroupingGroup::getGroupNumber() const { return _group_number; @@ -50,19 +50,19 @@ unsigned int GroupingGroup::getNumberOfSubgroups() const { const std::vector<const ProteinMatch *> & GroupingGroup::getProteinMatchList() const { return _protein_match_list; } -std::vector<const PeptideMatch *> GroupingGroup::getPeptideMatchList() const { - std::vector<const PeptideMatch *> peptide_match_list; - for (auto && pair_peptide_match :_pair_sg_number_peptide_match_list) { +std::vector<const PeptideEvidence *> GroupingGroup::getPeptideEvidenceList() const { + std::vector<const PeptideEvidence *> peptide_match_list; + for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { peptide_match_list.push_back(pair_peptide_match.second); } return peptide_match_list; } -const QStringList GroupingGroup::getSubgroupIdList(const PeptideMatch * p_peptide_match) const { +const QStringList GroupingGroup::getSubgroupIdList(const PeptideEvidence * p_peptide_match) const { std::set<unsigned int> subgroup_list; pappso::GrpPeptide * p_grp_peptide = p_peptide_match->getGrpPeptideSp().get(); if (p_grp_peptide != nullptr) { - for (auto && pair_peptide_match :_pair_sg_number_peptide_match_list) { + for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { if(pair_peptide_match.second->getGrpPeptideSp().get() == p_grp_peptide) { subgroup_list.insert(pair_peptide_match.first); } @@ -78,11 +78,11 @@ const QStringList GroupingGroup::getSubgroupIdList(const PeptideMatch * p_peptid } -unsigned int GroupingGroup::countSubgroupPresence(const PeptideMatch * p_peptide_match) const { +unsigned int GroupingGroup::countSubgroupPresence(const PeptideEvidence * p_peptide_evidence) const { std::set<unsigned int> subgroup_list; - pappso::GrpPeptide * p_grp_peptide = p_peptide_match->getGrpPeptideSp().get(); + pappso::GrpPeptide * p_grp_peptide = p_peptide_evidence->getGrpPeptideSp().get(); if (p_grp_peptide != nullptr) { - for (auto && pair_peptide_match :_pair_sg_number_peptide_match_list) { + for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { if(pair_peptide_match.second->getGrpPeptideSp().get() == p_grp_peptide) { subgroup_list.insert(pair_peptide_match.first); } @@ -97,20 +97,20 @@ std::size_t GroupingGroup::countSpecificSampleScan(const ProteinMatch * p_protei } std::set<size_t> spectrum_list_in; for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) { - if (p_peptide_match->getValidationState() >= state) { + if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { if(p_msrun_id == nullptr) { - spectrum_list_in.insert(p_peptide_match->getHashSampleScan()); + spectrum_list_in.insert(p_peptide_match.getPeptideEvidence()->getHashSampleScan()); } else { - if (p_peptide_match->getMsRunP() == p_msrun_id) { - spectrum_list_in.insert(p_peptide_match->getHashSampleScan()); + if (p_peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) { + spectrum_list_in.insert(p_peptide_match.getPeptideEvidence()->getHashSampleScan()); } } } } std::set<size_t> spectrum_list_out; unsigned int sg_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); - for (auto && pair_peptide_match :_pair_sg_number_peptide_match_list) { + for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { if (pair_peptide_match.first != sg_number) { spectrum_list_out.insert(pair_peptide_match.second->getHashSampleScan()); } @@ -132,20 +132,20 @@ std::size_t GroupingGroup::countSpecificSequenceLi(const ProteinMatch * p_protei } std::set<QString> sequence_list_in; for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) { - if (p_peptide_match->getValidationState() >= state) { + if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { if(p_msrun_id == nullptr) { - sequence_list_in.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi()); + sequence_list_in.insert(p_peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); } else { - if (p_peptide_match->getMsRunP() == p_msrun_id) { - sequence_list_in.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi()); + if (p_peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) { + sequence_list_in.insert(p_peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); } } } } std::set<QString> sequence_list_out; unsigned int sg_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); - for (auto && pair_peptide_match :_pair_sg_number_peptide_match_list) { + for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { if (pair_peptide_match.first != sg_number) { sequence_list_out.insert(pair_peptide_match.second->getPeptideXtpSp().get()->getSequenceLi()); } @@ -183,9 +183,9 @@ void GroupingGroup::add(const ProteinMatch * p_protein_match) { _number_of_subgroup++; unsigned int sg_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); - for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) { - if (p_peptide_match->isValidAndChecked()) { - _pair_sg_number_peptide_match_list.push_back(std::pair<unsigned int, const PeptideMatch * >(sg_number, p_peptide_match)); + for (auto && peptide_match :p_protein_match->getPeptideMatchList()) { + if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { + _pair_sg_number_peptide_evidence_list.push_back(std::pair<unsigned int, const PeptideEvidence * >(sg_number, peptide_match.getPeptideEvidence())); } } } diff --git a/src/grouping/groupinggroup.h b/src/grouping/groupinggroup.h index d351b18785fd20b907acfe2f76d80dcb1e534e97..1789a683b2c2facdefb5c75049565e8757c024b0 100644 --- a/src/grouping/groupinggroup.h +++ b/src/grouping/groupinggroup.h @@ -31,7 +31,7 @@ #include "../core/msrun.h" class ProteinMatch; -class PeptideMatch; +class PeptideEvidence; class GroupingGroup; typedef std::shared_ptr<GroupingGroup> GroupingGroupSp; @@ -57,11 +57,11 @@ public: /** @brief count number of subgroups in which this peptide is present * */ - unsigned int countSubgroupPresence(const PeptideMatch * p_peptide_match) const; + unsigned int countSubgroupPresence(const PeptideEvidence * p_peptide_evidence) const; /** @brief subgroup identifier list in which this peptide is present * */ - const QStringList getSubgroupIdList(const PeptideMatch * p_peptide_match) const; + const QStringList getSubgroupIdList(const PeptideEvidence * p_peptide_evidence) const; /** @brief give the protein group id of the representant of a subgroup * */ @@ -72,18 +72,18 @@ public: * */ const std::vector<const ProteinMatch *> & getProteinMatchList() const; - /** @brief get the list of peptide match included in this group + /** @brief get the list of peptide evidence included in this group * warning : it only contains the first protein representant in one subgroup * use a double loop with getProteinMatchList to scan every peptide match * */ - std::vector<const PeptideMatch *> getPeptideMatchList() const; + std::vector<const PeptideEvidence *> getPeptideEvidenceList() const; - const std::vector<std::pair<unsigned int, const PeptideMatch *>> & getPairSgNumberPeptideMatchList() const; + const std::vector<std::pair<unsigned int, const PeptideEvidence *>> & getPairSgNumberPeptideEvidenceList() const; private : unsigned int _group_number=0; unsigned int _number_of_subgroup=0; - std::vector<std::pair<unsigned int, const PeptideMatch *>> _pair_sg_number_peptide_match_list; + std::vector<std::pair<unsigned int, const PeptideEvidence *>> _pair_sg_number_peptide_evidence_list; std::vector<const ProteinMatch *> _protein_match_list; }; diff --git a/src/grouping/groupingpeptidemass.cpp b/src/grouping/groupingpeptidemass.cpp index a1b47b2ffd6679f9a6756a0eeaebf4d6dadc0ff2..108f89fb9ae1ab06f9994e370e9cdf897956c4e0 100644 --- a/src/grouping/groupingpeptidemass.cpp +++ b/src/grouping/groupingpeptidemass.cpp @@ -78,9 +78,9 @@ GroupingPeptideMass::~GroupingPeptideMass() pappso::GrpProteinSp & GroupingPeptideMass::getGrpProteinSp(ProteinMatch* p_protein_match) { return _p_grp_experiment->getGrpProteinSp(p_protein_match->getProteinXtpSp().get()->getAccession(),p_protein_match->getProteinXtpSp().get()->getDescription()); } -pappso::GrpPeptideSp & GroupingPeptideMass::setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideMatch* p_peptide_match) { +pappso::GrpPeptideSp & GroupingPeptideMass::setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideEvidence * p_peptide_evidence) { - return _p_grp_experiment->setGrpPeptide(proteinSp,p_peptide_match->getPeptideXtpSp().get()->getSequence(), p_peptide_match->getPeptideXtpSp().get()->getGroupingMass()); + return _p_grp_experiment->setGrpPeptide(proteinSp,p_peptide_evidence->getPeptideXtpSp().get()->getSequence(), p_peptide_evidence->getPeptideXtpSp().get()->getGroupingMass()); } void GroupingPeptideMass::startGrouping() { diff --git a/src/grouping/groupingpeptidemass.h b/src/grouping/groupingpeptidemass.h index 5f64a54c9548dbbd4e67fca04f87a624f07f7008..a1d1d4e4136cab76cfba42cb8e1e99ea87899bea 100644 --- a/src/grouping/groupingpeptidemass.h +++ b/src/grouping/groupingpeptidemass.h @@ -35,7 +35,7 @@ public: virtual ~GroupingPeptideMass(); virtual pappso::GrpProteinSp & getGrpProteinSp(ProteinMatch* p_protein_match) override; - virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideMatch* p_peptide_match) override; + virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideEvidence * p_peptide_evidence) override; virtual void addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) override; virtual void startGrouping() override; diff --git a/src/grouping/ptm/ptmgroupingexperiment.cpp b/src/grouping/ptm/ptmgroupingexperiment.cpp index 2e0dbe225bd926ce170c04ab2ed5ae87dae27827..524c75f68c4ea245f108ce67560078e9903c5e22 100644 --- a/src/grouping/ptm/ptmgroupingexperiment.cpp +++ b/src/grouping/ptm/ptmgroupingexperiment.cpp @@ -123,9 +123,9 @@ void PtmGroupingExperiment::addProteinMatch(const ProteinMatch* p_protein_match) for (unsigned int position : ptm_position_list) { ptm_island_list.push_back(std::make_shared<PtmIsland>(p_protein_match, position)); } - for (PeptideMatch * p_peptide_match: p_protein_match->getPeptideMatchList(_peptide_validation_state)) { + for (PeptideMatch & peptide_match: p_protein_match->getPeptideMatchList(_peptide_validation_state)) { for (PtmIslandSp ptm_island_sp:ptm_island_list) { - ptm_island_sp.get()->addPeptideMatch(p_peptide_match); + ptm_island_sp.get()->addPeptideMatch(peptide_match); } } @@ -153,30 +153,30 @@ std::vector< PtmIslandSp > PtmGroupingExperiment::mergePeptideMatchPtmIslandList } -unsigned int PtmGroupingExperiment::countPeptideMatchPtm(const PeptideMatch* p_peptide_match)const { +unsigned int PtmGroupingExperiment::countPeptideMatchPtm(const PeptideMatch & peptide_match)const { unsigned int number=0; for (const ModificationAndAa & modification: _modification_list) { if (modification.aa_list.size() == 0) { - number += p_peptide_match->getPeptideXtpSp().get()->getNumberOfModification(modification.modification); + number += peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNumberOfModification(modification.modification); } else { - number += p_peptide_match->getPeptideXtpSp().get()->countModificationOnAa(modification.modification, modification.aa_list); + number += peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->countModificationOnAa(modification.modification, modification.aa_list); } } return number; } -std::vector<unsigned int> PtmGroupingExperiment::getPtmPositions(const PeptideMatch * p_peptide_match) const { +std::vector<unsigned int> PtmGroupingExperiment::getPtmPositions(const PeptideMatch & peptide_match) const { std::vector<unsigned int> position_list; for (const ModificationAndAa & modification: _modification_list) { if (modification.aa_list.size() == 0) { - for (unsigned int position : p_peptide_match->getPeptideXtpSp().get()->getModificationPositionList(modification.modification)) { + for (unsigned int position : peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getModificationPositionList(modification.modification)) { position_list.push_back(position); } } else { - for (unsigned int position : p_peptide_match->getPeptideXtpSp().get()->getModificationPositionList(modification.modification, modification.aa_list)) { + for (unsigned int position : peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getModificationPositionList(modification.modification, modification.aa_list)) { position_list.push_back(position); } } @@ -191,9 +191,9 @@ std::vector<unsigned int> PtmGroupingExperiment::getPtmPositions(const PeptideMa std::vector<unsigned int> PtmGroupingExperiment::getPtmPositions(const ProteinMatch * protein_match) const { std::vector<unsigned int> position_list; - for (const PeptideMatch * p_peptide_match: protein_match->getPeptideMatchList(_peptide_validation_state)) { - unsigned int start = p_peptide_match->getStart(); - std::vector<unsigned int> positionb_list = this->getPtmPositions(p_peptide_match); + for (const PeptideMatch & peptide_match: protein_match->getPeptideMatchList(_peptide_validation_state)) { + unsigned int start = peptide_match.getStart(); + std::vector<unsigned int> positionb_list = this->getPtmPositions(peptide_match); for (unsigned int position: positionb_list) { position_list.push_back(start+position); } diff --git a/src/grouping/ptm/ptmgroupingexperiment.h b/src/grouping/ptm/ptmgroupingexperiment.h index 61ab3c26e0946fed1f8e3dd8b0b786a36c1c4403..abbdf2c6c3e0025637d9c841e1ab31d9203c7e72 100644 --- a/src/grouping/ptm/ptmgroupingexperiment.h +++ b/src/grouping/ptm/ptmgroupingexperiment.h @@ -58,8 +58,8 @@ public: const std::vector<PtmIslandSp> & getPtmIslandList() const; /** @brief count number of modifications in a PeptideMatch * */ - unsigned int countPeptideMatchPtm(const PeptideMatch* p_peptide_match)const; - std::vector<unsigned int> getPtmPositions(const PeptideMatch * p_peptide_match) const; + unsigned int countPeptideMatchPtm(const PeptideMatch & peptide_match)const; + std::vector<unsigned int> getPtmPositions(const PeptideMatch & peptide_match) const; private: std::vector<unsigned int> getPtmPositions(const ProteinMatch * protein_match) const; diff --git a/src/grouping/ptm/ptmisland.cpp b/src/grouping/ptm/ptmisland.cpp index 767c52a420a857e7832fa8fef3d10feee7cc5e1d..51d41937c73aa1a633f8450da42a326bb0a9888e 100644 --- a/src/grouping/ptm/ptmisland.cpp +++ b/src/grouping/ptm/ptmisland.cpp @@ -59,7 +59,7 @@ unsigned int PtmIsland::countSampleScanMultiPtm(const PtmGroupingExperiment * p_ std::set<std::size_t> sample_scan_list; for (auto & p_peptide_match : _peptide_match_list) { if (p_ptm_grouping_experiment->countPeptideMatchPtm(p_peptide_match) > 1) { - sample_scan_list.insert(p_peptide_match->getHashSampleScan()); + sample_scan_list.insert(p_peptide_match.getPeptideEvidence()->getHashSampleScan()); } } return sample_scan_list.size(); @@ -67,8 +67,8 @@ unsigned int PtmIsland::countSampleScanMultiPtm(const PtmGroupingExperiment * p_ unsigned int PtmIsland::countSequence() const { std::set<QString> sequence_list; - for (auto & p_peptide_match : _peptide_match_list) { - sequence_list.insert(p_peptide_match->getPeptideXtpSp().get()->getSequence()); + for (auto & peptide_match : _peptide_match_list) { + sequence_list.insert(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()); } //qDebug() <<"ProteinMatch::countValidAndCheckedPeptide end " << sequence_list.size(); return sequence_list.size(); @@ -97,8 +97,8 @@ const ProteinMatch * PtmIsland::getProteinMatch() const { } std::vector<std::size_t> PtmIsland::getSampleScanSet() const { std::vector<std::size_t> sample_scan_set; - for (const PeptideMatch * p_peptide_match:_peptide_match_list) { - sample_scan_set.push_back(p_peptide_match->getHashSampleScan()); + for (const PeptideMatch & peptide_match:_peptide_match_list) { + sample_scan_set.push_back(peptide_match.getPeptideEvidence()->getHashSampleScan()); } std::sort(sample_scan_set.begin(), sample_scan_set.end()); @@ -112,20 +112,20 @@ bool PtmIsland::containsPeptideMatch(const PeptideMatch* peptide_match) const { }); } -void PtmIsland::addPeptideMatch(PeptideMatch* p_peptide_match) { +void PtmIsland::addPeptideMatch(const PeptideMatch & peptide_match) { if (_position_list.size()==1) { unsigned int position = _position_list[0]; - if (p_peptide_match->containsPosition(position)) { + if (peptide_match.containsPosition(position)) { if (_peptide_match_list.size() == 0) { - _protein_start = p_peptide_match->getStart(); + _protein_start = peptide_match.getStart(); + } + _peptide_match_list.push_back(peptide_match); + if (peptide_match.getStart() < _protein_start) { + _protein_start = peptide_match.getStart(); + } + if (peptide_match.getStop() > _protein_stop) { + _protein_stop = peptide_match.getStop(); } - _peptide_match_list.push_back(p_peptide_match); - if (p_peptide_match->getStart() < _protein_start) { - _protein_start = p_peptide_match->getStart(); - } - if (p_peptide_match->getStop() > _protein_stop) { - _protein_stop = p_peptide_match->getStop(); - } } } else { @@ -155,17 +155,17 @@ bool PtmIsland::merge(PtmIslandSp ptm_island_sp) { _position_list.erase(std::unique(_position_list.begin(), _position_list.end()), _position_list.end()); - std::vector<PeptideMatch *>::const_iterator it_result = std::max_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch * a, const PeptideMatch * b) + std::vector<PeptideMatch>::const_iterator it_result = std::max_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch & a, const PeptideMatch & b) { - return (a->getStop() < b->getStop()); + return (a.getStop() < b.getStop()); }); - _protein_stop = (*it_result)->getStop(); + _protein_stop = it_result->getStop(); - it_result = std::min_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch * a, const PeptideMatch * b) + it_result = std::min_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch & a, const PeptideMatch & b) { - return a->getStart() < b->getStart(); + return a.getStart() < b.getStart(); }); - _protein_start = (*it_result)->getStart(); + _protein_start = it_result->getStart(); return true; } } @@ -173,17 +173,17 @@ bool PtmIsland::merge(PtmIslandSp ptm_island_sp) { std::vector<PtmSampleScanSp> PtmIsland::getPtmSampleScanSpList() const { qDebug() << "PtmIsland::getPtmSampleScanSpList begin" ; std::vector<PtmSampleScanSp> sample_scan_list; - for (PeptideMatch * p_peptide_match:_peptide_match_list) { - + for (const PeptideMatch & peptide_match:_peptide_match_list) { + std::vector<PtmSampleScanSp>::iterator it_ptm = sample_scan_list.begin(); std::vector<PtmSampleScanSp>::iterator it_ptm_end = sample_scan_list.end(); - while ((it_ptm != it_ptm_end) && (it_ptm->get()->add(p_peptide_match) == false)) { + while ((it_ptm != it_ptm_end) && (it_ptm->get()->add(peptide_match) == false)) { //peptide added it_ptm++; } if (it_ptm == it_ptm_end) { //peptide NOT added - sample_scan_list.push_back(std::make_shared<PtmSampleScan>(p_peptide_match)); + sample_scan_list.push_back(std::make_shared<PtmSampleScan>(peptide_match)); } } diff --git a/src/grouping/ptm/ptmisland.h b/src/grouping/ptm/ptmisland.h index 845ae3429729faa5719acc0c95dc51708e8f0d0b..d00537ec886f2537058fc2f8a0e3a81d29daf966 100644 --- a/src/grouping/ptm/ptmisland.h +++ b/src/grouping/ptm/ptmisland.h @@ -50,7 +50,7 @@ public: PtmIsland(const ProteinMatch* p_protein_match, unsigned int position); PtmIsland(const PtmIsland & other); ~PtmIsland(); - void addPeptideMatch(PeptideMatch* p_peptide_match); + void addPeptideMatch(const PeptideMatch & peptide_match); /** @brief merge with the given ptm island if there is at least one common peptide match * */ @@ -77,7 +77,7 @@ public: private: const ProteinMatch * _protein_match_p; - std::vector<PeptideMatch *> _peptide_match_list; + std::vector<PeptideMatch> _peptide_match_list; //std::vector<std::size_t> _sample_scan_set; std::vector<unsigned int> _position_list; unsigned int _protein_stop=0; diff --git a/src/grouping/ptm/ptmsamplescan.cpp b/src/grouping/ptm/ptmsamplescan.cpp index 361108102695b1aee25ae2cfe3e107fb5093c5c9..71a1abb5727c332bc51c17ac535a80b05d7708f4 100644 --- a/src/grouping/ptm/ptmsamplescan.cpp +++ b/src/grouping/ptm/ptmsamplescan.cpp @@ -36,8 +36,8 @@ QColor PtmSampleScan::_color_other_best = QColor("#ff7878"); QColor PtmSampleScan::_color_no_best = QColor("yellow"); -PtmSampleScan::PtmSampleScan(PeptideMatch * p_peptide_match) { - _peptide_match_list.push_back(p_peptide_match); +PtmSampleScan::PtmSampleScan(const PeptideMatch & peptide_match) { + _peptide_match_list.push_back(peptide_match); } PtmSampleScan::PtmSampleScan(const PtmSampleScan& other) { @@ -45,24 +45,24 @@ PtmSampleScan::PtmSampleScan(const PtmSampleScan& other) { PtmSampleScan::~PtmSampleScan() { } -const PeptideMatch * PtmSampleScan::getRepresentativePeptideMatch() const { +const PeptideMatch & PtmSampleScan::getRepresentativePeptideMatch() const { return _peptide_match_list[0]; } -bool PtmSampleScan::add(PeptideMatch * p_peptide_match) { - if(getRepresentativePeptideMatch()->getHashSampleScan() != p_peptide_match->getHashSampleScan()) { +bool PtmSampleScan::add(const PeptideMatch & peptide_match) { + if(getRepresentativePeptideMatch().getPeptideEvidence()->getHashSampleScan() != peptide_match.getPeptideEvidence()->getHashSampleScan()) { return false; } - if(getRepresentativePeptideMatch()->getPeptideXtpSp().get()->getSequence() != p_peptide_match->getPeptideXtpSp().get()->getSequence()) { + if(getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getSequence() != peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()) { return false; } - if(getRepresentativePeptideMatch()->getPeptideXtpSp().get()->getMass() != p_peptide_match->getPeptideXtpSp().get()->getMass()) { + if(getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getMass() != peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getMass()) { return false; } - _peptide_match_list.push_back(p_peptide_match); + _peptide_match_list.push_back(peptide_match); //sort list - std::sort(_peptide_match_list.begin(),_peptide_match_list.end(),[](const PeptideMatch * first, const PeptideMatch * second) { - return (first->getEvalue() < second->getEvalue()) ; + std::sort(_peptide_match_list.begin(),_peptide_match_list.end(),[](const PeptideMatch & first, const PeptideMatch & second) { + return (first.getPeptideEvidence()->getEvalue() < second.getPeptideEvidence()->getEvalue()) ; }); return true; @@ -75,8 +75,8 @@ std::vector<unsigned int> PtmSampleScan::getBestPtmPositionList(const PtmGroupin std::vector<unsigned int> PtmSampleScan::getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const { std::vector<unsigned int> position_list; - for (const PeptideMatch * p_peptide_match: _peptide_match_list) { - std::vector<unsigned int> positionb_list = p_ptm_grouping_experiment->getPtmPositions(p_peptide_match); + for (const PeptideMatch & peptide_match: _peptide_match_list) { + std::vector<unsigned int> positionb_list = p_ptm_grouping_experiment->getPtmPositions(peptide_match); for (unsigned int position: positionb_list) { position_list.push_back(position); } @@ -89,24 +89,24 @@ std::vector<unsigned int> PtmSampleScan::getObservedPtmPositionList(const PtmGro const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const { - const PeptideMatch * p_representative_peptide = getRepresentativePeptideMatch(); - size_t pep_size = p_representative_peptide->getPeptideXtpSp().get()->size(); + const PeptideMatch & representative_peptide = getRepresentativePeptideMatch(); + size_t pep_size = representative_peptide.getPeptideEvidence()->getPeptideXtpSp().get()->size(); //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); if (pep_size == 0) return 0; bool best_bool[pep_size] = {false}; bool other_best_bool[pep_size] = {false}; bool nobest_bool[pep_size] = {false}; - double best_evalue = p_representative_peptide->getEvalue(); + double best_evalue = representative_peptide.getPeptideEvidence()->getEvalue(); - for (auto & p_peptide_match : _peptide_match_list) { + for (auto & peptide_match : _peptide_match_list) { bool is_best= false; - if (p_peptide_match->getEvalue() == best_evalue) { + if (peptide_match.getPeptideEvidence()->getEvalue() == best_evalue) { is_best= true; } - std::vector<unsigned int> position_list = p_ptm_grouping_experiment->getPtmPositions(p_peptide_match); + std::vector<unsigned int> position_list = p_ptm_grouping_experiment->getPtmPositions(peptide_match); for (unsigned int position :position_list) { - if (p_representative_peptide == p_peptide_match) { + if (representative_peptide == peptide_match) { best_bool[position] = true; } else if (is_best) { @@ -117,7 +117,7 @@ const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm } } } - QString sequence = p_representative_peptide->getPeptideXtpSp().get()->getSequence(); + QString sequence = representative_peptide.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence(); QString sequence_html; for (unsigned int i=0; i < pep_size; i++) { if (best_bool[i]) { @@ -136,6 +136,6 @@ const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm return sequence_html; } -const std::vector<PeptideMatch *> & PtmSampleScan::getPeptideMatchList() const { +const std::vector<PeptideMatch> & PtmSampleScan::getPeptideMatchList() const { return _peptide_match_list; } diff --git a/src/grouping/ptm/ptmsamplescan.h b/src/grouping/ptm/ptmsamplescan.h index 3533ff92dad010a82af0493d2094b7d34d0ce455..3ff57ed59f3e779f735990b6947b4e180f13a259 100644 --- a/src/grouping/ptm/ptmsamplescan.h +++ b/src/grouping/ptm/ptmsamplescan.h @@ -44,19 +44,19 @@ typedef std::shared_ptr<PtmSampleScan> PtmSampleScanSp; class PtmSampleScan { public: - PtmSampleScan(PeptideMatch * p_peptide_match); + PtmSampleScan(const PeptideMatch & peptide_match); PtmSampleScan(const PtmSampleScan& other); ~PtmSampleScan(); - const PeptideMatch * getRepresentativePeptideMatch() const; - bool add(PeptideMatch * p_peptide_match); + const PeptideMatch & getRepresentativePeptideMatch() const; + bool add(const PeptideMatch & peptide_match); std::vector<unsigned int> getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; std::vector<unsigned int> getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; const QString getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; - const std::vector<PeptideMatch *> & getPeptideMatchList() const; + const std::vector<PeptideMatch> & getPeptideMatchList() const; private: - std::vector<PeptideMatch *> _peptide_match_list; + std::vector<PeptideMatch> _peptide_match_list; static QColor _color_best; static QColor _color_other_best; static QColor _color_no_best; diff --git a/src/input/identificationpwizreader.cpp b/src/input/identificationpwizreader.cpp index bfa3a3097e1d9357a1b82be22504b64314b2fbc9..78d69dacf58ed84777523945d6551b836324aa7f 100644 --- a/src/input/identificationpwizreader.cpp +++ b/src/input/identificationpwizreader.cpp @@ -239,28 +239,29 @@ void IdentificationPwizReader::read( //<cvParam accession="MS:1001331" cvRef="PSI-MS" value="24.275219" name="X!Tandem:hyperscore"/> // </SpectrumIdentificationItem> for ( pwiz::identdata::SpectrumIdentificationItemPtr spid_item : spectrum_ptr.get()->spectrumIdentificationItem) { - PeptideMatch * p_peptide_match = new PeptideMatch(_sp_msrun.get(), scan); - p_peptide_match->setRetentionTime(rt.toDouble()); - p_peptide_match->setCharge(spid_item->chargeState); + PeptideEvidence * p_peptide_evidence = new PeptideEvidence(_sp_msrun.get(), scan); + p_peptide_evidence->setRetentionTime(rt.toDouble()); + p_peptide_evidence->setCharge(spid_item->chargeState); pappso::pappso_double exp_mass = spid_item->experimentalMassToCharge * ((double) spid_item->chargeState) - (((double) spid_item->chargeState) * pappso::MHPLUS); - p_peptide_match->setExperimentalMass(exp_mass); - p_peptide_match->setIdentificationDataSource( p_identification_data_source); + p_peptide_evidence->setExperimentalMass(exp_mass); + p_peptide_evidence->setIdentificationDataSource( p_identification_data_source); - p_peptide_match->setChecked(true); + p_peptide_evidence->setChecked(true); QVariant evalue = getQVariantDoubleParam(spid_item.get(), pwiz::cv::MS_X_Tandem_expect); if (!evalue.isNull()) { - p_peptide_match->setEvalue(evalue.toDouble()); + p_peptide_evidence->setEvalue(evalue.toDouble()); } QVariant hyperscore = getQVariantDoubleParam(spid_item.get(), pwiz::cv::MS_X_Tandem_hyperscore); if (!hyperscore.isNull()) { - p_peptide_match->setParam(PeptideMatchParam::tandem_hyperscore, hyperscore); + p_peptide_evidence->setParam(PeptideMatchParam::tandem_hyperscore, hyperscore); } + for ( pwiz::identdata::PeptideEvidencePtr peptide_evidence_sp : spid_item.get()->peptideEvidencePtr) { - PeptideMatch * p_peptide_match_from_evidence = new PeptideMatch(*p_peptide_match); - p_peptide_match_from_evidence->setStart(peptide_evidence_sp.get()->start); + PeptideMatch peptide_match; + peptide_match.setStart(peptide_evidence_sp.get()->start); auto it_pep = map_id2peptide.find(QString::fromStdString(peptide_evidence_sp.get()->peptidePtr.get()->id)); @@ -270,7 +271,12 @@ void IdentificationPwizReader::read( .arg(QString::fromStdString(spid_item.get()->id)) ); } - p_peptide_match_from_evidence->setPeptideXtpSp(it_pep->second); + + + p_peptide_evidence->setPeptideXtpSp(it_pep->second); + PeptideEvidenceSp peptide_evidence_sp = p_identification_data_source->getPeptideEvidenceStore().getInstance(p_peptide_evidence); + + peptide_match.setPeptideEvidenceSp(peptide_evidence_sp); auto it = map_id2protein.find(QString::fromStdString(peptide_evidence_sp.get()->dbSequencePtr.get()->id)); if (it == map_id2protein.end()) { @@ -278,12 +284,10 @@ void IdentificationPwizReader::read( } ProteinMatch * protein_match_p = it->second; - protein_match_p->addPeptideMatchSp(p_peptide_match_from_evidence->getIdentificationDataSource()->getPeptideMatchStore().getInstance(p_peptide_match_from_evidence)); - - delete p_peptide_match_from_evidence; - //protein_match_p->addPeptideMatch(p_peptide_match_from_evidence); + protein_match_p->addPeptideMatch(peptide_match); } - delete p_peptide_match; + + delete p_peptide_evidence; } } } diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 9c580c9629effb049f9d4f13b2927c534ace4775..94fcd0345258253dbbdffa8377b32cbd46c25400 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -256,17 +256,17 @@ bool XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) { qDebug() << "startElement_peptide "; _current_peptide_sp = PeptideXtp(attributes.value("sequence").simplified()).makePeptideXtpSp(); MsRunSp ms_run_id = _p_project->getMsRunStore().getInstance(attributes.value("sample").simplified()); - _p_peptide_match = new PeptideMatch(ms_run_id.get(), attributes.value("scan").simplified().toUInt()); - _p_peptide_match->setRetentionTime(attributes.value("RT").simplified().toDouble()); - _p_peptide_match->setEvalue(attributes.value("evalue").simplified().toDouble()); + _p_peptide_evidence = new PeptideEvidence(ms_run_id.get(), attributes.value("scan").simplified().toUInt()); + _p_peptide_evidence->setRetentionTime(attributes.value("RT").simplified().toDouble()); + _p_peptide_evidence->setEvalue(attributes.value("evalue").simplified().toDouble()); pappso::pappso_double exp_mass = attributes.value("mhplus_obser").simplified().toDouble() - pappso::MHPLUS; - _p_peptide_match->setExperimentalMass(exp_mass); - _p_peptide_match->setStart(attributes.value("start").simplified().toUInt()-1); - _p_peptide_match->setCharge(attributes.value("charge").simplified().toUInt()); - _p_peptide_match->setParam(PeptideMatchParam::tandem_hyperscore, QVariant( attributes.value("hypercorr").toDouble())); + _p_peptide_evidence->setExperimentalMass(exp_mass); + _p_peptide_evidence->setStart(attributes.value("start").simplified().toUInt()-1); + _p_peptide_evidence->setCharge(attributes.value("charge").simplified().toUInt()); + _p_peptide_evidence->setParam(PeptideMatchParam::tandem_hyperscore, QVariant( attributes.value("hypercorr").toDouble())); IdentificationDataSource* p_identification_data_source = _p_project->getIdentificationDataSourceStore().getInstance(attributes.value("sample_file").simplified()).get(); - _p_peptide_match->setIdentificationDataSource( p_identification_data_source); + _p_peptide_evidence->setIdentificationDataSource( p_identification_data_source); if (p_identification_data_source->getMsRunSp().get() == nullptr) { p_identification_data_source->setMsRunSp(ms_run_id); } @@ -275,9 +275,9 @@ bool XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) { } _current_identification_group_p->addIdentificationDataSourceP(p_identification_data_source); p_identification_data_source->addFastaFile(_current_fasta_file_sp); - _p_peptide_match->setChecked(false); + _p_peptide_evidence->setChecked(false); if (attributes.value("validate").simplified().toLower() == "true") { - _p_peptide_match->setChecked(true); + _p_peptide_evidence->setChecked(true); } qDebug() << "startElement_peptide end" ; return true; diff --git a/src/input/xpipsaxhandler.h b/src/input/xpipsaxhandler.h index ebf326e7a0a76f66c1594eb4189ace41993506bd..29b75cf8738d9653ecc06c9a1c552c25f5d080aa 100644 --- a/src/input/xpipsaxhandler.h +++ b/src/input/xpipsaxhandler.h @@ -84,7 +84,7 @@ private: Project * _p_project; ProteinMatch * _p_protein_match; - PeptideMatch * _p_peptide_match; + PeptideEvidence * _p_peptide_evidence; ProteinXtp _current_protein; PeptideXtpSp _current_peptide_sp; IdentificationGroup * _current_identification_group_p; diff --git a/src/utils/peptideevidencestore.cpp b/src/utils/peptideevidencestore.cpp index 1de93d17124eb44d42a6db76ab282597805592a6..ad3110da70e086a616a99432b619e152e063d4fd 100644 --- a/src/utils/peptideevidencestore.cpp +++ b/src/utils/peptideevidencestore.cpp @@ -35,3 +35,12 @@ std::shared_ptr<PeptideEvidence> & PeptideEvidenceStore::getInstance(const PeptideEvidence * p_peptide_evidence) { } + +void PeptideEvidenceStore::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { + qDebug() << "PeptideEvidenceStore::updateAutomaticFilters begin" ; + for (PeptideEvidenceSp & peptide_evidence_sp:_peptide_evidence_list) { + peptide_evidence_sp.get()->updateAutomaticFilters(automatic_filter_parameters); + } + qDebug() << "PeptideEvidenceStore::updateAutomaticFilters end" ; + +} diff --git a/src/utils/peptideevidencestore.h b/src/utils/peptideevidencestore.h index 14727d03def2d7c807f3efba4ae10b202715cc5b..32d7895b3c5d4a6d2c845f60769bac6f8c4e8b41 100644 --- a/src/utils/peptideevidencestore.h +++ b/src/utils/peptideevidencestore.h @@ -32,6 +32,7 @@ #define PEPTIDEEVIDENCESTORE_H #include <memory> +#include "../core/automaticfilterparameters.h" class PeptideEvidence; @@ -39,6 +40,9 @@ class PeptideEvidenceStore { public: std::shared_ptr<PeptideEvidence> & getInstance(const PeptideEvidence * p_peptide_evidence); + void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); +private: + std::vector<std::shared_ptr<PeptideEvidence>> _peptide_evidence_list; }; #endif // PEPTIDEEVIDENCESTORE_H