From 54235386e35183a2ba324310ee9d44c876c58dad Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 23 Mar 2017 17:15:11 +0100 Subject: [PATCH] wip : protein store --- src/CMakeLists.txt | 1 + src/core/identificationgroup.cpp | 3 +++ src/core/proteinxtp.cpp | 13 +++++++++++++ src/core/proteinxtp.h | 7 ++++++- src/utils/proteinstore.cpp | 23 +++++++++++++++++++++-- src/utils/proteinstore.h | 11 +++++++++-- 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 62d5f18a2..9ddba1dee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -67,6 +67,7 @@ SET(CPP_FILES grouping/groupingpeptidemass.cpp input/xpipsaxhandler.cpp utils/peptidestore.cpp + utils/proteinstore.cpp utils/readspectrum.cpp ) diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index a6ac7bec6..c3ed62534 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -88,4 +88,7 @@ void IdentificationGroup::startGrouping (const GroupingType & grouping_type) { } _p_grp_experiment->startGrouping(); + + //remove contaminant groups + // renumbering } diff --git a/src/core/proteinxtp.cpp b/src/core/proteinxtp.cpp index 6e6121684..32cb090ad 100644 --- a/src/core/proteinxtp.cpp +++ b/src/core/proteinxtp.cpp @@ -48,3 +48,16 @@ ProteinXtpSp ProteinXtp::makeProteinXtpSp() const { return std::make_shared<ProteinXtp>(*this); } + + void ProteinXtp::setIsContaminant(bool conta) { + _is_contaminant = conta; + } + void ProteinXtp::setIsDecoy(bool conta){ + _is_decoy = conta; + } + bool ProteinXtp::getIsContaminant() const{ + return _is_contaminant; + } + bool ProteinXtp::getIsDecoy() const{ + return _is_decoy; + } diff --git a/src/core/proteinxtp.h b/src/core/proteinxtp.h index 0ce23be27..935dc282c 100644 --- a/src/core/proteinxtp.h +++ b/src/core/proteinxtp.h @@ -32,7 +32,7 @@ class ProteinXtp; /** \brief shared pointer on a Protein object */ -typedef std::shared_ptr<const ProteinXtp> ProteinXtpSp; +typedef std::shared_ptr<ProteinXtp> ProteinXtpSp; class ProteinXtp : public pappso::Protein { public: @@ -43,6 +43,11 @@ public: ProteinXtpSp makeProteinXtpSp() const; + + void setIsContaminant(bool conta); + void setIsDecoy(bool conta); + bool getIsContaminant() const; + bool getIsDecoy() const; private: SequenceDatabase * _p_sequence_database; diff --git a/src/utils/proteinstore.cpp b/src/utils/proteinstore.cpp index 2479cfc0d..d4d11d8ac 100644 --- a/src/utils/proteinstore.cpp +++ b/src/utils/proteinstore.cpp @@ -30,16 +30,35 @@ #include "proteinstore.h" +ProteinStore::ProteinStore() +{ +_regexp_contaminant.setPattern("([KR])([^P])"); + +_regexp_decoy.setPattern(".*\\|reversed$"); +} + +ProteinStore::~ProteinStore() +{ + +} + ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & peptide_in) { - std::pair<std::unordered_map< QString, ProteinXtpSp>::iterator,bool> ret = _map_accession_protein_list.insert(std::pair<QString, ProteinXtpSp>(peptide_in.get()->getAccession(),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); } - return ret.first->second; + return (ret.first->second); } void ProteinStore::setProteinInformations(ProteinXtpSp & peptide_in) { + QString accession = peptide_in.get()->getAccession(); + if (_regexp_contaminant.indexIn(accession, 0)>-1) { + peptide_in.get()->setIsContaminant(true); + } + if (_regexp_decoy.indexIn(accession, 0)>-1) { + peptide_in.get()->setIsDecoy(true); + } } diff --git a/src/utils/proteinstore.h b/src/utils/proteinstore.h index 081986aa0..fb09cdf6d 100644 --- a/src/utils/proteinstore.h +++ b/src/utils/proteinstore.h @@ -34,10 +34,13 @@ #include "../core/proteinxtp.h" #include <QString> -#include <unordered_map> +#include <QRegExp> +#include <map> class ProteinStore { + ProteinStore(); + ~ProteinStore(); ProteinXtpSp & getInstance(ProteinXtpSp & protein_in); @@ -45,7 +48,11 @@ private : void setProteinInformations(ProteinXtpSp & protein_in); private : - std::unordered_map<QString, ProteinXtpSp> _map_accession_protein_list; + std::map<QString, ProteinXtpSp> _map_accession_protein_list; + /** \brief recognize decoy accession */ + QRegExp _regexp_decoy; + /** \brief recognize contaminant accession */ + QRegExp _regexp_contaminant; }; -- GitLab