diff --git a/src/core/identification_sources/identificationpwizfile.cpp b/src/core/identification_sources/identificationpwizfile.cpp index 6a7d0b83f9df21262e7db6c8a93272b7f3ad45fb..2ee2672f2ee3fff7ef44d4bf2e276070c7e9a8b3 100644 --- a/src/core/identification_sources/identificationpwizfile.cpp +++ b/src/core/identification_sources/identificationpwizfile.cpp @@ -6,27 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and -*implementation -******************************************************************************/ + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ #include "../../input/identificationpwizreader.h" #include "../project.h" @@ -34,61 +34,79 @@ #include <pappsomspp/pappsoexception.h> IdentificationPwizFile::IdentificationPwizFile(const QFileInfo &ident_file) - : IdentificationDataSource(ident_file.absoluteFilePath()), - _ident_file(ident_file) { + : IdentificationDataSource(ident_file.absoluteFilePath()) + , _ident_file(ident_file) +{ //_engine = IdentificationEngine::XTandem; _engine = IdentificationEngine::peptider; } IdentificationPwizFile::IdentificationPwizFile( - const IdentificationPwizFile &other) - : IdentificationDataSource(other), _ident_file(other._ident_file) { + const IdentificationPwizFile &other) + : IdentificationDataSource(other), _ident_file(other._ident_file) +{ _engine = other._engine; } -IdentificationPwizFile::~IdentificationPwizFile() {} +IdentificationPwizFile::~IdentificationPwizFile() +{ +} -bool IdentificationPwizFile:: -operator==(const IdentificationPwizFile &other) const {} +bool +IdentificationPwizFile::operator==(const IdentificationPwizFile &other) const +{ +} pappso::SpectrumSp -IdentificationPwizFile::getSpectrumSp(unsigned int scan_number) const { +IdentificationPwizFile::getSpectrumSp(unsigned int scan_number) const +{ pappso::SpectrumSp spectrum_sp = - IdentificationDataSource::getSpectrumSp(scan_number); + IdentificationDataSource::getSpectrumSp(scan_number); return spectrum_sp; } -void IdentificationPwizFile::parseTo(Project *p_project) { +void +IdentificationPwizFile::parseTo(Project *p_project) +{ qDebug() << "IdentificationPwizFile::parseTo begin"; IdentificationPwizReader pwiz_reader(_ident_file); MsRunSp msrun_sp = - p_project->getMsRunStore().getInstance(pwiz_reader.getMsrunName()); + p_project->getMsRunStore().getInstance(pwiz_reader.getMsrunName()); _engine = pwiz_reader.getIdentificationEngine(); setMsRunSp(msrun_sp); std::vector<IdentificationGroup *> identification_list = - p_project->getIdentificationGroupList(); + p_project->getIdentificationGroupList(); IdentificationGroup *identification_group_p = nullptr; - if (p_project->getProjectMode() == ProjectMode::combined) { - if (identification_list.size() == 0) { - identification_group_p = p_project->newIdentificationGroup(); - } else { - identification_group_p = identification_list[0]; - } - } else { - for (IdentificationGroup *identification_p_flist : identification_list) { - if (identification_p_flist->containSample( - msrun_sp.get()->getSampleName())) { - identification_group_p = identification_p_flist; - break; - } + if(p_project->getProjectMode() == ProjectMode::combined) + { + if(identification_list.size() == 0) + { + identification_group_p = p_project->newIdentificationGroup(); + } + else + { + identification_group_p = identification_list[0]; + } } - if (identification_group_p == nullptr) { - identification_group_p = p_project->newIdentificationGroup(); + else + { + for(IdentificationGroup *identification_p_flist : identification_list) + { + if(identification_p_flist->containSample( + msrun_sp.get()->getSampleName())) + { + identification_group_p = identification_p_flist; + break; + } + } + if(identification_group_p == nullptr) + { + identification_group_p = p_project->newIdentificationGroup(); + } } - } identification_group_p->addIdentificationDataSourceP(this); pwiz_reader.read(this, p_project, identification_group_p); diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp index 5f4ee6b9dc98069e406274db355b3887ccf7102e..70cf209fc07e61a9ad59ddae313e427f87e5de2f 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.cpp +++ b/src/gui/peptide_list_view/peptidetablemodel.cpp @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ #include "peptidetablemodel.h" @@ -29,377 +30,526 @@ #include "peptidelistwindow.h" #include <pappsomspp/grouping/grppeptide.h> #include "../../core/labeling/label.h" +#include "../../utils/utils.h" -PeptideTableModel::PeptideTableModel(PeptideListWindow * parent) - :QAbstractTableModel(parent) +PeptideTableModel::PeptideTableModel(PeptideListWindow *parent) + : QAbstractTableModel(parent) { - _p_peptide_list_window = parent; - //ui->tableView->show(); - // QModelIndex topLeft = createIndex(0,0); - //emit a signal to make the view reread identified data - //emit dataChanged(topLeft, topLeft); + _p_peptide_list_window = parent; + // ui->tableView->show(); + // QModelIndex topLeft = createIndex(0,0); + // emit a signal to make the view reread identified data + // emit dataChanged(topLeft, topLeft); } -void PeptideTableModel::setProteinMatch(ProteinMatch * p_protein_match) { - qDebug() << "PeptideTableModel::setProteinMatch begin " ; +void +PeptideTableModel::setProteinMatch(ProteinMatch *p_protein_match) +{ + qDebug() << "PeptideTableModel::setProteinMatch begin "; - beginResetModel(); - _p_protein_match = p_protein_match; - endResetModel(); - //QModelIndex topLeft = createIndex(0,0); - //QModelIndex bottomRight = createIndex(rowCount(),columnCount()); + beginResetModel(); + _p_protein_match = p_protein_match; + endResetModel(); + // QModelIndex topLeft = createIndex(0,0); + // QModelIndex bottomRight = createIndex(rowCount(),columnCount()); - _p_peptide_list_window->resizeColumnsToContents(); - //emit dataChanged(topLeft, topLeft); - //emit headerDataChanged(Qt::Horizontal, 0,3); - qDebug() << "PeptideTableModel::setProteinMatch end " ; + _p_peptide_list_window->resizeColumnsToContents(); + // emit dataChanged(topLeft, topLeft); + // emit headerDataChanged(Qt::Horizontal, 0,3); + qDebug() << "PeptideTableModel::setProteinMatch end "; } -ProteinMatch * PeptideTableModel::getProteinMatch() { - return _p_protein_match; +ProteinMatch * +PeptideTableModel::getProteinMatch() +{ + return _p_protein_match; } -int PeptideTableModel::rowCount(const QModelIndex &parent ) const { - if (_p_protein_match != nullptr) { - //qDebug() << "PeptideTableModel::rowCount(const QModelIndex &parent ) " << _p_protein_match->getPeptideMatchList().size(); - return (int) _p_protein_match->getPeptideMatchList().size(); +int +PeptideTableModel::rowCount(const QModelIndex &parent) const +{ + if(_p_protein_match != nullptr) + { + // qDebug() << "PeptideTableModel::rowCount(const QModelIndex &parent ) " + // << _p_protein_match->getPeptideMatchList().size(); + return (int)_p_protein_match->getPeptideMatchList().size(); } - return 0; + return 0; } -int PeptideTableModel::columnCount(const QModelIndex &parent ) const { - return 22; +int +PeptideTableModel::columnCount(const QModelIndex &parent) const +{ + return 23; } -QVariant PeptideTableModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant +PeptideTableModel::headerData(int section, Qt::Orientation orientation, + int role) const { - if (orientation == Qt::Horizontal) { - switch (role) { - case Qt::DisplayRole : + if(orientation == Qt::Horizontal) + { + switch(role) + { + case Qt::DisplayRole: return QVariant(getTitle(section)); break; - case Qt::ToolTipRole : + case Qt::ToolTipRole: return QVariant(getDescription(section)); break; - } } -//if (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() == nullptr) { - return QVariant(); + // if + // (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() + // == nullptr) { + return QVariant(); } -QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const { - // generate a log message when this method gets called - int row = index.row(); - int col = index.column(); - //qDebug() << QString("row %1, col%2, role %3") - // .arg(row).arg(col).arg(role); +QVariant +PeptideTableModel::data(const QModelIndex &index, int role) const +{ + // generate a log message when this method gets called + int row = index.row(); + int col = index.column(); + // qDebug() << QString("row %1, col%2, role %3") + // .arg(row).arg(col).arg(role); - switch(role) { - case Qt::CheckStateRole: + switch(role) + { + case Qt::CheckStateRole: - if (col == 0) //add a checkbox to cell(1,0) - { - if ( _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->isChecked()) { + if(col == 0) // add a checkbox to cell(1,0) + { + if(_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->isChecked()) + { return Qt::Checked; - } - else { + } + else + { return Qt::Unchecked; - } - } - break; - case Qt::BackgroundRole: - if (_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->isValid() == false) - { + } + } + break; + case Qt::BackgroundRole: + if(_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->isValid() == false) + { return QVariant(QColor("grey")); - } - break; - case Qt::SizeHintRole : - //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); - return QSize( PeptideTableModel::getColumnWidth(col), 30 ); - break; - case Qt::DisplayRole: - if (_p_protein_match == nullptr) { - } - else { - pappso::GrpPeptide * p_grp_peptide; - const Label * p_label; - GroupingGroup * p_grp; - switch (col) { - case (std::int8_t)PeptideListColumn::checked: - return QVariant(); - break; + } + break; + case Qt::SizeHintRole: + // qDebug() << "ProteinTableModel::headerData " << + // ProteinTableModel::getColumnWidth(section); + return QSize(PeptideTableModel::getColumnWidth(col), 30); + break; + case Qt::DisplayRole: + if(_p_protein_match == nullptr) + { + } + else + { + pappso::GrpPeptide *p_grp_peptide; + const Label *p_label; + GroupingGroup *p_grp; + switch(col) + { + case(std::int8_t)PeptideListColumn::checked: + return QVariant(); + break; - case (std::int8_t)PeptideListColumn::peptide_grouping_id: - p_grp_peptide = _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getGrpPeptideSp().get(); - if (p_grp_peptide != nullptr) return p_grp_peptide->getGroupingId(); - return QVariant(); - break; - case (std::int8_t)PeptideListColumn::sample: - return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getIdentificationDataSource()->getSampleName(); - break; - case (std::int8_t)PeptideListColumn::scan: - return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getScan()); - break; - case (std::int8_t)PeptideListColumn::rtmin: - return QVariant ((qreal) (_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getRetentionTime()/60)); - break; - case (std::int8_t)PeptideListColumn::rt: - return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getRetentionTime()); - break; - case (std::int8_t)PeptideListColumn::charge: - return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getCharge()); - break; - case (std::int8_t)PeptideListColumn::experimental_mz: - return QVariant (_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getExperimentalMz()); - break; - case (std::int8_t)PeptideListColumn::sequence: - return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getSequence(); - break; - case (std::int8_t)PeptideListColumn::modifs: - return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getModifString(); - break; - case (std::int8_t)PeptideListColumn::label: - p_label = _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getLabel(); - if (p_label != nullptr) { - return QVariant(p_label->getXmlId()); - } - else { - return QVariant(); - } - break; - case (std::int8_t)PeptideListColumn::start: - return QVariant((quint32) _p_protein_match->getPeptideMatchList().at(row).getStart()+1); - break; - case (std::int8_t)PeptideListColumn::length: - return QVariant((quint32) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->size()); - break; - case (std::int8_t)PeptideListColumn::used: - p_grp = _p_protein_match->getGroupingGroupSp().get(); - if (p_grp != nullptr) return QVariant((qreal) p_grp->countSubgroupPresence(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence())); - return QVariant(); - break; - case (std::int8_t)PeptideListColumn::subgroups: - p_grp = _p_protein_match->getGroupingGroupSp().get(); - if (p_grp != nullptr) return QVariant( p_grp->getSubgroupIdList(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()).join(" ")); - return QVariant(); - break; - case (std::int8_t)PeptideListColumn::Evalue: - return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getEvalue()); - break; - case (std::int8_t)PeptideListColumn::experimental_mhplus: - return QVariant(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getExperimentalMhplus()); - break; - case (std::int8_t)PeptideListColumn::theoretical_mhplus: - return QVariant(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getMz(1)); - break; - case (std::int8_t)PeptideListColumn::delta_mhplus: - return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getDeltaMass()); - break; - case (std::int8_t)PeptideListColumn::delta_ppm: - return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPpmDeltaMass()); - break; - case (std::int8_t)PeptideListColumn::hyperscore: - return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getParam(PeptideEvidenceParam::tandem_hyperscore); - break; - case (std::int8_t)PeptideListColumn::mascot_score: - return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getParam(PeptideEvidenceParam::mascot_score); - break; - } - } + case(std::int8_t)PeptideListColumn::peptide_grouping_id: + p_grp_peptide = _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getGrpPeptideSp() + .get(); + if(p_grp_peptide != nullptr) + return p_grp_peptide->getGroupingId(); + return QVariant(); + break; + case(std::int8_t)PeptideListColumn::engine: + return Utils::getIdentificationEngineName( + _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getIdentificationEngine()); + break; + case(std::int8_t)PeptideListColumn::sample: + return _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getIdentificationDataSource() + ->getSampleName(); + break; + case(std::int8_t)PeptideListColumn::scan: + return QVariant( + (quint32)_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getScan()); + break; + case(std::int8_t)PeptideListColumn::rtmin: + return QVariant( + (qreal)(_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getRetentionTime() / + 60)); + break; + case(std::int8_t)PeptideListColumn::rt: + return QVariant((qreal)_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getRetentionTime()); + break; + case(std::int8_t)PeptideListColumn::charge: + return QVariant( + (quint32)_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getCharge()); + break; + case(std::int8_t)PeptideListColumn::experimental_mz: + return QVariant(_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getExperimentalMz()); + break; + case(std::int8_t)PeptideListColumn::sequence: + return _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequence(); + break; + case(std::int8_t)PeptideListColumn::modifs: + return _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getModifString(); + break; + case(std::int8_t)PeptideListColumn::label: + p_label = _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getLabel(); + if(p_label != nullptr) + { + return QVariant(p_label->getXmlId()); + } + else + { + return QVariant(); + } + break; + case(std::int8_t)PeptideListColumn::start: + return QVariant( + (quint32)_p_protein_match->getPeptideMatchList() + .at(row) + .getStart() + + 1); + break; + case(std::int8_t)PeptideListColumn::length: + return QVariant( + (quint32)_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->size()); + break; + case(std::int8_t)PeptideListColumn::used: + p_grp = _p_protein_match->getGroupingGroupSp().get(); + if(p_grp != nullptr) + return QVariant((qreal)p_grp->countSubgroupPresence( + _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence())); + return QVariant(); + break; + case(std::int8_t)PeptideListColumn::subgroups: + p_grp = _p_protein_match->getGroupingGroupSp().get(); + if(p_grp != nullptr) + return QVariant(p_grp + ->getSubgroupIdList( + _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence()) + .join(" ")); + return QVariant(); + break; + case(std::int8_t)PeptideListColumn::Evalue: + return QVariant((qreal)_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getEvalue()); + break; + case(std::int8_t)PeptideListColumn::experimental_mhplus: + return QVariant(_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getExperimentalMhplus()); + break; + case(std::int8_t)PeptideListColumn::theoretical_mhplus: + return QVariant(_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getMz(1)); + break; + case(std::int8_t)PeptideListColumn::delta_mhplus: + return QVariant((qreal)_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getDeltaMass()); + break; + case(std::int8_t)PeptideListColumn::delta_ppm: + return QVariant((qreal)_p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getPpmDeltaMass()); + break; + case(std::int8_t)PeptideListColumn::hyperscore: + return _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getParam(PeptideEvidenceParam::tandem_hyperscore); + break; + case(std::int8_t)PeptideListColumn::mascot_score: + return _p_protein_match->getPeptideMatchList() + .at(row) + .getPeptideEvidence() + ->getParam(PeptideEvidenceParam::mascot_score); + break; + } + } return QString("Row%1, Column%2") - .arg(index.row() + 1) - .arg(index.column() +1); + .arg(index.row() + 1) + .arg(index.column() + 1); } - return QVariant(); + return QVariant(); } -void PeptideTableModel::onPeptideDataChanged() { - qDebug() << "PeptideTableModel::onPeptideDataChanged begin " << rowCount(); - emit layoutAboutToBeChanged(); - emit layoutChanged(); +void +PeptideTableModel::onPeptideDataChanged() +{ + qDebug() << "PeptideTableModel::onPeptideDataChanged begin " << rowCount(); + emit layoutAboutToBeChanged(); + emit layoutChanged(); } - -PeptideListColumn PeptideTableModel::getPeptideListColumn(std::int8_t column) { - return static_cast<PeptideListColumn>(column); +PeptideListColumn +PeptideTableModel::getPeptideListColumn(std::int8_t column) +{ + return static_cast<PeptideListColumn>(column); } -const QString PeptideTableModel::getTitle(PeptideListColumn column) { - qDebug() << "PeptideTableModel::getTitle begin "; - return PeptideTableModel::getTitle((std::int8_t) column); - //qDebug() << "ProteinTableModel::getTitle end "; +const QString +PeptideTableModel::getTitle(PeptideListColumn column) +{ + qDebug() << "PeptideTableModel::getTitle begin "; + return PeptideTableModel::getTitle((std::int8_t)column); + // qDebug() << "ProteinTableModel::getTitle end "; } -const QString PeptideTableModel::getDescription(PeptideListColumn column) { - qDebug() << "PeptideTableModel::columnCount begin "; - return PeptideTableModel::getDescription((std::int8_t) column); - //qDebug() << "ProteinTableModel::columnCount end "; +const QString +PeptideTableModel::getDescription(PeptideListColumn column) +{ + qDebug() << "PeptideTableModel::columnCount begin "; + return PeptideTableModel::getDescription((std::int8_t)column); + // qDebug() << "ProteinTableModel::columnCount end "; } -const QString PeptideTableModel::getTitle(std::int8_t column) { +const QString +PeptideTableModel::getTitle(std::int8_t column) +{ - qDebug() << "PeptideTableModel::getTitle begin " << column; - switch (column) { + qDebug() << "PeptideTableModel::getTitle begin " << column; + switch(column) + { - case (std::int8_t) PeptideListColumn::checked: + case(std::int8_t)PeptideListColumn::checked: return "checked"; break; - case (std::int8_t) PeptideListColumn::peptide_grouping_id: + case(std::int8_t)PeptideListColumn::peptide_grouping_id: return "peptide ID"; break; - case (std::int8_t) PeptideListColumn::sample: + case(std::int8_t)PeptideListColumn::engine: + return "engine"; + break; + case(std::int8_t)PeptideListColumn::sample: return "sample"; break; - case (std::int8_t) PeptideListColumn::scan: + case(std::int8_t)PeptideListColumn::scan: return "scan"; break; - case (std::int8_t) PeptideListColumn::rtmin: + case(std::int8_t)PeptideListColumn::rtmin: return "RT min"; break; - case (std::int8_t) PeptideListColumn::rt: + case(std::int8_t)PeptideListColumn::rt: return "RT"; break; - case (std::int8_t) PeptideListColumn::charge: + case(std::int8_t)PeptideListColumn::charge: return "charge"; break; - case (std::int8_t) PeptideListColumn::experimental_mz: + case(std::int8_t)PeptideListColumn::experimental_mz: return "observed m/z"; break; - case (std::int8_t) PeptideListColumn::sequence: + case(std::int8_t)PeptideListColumn::sequence: return "sequence"; break; - case (std::int8_t) PeptideListColumn::modifs: + case(std::int8_t)PeptideListColumn::modifs: return "modifs"; break; - case (std::int8_t) PeptideListColumn::label: + case(std::int8_t)PeptideListColumn::label: return "label"; break; - case (std::int8_t) PeptideListColumn::start: + case(std::int8_t)PeptideListColumn::start: return "start"; break; - case (std::int8_t) PeptideListColumn::length: + case(std::int8_t)PeptideListColumn::length: return "length"; break; - case (std::int8_t) PeptideListColumn::used: + case(std::int8_t)PeptideListColumn::used: return "used"; break; - case (std::int8_t) PeptideListColumn::subgroups: + case(std::int8_t)PeptideListColumn::subgroups: return "subgroups"; break; - case (std::int8_t) PeptideListColumn::Evalue: + case(std::int8_t)PeptideListColumn::Evalue: return "Evalue"; break; - case (std::int8_t) PeptideListColumn::experimental_mhplus: + case(std::int8_t)PeptideListColumn::experimental_mhplus: return "observed MH+"; break; - case (std::int8_t) PeptideListColumn::theoretical_mhplus: + case(std::int8_t)PeptideListColumn::theoretical_mhplus: return "theoretical MH+"; break; - case (std::int8_t) PeptideListColumn::delta_mhplus: + case(std::int8_t)PeptideListColumn::delta_mhplus: return "delta MH+"; break; - case (std::int8_t) PeptideListColumn::delta_ppm: + case(std::int8_t)PeptideListColumn::delta_ppm: return "delta ppm"; break; - case (std::int8_t) PeptideListColumn::hyperscore: + case(std::int8_t)PeptideListColumn::hyperscore: return "hyperscore"; break; - case (std::int8_t) PeptideListColumn::mascot_score: + case(std::int8_t)PeptideListColumn::mascot_score: return "mascot score"; } - return ""; + return ""; } -const QString PeptideTableModel::getDescription(std::int8_t column) { +const QString +PeptideTableModel::getDescription(std::int8_t column) +{ - qDebug() << "ProteinTableModel::getDescription begin " << column; - switch (column) { + qDebug() << "ProteinTableModel::getDescription begin " << column; + switch(column) + { - case (std::int8_t) PeptideListColumn::checked: + case(std::int8_t)PeptideListColumn::checked: return "manual protein check"; break; - case (std::int8_t) PeptideListColumn::peptide_grouping_id: + case(std::int8_t)PeptideListColumn::peptide_grouping_id: return "unique peptide identifier within this grouping experiment"; break; - case (std::int8_t) PeptideListColumn::sample: + case(std::int8_t)PeptideListColumn::engine: + return "search engine"; + break; + case(std::int8_t)PeptideListColumn::sample: return "MS sample name"; break; - case (std::int8_t) PeptideListColumn::scan: + case(std::int8_t)PeptideListColumn::scan: return "scan number"; break; - case (std::int8_t) PeptideListColumn::rtmin: + case(std::int8_t)PeptideListColumn::rtmin: return "retention time in minutes"; break; - case (std::int8_t) PeptideListColumn::rt: + case(std::int8_t)PeptideListColumn::rt: return "retention time in seconds"; break; - case (std::int8_t) PeptideListColumn::charge: + case(std::int8_t)PeptideListColumn::charge: return "peptide charge"; break; - case (std::int8_t) PeptideListColumn::experimental_mz: + case(std::int8_t)PeptideListColumn::experimental_mz: return "observed m/z (experimental m/z of precursor)"; break; - case (std::int8_t) PeptideListColumn::sequence: + case(std::int8_t)PeptideListColumn::sequence: return "peptide sequence"; break; - case (std::int8_t) PeptideListColumn::modifs: + case(std::int8_t)PeptideListColumn::modifs: return "peptide modifications"; break; - case (std::int8_t) PeptideListColumn::label: + case(std::int8_t)PeptideListColumn::label: return "peptide label"; break; - case (std::int8_t) PeptideListColumn::start: + case(std::int8_t)PeptideListColumn::start: return "peptide start position on protein"; break; - case (std::int8_t) PeptideListColumn::length: + case(std::int8_t)PeptideListColumn::length: return "peptide length"; break; - case (std::int8_t) PeptideListColumn::used: + case(std::int8_t)PeptideListColumn::used: return "number of subgroups in which this peptide is used"; break; - case (std::int8_t) PeptideListColumn::subgroups: + case(std::int8_t)PeptideListColumn::subgroups: return "list of subgroups in which this peptide is used"; break; - case (std::int8_t) PeptideListColumn::Evalue: + case(std::int8_t)PeptideListColumn::Evalue: return "peptide Evalue"; break; - case (std::int8_t) PeptideListColumn::experimental_mhplus: + case(std::int8_t)PeptideListColumn::experimental_mhplus: return "observed peptide mass + H+"; break; - case (std::int8_t) PeptideListColumn::theoretical_mhplus: + case(std::int8_t)PeptideListColumn::theoretical_mhplus: return "peptide theoretical MH+"; break; - case (std::int8_t) PeptideListColumn::delta_mhplus: - return "peptide mass difference in dalton between observed mass and theoretical mass (observed - theoretical)"; + case(std::int8_t)PeptideListColumn::delta_mhplus: + return "peptide mass difference in dalton between observed mass and " + "theoretical mass (observed - theoretical)"; break; - case (std::int8_t) PeptideListColumn::delta_ppm: - return "peptide mass difference in ppm between observed mass and theoretical mass"; + case(std::int8_t)PeptideListColumn::delta_ppm: + return "peptide mass difference in ppm between observed mass and " + "theoretical mass"; break; - case (std::int8_t) PeptideListColumn::hyperscore: + case(std::int8_t)PeptideListColumn::hyperscore: return "X!Tandem hyperscore"; break; - case (std::int8_t) PeptideListColumn::mascot_score: + case(std::int8_t)PeptideListColumn::mascot_score: return "Mascot ion score"; - } - return ""; + return ""; } -int PeptideTableModel::getColumnWidth(int column) { - qDebug() << "PeptideTableModel::getColumnWidth " << column; - switch (column) { +int +PeptideTableModel::getColumnWidth(int column) +{ + qDebug() << "PeptideTableModel::getColumnWidth " << column; + switch(column) + { - case (int) PeptideListColumn::checked: + case(int)PeptideListColumn::checked: break; - case (int) PeptideListColumn::peptide_grouping_id: + case(int)PeptideListColumn::peptide_grouping_id: return 120; break; - case (int) PeptideListColumn::sample: + case(int)PeptideListColumn::sample: return 250; break; - case (int) PeptideListColumn::sequence: + case(int)PeptideListColumn::sequence: return 250; break; } - return 100; + return 100; } diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h index cde92b4753613c6d3a77d2d247567f4a1d1f4271..85c71922701cc2797e059b72a12988f865648971 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.h +++ b/src/gui/peptide_list_view/peptidetablemodel.h @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef PEPTIDETABLEMODEL_H #define PEPTIDETABLEMODEL_H @@ -31,62 +32,67 @@ * */ -enum class PeptideListColumn: std::int8_t { - checked=0, ///< manual checked - peptide_grouping_id=1, ///< manual checked - sample=2, - scan=3, - rtmin=4, - rt=5, - charge=6, - experimental_mz=7, - sequence=8, - modifs=9, - label=10, - start=11, - length=12, - used=13, - subgroups=14, - Evalue=15, - experimental_mhplus=16, - theoretical_mhplus=17, - delta_mhplus=18, - delta_ppm=19, - hyperscore=20, - mascot_score=21 +enum class PeptideListColumn : std::int8_t +{ + checked = 0, ///< manual checked + peptide_grouping_id = 1, ///< manual checked + engine = 2, + sample = 3, + scan = 4, + rtmin = 5, + rt = 6, + charge = 7, + experimental_mz = 8, + sequence = 9, + modifs = 10, + label = 11, + start = 12, + length = 13, + used = 14, + subgroups = 15, + Evalue = 16, + experimental_mhplus = 17, + theoretical_mhplus = 18, + delta_mhplus = 19, + delta_ppm = 20, + hyperscore = 21, + mascot_score = 22 }; class PeptideListWindow; -class PeptideTableModel: public QAbstractTableModel +class PeptideTableModel : public QAbstractTableModel { - Q_OBJECT -public: - PeptideTableModel(PeptideListWindow *parent); - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Q_OBJECT + public: + PeptideTableModel(PeptideListWindow *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + QVariant data(const QModelIndex &index, + int role = Qt::DisplayRole) const override; + + static const QString getTitle(PeptideListColumn column); + static const QString getDescription(PeptideListColumn column); + static PeptideListColumn getPeptideListColumn(std::int8_t column); - static const QString getTitle(PeptideListColumn column); - static const QString getDescription(PeptideListColumn column); - static PeptideListColumn getPeptideListColumn(std::int8_t column); + void setProteinMatch(ProteinMatch *p_protein_match); + ProteinMatch *getProteinMatch(); + signals: + void peptideEvidenceClicked(PeptideEvidence *p_peptide_evidence); - void setProteinMatch(ProteinMatch * p_protein_match); - ProteinMatch * getProteinMatch(); -signals: - void peptideEvidenceClicked(PeptideEvidence * p_peptide_evidence); + public slots: + void onPeptideDataChanged(); -public slots: - void onPeptideDataChanged(); + private: + static const QString getTitle(std::int8_t column); + static const QString getDescription(std::int8_t column); + static int getColumnWidth(int column); -private : - static const QString getTitle(std::int8_t column); - static const QString getDescription(std::int8_t column); - static int getColumnWidth(int column); -private : - ProteinMatch * _p_protein_match= nullptr; - PeptideListWindow * _p_peptide_list_window=nullptr; + private: + ProteinMatch *_p_protein_match = nullptr; + PeptideListWindow *_p_peptide_list_window = nullptr; }; #endif // PEPTIDETABLEMODEL_H diff --git a/src/gui/peptide_list_view/peptidetableproxymodel.cpp b/src/gui/peptide_list_view/peptidetableproxymodel.cpp index b43cbb2f994c7e9fafba8994566d6ac8dbdef00f..b2920c3741089881c17656dff27ba2bd2fde7a18 100644 --- a/src/gui/peptide_list_view/peptidetableproxymodel.cpp +++ b/src/gui/peptide_list_view/peptidetableproxymodel.cpp @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ #include <QDebug> #include <QSettings> @@ -29,264 +30,408 @@ #include "peptidelistwindow.h" #include "../project_view/projectwindow.h" -PeptideTableProxyModel::PeptideTableProxyModel(PeptideListWindow * p_peptide_list_window, PeptideTableModel * peptide_table_model_p): QSortFilterProxyModel(peptide_table_model_p) +PeptideTableProxyModel::PeptideTableProxyModel( + PeptideListWindow *p_peptide_list_window, + PeptideTableModel *peptide_table_model_p) + : QSortFilterProxyModel(peptide_table_model_p) { - _peptide_table_model_p = peptide_table_model_p; - _p_peptide_list_window = p_peptide_list_window; - _column_display.resize(30); - QSettings settings; + _peptide_table_model_p = peptide_table_model_p; + _p_peptide_list_window = p_peptide_list_window; + _column_display.resize(30); + QSettings settings; - for (std::size_t i=0; i < _column_display.size(); i++) { - _column_display[i] = settings.value(QString("peptide_list_columns/%1").arg(_peptide_table_model_p->getTitle((PeptideListColumn)i)), "true").toBool(); + for(std::size_t i = 0; i < _column_display.size(); i++) + { + _column_display[i] = + settings + .value(QString("peptide_list_columns/%1") + .arg(_peptide_table_model_p->getTitle((PeptideListColumn)i)), + "true") + .toBool(); } - _mass_delegate = new MassItemDelegate(_p_peptide_list_window); - _minute_delegate = new MinuteItemDelegate(_p_peptide_list_window); - _second_delegate = new SecondItemDelegate(_p_peptide_list_window); + _mass_delegate = new MassItemDelegate(_p_peptide_list_window); + _minute_delegate = new MinuteItemDelegate(_p_peptide_list_window); + _second_delegate = new SecondItemDelegate(_p_peptide_list_window); } PeptideTableProxyModel::~PeptideTableProxyModel() { - // delete _mass_delegate ; - // delete _minute_delegate ; - // delete _second_delegate ; + // delete _mass_delegate ; + // delete _minute_delegate ; + // delete _second_delegate ; } -bool PeptideTableProxyModel::filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const { - if (_peptide_table_model_p->getPeptideListColumn(source_column) == PeptideListColumn::label) { - if (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() == nullptr) { - return false; +bool +PeptideTableProxyModel::filterAcceptsColumn( + int source_column, const QModelIndex &source_parent) const +{ + if(_peptide_table_model_p->getPeptideListColumn(source_column) == + PeptideListColumn::label) + { + if(_p_peptide_list_window->getProjectWindow() + ->getProjectP() + ->getLabelingMethodSp() + .get() == nullptr) + { + return false; } } - return _column_display[source_column]; + return _column_display[source_column]; } -bool PeptideTableProxyModel::filterAcceptsRow(int source_row, - const QModelIndex &source_parent) const { - try { - qDebug() << "PeptideTableProxyModel::filterAcceptsRow begin " << source_row; - PeptideEvidence * peptide_evidence = _peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(source_row).getPeptideEvidence(); - qDebug() << "PeptideTableProxyModel::filterAcceptsRow protein_match " << source_row; - - qDebug() << "PeptideTableProxyModel::filterAcceptsRow valid "; - if (_hide_not_valid) { - if (! peptide_evidence->isValid()) { - return false; +bool +PeptideTableProxyModel::filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const +{ + try + { + qDebug() << "PeptideTableProxyModel::filterAcceptsRow begin " + << source_row; + PeptideEvidence *peptide_evidence = + _peptide_table_model_p->getProteinMatch() + ->getPeptideMatchList() + .at(source_row) + .getPeptideEvidence(); + qDebug() << "PeptideTableProxyModel::filterAcceptsRow protein_match " + << source_row; + + qDebug() << "PeptideTableProxyModel::filterAcceptsRow valid "; + if(_hide_not_valid) + { + if(!peptide_evidence->isValid()) + { + return false; } } - qDebug() << "PeptideTableProxyModel::filterAcceptsRow checked "; - if (_hide_not_checked) { - if (! peptide_evidence->isChecked()) { - return false; + qDebug() << "PeptideTableProxyModel::filterAcceptsRow checked "; + if(_hide_not_checked) + { + if(!peptide_evidence->isChecked()) + { + return false; } } - qDebug() << "PeptideTableProxyModel::filterAcceptsRow grouped "; - if (_hide_not_grouped) { - if (! peptide_evidence->isGrouped()) { - return false; + qDebug() << "PeptideTableProxyModel::filterAcceptsRow grouped "; + if(_hide_not_grouped) + { + if(!peptide_evidence->isGrouped()) + { + return false; } - } - if (_search_on == "msrun/scan") { - unsigned int scan_num = this->_p_peptide_list_window->ui->scan_number_edit->value(); - QString file_search_string = this->_p_peptide_list_window->ui->msrun_auto_completion->text().toLower(); - qDebug() << "PeptideTableProxyModel::filterAcceptsRow msrun/scan " << file_search_string << " " << scan_num; - bool scan_ok = true; - if (scan_num > 0) { - scan_ok = false; - if (peptide_evidence->getScan() == scan_num) { - scan_ok = true; + if(_search_on == "msrun/scan") + { + unsigned int scan_num = + this->_p_peptide_list_window->ui->scan_number_edit->value(); + QString file_search_string = + this->_p_peptide_list_window->ui->msrun_auto_completion->text() + .toLower(); + qDebug() << "PeptideTableProxyModel::filterAcceptsRow msrun/scan " + << file_search_string << " " << scan_num; + bool scan_ok = true; + if(scan_num > 0) + { + scan_ok = false; + if(peptide_evidence->getScan() == scan_num) + { + scan_ok = true; } } - bool msrun_ok = true; - if (!file_search_string.isEmpty()) { - msrun_ok = false; - if (peptide_evidence->getMsRunP()->getFilename().toLower().contains(file_search_string)) { - msrun_ok = true; + bool msrun_ok = true; + if(!file_search_string.isEmpty()) + { + msrun_ok = false; + if(peptide_evidence->getMsRunP() + ->getFilename() + .toLower() + .contains(file_search_string)) + { + msrun_ok = true; } } - if (msrun_ok && scan_ok ) { - return true; + if(msrun_ok && scan_ok) + { + return true; } - return false; + return false; } - if (!_peptide_search_string.isEmpty()) { - if (_search_on == "peptide") { - if (!peptide_evidence->getPeptideXtpSp().get()->getSequence().contains(_peptide_search_string)) { - return false; + if(!_peptide_search_string.isEmpty()) + { + if(_search_on == "peptide") + { + if(!peptide_evidence->getPeptideXtpSp() + .get() + ->getSequence() + .contains(_peptide_search_string)) + { + return false; } } - else if (_search_on == "sample") { - if (!peptide_evidence->getMsRunP()->getSampleName().contains(_peptide_search_string)) { - return false; + else if(_search_on == "sample") + { + if(!peptide_evidence->getMsRunP()->getSampleName().contains( + _peptide_search_string)) + { + return false; } - } else if (_search_on == "subgroup") { - if (peptide_evidence->getValidationState() != ValidationState::grouped) { - return false; + } + else if(_search_on == "subgroup") + { + if(peptide_evidence->getValidationState() != + ValidationState::grouped) + { + return false; } - unsigned int subgroup = _peptide_search_string.toUInt(); - return false; - } else if (_search_on == "modification") { - return false; + unsigned int subgroup = _peptide_search_string.toUInt(); + return false; + } + else if(_search_on == "modification") + { + return false; } } - if (_search_on == "modifications") { - QString mod_search_string = this->_p_peptide_list_window->ui->mod_auto_completion->text(); - - std::vector<pappso::AaModificationP> mod_list; - for (pappso::AaModificationP mod :_p_peptide_list_window->getProjectWindow()->getProjectP()->getPeptideStore().getModificationCollection()) { - if (QString("[%1] %2 %3").arg(mod->getAccession()).arg(mod->getName()).arg(mod->getMass()).contains(mod_search_string)) { - mod_list.push_back(mod); + if(_search_on == "modifications") + { + QString mod_search_string = + this->_p_peptide_list_window->ui->mod_auto_completion->text(); + + std::vector<pappso::AaModificationP> mod_list; + for(pappso::AaModificationP mod : + _p_peptide_list_window->getProjectWindow() + ->getProjectP() + ->getPeptideStore() + .getModificationCollection()) + { + if(QString("[%1] %2 %3") + .arg(mod->getAccession()) + .arg(mod->getName()) + .arg(mod->getMass()) + .contains(mod_search_string)) + { + mod_list.push_back(mod); } - //qDebug() << "ProteinListWindow::setIdentificationGroup " << msrun_sp.get()->getFilename(); + // qDebug() << "ProteinListWindow::setIdentificationGroup " << + // msrun_sp.get()->getFilename(); } - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow msrun/scan " << file_search_string << " " << scan_num; - for (pappso::AaModificationP mod :mod_list) { - if (peptide_evidence->getPeptideXtpSp().get()->getNumberOfModification(mod) > 0) { - return true; + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow msrun/scan " + // << file_search_string << " " << scan_num; + for(pappso::AaModificationP mod : mod_list) + { + if(peptide_evidence->getPeptideXtpSp() + .get() + ->getNumberOfModification(mod) > 0) + { + return true; } } - return false; + return false; } - return true; + return true; } - catch (pappso::PappsoException exception_pappso) { - //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_pappso.qwhat()); - qDebug() << "Error in PeptideTableProxyModel::acceptRow :" << exception_pappso.qwhat(); + catch(pappso::PappsoException exception_pappso) + { + // QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), + // exception_pappso.qwhat()); + qDebug() << "Error in PeptideTableProxyModel::acceptRow :" + << exception_pappso.qwhat(); } - catch (std::exception exception_std) { - //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); - qDebug() << "Error in PeptideTableProxyModel::acceptRow :" << exception_std.what(); + catch(std::exception exception_std) + { + // QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), + // exception_std.what()); + qDebug() << "Error in PeptideTableProxyModel::acceptRow :" + << exception_std.what(); } - return true; + return true; - //return true; + // return true; } - -void PeptideTableProxyModel::onTableClicked(const QModelIndex &index) +void +PeptideTableProxyModel::onTableClicked(const QModelIndex &index) { - qDebug() << "PeptideTableProxyModel::onTableClicked begin " << index.row(); - qDebug() << "PeptideTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); - - //_protein_table_model_p->onTableClicked(this->mapToSource(index)); - QModelIndex source_index(this->mapToSource(index)); - int row = source_index.row(); - PeptideListColumn col = (PeptideListColumn) source_index.column(); - PeptideMatch * peptide_match = &_peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(row); - if (col == PeptideListColumn::checked) //add a checkbox to cell(1,0) + qDebug() << "PeptideTableProxyModel::onTableClicked begin " << index.row(); + qDebug() << "PeptideTableProxyModel::onTableClicked begin " + << this->mapToSource(index).row(); + + //_protein_table_model_p->onTableClicked(this->mapToSource(index)); + QModelIndex source_index(this->mapToSource(index)); + int row = source_index.row(); + PeptideListColumn col = (PeptideListColumn)source_index.column(); + PeptideMatch *peptide_match = + &_peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(row); + if(col == PeptideListColumn::checked) // add a checkbox to cell(1,0) { - if ( peptide_match->getPeptideEvidence()->isChecked()) { - peptide_match->getPeptideEvidence()->setChecked(false); + if(peptide_match->getPeptideEvidence()->isChecked()) + { + peptide_match->getPeptideEvidence()->setChecked(false); } - else { - peptide_match->getPeptideEvidence()->setChecked(true); + else + { + peptide_match->getPeptideEvidence()->setChecked(true); } - _p_peptide_list_window->edited(); + _p_peptide_list_window->edited(); } - else { - _p_peptide_list_window->askPeptideDetailView(peptide_match->getPeptideEvidence()); + else + { + _p_peptide_list_window->askPeptideDetailView( + peptide_match->getPeptideEvidence()); } - qDebug() << "PeptideTableProxyModel::onTableClicked end " << index.row(); - + qDebug() << "PeptideTableProxyModel::onTableClicked end " << index.row(); } -bool PeptideTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const { - QVariant leftData = sourceModel()->data(left); - QVariant rightData = sourceModel()->data(right); - if (leftData.type() == QVariant::UInt) { - return leftData.toUInt() < rightData.toUInt(); +bool +PeptideTableProxyModel::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + QVariant leftData = sourceModel()->data(left); + QVariant rightData = sourceModel()->data(right); + if(leftData.type() == QVariant::UInt) + { + return leftData.toUInt() < rightData.toUInt(); } - if (leftData.type() == QVariant::UInt) { - return leftData.toUInt() < rightData.toUInt(); + if(leftData.type() == QVariant::UInt) + { + return leftData.toUInt() < rightData.toUInt(); } - if (leftData.type() == QVariant::Double) { - return leftData.toDouble() < rightData.toDouble(); + if(leftData.type() == QVariant::Double) + { + return leftData.toDouble() < rightData.toDouble(); } - return leftData.toString() < rightData.toString(); + return leftData.toString() < rightData.toString(); } -QVariant PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant +PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation, + int role) const { - int col = mapToSource(index(0,section)).column(); + int col = mapToSource(index(0, section)).column(); - return sourceModel()->headerData(col, orientation, - role); + return sourceModel()->headerData(col, orientation, role); } -void PeptideTableProxyModel::hideNotValid(bool hide) { - _hide_not_valid = hide; +QVariant +PeptideTableProxyModel::data(const QModelIndex &index, int role) const +{ + + //auto new_index = this->index(index.row(), mapToSource(index).column()); + return sourceModel()->data(mapToSource(index), role); } -void PeptideTableProxyModel::hideNotChecked(bool hide) { - qDebug() << "PeptideTableProxyModel::hideNotChecked begin "; - _hide_not_checked = hide; - qDebug() << "PeptideTableProxyModel::hideNotChecked end "; +void +PeptideTableProxyModel::hideNotValid(bool hide) +{ + _hide_not_valid = hide; } -void PeptideTableProxyModel::hideNotGrouped(bool hide) { - _hide_not_grouped = hide; + +void +PeptideTableProxyModel::hideNotChecked(bool hide) +{ + qDebug() << "PeptideTableProxyModel::hideNotChecked begin "; + _hide_not_checked = hide; + qDebug() << "PeptideTableProxyModel::hideNotChecked end "; +} +void +PeptideTableProxyModel::hideNotGrouped(bool hide) +{ + _hide_not_grouped = hide; } -void PeptideTableProxyModel::setSearchOn(QString search_on) { - _search_on = search_on; +void +PeptideTableProxyModel::setSearchOn(QString search_on) +{ + _search_on = search_on; } -void PeptideTableProxyModel::setPeptideSearchString(QString peptide_search_string) { - _peptide_search_string = peptide_search_string; +void +PeptideTableProxyModel::setPeptideSearchString(QString peptide_search_string) +{ + _peptide_search_string = peptide_search_string; } -bool PeptideTableProxyModel::getPeptideListColumnDisplay(PeptideListColumn column) const { - return _column_display[(std::int8_t) column]; +bool +PeptideTableProxyModel::getPeptideListColumnDisplay( + PeptideListColumn column) const +{ + return _column_display[(std::int8_t)column]; } -void PeptideTableProxyModel::setPeptideListColumnDisplay(PeptideListColumn column, bool toggled) { - qDebug() << "PeptideTableProxyModel::setPeptideListColumnDisplay begin " << toggled; - beginResetModel(); - QSettings settings; - settings.setValue(QString("peptide_list_columns/%1").arg(_peptide_table_model_p->getTitle(column)),toggled); - _column_display[(std::int8_t) column] = toggled; +void +PeptideTableProxyModel::setPeptideListColumnDisplay(PeptideListColumn column, + bool toggled) +{ + qDebug() << "PeptideTableProxyModel::setPeptideListColumnDisplay begin " + << toggled; + beginResetModel(); + QSettings settings; + settings.setValue(QString("peptide_list_columns/%1") + .arg(_peptide_table_model_p->getTitle(column)), + toggled); + _column_display[(std::int8_t)column] = toggled; - endResetModel(); + endResetModel(); - resteItemDelegates(); + resteItemDelegates(); - //emit columnsRemoved(createIndex(1, 2), (int) column, (int) column) + // emit columnsRemoved(createIndex(1, 2), (int) column, (int) column) } -void PeptideTableProxyModel::resteItemDelegates() const { +void +PeptideTableProxyModel::resteItemDelegates() const +{ - for (int i = 0; i < columnCount(); ++i) { - _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _p_peptide_list_window->ui->tableView->itemDelegate()); - if (mapToSource(index(0, i)).column() == (std::int8_t) PeptideListColumn::experimental_mhplus) { - _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _mass_delegate); + for(int i = 0; i < columnCount(); ++i) + { + _p_peptide_list_window->ui->tableView->setItemDelegateForColumn( + i, _p_peptide_list_window->ui->tableView->itemDelegate()); + if(mapToSource(index(0, i)).column() == + (std::int8_t)PeptideListColumn::experimental_mhplus) + { + _p_peptide_list_window->ui->tableView->setItemDelegateForColumn( + i, _mass_delegate); } - if (mapToSource(index(0, i)).column() == (std::int8_t) PeptideListColumn::theoretical_mhplus) { - _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _mass_delegate); + if(mapToSource(index(0, i)).column() == + (std::int8_t)PeptideListColumn::theoretical_mhplus) + { + _p_peptide_list_window->ui->tableView->setItemDelegateForColumn( + i, _mass_delegate); } - if (mapToSource(index(0, i)).column() == (std::int8_t) PeptideListColumn::experimental_mz) { - _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _mass_delegate); + if(mapToSource(index(0, i)).column() == + (std::int8_t)PeptideListColumn::experimental_mz) + { + _p_peptide_list_window->ui->tableView->setItemDelegateForColumn( + i, _mass_delegate); } - if (mapToSource(index(0, i)).column() == (std::int8_t) PeptideListColumn::rtmin) { - _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _minute_delegate); + if(mapToSource(index(0, i)).column() == + (std::int8_t)PeptideListColumn::rtmin) + { + _p_peptide_list_window->ui->tableView->setItemDelegateForColumn( + i, _minute_delegate); } - if (mapToSource(index(0, i)).column() == (std::int8_t) PeptideListColumn::rt) { - _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _second_delegate); + if(mapToSource(index(0, i)).column() == + (std::int8_t)PeptideListColumn::rt) + { + _p_peptide_list_window->ui->tableView->setItemDelegateForColumn( + i, _second_delegate); } } - /* - MinuteItemDelegate * minute_delegate = new MinuteItemDelegate(ui->tableView); - ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::rtmin, minute_delegate); - SecondItemDelegate * second_delegate = new SecondItemDelegate(ui->tableView); - ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::rt, second_delegate); - */ + /* + MinuteItemDelegate * minute_delegate = new MinuteItemDelegate(ui->tableView); + ui->tableView->setItemDelegateForColumn((std::int8_t) + PeptideListColumn::rtmin, minute_delegate); SecondItemDelegate * + second_delegate = new SecondItemDelegate(ui->tableView); + ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::rt, + second_delegate); + */ } diff --git a/src/gui/peptide_list_view/peptidetableproxymodel.h b/src/gui/peptide_list_view/peptidetableproxymodel.h index d8bd68652031fe21e3c157511d2355046273f33a..569bc20165262113be3f1f742115c9b48e215375 100644 --- a/src/gui/peptide_list_view/peptidetableproxymodel.h +++ b/src/gui/peptide_list_view/peptidetableproxymodel.h @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef PEPTIDETABLEPROXYMODEL_H #define PEPTIDETABLEPROXYMODEL_H @@ -36,42 +37,48 @@ class PeptideTableModel; class PeptideTableProxyModel : public QSortFilterProxyModel { - Q_OBJECT -public: - PeptideTableProxyModel(PeptideListWindow * p_peptide_list_window, PeptideTableModel* peptide_table_model_p); - virtual ~PeptideTableProxyModel(); - bool filterAcceptsRow(int source_row, - const QModelIndex &source_parent) const override; - bool filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const override; - - QVariant headerData(int section, Qt::Orientation orientation, - int role) const override; - bool lessThan(const QModelIndex & left, const QModelIndex & right) const override; - - void hideNotValid(bool hide); - void hideNotChecked(bool hide); - void hideNotGrouped(bool hide); - void setPeptideSearchString(QString peptide_search_string); - void setSearchOn(QString search_on); - void setPeptideListColumnDisplay(PeptideListColumn column, bool toggled); - bool getPeptideListColumnDisplay(PeptideListColumn column) const; + Q_OBJECT + public: + PeptideTableProxyModel(PeptideListWindow *p_peptide_list_window, + PeptideTableModel *peptide_table_model_p); + virtual ~PeptideTableProxyModel(); + bool filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const override; + bool filterAcceptsColumn(int source_column, + const QModelIndex &source_parent) const override; - void resteItemDelegates() const; -public slots: - void onTableClicked(const QModelIndex &index); -private : -private: - PeptideTableModel* _peptide_table_model_p; - PeptideListWindow * _p_peptide_list_window; - QString _peptide_search_string; - bool _hide_not_valid = true; - bool _hide_not_checked = true; - bool _hide_not_grouped = true; - QString _search_on = "peptide"; - std::vector<bool> _column_display; - MassItemDelegate * _mass_delegate; - MinuteItemDelegate * _minute_delegate; - SecondItemDelegate * _second_delegate; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + QVariant data(const QModelIndex &index, + int role = Qt::DisplayRole) const override; + bool lessThan(const QModelIndex &left, + const QModelIndex &right) const override; + + void hideNotValid(bool hide); + void hideNotChecked(bool hide); + void hideNotGrouped(bool hide); + void setPeptideSearchString(QString peptide_search_string); + void setSearchOn(QString search_on); + void setPeptideListColumnDisplay(PeptideListColumn column, bool toggled); + bool getPeptideListColumnDisplay(PeptideListColumn column) const; + + void resteItemDelegates() const; + public slots: + void onTableClicked(const QModelIndex &index); + + private: + private: + PeptideTableModel *_peptide_table_model_p; + PeptideListWindow *_p_peptide_list_window; + QString _peptide_search_string; + bool _hide_not_valid = true; + bool _hide_not_checked = true; + bool _hide_not_grouped = true; + QString _search_on = "peptide"; + std::vector<bool> _column_display; + MassItemDelegate *_mass_delegate; + MinuteItemDelegate *_minute_delegate; + SecondItemDelegate *_second_delegate; }; #endif // PEPTIDETABLEPROXYMODEL_H diff --git a/src/gui/protein_list_view/proteintableproxymodel.cpp b/src/gui/protein_list_view/proteintableproxymodel.cpp index 08806350a084598fa03c7eaec0e42375eb57dd53..7aa1d8ec30988128a3a66b2260af7289a617e1c1 100644 --- a/src/gui/protein_list_view/proteintableproxymodel.cpp +++ b/src/gui/protein_list_view/proteintableproxymodel.cpp @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ #include <QDebug> #include <QSettings> @@ -30,269 +31,420 @@ #include "proteinlistwindow.h" #include "../project_view/projectwindow.h" -ProteinTableProxyModel::ProteinTableProxyModel(ProteinListWindow * p_protein_list_window, ProteinTableModel* protein_table_model_p): QSortFilterProxyModel(protein_table_model_p) +ProteinTableProxyModel::ProteinTableProxyModel( + ProteinListWindow *p_protein_list_window, + ProteinTableModel *protein_table_model_p) + : QSortFilterProxyModel(protein_table_model_p) { - _protein_table_model_p = protein_table_model_p; - _p_protein_list_window = p_protein_list_window; - _column_display.resize(30); - QSettings settings; - for (std::size_t i=0; i < _column_display.size(); i++) { + _protein_table_model_p = protein_table_model_p; + _p_protein_list_window = p_protein_list_window; + _column_display.resize(30); + QSettings settings; + for(std::size_t i = 0; i < _column_display.size(); i++) + { - _column_display[i] = settings.value(QString("protein_list_columns/%1").arg(_protein_table_model_p->getTitle((ProteinListColumn)i)), "true").toBool(); + _column_display[i] = + settings + .value(QString("protein_list_columns/%1") + .arg(_protein_table_model_p->getTitle((ProteinListColumn)i)), + "true") + .toBool(); } - - _percent_delegate = new PercentItemDelegate(p_protein_list_window->ui->tableView); + _percent_delegate = + new PercentItemDelegate(p_protein_list_window->ui->tableView); } ProteinTableProxyModel::~ProteinTableProxyModel() { - //delete _percent_delegate; + // delete _percent_delegate; } -bool ProteinTableProxyModel::filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const { - return _column_display[source_column]; +bool +ProteinTableProxyModel::filterAcceptsColumn( + int source_column, const QModelIndex &source_parent) const +{ + return _column_display[source_column]; } -bool ProteinTableProxyModel::filterAcceptsRow(int source_row, - const QModelIndex &source_parent) const { - try { - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow begin " << source_row; - ProteinMatch * protein_match = _protein_table_model_p->getIdentificationGroup()->getProteinMatchList().at(source_row); - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match " << source_row; - - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow valid "; - if (_hide_not_valid) { - if (! protein_match->isValid()) { - return false; +bool +ProteinTableProxyModel::filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const +{ + try + { + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow begin " << + // source_row; + ProteinMatch *protein_match = + _protein_table_model_p->getIdentificationGroup() + ->getProteinMatchList() + .at(source_row); + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match " + // << source_row; + + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow valid "; + if(_hide_not_valid) + { + if(!protein_match->isValid()) + { + return false; } } - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow checked "; - if (_hide_not_checked) { - if (! protein_match->isChecked()) { - return false; + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow checked "; + if(_hide_not_checked) + { + if(!protein_match->isChecked()) + { + return false; } } - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow grouped "; - pappso::GrpProtein * p_grp_prot = protein_match->getGrpProteinSp().get(); - if (_hide_not_grouped) { - if (p_grp_prot == nullptr) { - return false; + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow grouped "; + pappso::GrpProtein *p_grp_prot = protein_match->getGrpProteinSp().get(); + if(_hide_not_grouped) + { + if(p_grp_prot == nullptr) + { + return false; } - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow grouped 2"; - if (p_grp_prot->getGroupingId().isEmpty()) { - return false; + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow grouped 2"; + if(p_grp_prot->getGroupingId().isEmpty()) + { + return false; } } - if (_search_on == "msrun/scan") { - unsigned int scan_num = this->_p_protein_list_window->ui->scan_number_edit->value(); - QString file_search_string = this->_p_protein_list_window->ui->msrun_auto_completion->text().toLower(); - qDebug() << "ProteinTableProxyModel::filterAcceptsRow msrun/scan " << file_search_string << " " << scan_num; - for (const PeptideMatch & p_peptide_match: protein_match->getPeptideMatchList()) { - bool scan_ok = true; - if (scan_num > 0) { - scan_ok = false; - if (p_peptide_match.getPeptideEvidence()->getScan() == scan_num) { - scan_ok = true; + if(_search_on == "msrun/scan") + { + unsigned int scan_num = + this->_p_protein_list_window->ui->scan_number_edit->value(); + QString file_search_string = + this->_p_protein_list_window->ui->msrun_auto_completion->text() + .toLower(); + qDebug() << "ProteinTableProxyModel::filterAcceptsRow msrun/scan " + << file_search_string << " " << scan_num; + for(const PeptideMatch &p_peptide_match : + protein_match->getPeptideMatchList()) + { + bool scan_ok = true; + if(scan_num > 0) + { + scan_ok = false; + if(p_peptide_match.getPeptideEvidence()->getScan() == + scan_num) + { + scan_ok = true; } } - bool msrun_ok = true; - if (!file_search_string.isEmpty()) { - msrun_ok = false; - if (p_peptide_match.getPeptideEvidence()->getMsRunP()->getFilename().toLower().contains(file_search_string)) { - msrun_ok = true; + bool msrun_ok = true; + if(!file_search_string.isEmpty()) + { + msrun_ok = false; + if(p_peptide_match.getPeptideEvidence() + ->getMsRunP() + ->getFilename() + .toLower() + .contains(file_search_string)) + { + msrun_ok = true; } } - if (msrun_ok && scan_ok ) { - return true; + if(msrun_ok && scan_ok) + { + return true; } } - return false; + return false; } - if (!_protein_search_string.isEmpty()) { - if (_search_on == "accession") { - if (!protein_match->getProteinXtpSp().get()->getAccession().contains(_protein_search_string)) { - return false; + if(!_protein_search_string.isEmpty()) + { + if(_search_on == "accession") + { + if(!protein_match->getProteinXtpSp() + .get() + ->getAccession() + .contains(_protein_search_string)) + { + return false; } } - else if (_search_on == "group") { - pappso::GrpProtein * p_grp_prot = protein_match->getGrpProteinSp().get(); - if (p_grp_prot == nullptr) { - return false; + else if(_search_on == "group") + { + pappso::GrpProtein *p_grp_prot = + protein_match->getGrpProteinSp().get(); + if(p_grp_prot == nullptr) + { + return false; } - else { - p_grp_prot->getGroupingId(); - if (!p_grp_prot->getGroupingId().startsWith(_protein_search_string)) { - return false; + else + { + p_grp_prot->getGroupingId(); + if(!p_grp_prot->getGroupingId().startsWith( + _protein_search_string)) + { + return false; } } } - else if (_search_on == "sequence") { - if (!protein_match->getProteinXtpSp().get()->getSequence().contains(_protein_search_string)) { - return false; + else if(_search_on == "sequence") + { + if(!protein_match->getProteinXtpSp() + .get() + ->getSequence() + .contains(_protein_search_string)) + { + return false; } } - else if (_search_on == "peptide") { - QString peptide_search_string = QString(_protein_search_string).replace("L","I"); - for (const PeptideMatch & p_peptide_match: protein_match->getPeptideMatchList()) { - if (p_peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi().contains(peptide_search_string)) { - return true; + else if(_search_on == "peptide") + { + QString peptide_search_string = + QString(_protein_search_string).replace("L", "I"); + for(const PeptideMatch &p_peptide_match : + protein_match->getPeptideMatchList()) + { + if(p_peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequenceLi() + .contains(peptide_search_string)) + { + return true; } } - return false; + return false; } - else { - if (!protein_match->getProteinXtpSp().get()->getDescription().contains(_protein_search_string)) { - return false; + else + { + if(!protein_match->getProteinXtpSp() + .get() + ->getDescription() + .contains(_protein_search_string)) + { + return false; } } } - if (_search_on == "modifications") { - QString mod_search_string = this->_p_protein_list_window->ui->mod_auto_completion->text(); - - std::vector<pappso::AaModificationP> mod_list; - for (pappso::AaModificationP mod :_p_protein_list_window->getProjectWindow()->getProjectP()->getPeptideStore().getModificationCollection()) { - if (QString("[%1] %2 %3").arg(mod->getAccession()).arg(mod->getName()).arg(mod->getMass()).contains(mod_search_string)) { - mod_list.push_back(mod); + if(_search_on == "modifications") + { + QString mod_search_string = + this->_p_protein_list_window->ui->mod_auto_completion->text(); + + std::vector<pappso::AaModificationP> mod_list; + for(pappso::AaModificationP mod : + _p_protein_list_window->getProjectWindow() + ->getProjectP() + ->getPeptideStore() + .getModificationCollection()) + { + if(QString("[%1] %2 %3") + .arg(mod->getAccession()) + .arg(mod->getName()) + .arg(mod->getMass()) + .contains(mod_search_string)) + { + mod_list.push_back(mod); } - //qDebug() << "ProteinListWindow::setIdentificationGroup " << msrun_sp.get()->getFilename(); + // qDebug() << "ProteinListWindow::setIdentificationGroup " << + // msrun_sp.get()->getFilename(); } - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow msrun/scan " << file_search_string << " " << scan_num; - for (const PeptideMatch & p_peptide_match: protein_match->getPeptideMatchList()) { - for (pappso::AaModificationP mod :mod_list) { - if (p_peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNumberOfModification(mod) > 0) { - return true; + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow msrun/scan " + // << file_search_string << " " << scan_num; + for(const PeptideMatch &p_peptide_match : + protein_match->getPeptideMatchList()) + { + for(pappso::AaModificationP mod : mod_list) + { + if(p_peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getNumberOfModification(mod) > 0) + { + return true; } } } - return false; + return false; } } - catch (pappso::PappsoException exception_pappso) { - //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_pappso.qwhat()); - qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_pappso.qwhat(); + catch(pappso::PappsoException exception_pappso) + { + // QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), + // exception_pappso.qwhat()); + qDebug() << "Error in ProteinTableModel::acceptRow :" + << exception_pappso.qwhat(); } - catch (std::exception exception_std) { - //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); - qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_std.what(); + catch(std::exception exception_std) + { + // QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), + // exception_std.what()); + qDebug() << "Error in ProteinTableModel::acceptRow :" + << exception_std.what(); } - return true; + return true; - //return true; + // return true; } - -void ProteinTableProxyModel::onTableClicked(const QModelIndex &index) +void +ProteinTableProxyModel::onTableClicked(const QModelIndex &index) { - qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row(); - qDebug() << "ProteinTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); - - //_protein_table_model_p->onTableClicked(this->mapToSource(index)); - QModelIndex source_index(this->mapToSource(index)); - int row = source_index.row(); - ProteinListColumn col = (ProteinListColumn) source_index.column(); - ProteinMatch* p_protein_match = _protein_table_model_p->getIdentificationGroup()->getProteinMatchList().at(row); - if (col == ProteinListColumn::checked) //add a checkbox to cell(1,0) + qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row(); + qDebug() << "ProteinTableProxyModel::onTableClicked begin " + << this->mapToSource(index).row(); + + //_protein_table_model_p->onTableClicked(this->mapToSource(index)); + QModelIndex source_index(this->mapToSource(index)); + int row = source_index.row(); + ProteinListColumn col = (ProteinListColumn)source_index.column(); + ProteinMatch *p_protein_match = + _protein_table_model_p->getIdentificationGroup()->getProteinMatchList().at( + row); + if(col == ProteinListColumn::checked) // add a checkbox to cell(1,0) { - if ( p_protein_match->isChecked()) { - p_protein_match->setChecked(false); + if(p_protein_match->isChecked()) + { + p_protein_match->setChecked(false); } - else { - p_protein_match->setChecked(true); + else + { + p_protein_match->setChecked(true); } - _p_protein_list_window->edited(); + _p_protein_list_window->edited(); } - else { - if ((col == ProteinListColumn::accession)||(col == ProteinListColumn::description)||(col == ProteinListColumn::coverage)) { - _p_protein_list_window->askProteinDetailView(p_protein_match); + else + { + if((col == ProteinListColumn::accession) || + (col == ProteinListColumn::description) || + (col == ProteinListColumn::coverage)) + { + _p_protein_list_window->askProteinDetailView(p_protein_match); } - else { - _p_protein_list_window->askPeptideListView(p_protein_match); + else + { + _p_protein_list_window->askPeptideListView(p_protein_match); } } - qDebug() << "ProteinTableProxyModel::onTableClicked end " << index.row(); - + qDebug() << "ProteinTableProxyModel::onTableClicked end " << index.row(); } -bool ProteinTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const { - QVariant leftData = sourceModel()->data(left); - QVariant rightData = sourceModel()->data(right); - if (leftData.type() == QVariant::UInt) { - return leftData.toUInt() < rightData.toUInt(); +bool +ProteinTableProxyModel::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + QVariant leftData = sourceModel()->data(left); + QVariant rightData = sourceModel()->data(right); + if(leftData.type() == QVariant::UInt) + { + return leftData.toUInt() < rightData.toUInt(); } - if (leftData.type() == QVariant::UInt) { - return leftData.toUInt() < rightData.toUInt(); + if(leftData.type() == QVariant::UInt) + { + return leftData.toUInt() < rightData.toUInt(); } - if (leftData.type() == QVariant::Double) { - return leftData.toDouble() < rightData.toDouble(); + if(leftData.type() == QVariant::Double) + { + return leftData.toDouble() < rightData.toDouble(); } - return leftData.toString() < rightData.toString(); + return leftData.toString() < rightData.toString(); } -QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orientation, - int role) const { - int col = mapToSource(index(0,section)).column(); +QVariant +ProteinTableProxyModel::data(const QModelIndex &index, int role) const +{ - return sourceModel()->headerData(col, orientation, - role); + return sourceModel()->data(mapToSource(index), role); +} + +QVariant +ProteinTableProxyModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + int col = mapToSource(index(0, section)).column(); + return sourceModel()->headerData(col, orientation, role); } -void ProteinTableProxyModel::hideNotValid(bool hide) { - _hide_not_valid = hide; +void +ProteinTableProxyModel::hideNotValid(bool hide) +{ + _hide_not_valid = hide; } -void ProteinTableProxyModel::hideNotChecked(bool hide) { - qDebug() << "ProteinTableProxyModel::hideNotChecked begin "; - _hide_not_checked = hide; - qDebug() << "ProteinTableProxyModel::hideNotChecked end "; +void +ProteinTableProxyModel::hideNotChecked(bool hide) +{ + qDebug() << "ProteinTableProxyModel::hideNotChecked begin "; + _hide_not_checked = hide; + qDebug() << "ProteinTableProxyModel::hideNotChecked end "; } -void ProteinTableProxyModel::hideNotGrouped(bool hide) { - _hide_not_grouped = hide; +void +ProteinTableProxyModel::hideNotGrouped(bool hide) +{ + _hide_not_grouped = hide; } -void ProteinTableProxyModel::setSearchOn(QString search_on) { - _search_on = search_on; +void +ProteinTableProxyModel::setSearchOn(QString search_on) +{ + _search_on = search_on; } -void ProteinTableProxyModel::setMsrunFileSearch(QString msrun_file_search) { +void +ProteinTableProxyModel::setMsrunFileSearch(QString msrun_file_search) +{ } -void ProteinTableProxyModel::setProteinSearchString(QString protein_search_string) { - _protein_search_string = protein_search_string; +void +ProteinTableProxyModel::setProteinSearchString(QString protein_search_string) +{ + _protein_search_string = protein_search_string; } -void ProteinTableProxyModel::setProteinListColumnDisplay(ProteinListColumn column, bool toggled) { - qDebug() << "ProteinTableProxyModel::setProteinListColumnDisplay begin " << toggled; - beginResetModel(); - QSettings settings; - settings.setValue(QString("protein_list_columns/%1").arg(_protein_table_model_p->getTitle(column)),toggled); - - _column_display[(std::int8_t) column] = toggled; - endResetModel(); - - resteItemDelegates(); +void +ProteinTableProxyModel::setProteinListColumnDisplay(ProteinListColumn column, + bool toggled) +{ + qDebug() << "ProteinTableProxyModel::setProteinListColumnDisplay begin " + << toggled; + beginResetModel(); + QSettings settings; + settings.setValue(QString("protein_list_columns/%1") + .arg(_protein_table_model_p->getTitle(column)), + toggled); + + _column_display[(std::int8_t)column] = toggled; + endResetModel(); + + resteItemDelegates(); } -bool ProteinTableProxyModel::getProteinListColumnDisplay(ProteinListColumn column) const { - return _column_display[(std::int8_t) column]; +bool +ProteinTableProxyModel::getProteinListColumnDisplay( + ProteinListColumn column) const +{ + return _column_display[(std::int8_t)column]; } +void +ProteinTableProxyModel::resteItemDelegates() const +{ -void ProteinTableProxyModel::resteItemDelegates() const { - - for (int i = 0; i < columnCount(); ++i) { - _p_protein_list_window->ui->tableView->setItemDelegateForColumn(i, _p_protein_list_window->ui->tableView->itemDelegate()); - if (mapToSource(index(0, i)).column() == (std::int8_t) ProteinListColumn::coverage) { - _p_protein_list_window->ui->tableView->setItemDelegateForColumn(i, _percent_delegate); + for(int i = 0; i < columnCount(); ++i) + { + _p_protein_list_window->ui->tableView->setItemDelegateForColumn( + i, _p_protein_list_window->ui->tableView->itemDelegate()); + if(mapToSource(index(0, i)).column() == + (std::int8_t)ProteinListColumn::coverage) + { + _p_protein_list_window->ui->tableView->setItemDelegateForColumn( + i, _percent_delegate); } } } diff --git a/src/gui/protein_list_view/proteintableproxymodel.h b/src/gui/protein_list_view/proteintableproxymodel.h index 13fe073b95b1be5c541ec4dff1067d9ceb429023..adefbcb080a05dd1168a1d9e1232a685c7adb328 100644 --- a/src/gui/protein_list_view/proteintableproxymodel.h +++ b/src/gui/protein_list_view/proteintableproxymodel.h @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef PROTEINTABLEPROXYMODEL_H #define PROTEINTABLEPROXYMODEL_H @@ -36,43 +37,48 @@ class ProteinTableModel; class ProteinTableProxyModel : public QSortFilterProxyModel { - Q_OBJECT -public: - ProteinTableProxyModel(ProteinListWindow * p_protein_list_window, ProteinTableModel* protein_table_model_p); - virtual ~ProteinTableProxyModel(); - - bool filterAcceptsRow(int source_row, - const QModelIndex &source_parent) const override; - bool filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const override; - - QVariant headerData(int section, Qt::Orientation orientation, - int role) const override; - bool lessThan(const QModelIndex & left, const QModelIndex & right) const override; - - void hideNotValid(bool hide); - void hideNotChecked(bool hide); - void hideNotGrouped(bool hide); - void setProteinSearchString(QString protein_search_string); - void setMsrunFileSearch(QString msrun_file_search); - void setSearchOn(QString search_on); - void setProteinListColumnDisplay(ProteinListColumn column, bool toggled); - bool getProteinListColumnDisplay(ProteinListColumn column) const; - void resteItemDelegates() const; + Q_OBJECT + public: + ProteinTableProxyModel(ProteinListWindow *p_protein_list_window, + ProteinTableModel *protein_table_model_p); + virtual ~ProteinTableProxyModel(); -public slots: - void onTableClicked(const QModelIndex &index); - + bool filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const override; + bool filterAcceptsColumn(int source_column, + const QModelIndex &source_parent) const override; -private: - ProteinTableModel* _protein_table_model_p; - ProteinListWindow * _p_protein_list_window; - QString _search_on = "accession"; - QString _protein_search_string; - bool _hide_not_valid = true; - bool _hide_not_checked = true; - bool _hide_not_grouped = true; - std::vector<bool> _column_display; - PercentItemDelegate * _percent_delegate; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + QVariant data(const QModelIndex &index, + int role = Qt::DisplayRole) const override; + bool lessThan(const QModelIndex &left, + const QModelIndex &right) const override; + + void hideNotValid(bool hide); + void hideNotChecked(bool hide); + void hideNotGrouped(bool hide); + void setProteinSearchString(QString protein_search_string); + void setMsrunFileSearch(QString msrun_file_search); + void setSearchOn(QString search_on); + void setProteinListColumnDisplay(ProteinListColumn column, bool toggled); + bool getProteinListColumnDisplay(ProteinListColumn column) const; + void resteItemDelegates() const; + + public slots: + void onTableClicked(const QModelIndex &index); + + + private: + ProteinTableModel *_protein_table_model_p; + ProteinListWindow *_p_protein_list_window; + QString _search_on = "accession"; + QString _protein_search_string; + bool _hide_not_valid = true; + bool _hide_not_checked = true; + bool _hide_not_grouped = true; + std::vector<bool> _column_display; + PercentItemDelegate *_percent_delegate; }; #endif // PROTEINTABLEPROXYMODEL_H diff --git a/src/input/pepxmlsaxhandler.cpp b/src/input/pepxmlsaxhandler.cpp index 809b6857549411a3ca63d001c9b18290c6dfe1c6..87f24235f4180716b76d2803c770e94b7e02182f 100644 --- a/src/input/pepxmlsaxhandler.cpp +++ b/src/input/pepxmlsaxhandler.cpp @@ -308,7 +308,8 @@ PepXmlSaxHandler::startElement_spectrum_query(QXmlAttributes attributes) "unable to read search results from '%1' as retention time " "is not given in spectrum_query elements") .arg(_current_search_engine); - qDebug() << message; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << message; // throw new MSMSException(message); _current_retention_time = 0; @@ -325,7 +326,7 @@ PepXmlSaxHandler::startElement_spectrum_query(QXmlAttributes attributes) //<alternative_protein protein="sp|P46784|RS10B_YEAST" protein_descr="40S // ribosomal protein S10-B OS=Saccharomyces cerevisiae (strain ATCC 204508 -// \ +// \ //S288c) GN=RPS10B PE=1 SV=1" num_tol_term="2" peptide_prev_aa="K" // peptide_next_aa="N"/> bool @@ -590,8 +591,9 @@ PepXmlSaxHandler::startElement_mod_aminoacid_mass(QXmlAttributes attributes) bool is_ok = true; double mass = attributes.value("mass").toDouble(); unsigned int position = attributes.value("position").toUInt() - 1; - const pappso::Aa aa(_current_peptide_sp.get()->getSequence()[position].toLatin1()); - double mass_modif = mass - aa.getMass(); + const pappso::Aa aa( + _current_peptide_sp.get()->getSequence()[position].toLatin1()); + double mass_modif = mass - aa.getMass(); pappso::AaModificationP modif = Utils::guessAaModificationPbyMonoisotopicMassDelta(mass_modif); diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 227c40d54a98df7069788faeb550d1a9611f8547..6ead071872634638b71416170bad6d15088b1c54 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -3,120 +3,203 @@ #include <pappsomspp/mass_range.h> #include <cmath> -const QUrl Utils::getOlsUrl(QString psimod_accession) { +const QUrl +Utils::getOlsUrl(QString psimod_accession) +{ - QString iri(QString("http://purl.obolibrary.org/obo/%1").arg(psimod_accession.replace(":","_"))); - QUrl url(QString("http://www.ebi.ac.uk/ols/ontologies/mod/terms?iri=%1").arg(iri)); - return url; + QString iri(QString("http://purl.obolibrary.org/obo/%1") + .arg(psimod_accession.replace(":", "_"))); + QUrl url( + QString("http://www.ebi.ac.uk/ols/ontologies/mod/terms?iri=%1").arg(iri)); + return url; } -const QString Utils::getXmlDouble(pappso::pappso_double number) { - return QString::number(number,'g',6); +const QString +Utils::getXmlDouble(pappso::pappso_double number) +{ + return QString::number(number, 'g', 6); } -const QString Utils::getDatabaseName(ExternalDatabase database) { - QString database_name; - switch (database) { - case ExternalDatabase::AGI_LocusCode : +const QString +Utils::getIdentificationEngineName(IdentificationEngine engine) +{ + QString engine_name; + switch(engine) + { + case IdentificationEngine::XTandem: + engine_name = "X!Tandem"; + break; + case IdentificationEngine::mascot: + engine_name = "Mascot"; + break; + + case IdentificationEngine::peptider: + engine_name = "Peptider"; + break; + case IdentificationEngine::OMSSA: + engine_name = "OMSSA"; + break; + case IdentificationEngine::SEQUEST: + engine_name = "Sequest"; + break; + case IdentificationEngine::Comet: + engine_name = "Comet"; + break; + case IdentificationEngine::Morpheus: + engine_name = "Morpheus"; + break; + case IdentificationEngine::MSGFplus: + engine_name = "MS-GF+"; + break; + } + return engine_name; +} + +const QString +Utils::getDatabaseName(ExternalDatabase database) +{ + QString database_name; + switch(database) + { + case ExternalDatabase::AGI_LocusCode: database_name = "AGI_LocusCode"; break; - case ExternalDatabase::NCBI_gi : + case ExternalDatabase::NCBI_gi: database_name = "NCBI_gi"; break; - case ExternalDatabase::SwissProt : + case ExternalDatabase::SwissProt: database_name = "Swiss-Prot"; break; - case ExternalDatabase::TrEMBL : + case ExternalDatabase::TrEMBL: database_name = "TrEMBL"; break; - case ExternalDatabase::ref : + case ExternalDatabase::ref: database_name = "ref"; break; } - return database_name; + return database_name; } -std::vector<std::pair<pappso::pappso_double, size_t>> Utils::getHistogram(std::vector<pappso::pappso_double> data_values, unsigned int number_of_class) { - std::vector<std::pair<pappso::pappso_double, size_t>> histogram(number_of_class+1); - try { - qDebug() << "Utils::getHistogram begin"; - - std::sort(data_values.begin(), data_values.end()); - pappso::pappso_double min = *data_values.begin(); - pappso::pappso_double max = *(data_values.end()-1); - pappso::pappso_double total = std::abs(max-min); - pappso::pappso_double offset = (total/ (pappso::pappso_double) number_of_class); - //qDebug() << "Utils::getHistogram number_of_class offset=" << offset; - for (unsigned int i= 0; i < histogram.size(); i++) { - histogram[i] = std::pair<pappso::pappso_double, size_t> {(min + (offset * i) + (offset/2)), 0}; - //qDebug() << "Utils::getHistogram x=" << histogram[i].first; +std::vector<std::pair<pappso::pappso_double, size_t>> +Utils::getHistogram(std::vector<pappso::pappso_double> data_values, + unsigned int number_of_class) +{ + std::vector<std::pair<pappso::pappso_double, size_t>> histogram( + number_of_class + 1); + try + { + qDebug() << "Utils::getHistogram begin"; + + std::sort(data_values.begin(), data_values.end()); + pappso::pappso_double min = *data_values.begin(); + pappso::pappso_double max = *(data_values.end() - 1); + pappso::pappso_double total = std::abs(max - min); + pappso::pappso_double offset = + (total / (pappso::pappso_double)number_of_class); + // qDebug() << "Utils::getHistogram number_of_class offset=" << offset; + for(unsigned int i = 0; i < histogram.size(); i++) + { + histogram[i] = std::pair<pappso::pappso_double, size_t>{ + (min + (offset * i) + (offset / 2)), 0}; + // qDebug() << "Utils::getHistogram x=" << histogram[i].first; } - //qDebug() << "Utils::getHistogram data_values"; - for (pappso::pappso_double value :data_values) { - //qDebug() << "Utils::getHistogram value=" << value; - unsigned int i = std::abs((value-min)/offset ); - //qDebug() << "Utils::getHistogram i=" << i << " size=" << histogram.size(); - histogram.at(i).second++; + // qDebug() << "Utils::getHistogram data_values"; + for(pappso::pappso_double value : data_values) + { + // qDebug() << "Utils::getHistogram value=" << value; + unsigned int i = std::abs((value - min) / offset); + // qDebug() << "Utils::getHistogram i=" << i << " size=" << + // histogram.size(); + histogram.at(i).second++; } } - catch (std::exception exception_std) { - throw pappso::PappsoException(QObject::tr("Utils::getHistogram error %1").arg(exception_std.what())); + catch(std::exception exception_std) + { + throw pappso::PappsoException( + QObject::tr("Utils::getHistogram error %1").arg(exception_std.what())); } - qDebug() << "Utils::getHistogram end"; - return histogram; + qDebug() << "Utils::getHistogram end"; + return histogram; } -pappso::AaModificationP Utils::guessAaModificationPbyMonoisotopicMassDelta(pappso::mz mass) { - pappso::PrecisionP precision = pappso::Precision::getDaltonInstance(0.01); +pappso::AaModificationP +Utils::guessAaModificationPbyMonoisotopicMassDelta(pappso::mz mass) +{ + pappso::PrecisionP precision = pappso::Precision::getDaltonInstance(0.01); - pappso::AaModificationP oxidation = pappso::AaModification::getInstance("MOD:00719"); - if (pappso::MassRange(oxidation->getMass(),precision).contains(mass)) { - return oxidation; + pappso::AaModificationP oxidation = + pappso::AaModification::getInstance("MOD:00719"); + if(pappso::MassRange(oxidation->getMass(), precision).contains(mass)) + { + return oxidation; } - pappso::AaModificationP iodoacetamide = pappso::AaModification::getInstance("MOD:00397"); - if (pappso::MassRange(iodoacetamide->getMass(),precision).contains(mass)) { - return iodoacetamide; + pappso::AaModificationP iodoacetamide = + pappso::AaModification::getInstance("MOD:00397"); + if(pappso::MassRange(iodoacetamide->getMass(), precision).contains(mass)) + { + return iodoacetamide; } - pappso::AaModificationP acetylated = pappso::AaModification::getInstance("MOD:00408"); - if (pappso::MassRange(acetylated->getMass(),precision).contains(mass)) { - return acetylated; + pappso::AaModificationP acetylated = + pappso::AaModification::getInstance("MOD:00408"); + if(pappso::MassRange(acetylated->getMass(), precision).contains(mass)) + { + return acetylated; } - pappso::AaModificationP phosphorylated = pappso::AaModification::getInstance("MOD:00696"); - if (pappso::MassRange(phosphorylated->getMass(),precision).contains(mass)) { - return phosphorylated; + pappso::AaModificationP phosphorylated = + pappso::AaModification::getInstance("MOD:00696"); + if(pappso::MassRange(phosphorylated->getMass(), precision).contains(mass)) + { + return phosphorylated; } - pappso::AaModificationP ammonia = pappso::AaModification::getInstance("MOD:01160"); - if (pappso::MassRange(ammonia->getMass(),precision).contains(mass)) { - return ammonia; + pappso::AaModificationP ammonia = + pappso::AaModification::getInstance("MOD:01160"); + if(pappso::MassRange(ammonia->getMass(), precision).contains(mass)) + { + return ammonia; } - pappso::AaModificationP dehydrated = pappso::AaModification::getInstance("MOD:00704"); - if (pappso::MassRange(dehydrated->getMass(),precision).contains(mass)) { - return dehydrated; + pappso::AaModificationP dehydrated = + pappso::AaModification::getInstance("MOD:00704"); + if(pappso::MassRange(dehydrated->getMass(), precision).contains(mass)) + { + return dehydrated; } - pappso::AaModificationP dimethylated = pappso::AaModification::getInstance("MOD:00429"); - if (pappso::MassRange(dimethylated->getMass(),precision).contains(mass)) { - return dimethylated; + pappso::AaModificationP dimethylated = + pappso::AaModification::getInstance("MOD:00429"); + if(pappso::MassRange(dimethylated->getMass(), precision).contains(mass)) + { + return dimethylated; } - pappso::AaModificationP dimethylated_medium = pappso::AaModification::getInstance("MOD:00552"); - if (pappso::MassRange(dimethylated_medium->getMass(),precision).contains(mass)) { - return dimethylated_medium; + pappso::AaModificationP dimethylated_medium = + pappso::AaModification::getInstance("MOD:00552"); + if(pappso::MassRange(dimethylated_medium->getMass(), precision) + .contains(mass)) + { + return dimethylated_medium; } - pappso::AaModificationP dimethylated_heavy = pappso::AaModification::getInstance("MOD:00638"); - if (pappso::MassRange(dimethylated_heavy->getMass(),precision).contains(mass)) { - return dimethylated_heavy; + pappso::AaModificationP dimethylated_heavy = + pappso::AaModification::getInstance("MOD:00638"); + if(pappso::MassRange(dimethylated_heavy->getMass(), precision).contains(mass)) + { + return dimethylated_heavy; } - pappso::AaModificationP DimethylpyrroleAdduct = pappso::AaModification::getInstance("MOD:00628"); - if (pappso::MassRange(DimethylpyrroleAdduct->getMass(),precision).contains(mass)) { - return DimethylpyrroleAdduct; + pappso::AaModificationP DimethylpyrroleAdduct = + pappso::AaModification::getInstance("MOD:00628"); + if(pappso::MassRange(DimethylpyrroleAdduct->getMass(), precision) + .contains(mass)) + { + return DimethylpyrroleAdduct; } - // modification not found, creating customized mod : - return pappso::AaModification::getInstanceCustomizedMod(mass); + // modification not found, creating customized mod : + return pappso::AaModification::getInstanceCustomizedMod(mass); - throw pappso::ExceptionNotFound(QObject::tr("Utils::guessAaModificationPbyMonoisotopicMassDelta => modification not found for mass %1").arg(mass)); + throw pappso::ExceptionNotFound( + QObject::tr("Utils::guessAaModificationPbyMonoisotopicMassDelta => " + "modification not found for mass %1") + .arg(mass)); } diff --git a/src/utils/utils.h b/src/utils/utils.h index 09e85186294c6cd6304ecac07d5ac882af11f25d..7fa5195edc9c31eb7a999bb729a1329f4b804c55 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -1,26 +1,27 @@ /******************************************************************************* -* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. -* -* This file is part of XTPcpp. -* -* XTPcpp is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* XTPcpp is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. -* -* Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation -******************************************************************************/ -#include<QUrl> + * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. + * + * This file is part of XTPcpp. + * + * XTPcpp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * XTPcpp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. + * + * Contributors: + * Olivier Langella <olivier.langella@u-psud.fr> - initial API and + *implementation + ******************************************************************************/ +#include <QUrl> #include <QString> #include "types.h" #include <pappsomspp/types.h> @@ -30,13 +31,16 @@ #define XTPUTILS_H class Utils { -public: - static const QUrl getOlsUrl(QString modification); - static const QString getDatabaseName(ExternalDatabase database); - static const QString getXmlDouble(pappso::pappso_double number); - static pappso::AaModificationP guessAaModificationPbyMonoisotopicMassDelta(pappso::mz mass); - static std::vector<std::pair<pappso::pappso_double, size_t>> getHistogram(std::vector<pappso::pappso_double> data_values, unsigned int number_of_class); - + public: + static const QUrl getOlsUrl(QString modification); + static const QString getIdentificationEngineName(IdentificationEngine engine); + static const QString getDatabaseName(ExternalDatabase database); + static const QString getXmlDouble(pappso::pappso_double number); + static pappso::AaModificationP + guessAaModificationPbyMonoisotopicMassDelta(pappso::mz mass); + static std::vector<std::pair<pappso::pappso_double, size_t>> + getHistogram(std::vector<pappso::pappso_double> data_values, + unsigned int number_of_class); }; #endif // XTPUTILS_H