From 26d3343c191f67087414a8392ce018acd237ffc7 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 23 Mar 2017 22:28:01 +0100 Subject: [PATCH] protein store and peptide store inside the project, contaminant groups removed --- src/CMakeLists.txt | 4 ++-- src/core/project.cpp | 10 +++++++++- src/core/project.h | 9 ++++++++- src/core/proteinmatch.cpp | 8 +++++++- src/core/proteinxtp.cpp | 4 ++-- src/core/proteinxtp.h | 4 ++-- src/grouping/groupingexperiment.h | 1 + src/grouping/groupingpeptidemass.cpp | 4 ++++ src/grouping/groupingpeptidemass.h | 2 ++ src/input/xpipsaxhandler.cpp | 8 ++++++-- src/input/xpipsaxhandler.h | 2 -- src/utils/proteinstore.cpp | 10 +++++++--- src/utils/proteinstore.h | 1 + 13 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ddba1dee..d0ea825a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,8 +29,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 #sudo apt-get install libpappsomspp-dev #FIND_PACKAGE( Pappsomspp REQUIRED ) -# SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") - SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") + SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") +# SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so") diff --git a/src/core/project.cpp b/src/core/project.cpp index f4a69901d..b5b3940dc 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -39,6 +39,14 @@ Project::~Project() } } +PeptideStore & Project::getPeptideStore() { + return _peptide_store; +} + +ProteinStore & Project::getProteinStore() { + return _protein_store; +} + void Project::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { _automatic_filter_parameters = automatic_filter_parameters; for (auto & p_id_group : _identification_goup_list) { @@ -91,7 +99,7 @@ IdentificationGroup* Project::getCurrentIdentificationGroupP() const { void Project::startGrouping() { - for (auto & p_id_group : _identification_goup_list) { + for (auto & p_id_group : _identification_goup_list) { p_id_group->startGrouping(_grouping_type); } diff --git a/src/core/project.h b/src/core/project.h index 5992dbf88..2e98fc3cf 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -26,7 +26,9 @@ #include<memory> #include "identificationgroup.h" #include "automaticfilterparameters.h" -#include "utils/types.h" +#include "../utils/types.h" +#include "../utils/peptidestore.h" +#include "../utils/proteinstore.h" class Project; typedef std::shared_ptr<Project> ProjectSp; @@ -41,6 +43,8 @@ public: ~Project(); ProjectSp makeProjectSp() const; + ProteinStore & getProteinStore(); + PeptideStore & getPeptideStore(); void readXpipFile(QFileInfo xpip_source); IdentificationGroup* newIdentificationGroup(); IdentificationGroup* getCurrentIdentificationGroupP() const; @@ -58,6 +62,9 @@ private : AutomaticFilterParameters _automatic_filter_parameters; GroupingType _grouping_type = GroupingType::PeptideMass; + + ProteinStore _protein_store; + PeptideStore _peptide_store; }; #endif // PROJECT_H diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index b03473c2a..e750622d0 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -116,13 +116,19 @@ void ProteinMatch::setGroupingExperiment(GroupingExperiment * p_grp_experiment) _sp_grp_protein = nullptr; if (isValidAndChecked()) { _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)); } } + + + if (_protein_sp.get()->isContaminant()) { + p_grp_experiment->addPostGroupingGrpProteinSpRemoval(_sp_grp_protein); + } + } } diff --git a/src/core/proteinxtp.cpp b/src/core/proteinxtp.cpp index 32cb090ad..ed3226324 100644 --- a/src/core/proteinxtp.cpp +++ b/src/core/proteinxtp.cpp @@ -55,9 +55,9 @@ ProteinXtpSp ProteinXtp::makeProteinXtpSp() const { void ProteinXtp::setIsDecoy(bool conta){ _is_decoy = conta; } - bool ProteinXtp::getIsContaminant() const{ + bool ProteinXtp::isContaminant() const{ return _is_contaminant; } - bool ProteinXtp::getIsDecoy() const{ + bool ProteinXtp::isDecoy() const{ return _is_decoy; } diff --git a/src/core/proteinxtp.h b/src/core/proteinxtp.h index 935dc282c..764266d3e 100644 --- a/src/core/proteinxtp.h +++ b/src/core/proteinxtp.h @@ -46,8 +46,8 @@ public: void setIsContaminant(bool conta); void setIsDecoy(bool conta); - bool getIsContaminant() const; - bool getIsDecoy() const; + bool isContaminant() const; + bool isDecoy() const; private: SequenceDatabase * _p_sequence_database; diff --git a/src/grouping/groupingexperiment.h b/src/grouping/groupingexperiment.h index e05d9e0f1..af56449df 100644 --- a/src/grouping/groupingexperiment.h +++ b/src/grouping/groupingexperiment.h @@ -41,6 +41,7 @@ public: virtual pappso::GrpProteinSp & getGrpProteinSp(ProteinMatch* p_protein_match) = 0; virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideMatch* p_peptide_match) = 0; + virtual void addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) = 0; virtual void startGrouping()= 0; }; diff --git a/src/grouping/groupingpeptidemass.cpp b/src/grouping/groupingpeptidemass.cpp index 7dc382e8c..8368af9d7 100644 --- a/src/grouping/groupingpeptidemass.cpp +++ b/src/grouping/groupingpeptidemass.cpp @@ -50,3 +50,7 @@ pappso::GrpPeptideSp & GroupingPeptideMass::setGrpPeptide(pappso::GrpProteinSp p void GroupingPeptideMass::startGrouping() { _p_grp_experiment->startGrouping(); } + +void GroupingPeptideMass::addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) { + _p_grp_experiment->addPostGroupingGrpProteinSpRemoval(sp_protein); +} diff --git a/src/grouping/groupingpeptidemass.h b/src/grouping/groupingpeptidemass.h index 2d585026c..2391bba35 100644 --- a/src/grouping/groupingpeptidemass.h +++ b/src/grouping/groupingpeptidemass.h @@ -34,6 +34,8 @@ public: virtual pappso::GrpProteinSp & getGrpProteinSp(ProteinMatch* p_protein_match) override; virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideMatch* p_peptide_match) override; + virtual void addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) override; + virtual void startGrouping() override; protected : diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 719ebbd8e..921d4262a 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -24,6 +24,8 @@ #include <pappsomspp/msrun/msrunid.h> #include <pappsomspp/exception/exceptionnotfound.h> #include <cmath> +#include "../utils/peptidestore.h" +#include "../utils/proteinstore.h" XpipSaxHandler::XpipSaxHandler(Project * p_project):_p_project(p_project) { @@ -277,7 +279,7 @@ bool XpipSaxHandler::endElement_peptide() { qDebug() << "endElement_peptide "; pappso::PeptideSp peptide_const = pappso::Peptide(*(_current_peptide_sp.get())).makePeptideSp(); - peptide_const = _peptide_store.getInstance(peptide_const); + peptide_const = _p_project->getPeptideStore().getInstance(peptide_const); _p_peptide_match->setPeptideSp(peptide_const); return true; } @@ -292,7 +294,9 @@ bool XpipSaxHandler::endElement_sequence() { return true; } bool XpipSaxHandler::endElement_protein() { - _p_protein_match->setProteinXtpSp(_current_protein.makeProteinXtpSp()); + ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp(); + + _p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein)); return true; } diff --git a/src/input/xpipsaxhandler.h b/src/input/xpipsaxhandler.h index 804a40c61..063d13d04 100644 --- a/src/input/xpipsaxhandler.h +++ b/src/input/xpipsaxhandler.h @@ -30,7 +30,6 @@ #include <pappsomspp/amino_acid/aamodification.h> #include "../core/project.h" #include "../core/proteinmatch.h" -#include "../utils/peptidestore.h" class XpipSaxHandler: public QXmlDefaultHandler { @@ -87,7 +86,6 @@ private: pappso::NoConstPeptideSp _current_peptide_sp; IdentificationGroup * _current_identification_group_p; - PeptideStore _peptide_store; QMap<QString, pappso::AaModificationP> _map_massstr_aamod; QMap<QString, pappso::MsRunIdSp> _map_msrunid; }; diff --git a/src/utils/proteinstore.cpp b/src/utils/proteinstore.cpp index d4d11d8ac..acb0a8763 100644 --- a/src/utils/proteinstore.cpp +++ b/src/utils/proteinstore.cpp @@ -28,13 +28,14 @@ ******************************************************************************/ #include "proteinstore.h" +#include <QDebug> ProteinStore::ProteinStore() { -_regexp_contaminant.setPattern("([KR])([^P])"); + _regexp_contaminant.setPattern("^conta\\|"); -_regexp_decoy.setPattern(".*\\|reversed$"); + _regexp_decoy.setPattern(".*\\|reversed$"); } ProteinStore::~ProteinStore() @@ -45,7 +46,7 @@ ProteinStore::~ProteinStore() ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & peptide_in) { std::pair<std::map< QString, ProteinXtpSp>::iterator,bool> ret = _map_accession_protein_list.insert(std::pair<QString, ProteinXtpSp>(peptide_in.get()->getAccession(),peptide_in)); - + if (ret.second) { setProteinInformations(ret.first->second); } @@ -54,11 +55,14 @@ ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & peptide_in) { } void ProteinStore::setProteinInformations(ProteinXtpSp & peptide_in) { + qDebug() << "ProteinStore::setProteinInformations begin"; QString accession = peptide_in.get()->getAccession(); if (_regexp_contaminant.indexIn(accession, 0)>-1) { + qDebug() << "ProteinStore::setProteinInformations is contaminant " << accession; peptide_in.get()->setIsContaminant(true); } if (_regexp_decoy.indexIn(accession, 0)>-1) { peptide_in.get()->setIsDecoy(true); } + qDebug() << "ProteinStore::setProteinInformations end"; } diff --git a/src/utils/proteinstore.h b/src/utils/proteinstore.h index fb09cdf6d..14d7f1945 100644 --- a/src/utils/proteinstore.h +++ b/src/utils/proteinstore.h @@ -39,6 +39,7 @@ class ProteinStore { +public: ProteinStore(); ~ProteinStore(); -- GitLab