diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f7b3c632b36c8949a3571f54b758ee2df8f06fe3..7a1be53fac2af067b3de8160977edb59680069c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,6 +106,7 @@ SET(CPP_FILES utils/identificationdatasourcestore.cpp utils/groupstore.cpp utils/msrunstore.cpp + utils/peptidematchstore.cpp utils/peptidestore.cpp utils/proteinstore.cpp utils/readspectrum.cpp diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp index ca74c0739bee724cf453c92354e21e73c093834c..d300871d28df34d0eb05990bae4e3ecf099a790f 100644 --- a/src/core/identification_sources/identificationdatasource.cpp +++ b/src/core/identification_sources/identificationdatasource.cpp @@ -27,7 +27,6 @@ #include <QFileInfo> #include "../../utils/readspectrum.h" - IdentificationDataSource::IdentificationDataSource(const QString resource_name) { _resource_name = resource_name; @@ -45,6 +44,10 @@ IdentificationDataSource::~IdentificationDataSource() } +PeptideMatchStore & IdentificationDataSource::getPeptideMatchStore() { + return _peptide_match_store; +} + void IdentificationDataSource::setXmlId(const QString xmlid) { _xml_id = xmlid; } diff --git a/src/core/identification_sources/identificationdatasource.h b/src/core/identification_sources/identificationdatasource.h index 7d23ac48213a1debe546e1840df116c31e611d62..de98f146b9960ebb3801bbf7ca5efca1ee0aee6b 100644 --- a/src/core/identification_sources/identificationdatasource.h +++ b/src/core/identification_sources/identificationdatasource.h @@ -29,12 +29,14 @@ #include <QVariant> #include "../msrun.h" #include "../../utils/fastafilestore.h" +#include "../../utils/peptidematchstore.h" class Project; class IdentificationDataSource; typedef std::shared_ptr<IdentificationDataSource> IdentificationDataSourceSp; + class IdentificationDataSource { public: @@ -44,6 +46,7 @@ public: ~IdentificationDataSource(); bool operator==(const IdentificationDataSource& other) const; + PeptideMatchStore & getPeptideMatchStore(); void setXmlId(const QString xmlid); const QString & getXmlId() const; @@ -118,6 +121,8 @@ private : std::map<IdentificationEngineParam, QVariant> _params; std::map<IdentificationEngineStatistics, QVariant> _param_stats; std::vector<FastaFileSp> _fastafile_list; + + PeptideMatchStore _peptide_match_store; }; #endif // IDENTIFICATIONDATASOURCE_H diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp index 4e51d36a7c560f49d4c584444ce8dfe00ec37ab5..ad0938af0b99b32021fc746d6546510836caf011 100644 --- a/src/core/peptidematch.cpp +++ b/src/core/peptidematch.cpp @@ -49,6 +49,10 @@ PeptideMatch::PeptideMatch(const PeptideMatch & other): PeptideMatch(other._msru } +PeptideMatchSp PeptideMatch::makePeptideMatchSp() const { + return std::make_shared<PeptideMatch>(*this); +} + void PeptideMatch::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { _proxy_valid = false; diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h index 2ae750d44ff530449f2b2e01d9ffda6b42a01c5a..2f28bfe01659eb88122fe2077126c64f3236bb20 100644 --- a/src/core/peptidematch.h +++ b/src/core/peptidematch.h @@ -45,6 +45,8 @@ public : std::size_t getHashSampleScan() const; std::size_t getHashPeptideMassSample() const; + PeptideMatchSp makePeptideMatchSp() const; + void setRetentionTime(pappso::pappso_double rt); void setEvalue(pappso::pappso_double evalue); @@ -72,7 +74,7 @@ public : /** \brief get specific parameter value */ virtual const QVariant getParam(PeptideMatchParam param) const; - + const std::map<PeptideMatchParam, QVariant> & getParamList() const; @@ -118,7 +120,7 @@ public : pappso::mz getDeltaMass() const; ValidationState getValidationState() const; - + /** @brief tells if this peptide contains a protein position * the position is the amino acid position on the protein sequence (starts from 0) * */ diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index 4400d062cbe658b44b5e7e901756bff3e061e6b9..37795b3f75c9c79644ff626689f9ea716533f076 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -39,12 +39,8 @@ ProteinMatch::ProteinMatch() ProteinMatch::~ProteinMatch() { - auto it = _peptide_match_list.begin(); - while (it != _peptide_match_list.end()) { - delete (*it); - it++; - } } + ValidationState ProteinMatch::getValidationState() const { if (isGrouped()) { return ValidationState::grouped; @@ -141,8 +137,8 @@ bool ProteinMatch::isGrouped() const { void ProteinMatch::setChecked(bool arg1) { _checked = arg1; } -void ProteinMatch::addPeptideMatch(PeptideMatch * peptide_match) { - _peptide_match_list.push_back(peptide_match); +void ProteinMatch::addPeptideMatchSp(PeptideMatchSp peptide_match) { + _peptide_match_list.push_back(peptide_match.get()); } diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index 01717dd4e013c56c6d5f081847d759acc28ef870..e4d0c66065d289ef68f1ac2aba57858097a6724e 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.h @@ -74,7 +74,7 @@ public: pappso::pappso_double getEmPAI(const MsRun * sp_msrun_id = nullptr) const; void setProteinXtpSp(ProteinXtpSp protein_sp); - void addPeptideMatch(PeptideMatch * peptide_match); + void addPeptideMatchSp(PeptideMatchSp peptide_match); std::vector<PeptideMatch *> & getPeptideMatchList(); const std::vector<PeptideMatch *> & getPeptideMatchList() const; diff --git a/src/input/identificationpwizreader.cpp b/src/input/identificationpwizreader.cpp index 3f271316bc38362689ea65a733862d202b96c685..bfa3a3097e1d9357a1b82be22504b64314b2fbc9 100644 --- a/src/input/identificationpwizreader.cpp +++ b/src/input/identificationpwizreader.cpp @@ -278,7 +278,10 @@ void IdentificationPwizReader::read( } ProteinMatch * protein_match_p = it->second; - protein_match_p->addPeptideMatch(p_peptide_match_from_evidence); + 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); } delete p_peptide_match; } diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index a5b4cd840173ef5d57b0118d37d8480b8be81c8b..9c580c9629effb049f9d4f13b2927c534ace4775 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -279,7 +279,6 @@ bool XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) { if (attributes.value("validate").simplified().toLower() == "true") { _p_peptide_match->setChecked(true); } - _p_protein_match->addPeptideMatch(_p_peptide_match); qDebug() << "startElement_peptide end" ; return true; } @@ -296,10 +295,11 @@ bool XpipSaxHandler::startElement_modif(QXmlAttributes attributes) { } bool XpipSaxHandler::endElement_peptide() { qDebug() << "endElement_peptide "; - PeptideXtpSp peptide_const = PeptideXtp(*(_current_peptide_sp.get())).makePeptideXtpSp(); peptide_const = _p_project->getPeptideStore().getInstance(peptide_const); _p_peptide_match->setPeptideXtpSp(peptide_const); + _p_protein_match->addPeptideMatchSp(_p_peptide_match->getIdentificationDataSource()->getPeptideMatchStore().getInstance(_p_peptide_match)); + delete _p_peptide_match; return true; } diff --git a/src/input/xtandemsaxhandler.cpp b/src/input/xtandemsaxhandler.cpp index 396dba1588aa10afe68a249aedb3687e2a87bf31..d1cdd2fcd10dceeb85223a9e513701313864bdd1 100644 --- a/src/input/xtandemsaxhandler.cpp +++ b/src/input/xtandemsaxhandler.cpp @@ -303,7 +303,6 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) { _p_peptide_match->setIdentificationDataSource( _p_identification_data_source); _p_peptide_match->setChecked(true); - _p_protein_match->addPeptideMatch(_p_peptide_match); @@ -331,6 +330,11 @@ bool XtandemSaxHandler::endElement_domain() { _current_peptide_sp = _p_project->getPeptideStore().getInstance(_current_peptide_sp); _p_peptide_match->setPeptideXtpSp(_current_peptide_sp); + + + _p_protein_match->addPeptideMatchSp(_p_peptide_match->getIdentificationDataSource()->getPeptideMatchStore().getInstance(_p_peptide_match)); + + delete _p_peptide_match; return is_ok; } bool XtandemSaxHandler::endElement_note() { diff --git a/src/utils/peptidematchstore.cpp b/src/utils/peptidematchstore.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2fbef9d23db3c0af8acd1d69ada99f871fe7c2e --- /dev/null +++ b/src/utils/peptidematchstore.cpp @@ -0,0 +1,36 @@ +/** + * \file utils/peptidematchstore.cpp + * \date 18/11/2017 + * \author Olivier Langella + * \brief store unique instances of peptide match + */ + + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and implementation +******************************************************************************/ + +#include "peptidematchstore.h" + +#include "../core/peptidematch.h" + +std::shared_ptr<PeptideMatch> & PeptideMatchStore::getInstance(const PeptideMatch * p_peptide_match) { +} diff --git a/src/utils/peptidematchstore.h b/src/utils/peptidematchstore.h new file mode 100644 index 0000000000000000000000000000000000000000..912f17382144844351dfd6b709a3e771d31c200b --- /dev/null +++ b/src/utils/peptidematchstore.h @@ -0,0 +1,44 @@ +/** + * \file utils/peptidematchstore.h + * \date 18/11/2017 + * \author Olivier Langella + * \brief store unique instances of peptide match + */ + + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and implementation +******************************************************************************/ + +#ifndef PEPTIDEMATCHSTORE_H +#define PEPTIDEMATCHSTORE_H + +#include <memory> + +class PeptideMatch; + +class PeptideMatchStore +{ +public: + std::shared_ptr<PeptideMatch> & getInstance(const PeptideMatch * p_peptide_match); +}; + +#endif // PEPTIDEMATCHSTORE_H