From 863d97f18802f3796ab485fbb6f34b5f5bbb02aa Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Sat, 29 Apr 2017 16:12:01 +0200 Subject: [PATCH] replacing X amino acid by nothing to compute mass and valid tryptic peptide number --- src/CMakeLists.txt | 8 ++++---- src/core/proteinmatch.cpp | 7 +++++++ src/core/proteinxtp.cpp | 19 ++++++++++++++++--- src/output/ods/proteinsheet.cpp | 11 ++++++++++- src/output/ods/spectrasheet.cpp | 10 +++++----- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c08b83a5..a16ae686 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,11 +27,11 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 #sudo apt-get install libpappsomspp-dev -FIND_PACKAGE( Pappsomspp REQUIRED ) +#FIND_PACKAGE( Pappsomspp REQUIRED ) # 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") + 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") set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules) diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index f0c4cdd8..a03347af 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -23,6 +23,7 @@ #include "proteinmatch.h" #include <pappsomspp/grouping/grpprotein.h> +#include <pappsomspp/pappsoexception.h> #include <set> #include <cmath> @@ -308,8 +309,14 @@ pappso::pappso_double ProteinMatch::getEvalue(const MsRun * sp_msrun_id) const { } pappso::pappso_double ProteinMatch::getPAI(const MsRun * sp_msrun_id) const { + try { pappso::pappso_double PAI = (pappso::pappso_double) countPeptideMassCharge(ValidationState::validAndChecked ,sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->countTrypticPeptidesForPAI(); return PAI; + + } + catch (pappso::PappsoException error) { + throw pappso::PappsoException(QObject::tr("Error computing PAI for protein %1 :\n%2").arg(this->getProteinXtpSp().get()->getAccession()).arg(error.qwhat())); + } } pappso::pappso_double ProteinMatch::getEmPAI(const MsRun * sp_msrun_id) const { diff --git a/src/core/proteinxtp.cpp b/src/core/proteinxtp.cpp index 0b593577..3f468ea4 100644 --- a/src/core/proteinxtp.cpp +++ b/src/core/proteinxtp.cpp @@ -23,6 +23,7 @@ #include "proteinxtp.h" #include <pappsomspp/protein/enzyme.h> +#include <pappsomspp/pappsoexception.h> ProteinXtp::ProteinXtp():pappso::Protein() { @@ -74,8 +75,14 @@ QString ProteinXtp::getOnlyAminoAcidSequence() const { } pappso::pappso_double ProteinXtp::getMass() const { - pappso::Peptide peptide(getOnlyAminoAcidSequence()); + try { + pappso::Peptide peptide(getOnlyAminoAcidSequence().replace("X","")); return peptide.getMass(); + + } + catch (pappso::PappsoException error) { + throw pappso::PappsoException(QObject::tr("Error computing mass for protein %1 :\n%2").arg(getAccession()).arg(error.qwhat())); + } } class DigestionHandler: public pappso::EnzymeProductInterface { @@ -89,11 +96,12 @@ public: unsigned int ProteinXtp::countTrypticPeptidesForPAI() const { qDebug() << "ProteinXtp::countTrypticPeptidesForPAI begin"; + try { pappso::Enzyme kinase; kinase.setMiscleavage(0); DigestionHandler digestion; - pappso::ProteinSp protein = std::make_shared<const pappso::Protein>(this->getDescription(),this->getOnlyAminoAcidSequence()); + pappso::ProteinSp protein = std::make_shared<const pappso::Protein>(this->getDescription(),this->getOnlyAminoAcidSequence().replace("X","")); kinase.eat(0,protein,false,digestion); unsigned int count = 0; @@ -105,6 +113,11 @@ unsigned int ProteinXtp::countTrypticPeptidesForPAI() const { } } - return count; qDebug() << "ProteinXtp::countTrypticPeptidesForPAI end"; + return count; + + } + catch (pappso::PappsoException error) { + throw pappso::PappsoException(QObject::tr("Error in countTrypticPeptidesForPAI for protein %1 :\n%2").arg(getAccession()).arg(error.qwhat())); + } } diff --git a/src/output/ods/proteinsheet.cpp b/src/output/ods/proteinsheet.cpp index a16bbff3..150bc996 100644 --- a/src/output/ods/proteinsheet.cpp +++ b/src/output/ods/proteinsheet.cpp @@ -30,6 +30,7 @@ #include "proteinsheet.h" #include "../../core/identificationgroup.h" #include <pappsomspp/utils.h> +#include <pappsomspp/pappsoexception.h> ProteinSheet::ProteinSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { _p_writer = p_writer; @@ -102,8 +103,10 @@ void ProteinSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { void ProteinSheet::writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match) { + try { _p_writer->writeLine(); + qDebug() << "ProteinSheet::writeOneProtein begin" ; ValidationState validation_state = ValidationState::validAndChecked; pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get(); @@ -140,6 +143,7 @@ void ProteinSheet::writeOneProtein(const GroupingGroup * p_group, const ProteinM _p_writer->writeCell(p_protein_match->countPeptideMassCharge(validation_state)); + qDebug() << "ProteinSheet::writeOneProtein tryptic" ; _p_writer->writeCell(p_protein->countTrypticPeptidesForPAI()); // _p_writer->writeCell("PAI"); // _p_writer->writeCell(new Double((float) hashProt @@ -160,5 +164,10 @@ void ProteinSheet::writeOneProtein(const GroupingGroup * p_group, const ProteinM //number of MS sample _p_writer->writeCell(p_protein_match->countDistinctMsSamples(validation_state)); - + + qDebug() << "ProteinSheet::writeOneProtein end" ; + } + catch (pappso::PappsoException error) { + throw pappso::PappsoException(QObject::tr("Error writing protein %1 :\n%2").arg(p_protein_match->getProteinXtpSp().get()->getAccession()).arg(error.qwhat())); + } } diff --git a/src/output/ods/spectrasheet.cpp b/src/output/ods/spectrasheet.cpp index feec26b6..90f179fe 100644 --- a/src/output/ods/spectrasheet.cpp +++ b/src/output/ods/spectrasheet.cpp @@ -35,7 +35,7 @@ SpectraSheet::SpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { _p_ods_export = p_ods_export; _p_writer = p_writer; - p_writer->writeSheet("peptides"); + p_writer->writeSheet("spectra"); std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); for (IdentificationGroup * p_ident:identification_list) { @@ -90,12 +90,12 @@ void SpectraSheet::writeBestPeptideMatch(const GroupingGroup * p_group,const Pep _p_writer->writeCell(p_peptide_match->getGrpPeptideSp().get()->getGroupingId()); _p_writer->clearTableCellStyleRef(); _p_writer->writeCell(p_peptide_match->getMsRunP()->getSampleName()); - _p_writer->writeCell(QString("%1").arg(p_peptide_match->getScan())); - _p_writer->writeCell(QString::number(p_peptide_match->getRetentionTime(), 'f', 2)); + _p_writer->writeCell(p_peptide_match->getScan()); + _p_writer->writeCell(p_peptide_match->getRetentionTime()); _p_writer->writeCell(p_peptide_match->getPeptideXtpSp().get()->getSequence()); _p_writer->writeCell(p_peptide_match->getPeptideXtpSp().get()->getModifString()); - _p_writer->writeCell(QString::number(p_peptide_match->getEvalue(), 'f', 2)); - _p_writer->writeCell(QString::number(p_peptide_match->getParam(PeptideMatchParam::tandem_hyperscore).toDouble(), 'f', 2)); + _p_writer->writeCell(p_peptide_match->getEvalue()); + _p_writer->writeCell(p_peptide_match->getParam(PeptideMatchParam::tandem_hyperscore).toDouble()); } -- GitLab