From d9b07c79783ac146600799a392cd2d005735bef3 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 23 Mar 2017 23:01:16 +0100 Subject: [PATCH] protein coverage OK --- src/core/proteinmatch.cpp | 42 ++++++++++--------- .../protein_list_view/proteintablemodel.cpp | 9 +++- src/input/xpipsaxhandler.cpp | 14 +++---- src/utils/proteinstore.cpp | 6 +-- 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index e750622d..f035edbc 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -116,15 +116,15 @@ 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); } @@ -137,24 +137,26 @@ const pappso::GrpProteinSp & ProteinMatch::getGrpProteinSp() const { } - pappso::pappso_double ProteinMatch::getCoverage() const { - size_t prot_size = _protein_sp.get()->size(); - if (prot_size == 0) return 0; - bool cover_bool[prot_size] = {false}; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match->isValidAndChecked()) { - size_t size = p_peptide_match->getPeptideSp().get()->size(); - size_t offset = p_peptide_match->getStart(); - if (offset >= 0) { - for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { - cover_bool[offset] = true; - } +pappso::pappso_double ProteinMatch::getCoverage() const { + size_t prot_size = _protein_sp.get()->size(); + //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); + if (prot_size == 0) return 0; + bool cover_bool[prot_size] = {false}; + for (auto & p_peptide_match : _peptide_match_list) { + if (p_peptide_match->isValidAndChecked()) { + size_t size = p_peptide_match->getPeptideSp().get()->size(); + size_t offset = p_peptide_match->getStart(); + if (offset >= 0) { + for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { + cover_bool[offset] = true; } } } - size_t count = 0; - for (size_t i=0; i < prot_size; i++) { - if(cover_bool[i]) count++; - } - return ((pappso::pappso_double)count/ (pappso::pappso_double)prot_size); } + size_t count = 0; + for (size_t i=0; i < prot_size; i++) { + if(cover_bool[i]) count++; + } + //qDebug() << "ProteinMatch::getCoverage count=" << count << " prot_size=" << prot_size; + return (((pappso::pappso_double)count)/ ((pappso::pappso_double)prot_size)); +} diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index 341b67d8..711528c8 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -127,7 +127,7 @@ int ProteinTableModel::rowCount(const QModelIndex &parent ) const { return 0; } int ProteinTableModel::columnCount(const QModelIndex &parent ) const { - return 5; + return 7; } QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -146,6 +146,10 @@ QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, return QString("protein description"); case 4: return QString("Evalue"); + case 5: + return QString("spectrum"); + case 6: + return QString("coverage"); } } } @@ -201,6 +205,9 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { if (col == 5) { return QVariant ((quint16) _p_identification_group->getProteinMatchList().at(row)->getPeptideMatchList().size()); } + if (col == 6) { + return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getCoverage()); + } return QString("Row%1, Column%2") .arg(index.row() + 1) diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 921d4262..1d42b8ca 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -285,17 +285,17 @@ bool XpipSaxHandler::endElement_peptide() { } bool XpipSaxHandler::endElement_sequence() { - if ((_tag_stack.size() > 1) && (_tag_stack[_tag_stack.size() - 1] == "protein")) { - _current_protein.setSequence(_current_text); - } - else { - // XtandemHyperscore hyperscore(_curent_spectrum, _current_peptide_sp, _precision, _ion_list, _max_charge,_refine_spectrum_synthesis); - } + //if ((_tag_stack.size() > 1) && (_tag_stack[_tag_stack.size() - 1] == "protein")) { + _current_protein.setSequence(_current_text); + //} + //else { + // XtandemHyperscore hyperscore(_curent_spectrum, _current_peptide_sp, _precision, _ion_list, _max_charge,_refine_spectrum_synthesis); + //} return true; } bool XpipSaxHandler::endElement_protein() { ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp(); - + _p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein)); return true; diff --git a/src/utils/proteinstore.cpp b/src/utils/proteinstore.cpp index acb0a876..7eab25a1 100644 --- a/src/utils/proteinstore.cpp +++ b/src/utils/proteinstore.cpp @@ -55,14 +55,14 @@ ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & peptide_in) { } void ProteinStore::setProteinInformations(ProteinXtpSp & peptide_in) { - qDebug() << "ProteinStore::setProteinInformations begin"; + //qDebug() << "ProteinStore::setProteinInformations begin" << peptide_in.get()->getSequence(); QString accession = peptide_in.get()->getAccession(); if (_regexp_contaminant.indexIn(accession, 0)>-1) { - qDebug() << "ProteinStore::setProteinInformations is contaminant " << accession; + //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"; + //qDebug() << "ProteinStore::setProteinInformations end"; } -- GitLab