From 1b4de1825504c1e8cc9b9ba1c7e2538fe1f5a2a4 Mon Sep 17 00:00:00 2001 From: Olivier Langella <olivier.langella@u-psud.fr> Date: Fri, 12 Jan 2018 22:45:51 +0100 Subject: [PATCH] draw xic with all MSMS events --- src/CMakeLists.txt | 4 ++-- src/core/identificationgroup.cpp | 9 +++++++++ src/core/identificationgroup.h | 8 ++++++++ src/core/project.cpp | 6 ++++++ src/core/project.h | 18 ++++++++++++------ src/gui/xic_view/xic_box/xic_box.ui | 15 ++++++++++++++- src/gui/xic_view/xic_box/xicbox.cpp | 12 +++++++++++- src/gui/xic_view/xic_box/xicbox.h | 1 + src/gui/xic_view/xic_window.ui | 17 ++++++++++++++++- src/gui/xic_view/xicwindow.cpp | 6 ++++-- src/gui/xic_view/xicwindow.h | 2 +- src/utils/peptideevidencestore.cpp | 10 ++++++++++ src/utils/peptideevidencestore.h | 9 +++++++++ src/utils/readspectrum.cpp | 1 + 14 files changed, 104 insertions(+), 14 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 159b03b3f..71bd578d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,8 +28,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_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt5.so") SET (PAPPSOMSPP_WIDGET_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/pappsomspp/widget/libpappsomspp-widget-qt5.so") diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index dd7ec45b7..267c9e895 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -320,3 +320,12 @@ pappso::pappso_double IdentificationGroup::getProteinFdr(ValidationState state) return (false_prot/total_prot); } + +void IdentificationGroup::getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const { + if (!contains(p_peptide_evidence->getMsRunP())) return; + for (const IdentificationDataSource * p_identification_source:_id_source_list) { + if (p_peptide_evidence->getMsRunP() == p_identification_source->getMsRunSp().get()) { + p_identification_source->getPeptideEvidenceStore().getSameXicPeptideEvidenceList(p_peptide_evidence, peptide_evidence_list); + } + } +} diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index 0469f961e..ea4ade657 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.h @@ -132,6 +132,14 @@ public: * each peptide evidence is only counted once */ void collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const; + + + /** @brief look for a peptide in the same XIC + * @param p_peptide_evidence the peptide to look for + * @param peptide_evidence_list the peptide evidence list to build + */ + void getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const; + private : void addMsRunSp(MsRunSp ms_run_sp); diff --git a/src/core/project.cpp b/src/core/project.cpp index 937fec4e5..1bd84997c 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -200,3 +200,9 @@ bool Project::hasPtmExperiment() const { if (getIdentificationGroupList().at(0)->getPtmGroupingExperiment() != nullptr) return true; return false; } + +void Project::getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const { + for (const IdentificationGroup * p_ident_group: _identification_goup_list) { + p_ident_group->getSameXicPeptideEvidenceList(p_peptide_evidence, peptide_evidence_list); + } +} diff --git a/src/core/project.h b/src/core/project.h index c4e762931..b21d48385 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -72,21 +72,27 @@ public: std::vector<IdentificationGroup *> getIdentificationGroupList(); const std::vector<IdentificationGroup *> getIdentificationGroupList() const; void readResultFile(QString filename); - + /** @brief check that modifications are coded with PSI MOD accessions */ bool checkPsimodCompliance() const; - + /** @brief apply labeling method to all peptide match * */ void setLabelingMethodSp(LabelingMethodSp labeling_method_sp); - + /** @brief get labeling method shared pointer * */ LabelingMethodSp getLabelingMethodSp() const; - + bool hasPtmExperiment() const; - + + /** @brief look for a peptide in the same XIC + * @param p_peptide_evidence the peptide to look for + * @param peptide_evidence_list the peptide evidence list to build + */ + void getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const; + private : LabelingMethodSp _labeling_method_sp; ProjectMode _project_mode = ProjectMode::combined; @@ -102,7 +108,7 @@ private : IdentificationDataSourceStore _identification_data_source_store; MsRunStore _msrun_store; FastaFileStore _fasta_file_store; - + }; #endif // PROJECT_H diff --git a/src/gui/xic_view/xic_box/xic_box.ui b/src/gui/xic_view/xic_box/xic_box.ui index f6a62be40..b7e5d597b 100644 --- a/src/gui/xic_view/xic_box/xic_box.ui +++ b/src/gui/xic_view/xic_box/xic_box.ui @@ -18,6 +18,12 @@ <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QLabel" name="peptide_label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> <string>TextLabel</string> </property> @@ -28,7 +34,14 @@ <item> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="pappso::XicWidget" name="xic_widget" native="true"/> + <widget class="pappso::XicWidget" name="xic_widget" native="true"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>150</height> + </size> + </property> + </widget> </item> </layout> </item> diff --git a/src/gui/xic_view/xic_box/xicbox.cpp b/src/gui/xic_view/xic_box/xicbox.cpp index 169eef1e8..92bae7c23 100644 --- a/src/gui/xic_view/xic_box/xicbox.cpp +++ b/src/gui/xic_view/xic_box/xicbox.cpp @@ -31,6 +31,7 @@ #include <QMessageBox> #include <pappsomspp/pappsoexception.h> #include "../xicworkerthread.h" +#include "../../project_view/projectwindow.h" XicBox::XicBox(XicWindow *parent): QWidget(parent), @@ -73,6 +74,11 @@ void XicBox::setPeptideEvidence(const PeptideEvidence * p_peptide_evidence) { _p_peptide_evidence = p_peptide_evidence; ui->peptide_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->toString()); + //get same xic peptide evidence (msrun, peptide, charge) + //p_projet + _peptide_evidence_list.clear(); + _p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(p_peptide_evidence, _peptide_evidence_list); + emit loadXic(_p_peptide_evidence->getMsRunP(), _p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge()), _p_xic_window->getXicExtractPrecision(), XicExtractMethod::max); } @@ -81,7 +87,11 @@ void XicBox::setPeptideEvidence(const PeptideEvidence * p_peptide_evidence) { void XicBox::setXic(pappso::XicSp xic_sp) { qDebug() << "XicBox::setXic begin"; ui->xic_widget->setXicSp(xic_sp); + for (const PeptideEvidence * peptide_evidence:_peptide_evidence_list) { + ui->xic_widget->addMsMsEvent(peptide_evidence->getRetentionTime()); + } + ui->xic_widget->rescale(); ui->xic_widget->plot(); qDebug() << "XicBox::setXic end"; - + } diff --git a/src/gui/xic_view/xic_box/xicbox.h b/src/gui/xic_view/xic_box/xicbox.h index 4ad6e9162..b28336fc2 100644 --- a/src/gui/xic_view/xic_box/xicbox.h +++ b/src/gui/xic_view/xic_box/xicbox.h @@ -59,6 +59,7 @@ private: QThread _xic_thread; XicWindow * _p_xic_window; const PeptideEvidence * _p_peptide_evidence; + std::vector<const PeptideEvidence *> _peptide_evidence_list; }; diff --git a/src/gui/xic_view/xic_window.ui b/src/gui/xic_view/xic_window.ui index fa9b6cb85..87a851d17 100644 --- a/src/gui/xic_view/xic_window.ui +++ b/src/gui/xic_view/xic_window.ui @@ -16,7 +16,22 @@ <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <layout class="QVBoxLayout" name="xic_vertical_layout"/> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="xic_vertical_layout"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>780</width> + <height>530</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"/> + </widget> + </widget> </item> </layout> </widget> diff --git a/src/gui/xic_view/xicwindow.cpp b/src/gui/xic_view/xicwindow.cpp index 56118dbd4..c7af95449 100644 --- a/src/gui/xic_view/xicwindow.cpp +++ b/src/gui/xic_view/xicwindow.cpp @@ -55,11 +55,13 @@ XicWindow::~XicWindow() { qDebug() << "XicWindow::~XicWindow"; } - +ProjectWindow * XicWindow::getProjectWindow() { + return _project_window; +} void XicWindow::addXic(const PeptideEvidence * p_peptide_evidence) { XicBox * p_box = new XicBox(this); p_box->setPeptideEvidence(p_peptide_evidence); - ui->xic_vertical_layout->addWidget(p_box); + ui->xic_vertical_layout->layout()->addWidget(p_box); } pappso::PrecisionP XicWindow::getXicExtractPrecision() const { diff --git a/src/gui/xic_view/xicwindow.h b/src/gui/xic_view/xicwindow.h index b6462314a..d48531dc2 100644 --- a/src/gui/xic_view/xicwindow.h +++ b/src/gui/xic_view/xicwindow.h @@ -56,7 +56,7 @@ public: pappso::PrecisionP getXicExtractPrecision() const; protected: - + ProjectWindow * getProjectWindow(); private: ProjectWindow * _project_window; Ui::XicWindow *ui; diff --git a/src/utils/peptideevidencestore.cpp b/src/utils/peptideevidencestore.cpp index e002f542a..28b2928f6 100644 --- a/src/utils/peptideevidencestore.cpp +++ b/src/utils/peptideevidencestore.cpp @@ -93,3 +93,13 @@ void PeptideEvidenceStore::updateAutomaticFilters(const AutomaticFilterParameter const std::vector<std::shared_ptr<PeptideEvidence>> & PeptideEvidenceStore::getPeptideEvidenceList() const { return _peptide_evidence_list; } + + +void PeptideEvidenceStore::getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const { + for (const PeptideEvidenceSp & peptide_evidence_sp:_peptide_evidence_list) { + if (p_peptide_evidence->getMsRunP() != peptide_evidence_sp.get()->getMsRunP()) continue; + if (p_peptide_evidence->getPeptideXtpSp().get() != peptide_evidence_sp.get()->getPeptideXtpSp().get()) continue; + if (p_peptide_evidence->getCharge() != peptide_evidence_sp.get()->getCharge()) continue; + peptide_evidence_list.push_back(peptide_evidence_sp.get()); + } +} diff --git a/src/utils/peptideevidencestore.h b/src/utils/peptideevidencestore.h index 755ec66ea..c1d4ff894 100644 --- a/src/utils/peptideevidencestore.h +++ b/src/utils/peptideevidencestore.h @@ -52,6 +52,15 @@ public: const std::vector<std::shared_ptr<PeptideEvidence>> & getPeptideEvidenceList() const; std::size_t size() const; void clearMap(); + + + + /** @brief look for a peptide in the same XIC + * @param p_peptide_evidence the peptide to look for + * @param peptide_evidence_list the peptide evidence list to build + */ + void getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const; + private: std::vector<std::shared_ptr<PeptideEvidence>> _peptide_evidence_list; diff --git a/src/utils/readspectrum.cpp b/src/utils/readspectrum.cpp index 50f208feb..051cf3c39 100644 --- a/src/utils/readspectrum.cpp +++ b/src/utils/readspectrum.cpp @@ -127,6 +127,7 @@ void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso: } + p_xic->sortByRetentionTime(); -- GitLab