diff --git a/src/core/automaticfilterparameters.cpp b/src/core/automaticfilterparameters.cpp index ca12bdd2ad13d74d6ca3228b669127de15cdf434..531362bfcd2ddc81edc95c052d6678e822fdd0b3 100644 --- a/src/core/automaticfilterparameters.cpp +++ b/src/core/automaticfilterparameters.cpp @@ -1,68 +1,85 @@ /******************************************************************************* -* 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 "automaticfilterparameters.h" AutomaticFilterParameters::AutomaticFilterParameters() { - } -AutomaticFilterParameters::AutomaticFilterParameters(const AutomaticFilterParameters& other) +AutomaticFilterParameters::AutomaticFilterParameters( + const AutomaticFilterParameters &other) { - _filter_minimum_peptide_evalue=other._filter_minimum_peptide_evalue; - _filter_minimum_protein_evalue=other._filter_minimum_protein_evalue; - _filter_minimum_peptide_per_match=other._filter_minimum_peptide_per_match; - _filter_is_cross_sample_peptide_number=other._filter_is_cross_sample_peptide_number; + _filter_minimum_peptide_evalue = other._filter_minimum_peptide_evalue; + _filter_minimum_protein_evalue = other._filter_minimum_protein_evalue; + _filter_minimum_peptide_per_match = other._filter_minimum_peptide_per_match; + _filter_is_cross_sample_peptide_number = + other._filter_is_cross_sample_peptide_number; } AutomaticFilterParameters::~AutomaticFilterParameters() { - } -void AutomaticFilterParameters::setFilterPeptideEvalue( pappso::pappso_double evalue) { - _filter_minimum_peptide_evalue = evalue; +void +AutomaticFilterParameters::setFilterPeptideEvalue(pappso::pappso_double evalue) +{ + _filter_minimum_peptide_evalue = evalue; } -void AutomaticFilterParameters::setFilterProteinEvalue( pappso::pappso_double evalue) { - _filter_minimum_protein_evalue = evalue; +void +AutomaticFilterParameters::setFilterProteinEvalue(pappso::pappso_double evalue) +{ + _filter_minimum_protein_evalue = evalue; } -void AutomaticFilterParameters::setFilterMinimumPeptidePerMatch(unsigned int number) { - _filter_minimum_peptide_per_match = number; +void +AutomaticFilterParameters::setFilterMinimumPeptidePerMatch(unsigned int number) +{ + _filter_minimum_peptide_per_match = number; } -void AutomaticFilterParameters::setFilterCrossSamplePeptideNumber(bool cross) { - _filter_is_cross_sample_peptide_number = cross; +void +AutomaticFilterParameters::setFilterCrossSamplePeptideNumber(bool cross) +{ + _filter_is_cross_sample_peptide_number = cross; } -pappso::pappso_double AutomaticFilterParameters::getFilterPeptideEvalue() const { - return (_filter_minimum_peptide_evalue ); +pappso::pappso_double +AutomaticFilterParameters::getFilterPeptideEvalue() const +{ + return (_filter_minimum_peptide_evalue); } -pappso::pappso_double AutomaticFilterParameters::getFilterProteinEvalue() const { - return ( _filter_minimum_protein_evalue ); +pappso::pappso_double +AutomaticFilterParameters::getFilterProteinEvalue() const +{ + return (_filter_minimum_protein_evalue); } -unsigned int AutomaticFilterParameters::getFilterMinimumPeptidePerMatch()const { - return (_filter_minimum_peptide_per_match ); +unsigned int +AutomaticFilterParameters::getFilterMinimumPeptidePerMatch() const +{ + return (_filter_minimum_peptide_per_match); } -bool AutomaticFilterParameters::getFilterCrossSamplePeptideNumber()const { - return _filter_is_cross_sample_peptide_number ; +bool +AutomaticFilterParameters::getFilterCrossSamplePeptideNumber() const +{ + return _filter_is_cross_sample_peptide_number; } diff --git a/src/core/automaticfilterparameters.h b/src/core/automaticfilterparameters.h index f76fdabe219bbc2ff21889e53dbe418588539489..b8f1e35622945a3a958052d302067ad99cea0d40 100644 --- a/src/core/automaticfilterparameters.h +++ b/src/core/automaticfilterparameters.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 AUTOMATICFILTERPARAMETERS_H #define AUTOMATICFILTERPARAMETERS_H @@ -27,29 +28,28 @@ class AutomaticFilterParameters { -public: - AutomaticFilterParameters(); - AutomaticFilterParameters(const AutomaticFilterParameters& other); - ~AutomaticFilterParameters(); + public: + AutomaticFilterParameters(); + AutomaticFilterParameters(const AutomaticFilterParameters &other); + ~AutomaticFilterParameters(); - void setFilterPeptideEvalue( pappso::pappso_double evalue); - void setFilterProteinEvalue( pappso::pappso_double evalue); - void setFilterMinimumPeptidePerMatch(unsigned int number); - void setFilterCrossSamplePeptideNumber(bool cross); + void setFilterPeptideEvalue(pappso::pappso_double evalue); + void setFilterProteinEvalue(pappso::pappso_double evalue); + void setFilterMinimumPeptidePerMatch(unsigned int number); + void setFilterCrossSamplePeptideNumber(bool cross); - pappso::pappso_double getFilterPeptideEvalue() const; - pappso::pappso_double getFilterProteinEvalue()const; - unsigned int getFilterMinimumPeptidePerMatch()const; - bool getFilterCrossSamplePeptideNumber()const; + pappso::pappso_double getFilterPeptideEvalue() const; + pappso::pappso_double getFilterProteinEvalue() const; + unsigned int getFilterMinimumPeptidePerMatch() const; + bool getFilterCrossSamplePeptideNumber() const; -private : - - pappso::pappso_double _filter_minimum_peptide_evalue=1; - pappso::pappso_double _filter_minimum_protein_evalue=1; - unsigned int _filter_minimum_peptide_per_match=1; - bool _filter_is_cross_sample_peptide_number=false; + private: + pappso::pappso_double _filter_minimum_peptide_evalue = 1; + pappso::pappso_double _filter_minimum_protein_evalue = 1; + unsigned int _filter_minimum_peptide_per_match = 1; + bool _filter_is_cross_sample_peptide_number = false; }; #endif // AUTOMATICFILTERPARAMETERS_H diff --git a/src/core/identification_sources/identificationdatasource.h b/src/core/identification_sources/identificationdatasource.h index abb4a98b61e5a6e4ed3828c1990081a82e414973..519225b5ff6a9b9a48f7b4c8971a4a03ae7a5f19 100644 --- a/src/core/identification_sources/identificationdatasource.h +++ b/src/core/identification_sources/identificationdatasource.h @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef IDENTIFICATIONDATASOURCE_H #define IDENTIFICATIONDATASOURCE_H @@ -39,106 +40,116 @@ typedef std::shared_ptr<IdentificationDataSource> IdentificationDataSourceSp; class IdentificationDataSource { -public: - - IdentificationDataSource(const QString resource_name); - IdentificationDataSource(const IdentificationDataSource& other); - ~IdentificationDataSource(); - bool operator==(const IdentificationDataSource& other) const; - - PeptideEvidenceStore & getPeptideEvidenceStore(); - const PeptideEvidenceStore & getPeptideEvidenceStore() const; - - void setXmlId(const QString xmlid); - const QString & getXmlId() const; - - /** @brief URL or filename containing identification data - * */ - const QString & getResourceName () const; - - /** @brief get biological sample name - * */ - const QString getSampleName () const; - void setMsRunSp (MsRunSp ms_run_sp); - MsRunSp getMsRunSp () const; - /** @brief get the spectrum with scan number - * */ - virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const; - - - /** \brief read source content to store it in project - */ - virtual void parseTo(Project* p_project)=0; - - /** \brief set identification engine - */ - virtual void setIdentificationEngine(IdentificationEngine engine); - - /** \brief identification engine - */ - virtual IdentificationEngine getIdentificationEngine() const; - - /** \brief identification engine name - */ - const QString getIdentificationEngineName() const; - - /** \brief identification engine version - */ - virtual const QString& getIdentificationEngineVersion() const; - /** \brief set identification engine version - */ - virtual void setIdentificationEngineVersion(const QString& version); - - /** \brief set identification engine parameter value - */ - virtual void setIdentificationEngineParam(IdentificationEngineParam param, const QVariant& value); - - - /** \brief get specific identification engine parameter value - */ - virtual const QVariant getIdentificationEngineParam(IdentificationEngineParam param) const; - - - /** \brief set identification engine statistics - * any statistics on this identification run that can be told by the identification engine - */ - virtual void setIdentificationEngineStatistics(IdentificationEngineStatistics param, const QVariant& value); - - - /** \brief get specific identification engine statistics value - */ - virtual const QVariant getIdentificationEngineStatistics(IdentificationEngineStatistics param) const; - - /** \brief add Fastafile used by the identification engine - */ - void addFastaFile (FastaFileSp file); - - const std::vector<FastaFileSp> & getFastaFileList() const; - - - /** \brief get identification engine statistics map - */ - virtual const std::map<IdentificationEngineStatistics, QVariant> & getIdentificationEngineStatisticsMap() const; - - /** \brief get identification engine param map - */ - virtual const std::map<IdentificationEngineParam, QVariant> & getIdentificationEngineParamMap() const; - - virtual const bool isValid(const PeptideEvidence * p_peptide_evidence, const AutomaticFilterParameters & automatic_filter_parameters) const; - -protected : - QString _resource_name; - IdentificationEngine _engine = IdentificationEngine::unknown; -private : - //static std::map<QString, pappso::MsRunIdSp> _map_msrunidsp; - QString _xml_id; - QString _version; - MsRunSp _ms_run_sp = nullptr; - std::map<IdentificationEngineParam, QVariant> _params; - std::map<IdentificationEngineStatistics, QVariant> _param_stats; - std::vector<FastaFileSp> _fastafile_list; - - PeptideEvidenceStore _peptide_evidence_store; + public: + IdentificationDataSource(const QString resource_name); + IdentificationDataSource(const IdentificationDataSource &other); + ~IdentificationDataSource(); + bool operator==(const IdentificationDataSource &other) const; + + PeptideEvidenceStore &getPeptideEvidenceStore(); + const PeptideEvidenceStore &getPeptideEvidenceStore() const; + + void setXmlId(const QString xmlid); + const QString &getXmlId() const; + + /** @brief URL or filename containing identification data + * */ + const QString &getResourceName() const; + + /** @brief get biological sample name + * */ + const QString getSampleName() const; + void setMsRunSp(MsRunSp ms_run_sp); + MsRunSp getMsRunSp() const; + /** @brief get the spectrum with scan number + * */ + virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const; + + + /** \brief read source content to store it in project + */ + virtual void parseTo(Project *p_project) = 0; + + /** \brief set identification engine + */ + virtual void setIdentificationEngine(IdentificationEngine engine); + + /** \brief identification engine + */ + virtual IdentificationEngine getIdentificationEngine() const; + + /** \brief identification engine name + */ + const QString getIdentificationEngineName() const; + + /** \brief identification engine version + */ + virtual const QString &getIdentificationEngineVersion() const; + /** \brief set identification engine version + */ + virtual void setIdentificationEngineVersion(const QString &version); + + /** \brief set identification engine parameter value + */ + virtual void setIdentificationEngineParam(IdentificationEngineParam param, + const QVariant &value); + + + /** \brief get specific identification engine parameter value + */ + virtual const QVariant + getIdentificationEngineParam(IdentificationEngineParam param) const; + + + /** \brief set identification engine statistics + * any statistics on this identification run that can be told by the + * identification engine + */ + virtual void + setIdentificationEngineStatistics(IdentificationEngineStatistics param, + const QVariant &value); + + + /** \brief get specific identification engine statistics value + */ + virtual const QVariant + getIdentificationEngineStatistics(IdentificationEngineStatistics param) const; + + /** \brief add Fastafile used by the identification engine + */ + void addFastaFile(FastaFileSp file); + + const std::vector<FastaFileSp> &getFastaFileList() const; + + + /** \brief get identification engine statistics map + */ + virtual const std::map<IdentificationEngineStatistics, QVariant> & + getIdentificationEngineStatisticsMap() const; + + /** \brief get identification engine param map + */ + virtual const std::map<IdentificationEngineParam, QVariant> & + getIdentificationEngineParamMap() const; + + virtual const bool + isValid(const PeptideEvidence *p_peptide_evidence, + const AutomaticFilterParameters &automatic_filter_parameters) const; + + protected: + QString _resource_name; + IdentificationEngine _engine = IdentificationEngine::unknown; + + private: + // static std::map<QString, pappso::MsRunIdSp> _map_msrunidsp; + QString _xml_id; + QString _version; + MsRunSp _ms_run_sp = nullptr; + std::map<IdentificationEngineParam, QVariant> _params; + std::map<IdentificationEngineStatistics, QVariant> _param_stats; + std::vector<FastaFileSp> _fastafile_list; + + PeptideEvidenceStore _peptide_evidence_store; }; #endif // IDENTIFICATIONDATASOURCE_H diff --git a/src/core/identification_sources/identificationmascotdatfile.cpp b/src/core/identification_sources/identificationmascotdatfile.cpp index 459288fc0885774ea50763a87573eeb337827dc2..01e804a3d1f54627f28c00628559c9be54f400a7 100644 --- a/src/core/identification_sources/identificationmascotdatfile.cpp +++ b/src/core/identification_sources/identificationmascotdatfile.cpp @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "identificationmascotdatfile.h" @@ -33,75 +34,98 @@ #include "../project.h" #include "../../input/mascot/mascotdatparser.h" -IdentificationMascotDatFile::IdentificationMascotDatFile(const QFileInfo & mascot_dat_file) : IdentificationDataSource(mascot_dat_file.absoluteFilePath()), _mascot_dat_file(mascot_dat_file) +IdentificationMascotDatFile::IdentificationMascotDatFile( + const QFileInfo &mascot_dat_file) + : IdentificationDataSource(mascot_dat_file.absoluteFilePath()) + , _mascot_dat_file(mascot_dat_file) { - _engine = IdentificationEngine::mascot; + _engine = IdentificationEngine::mascot; } -IdentificationMascotDatFile::IdentificationMascotDatFile(const IdentificationMascotDatFile& other) : IdentificationDataSource(other),_mascot_dat_file (other._mascot_dat_file) +IdentificationMascotDatFile::IdentificationMascotDatFile( + const IdentificationMascotDatFile &other) + : IdentificationDataSource(other), _mascot_dat_file(other._mascot_dat_file) { - _engine = IdentificationEngine::mascot; + _engine = IdentificationEngine::mascot; } IdentificationMascotDatFile::~IdentificationMascotDatFile() { - } -bool IdentificationMascotDatFile::operator==(const IdentificationMascotDatFile& other) const +bool +IdentificationMascotDatFile:: +operator==(const IdentificationMascotDatFile &other) const { - } -pappso::SpectrumSp IdentificationMascotDatFile::getSpectrumSp(unsigned int scan_number) const { - pappso::SpectrumSp spectrum_sp = IdentificationDataSource::getSpectrumSp(scan_number); - return spectrum_sp; +pappso::SpectrumSp +IdentificationMascotDatFile::getSpectrumSp(unsigned int scan_number) const +{ + pappso::SpectrumSp spectrum_sp = + IdentificationDataSource::getSpectrumSp(scan_number); + return spectrum_sp; } -void IdentificationMascotDatFile::parseTo(Project* p_project) { - qDebug() << "IdentificationMascotDatFile::parseTo begin"; - - qDebug() << "Read Mascot dat result file '" << _mascot_dat_file.absoluteFilePath() << "'"; - - MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(QFileInfo(_mascot_dat_file).baseName()); - setMsRunSp(msrun_sp); - std::vector<IdentificationGroup *> identification_list = 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(); +void +IdentificationMascotDatFile::parseTo(Project *p_project) +{ + qDebug() << "IdentificationMascotDatFile::parseTo begin"; + + qDebug() << "Read Mascot dat result file '" + << _mascot_dat_file.absoluteFilePath() << "'"; + + MsRunSp msrun_sp = p_project->getMsRunStore().getInstance( + QFileInfo(_mascot_dat_file).baseName()); + setMsRunSp(msrun_sp); + std::vector<IdentificationGroup *> identification_list = + 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 + { + 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; + 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(); + if(identification_group_p == nullptr) + { + identification_group_p = p_project->newIdentificationGroup(); } } - identification_group_p->addIdentificationDataSourceP(this); - MascotDatParser mascot_parser(p_project, identification_group_p, this); + identification_group_p->addIdentificationDataSourceP(this); + MascotDatParser mascot_parser(p_project, identification_group_p, this); - QFile qfile(_mascot_dat_file.absoluteFilePath()); - mascot_parser.parse(&qfile); - - qfile.close(); + QFile qfile(_mascot_dat_file.absoluteFilePath()); + mascot_parser.parse(&qfile); - qDebug() << "IdentificationMascotDatFile::parseTo end"; + qfile.close(); + + qDebug() << "IdentificationMascotDatFile::parseTo end"; } /* -const bool IdentificationMascotDatFile::isValid(const PeptideEvidence * p_peptide_evidence, const AutomaticFilterParameters & automatic_filter_parameters) const { - +const bool IdentificationMascotDatFile::isValid(const PeptideEvidence * +p_peptide_evidence, const AutomaticFilterParameters & +automatic_filter_parameters) const { + return true; } */ diff --git a/src/core/identification_sources/identificationmascotdatfile.h b/src/core/identification_sources/identificationmascotdatfile.h index 4c6a8d2539cb8fadeff3b8b7dc5e24142465d9fd..a1d856f03c681a6f85555051b74500f9a5601803 100644 --- a/src/core/identification_sources/identificationmascotdatfile.h +++ b/src/core/identification_sources/identificationmascotdatfile.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 IDENTIFICATIONMASCOTDATFILE_H #define IDENTIFICATIONMASCOTDATFILE_H @@ -33,21 +34,24 @@ #include "identificationdatasource.h" #include <QFileInfo> -class IdentificationMascotDatFile: public IdentificationDataSource +class IdentificationMascotDatFile : public IdentificationDataSource { -public: - IdentificationMascotDatFile(const QFileInfo & mascot_dat_file); - IdentificationMascotDatFile(const IdentificationMascotDatFile& other); - ~IdentificationMascotDatFile(); - bool operator==(const IdentificationMascotDatFile& other) const; - - virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const override; - virtual void parseTo(Project* p_project) override; - - //virtual const bool isValid(const PeptideEvidence * p_peptide_evidence, const AutomaticFilterParameters & automatic_filter_parameters) const override; - -private: - const QFileInfo _mascot_dat_file; + public: + IdentificationMascotDatFile(const QFileInfo &mascot_dat_file); + IdentificationMascotDatFile(const IdentificationMascotDatFile &other); + ~IdentificationMascotDatFile(); + bool operator==(const IdentificationMascotDatFile &other) const; + + virtual pappso::SpectrumSp + getSpectrumSp(unsigned int scan_number) const override; + virtual void parseTo(Project *p_project) override; + + // virtual const bool isValid(const PeptideEvidence * p_peptide_evidence, + // const AutomaticFilterParameters & automatic_filter_parameters) const + // override; + + private: + const QFileInfo _mascot_dat_file; }; #endif // IDENTIFICATIONMASCOTDATFILE_H diff --git a/src/core/identification_sources/identificationpepxmlfile.h b/src/core/identification_sources/identificationpepxmlfile.h index 168c6dc043e6d174edf824eb34db1f94316096ad..2a66e24c6161be2b82e2964e914199fbd72f3a16 100644 --- a/src/core/identification_sources/identificationpepxmlfile.h +++ b/src/core/identification_sources/identificationpepxmlfile.h @@ -6,24 +6,24 @@ */ /******************************************************************************* -* Copyright (c) 2018 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/>. -* -******************************************************************************/ + * Copyright (c) 2018 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/>. + * + ******************************************************************************/ #ifndef IDENTIFICATIONPEPXMLFILE_H #define IDENTIFICATIONPEPXMLFILE_H @@ -31,21 +31,24 @@ #include "identificationdatasource.h" #include <QFileInfo> -class IdentificationPepXmlFile: public IdentificationDataSource +class IdentificationPepXmlFile : public IdentificationDataSource { -public: - IdentificationPepXmlFile(const QFileInfo & mascot_dat_file); - IdentificationPepXmlFile(const IdentificationPepXmlFile& other); - ~IdentificationPepXmlFile(); - bool operator==(const IdentificationPepXmlFile& other) const; - - virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const override; - virtual void parseTo(Project* p_project) override; - - //virtual const bool isValid(const PeptideEvidence * p_peptide_evidence, const AutomaticFilterParameters & automatic_filter_parameters) const override; - -private: - const QFileInfo _pep_xml_file; + public: + IdentificationPepXmlFile(const QFileInfo &mascot_dat_file); + IdentificationPepXmlFile(const IdentificationPepXmlFile &other); + ~IdentificationPepXmlFile(); + bool operator==(const IdentificationPepXmlFile &other) const; + + virtual pappso::SpectrumSp + getSpectrumSp(unsigned int scan_number) const override; + virtual void parseTo(Project *p_project) override; + + // virtual const bool isValid(const PeptideEvidence * p_peptide_evidence, + // const AutomaticFilterParameters & automatic_filter_parameters) const + // override; + + private: + const QFileInfo _pep_xml_file; }; #endif // IDENTIFICATIONPEPXMLFILE_H diff --git a/src/core/identification_sources/identificationpwizfile.h b/src/core/identification_sources/identificationpwizfile.h index 01da96a8c9f8369255d34688982f161a88f0b421..183041351028688f2098e62dcb6cefb45b667697 100644 --- a/src/core/identification_sources/identificationpwizfile.h +++ b/src/core/identification_sources/identificationpwizfile.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef IDENTIFICATIONPWIZFILE_H #define IDENTIFICATIONPWIZFILE_H @@ -34,19 +35,20 @@ #include "identificationdatasource.h" #include <QFileInfo> -class IdentificationPwizFile: public IdentificationDataSource +class IdentificationPwizFile : public IdentificationDataSource { -public: - IdentificationPwizFile(const QFileInfo & ident_file); - IdentificationPwizFile(const IdentificationPwizFile& other); - ~IdentificationPwizFile(); - bool operator==(const IdentificationPwizFile& other) const; - - virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const override; - virtual void parseTo(Project* p_project) override; - -private: - const QFileInfo _ident_file; + public: + IdentificationPwizFile(const QFileInfo &ident_file); + IdentificationPwizFile(const IdentificationPwizFile &other); + ~IdentificationPwizFile(); + bool operator==(const IdentificationPwizFile &other) const; + + virtual pappso::SpectrumSp + getSpectrumSp(unsigned int scan_number) const override; + virtual void parseTo(Project *p_project) override; + + private: + const QFileInfo _ident_file; }; #endif // IDENTIFICATIONPWIZFILE_H diff --git a/src/core/identification_sources/identificationxtandemfile.cpp b/src/core/identification_sources/identificationxtandemfile.cpp index 09da37165a928cf37f7612f232f2e37604314583..74d6313864a4cb935ac753826fccc9a6d5578995 100644 --- a/src/core/identification_sources/identificationxtandemfile.cpp +++ b/src/core/identification_sources/identificationxtandemfile.cpp @@ -1,108 +1,137 @@ /******************************************************************************* -* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #include "identificationxtandemfile.h" #include <pappsomspp/pappsoexception.h> #include "../project.h" #include "../../input/xtandemsaxhandler.h" -IdentificationXtandemFile::IdentificationXtandemFile(const QFileInfo & xtandem_file) : IdentificationDataSource(xtandem_file.absoluteFilePath()), _xtandem_file(xtandem_file) +IdentificationXtandemFile::IdentificationXtandemFile( + const QFileInfo &xtandem_file) + : IdentificationDataSource(xtandem_file.absoluteFilePath()) + , _xtandem_file(xtandem_file) { - _engine = IdentificationEngine::XTandem; + _engine = IdentificationEngine::XTandem; } -IdentificationXtandemFile::IdentificationXtandemFile(const IdentificationXtandemFile& other) : IdentificationDataSource(other),_xtandem_file (other._xtandem_file) +IdentificationXtandemFile::IdentificationXtandemFile( + const IdentificationXtandemFile &other) + : IdentificationDataSource(other), _xtandem_file(other._xtandem_file) { - _engine = IdentificationEngine::XTandem; + _engine = IdentificationEngine::XTandem; } IdentificationXtandemFile::~IdentificationXtandemFile() { - } -bool IdentificationXtandemFile::operator==(const IdentificationXtandemFile& other) const +bool +IdentificationXtandemFile:: +operator==(const IdentificationXtandemFile &other) const { - } -pappso::SpectrumSp IdentificationXtandemFile::getSpectrumSp(unsigned int scan_number) const { - pappso::SpectrumSp spectrum_sp = IdentificationDataSource::getSpectrumSp(scan_number); - return spectrum_sp; +pappso::SpectrumSp +IdentificationXtandemFile::getSpectrumSp(unsigned int scan_number) const +{ + pappso::SpectrumSp spectrum_sp = + IdentificationDataSource::getSpectrumSp(scan_number); + return spectrum_sp; } -void IdentificationXtandemFile::parseTo(Project* p_project) { - qDebug() << "IdentificationXtandemFile::parseTo begin"; - - qDebug() << "Read X!Tandem XML result file '" << _xtandem_file.absoluteFilePath() << "'"; - - MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(QFileInfo(_xtandem_file).baseName()); - setMsRunSp(msrun_sp); - std::vector<IdentificationGroup *> identification_list = 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(); +void +IdentificationXtandemFile::parseTo(Project *p_project) +{ + qDebug() << "IdentificationXtandemFile::parseTo begin"; + + qDebug() << "Read X!Tandem XML result file '" + << _xtandem_file.absoluteFilePath() << "'"; + + MsRunSp msrun_sp = + p_project->getMsRunStore().getInstance(QFileInfo(_xtandem_file).baseName()); + setMsRunSp(msrun_sp); + std::vector<IdentificationGroup *> identification_list = + 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 + { + 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; + 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(); + if(identification_group_p == nullptr) + { + identification_group_p = p_project->newIdentificationGroup(); } } - - identification_group_p->addIdentificationDataSourceP(this); - XtandemSaxHandler * parser = new XtandemSaxHandler(p_project, identification_group_p, this); - QXmlSimpleReader simplereader; - simplereader.setContentHandler(parser); - simplereader.setErrorHandler(parser); + identification_group_p->addIdentificationDataSourceP(this); + XtandemSaxHandler *parser = + new XtandemSaxHandler(p_project, identification_group_p, this); - QFile qfile(_xtandem_file.absoluteFilePath()); - QXmlInputSource xmlInputSource(&qfile); + QXmlSimpleReader simplereader; + simplereader.setContentHandler(parser); + simplereader.setErrorHandler(parser); - if (simplereader.parse(xmlInputSource)) { + QFile qfile(_xtandem_file.absoluteFilePath()); + QXmlInputSource xmlInputSource(&qfile); - qfile.close(); - } else { - qDebug() << parser->errorString(); - // throw PappsoException( - // QObject::tr("error reading tandem XML result file :\n").append( - // parser->errorString())); + if(simplereader.parse(xmlInputSource)) + { - qfile.close(); - - throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(_xtandem_file.absoluteFilePath()).arg(parser->errorString())); + qfile.close(); + } + else + { + qDebug() << parser->errorString(); + // throw PappsoException( + // QObject::tr("error reading tandem XML result file :\n").append( + // parser->errorString())); + + qfile.close(); + + throw pappso::PappsoException( + QObject::tr("Error reading %1 XPIP file :\n %2") + .arg(_xtandem_file.absoluteFilePath()) + .arg(parser->errorString())); } - qDebug() << "IdentificationXtandemFile::parseTo end"; + qDebug() << "IdentificationXtandemFile::parseTo end"; } diff --git a/src/core/identification_sources/identificationxtandemfile.h b/src/core/identification_sources/identificationxtandemfile.h index 6a84fd71285727341f72d4359ce0355a8c4741ad..751eb6c9c6503150ab1b07beda784c75a6889661 100644 --- a/src/core/identification_sources/identificationxtandemfile.h +++ b/src/core/identification_sources/identificationxtandemfile.h @@ -1,44 +1,46 @@ /******************************************************************************* -* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef IDENTIFICATIONXTANDEMFILE_H #define IDENTIFICATIONXTANDEMFILE_H #include "identificationdatasource.h" #include <QFileInfo> -class IdentificationXtandemFile: public IdentificationDataSource +class IdentificationXtandemFile : public IdentificationDataSource { -public: - IdentificationXtandemFile(const QFileInfo & xtandem_file); - IdentificationXtandemFile(const IdentificationXtandemFile& other); - ~IdentificationXtandemFile(); - bool operator==(const IdentificationXtandemFile& other) const; + public: + IdentificationXtandemFile(const QFileInfo &xtandem_file); + IdentificationXtandemFile(const IdentificationXtandemFile &other); + ~IdentificationXtandemFile(); + bool operator==(const IdentificationXtandemFile &other) const; - virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const override; - virtual void parseTo(Project* p_project) override; - -private: - const QFileInfo _xtandem_file; + virtual pappso::SpectrumSp + getSpectrumSp(unsigned int scan_number) const override; + virtual void parseTo(Project *p_project) override; + + private: + const QFileInfo _xtandem_file; }; #endif // IDENTIFICATIONXTANDEMFILE_H diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index ef5736adff4de3aa6544b5821218f9969e75df30..1f805b5e69e38909f4ea7352164ff997acafc84f 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -130,8 +130,7 @@ unsigned int IdentificationGroup::countDecoyProteinMatch(ValidationState state) const { return std::count_if( - _protein_match_list.begin(), - _protein_match_list.end(), + _protein_match_list.begin(), _protein_match_list.end(), [state](const ProteinMatch *p_protein_match) { if((p_protein_match->getProteinXtpSp().get()->isDecoy()) && (p_protein_match->getValidationState() >= state)) @@ -210,8 +209,7 @@ IdentificationGroup::countDecoyPeptideMatch(ValidationState state) const unsigned int IdentificationGroup::countProteinMatch(ValidationState state) const { - return std::count_if(_protein_match_list.begin(), - _protein_match_list.end(), + return std::count_if(_protein_match_list.begin(), _protein_match_list.end(), [state](const ProteinMatch *p_protein_match) { if(p_protein_match->getValidationState() >= state) { @@ -304,8 +302,8 @@ IdentificationGroup::addIdentificationDataSourceP( IdentificationDataSource *p_identification_source) { addMsRunSp(p_identification_source->getMsRunSp()); - auto it = std::find( - _id_source_list.begin(), _id_source_list.end(), p_identification_source); + auto it = std::find(_id_source_list.begin(), _id_source_list.end(), + p_identification_source); if(it == _id_source_list.end()) { _id_source_list.push_back(p_identification_source); @@ -355,8 +353,7 @@ IdentificationGroup::countSubGroup() const void IdentificationGroup::collectMhDelta( - std::vector<pappso::pappso_double> &delta_list, - pappso::PrecisionUnit unit, + std::vector<pappso::pappso_double> &delta_list, pappso::PrecisionUnit unit, ValidationState state) const { std::set<const PeptideEvidence *> peptide_evidence_list; @@ -469,9 +466,7 @@ IdentificationGroup::getProteinFdr(ValidationState state) const void IdentificationGroup::getSameXicPeptideEvidenceList( std::vector<const PeptideEvidence *> &peptide_evidence_list, - const MsRun *p_msrun, - const PeptideXtp *p_peptide, - unsigned int charge) const + const MsRun *p_msrun, const PeptideXtp *p_peptide, unsigned int charge) const { if(!contains(p_msrun)) return; @@ -480,8 +475,8 @@ IdentificationGroup::getSameXicPeptideEvidenceList( if(p_msrun == p_identification_source->getMsRunSp().get()) { p_identification_source->getPeptideEvidenceStore() - .getSameXicPeptideEvidenceList( - peptide_evidence_list, p_msrun, p_peptide, charge); + .getSameXicPeptideEvidenceList(peptide_evidence_list, p_msrun, + p_peptide, charge); } } } diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index eac9dd5fa7e572b8bea424846dbe18b0755e76f7..43e03e2bd4e5088115bd930ce990c92ba2220bda 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.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 + ******************************************************************************/ #include <memory> #include <QFileInfo> #include "proteinmatch.h" @@ -37,134 +38,151 @@ class Project; -/** @brief an identification group contains one or more sample to consider for grouping +/** @brief an identification group contains one or more sample to consider for + * grouping */ class IdentificationGroup { -public: - IdentificationGroup(Project * project); - ~IdentificationGroup(); - - ProteinMatch * getProteinMatchInstance(const QString accession); - const GroupStore & getGroupStore() const; - void addProteinMatch(ProteinMatch * protein_match); - std::vector<ProteinMatch *> & getProteinMatchList(); - const std::vector<ProteinMatch *> & getProteinMatchList() const; - void addIdentificationDataSourceP(IdentificationDataSource * p_identification_source); - - const PtmGroupingExperiment * getPtmGroupingExperiment() const; - - /** @brief compute proto NSAF sum within msrun - * Warning: this is not NSAF, just a part - * @param p_msrun_id pointer on the msrun to get NSAF. - * */ - pappso::pappso_double computeProtoNsafSum(const MsRun * p_msrun_id) const; - - /** @brief count groups - * */ - std::size_t countGroup()const; - - /** @brief count subgroups - * */ - std::size_t countSubGroup()const; - - /** @brief count proteins - * */ - unsigned int countProteinMatch(ValidationState state) const; - - /** @brief count decoy proteins - * */ - unsigned int countDecoyProteinMatch(ValidationState state) const; - - /** @brief count peptide evidences (peptide spectrum match + identification engine) - * */ - unsigned int countPeptideEvidence(ValidationState state) const; - - /** @brief count peptide evidences (peptide spectrum match + identification engine) - * */ - unsigned int countDecoyPeptideEvidence(ValidationState state) const; - - /** @brief count peptide match (peptide spectrum match + protein match) - * */ - unsigned int countPeptideMatch(ValidationState state) const; - - /** @brief count decoy peptide match - * */ - unsigned int countDecoyPeptideMatch(ValidationState state) const; - - /** @brief count distinct peptides overall samples(peptide+mass) including peptides from decoy proteins - * */ - unsigned int countPeptideMass(ValidationState state) const; - - /** @brief count peptide (peptide+mass+sample) including peptides from decoy proteins - * */ - unsigned int countPeptideMassSample(ValidationState state) const; - - /** @brief count peptide (peptide+mass+sample) only on decoy proteins - * */ - unsigned int countDecoyPeptideMassSample(ValidationState state) const; - - /** @brief get False Discovery Rate of proteins - */ - pappso::pappso_double getProteinFdr(ValidationState state = ValidationState::valid) const; - - /** @brief get False Discovery Rate of peptide/mass (unique sequence+modifications) - */ - pappso::pappso_double getPeptideMassFdr(ValidationState state = ValidationState::valid) const; - - - /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks - * */ - void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); - - void startGrouping (const GroupingType & grouping_type, WorkMonitorInterface * p_work_monitor); - /** @brief creates a new PTM grouping experiment - * */ - void startPtmGrouping (); - - const std::vector<MsRunSp> & getMsRunSpList() const; - const std::vector<IdentificationDataSource *> & getIdentificationDataSourceList() const; - - /** @brief get tab name for qtabwidget - * */ - const QString getTabName() const; - - bool contains (const MsRun * p_msrun) const; - bool containSample (const QString & sample) const; - - - /** @brief collect mass delta between theoretical mass and observed mass - * each peptide evidence is only counted once - */ - void collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const; - - - /** @brief look for a peptide in the same XIC - * @param peptide_evidence_list the peptide evidence list to build - * @param p_msrun MSrun to look for - * @param p_peptide peptide to look for - * @param charge charge to look for - */ - void getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const; - -private : - - void addMsRunSp(MsRunSp ms_run_sp); -private : - GroupingExperiment * _p_grp_experiment= nullptr; - PtmGroupingExperiment * _p_grp_ptm_experiment= nullptr; - - Project * _p_project; - - GroupStore _group_store; + public: + IdentificationGroup(Project *project); + ~IdentificationGroup(); + + ProteinMatch *getProteinMatchInstance(const QString accession); + const GroupStore &getGroupStore() const; + void addProteinMatch(ProteinMatch *protein_match); + std::vector<ProteinMatch *> &getProteinMatchList(); + const std::vector<ProteinMatch *> &getProteinMatchList() const; + void addIdentificationDataSourceP( + IdentificationDataSource *p_identification_source); + + const PtmGroupingExperiment *getPtmGroupingExperiment() const; + + /** @brief compute proto NSAF sum within msrun + * Warning: this is not NSAF, just a part + * @param p_msrun_id pointer on the msrun to get NSAF. + * */ + pappso::pappso_double computeProtoNsafSum(const MsRun *p_msrun_id) const; + + /** @brief count groups + * */ + std::size_t countGroup() const; + + /** @brief count subgroups + * */ + std::size_t countSubGroup() const; + + /** @brief count proteins + * */ + unsigned int countProteinMatch(ValidationState state) const; + + /** @brief count decoy proteins + * */ + unsigned int countDecoyProteinMatch(ValidationState state) const; + + /** @brief count peptide evidences (peptide spectrum match + identification + * engine) + * */ + unsigned int countPeptideEvidence(ValidationState state) const; + + /** @brief count peptide evidences (peptide spectrum match + identification + * engine) + * */ + unsigned int countDecoyPeptideEvidence(ValidationState state) const; + + /** @brief count peptide match (peptide spectrum match + protein match) + * */ + unsigned int countPeptideMatch(ValidationState state) const; + + /** @brief count decoy peptide match + * */ + unsigned int countDecoyPeptideMatch(ValidationState state) const; + + /** @brief count distinct peptides overall samples(peptide+mass) including + * peptides from decoy proteins + * */ + unsigned int countPeptideMass(ValidationState state) const; + + /** @brief count peptide (peptide+mass+sample) including peptides from decoy + * proteins + * */ + unsigned int countPeptideMassSample(ValidationState state) const; + + /** @brief count peptide (peptide+mass+sample) only on decoy proteins + * */ + unsigned int countDecoyPeptideMassSample(ValidationState state) const; + + /** @brief get False Discovery Rate of proteins + */ + pappso::pappso_double + getProteinFdr(ValidationState state = ValidationState::valid) const; + + /** @brief get False Discovery Rate of peptide/mass (unique + * sequence+modifications) + */ + pappso::pappso_double + getPeptideMassFdr(ValidationState state = ValidationState::valid) const; + + + /** @brief validate or invalidate peptides and proteins based automatic + * filters and manual checks + * */ + void updateAutomaticFilters( + const AutomaticFilterParameters &automatic_filter_parameters); + + void startGrouping(const GroupingType &grouping_type, + WorkMonitorInterface *p_work_monitor); + /** @brief creates a new PTM grouping experiment + * */ + void startPtmGrouping(); + + const std::vector<MsRunSp> &getMsRunSpList() const; + const std::vector<IdentificationDataSource *> & + getIdentificationDataSourceList() const; + + /** @brief get tab name for qtabwidget + * */ + const QString getTabName() const; + + bool contains(const MsRun *p_msrun) const; + bool containSample(const QString &sample) const; + + + /** @brief collect mass delta between theoretical mass and observed mass + * each peptide evidence is only counted once + */ + void collectMhDelta(std::vector<pappso::pappso_double> &delta_list, + pappso::PrecisionUnit unit, ValidationState state) const; - std::vector<ProteinMatch *> _protein_match_list; - std::vector<MsRunSp> _ms_run_list; - std::vector<IdentificationDataSource *> _id_source_list; + /** @brief look for a peptide in the same XIC + * @param peptide_evidence_list the peptide evidence list to build + * @param p_msrun MSrun to look for + * @param p_peptide peptide to look for + * @param charge charge to look for + */ + void getSameXicPeptideEvidenceList( + std::vector<const PeptideEvidence *> &peptide_evidence_list, + const MsRun *p_msrun, const PeptideXtp *p_peptide, + unsigned int charge) const; - std::map<QString, ProteinMatch *> _cache_accession_protein_match; + private: + void addMsRunSp(MsRunSp ms_run_sp); + + private: + GroupingExperiment *_p_grp_experiment = nullptr; + PtmGroupingExperiment *_p_grp_ptm_experiment = nullptr; + + Project *_p_project; + + GroupStore _group_store; + + std::vector<ProteinMatch *> _protein_match_list; + + std::vector<MsRunSp> _ms_run_list; + std::vector<IdentificationDataSource *> _id_source_list; + + std::map<QString, ProteinMatch *> _cache_accession_protein_match; }; #endif // IDENTIFICATIONGROUP_H diff --git a/src/core/labeling/label.cpp b/src/core/labeling/label.cpp index c0a50b11eace2add49ea370a4b796497887dfbfc..4eb7b7b22f116fd4ccba995fe7f60a9781d5604f 100644 --- a/src/core/labeling/label.cpp +++ b/src/core/labeling/label.cpp @@ -6,26 +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 "label.h" #include "../../utils/utils.h" @@ -33,78 +34,111 @@ #include <pappsomspp/pappsoexception.h> #include <QDebug> -Label::Label(QDomNode & label_node) { - //<isotope_label id="light"> - _xml_id =label_node.toElement().attribute("id"); - qDebug() <<"Label::Label begin "<<_xml_id; - try { - //<mod at="Nter" value="28.0" acc="MOD:00429"/> - //<mod at="K" value="28.0" acc="MOD:00429"/> - QDomNode child = label_node.firstChild(); - while (!child.isNull()) { - if (child.toElement().tagName() == "mod") { - if (child.toElement().attribute("acc").isEmpty()) { - throw pappso::PappsoException(QObject::tr("acc attribute is empty : PSIMOD accession required")); +Label::Label(QDomNode &label_node) +{ + //<isotope_label id="light"> + _xml_id = label_node.toElement().attribute("id"); + qDebug() << "Label::Label begin " << _xml_id; + try + { + //<mod at="Nter" value="28.0" acc="MOD:00429"/> + //<mod at="K" value="28.0" acc="MOD:00429"/> + QDomNode child = label_node.firstChild(); + while(!child.isNull()) + { + if(child.toElement().tagName() == "mod") + { + if(child.toElement().attribute("acc").isEmpty()) + { + throw pappso::PappsoException(QObject::tr( + "acc attribute is empty : PSIMOD accession required")); } - qDebug() <<"Label::Label mod at="<<child.toElement().attribute("at") << " mod="<< child.toElement().attribute("acc"); - LabelModification label_modification = {child.toElement().attribute("at"), pappso::AaModification::getInstance( child.toElement().attribute("acc"))}; - _modification_list.push_back (label_modification); + qDebug() << "Label::Label mod at=" + << child.toElement().attribute("at") + << " mod=" << child.toElement().attribute("acc"); + LabelModification label_modification = { + child.toElement().attribute("at"), + pappso::AaModification::getInstance( + child.toElement().attribute("acc"))}; + _modification_list.push_back(label_modification); } - child = child.nextSibling(); + child = child.nextSibling(); } } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("error creating Label : %1").arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("error creating Label : %1").arg(error.qwhat())); } } -Label::Label( const Label & other) { - _xml_id = other._xml_id; - _modification_list = other._modification_list; +Label::Label(const Label &other) +{ + _xml_id = other._xml_id; + _modification_list = other._modification_list; } -bool Label::containsAaModificationP(const std::list<pappso::AaModificationP> & modification_set) const { - for (LabelModification label_modification: _modification_list) { - if (std::find(modification_set.begin(), modification_set.end(), label_modification.modification) != modification_set.end()) { - return true; +bool +Label::containsAaModificationP( + const std::list<pappso::AaModificationP> &modification_set) const +{ + for(LabelModification label_modification : _modification_list) + { + if(std::find(modification_set.begin(), modification_set.end(), + label_modification.modification) != modification_set.end()) + { + return true; } } - return false; + return false; } -pappso::PeptideSp Label::getLabeledPeptideSp(const pappso::Peptide * p_peptide) const { - pappso::Peptide peptide(*p_peptide); - for (LabelModification label_modification: _modification_list) { - peptide.removeAaModification(label_modification.modification); +pappso::PeptideSp +Label::getLabeledPeptideSp(const pappso::Peptide *p_peptide) const +{ + pappso::Peptide peptide(*p_peptide); + for(LabelModification label_modification : _modification_list) + { + peptide.removeAaModification(label_modification.modification); } - return (peptide.makePeptideSp()); + return (peptide.makePeptideSp()); } -const QString & Label::getXmlId() const { - return _xml_id; +const QString & +Label::getXmlId() const +{ + return _xml_id; } -const std::vector<LabelModification> & Label::getLabelModifictionList() const { - return _modification_list; +const std::vector<LabelModification> & +Label::getLabelModifictionList() const +{ + return _modification_list; } -void Label::writeMassChroqMl(QXmlStreamWriter* output_stream) const { +void +Label::writeMassChroqMl(QXmlStreamWriter *output_stream) const +{ - //<isotope_label id="iso1"> - output_stream->writeStartElement("isotope_label"); - output_stream->writeAttribute("id",_xml_id); - // <mod at="Nter" value="28.0" acc="MOD:00429"/> - // <mod at="K" value="28.0" acc="MOD:00429"/> - for (const LabelModification label_modification: _modification_list) { - output_stream->writeStartElement("mod"); - output_stream->writeAttribute("at",label_modification.at); - output_stream->writeAttribute("value",Utils::getXmlDouble(label_modification.modification->getMass())); - output_stream->writeAttribute("acc",label_modification.modification->getAccession()); - output_stream->writeEndElement(); - output_stream->writeComment(label_modification.modification->getName()); + //<isotope_label id="iso1"> + output_stream->writeStartElement("isotope_label"); + output_stream->writeAttribute("id", _xml_id); + // <mod at="Nter" value="28.0" acc="MOD:00429"/> + // <mod at="K" value="28.0" acc="MOD:00429"/> + for(const LabelModification label_modification : _modification_list) + { + output_stream->writeStartElement("mod"); + output_stream->writeAttribute("at", label_modification.at); + output_stream->writeAttribute( + "value", + Utils::getXmlDouble(label_modification.modification->getMass())); + output_stream->writeAttribute( + "acc", label_modification.modification->getAccession()); + output_stream->writeEndElement(); + output_stream->writeComment(label_modification.modification->getName()); } - // </isotope_label> - output_stream->writeEndElement(); + // </isotope_label> + output_stream->writeEndElement(); } diff --git a/src/core/labeling/label.h b/src/core/labeling/label.h index 00140c1d8de0197ceaea7bb1c4f5b9a312eebe36..ed21b41c6884825733ea69bcfa9705043f654f7c 100644 --- a/src/core/labeling/label.h +++ b/src/core/labeling/label.h @@ -6,26 +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 + ******************************************************************************/ #ifndef LABEL_H #define LABEL_H @@ -37,27 +38,29 @@ #include <QXmlStreamWriter> -struct LabelModification { - QString at; - pappso::AaModificationP modification; +struct LabelModification +{ + QString at; + pappso::AaModificationP modification; }; class Label { -public: - Label(QDomNode & method_node); - Label( const Label & other); - bool containsAaModificationP(const std::list<pappso::AaModificationP> & modification_set) const; - pappso::PeptideSp getLabeledPeptideSp(const pappso::Peptide * p_peptide) const; - void writeMassChroqMl(QXmlStreamWriter* output_stream) const; - const QString & getXmlId() const; - - const std::vector<LabelModification> & getLabelModifictionList() const; - -private: - QString _xml_id; - std::vector<LabelModification> _modification_list; + public: + Label(QDomNode &method_node); + Label(const Label &other); + bool containsAaModificationP( + const std::list<pappso::AaModificationP> &modification_set) const; + pappso::PeptideSp getLabeledPeptideSp(const pappso::Peptide *p_peptide) const; + void writeMassChroqMl(QXmlStreamWriter *output_stream) const; + const QString &getXmlId() const; + + const std::vector<LabelModification> &getLabelModifictionList() const; + + private: + QString _xml_id; + std::vector<LabelModification> _modification_list; }; #endif // LABEL_H diff --git a/src/core/labeling/labelingmethod.cpp b/src/core/labeling/labelingmethod.cpp index bdd45035d383f1b3dc66441f82e74d9dc8cc2e49..aed64bb8558b1a6ecdf15b906f4a587f86af58c4 100644 --- a/src/core/labeling/labelingmethod.cpp +++ b/src/core/labeling/labelingmethod.cpp @@ -6,118 +6,149 @@ */ /******************************************************************************* -* 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 "labelingmethod.h" #include <pappsomspp/pappsoexception.h> #include <QFile> #include <QDomDocument> -LabelingMethod::LabelingMethod(const QString & method_id):_xml_id(method_id) { +LabelingMethod::LabelingMethod(const QString &method_id) : _xml_id(method_id) +{ - qDebug() <<"LabelingMethod::LabelingMethod begin "<<_xml_id; - QDomDocument *dom = new QDomDocument("labeling_methods"); - QFile xml_doc(":/labeling/resources/catalog_label.xml"); - if(!xml_doc.open(QIODevice::ReadOnly)) + qDebug() << "LabelingMethod::LabelingMethod begin " << _xml_id; + QDomDocument *dom = new QDomDocument("labeling_methods"); + QFile xml_doc(":/labeling/resources/catalog_label.xml"); + if(!xml_doc.open(QIODevice::ReadOnly)) { - //error - throw pappso::PappsoException(QObject::tr("error opening catalog_label resource file")); + // error + throw pappso::PappsoException( + QObject::tr("error opening catalog_label resource file")); } - if (!dom->setContent(&xml_doc)) { - xml_doc.close(); - throw pappso::PappsoException(QObject::tr("error opening catalog_label xml content")); + if(!dom->setContent(&xml_doc)) + { + xml_doc.close(); + throw pappso::PappsoException( + QObject::tr("error opening catalog_label xml content")); } - QDomNode child = dom->documentElement().firstChild(); - while (!child.isNull()) { - if (child.toElement().tagName() == "isotope_label_list") { - if (child.toElement().attribute("id")== _xml_id) { - parseMethod(child); + QDomNode child = dom->documentElement().firstChild(); + while(!child.isNull()) + { + if(child.toElement().tagName() == "isotope_label_list") + { + if(child.toElement().attribute("id") == _xml_id) + { + parseMethod(child); } } - child = child.nextSibling(); + child = child.nextSibling(); } - xml_doc.close(); - delete dom; + xml_doc.close(); + delete dom; } -Label * LabelingMethod::getLabel(const std::list<pappso::AaModificationP> & modification_set) const { - for (Label * p_label: _label_list) { - if (p_label->containsAaModificationP(modification_set)) { - return p_label; +Label * +LabelingMethod::getLabel( + const std::list<pappso::AaModificationP> &modification_set) const +{ + for(Label *p_label : _label_list) + { + if(p_label->containsAaModificationP(modification_set)) + { + return p_label; } } - return nullptr; + return nullptr; } -const QString & LabelingMethod::getXmlId() const { - return _xml_id; +const QString & +LabelingMethod::getXmlId() const +{ + return _xml_id; } -LabelingMethod::LabelingMethod( const LabelingMethod & other):_xml_id(other._xml_id) { - for (Label * p_label: other._label_list) { - _label_list.push_back( new Label(*p_label)); +LabelingMethod::LabelingMethod(const LabelingMethod &other) + : _xml_id(other._xml_id) +{ + for(Label *p_label : other._label_list) + { + _label_list.push_back(new Label(*p_label)); } } -LabelingMethod::~LabelingMethod() { - for (Label * p_label: _label_list) { - delete p_label; +LabelingMethod::~LabelingMethod() +{ + for(Label *p_label : _label_list) + { + delete p_label; } } -LabelingMethodSp LabelingMethod::makeLabelingMethodSp() const { - return std::make_shared<LabelingMethod>(*this); +LabelingMethodSp +LabelingMethod::makeLabelingMethodSp() const +{ + return std::make_shared<LabelingMethod>(*this); } -void LabelingMethod::parseMethod(QDomNode & method_node) { - QDomNode child = method_node.firstChild(); - while (!child.isNull()) { - if (child.toElement().tagName() == "isotope_label") { - _label_list.push_back( new Label(child)); +void +LabelingMethod::parseMethod(QDomNode &method_node) +{ + QDomNode child = method_node.firstChild(); + while(!child.isNull()) + { + if(child.toElement().tagName() == "isotope_label") + { + _label_list.push_back(new Label(child)); } - child = child.nextSibling(); + child = child.nextSibling(); } } -void LabelingMethod::writeMassChroqMl(QXmlStreamWriter* output_stream) const { - //<isotope_label_list> - output_stream->writeStartElement("isotope_label_list"); - output_stream->writeComment(getXmlId()); - /* - <isotope_label id="iso1"> - <mod at="Nter" value="28.0" acc="MOD:00429"/> - <mod at="K" value="28.0" acc="MOD:00429"/> - </isotope_label> - <isotope_label id="iso2"> - <mod at="Nter" value="32.0" /> - <mod at="K" value="32.0" /> - </isotope_label>*/ - for (Label * p_label: _label_list) { - p_label->writeMassChroqMl(output_stream); +void +LabelingMethod::writeMassChroqMl(QXmlStreamWriter *output_stream) const +{ + //<isotope_label_list> + output_stream->writeStartElement("isotope_label_list"); + output_stream->writeComment(getXmlId()); + /* + <isotope_label id="iso1"> + <mod at="Nter" value="28.0" acc="MOD:00429"/> + <mod at="K" value="28.0" acc="MOD:00429"/> + </isotope_label> + <isotope_label id="iso2"> + <mod at="Nter" value="32.0" /> + <mod at="K" value="32.0" /> + </isotope_label>*/ + for(Label *p_label : _label_list) + { + p_label->writeMassChroqMl(output_stream); } - //</isotope_label_list> - output_stream->writeEndElement(); + //</isotope_label_list> + output_stream->writeEndElement(); } -const std::vector<Label *> & LabelingMethod::getLabelList() const { - return _label_list; +const std::vector<Label *> & +LabelingMethod::getLabelList() const +{ + return _label_list; } diff --git a/src/core/labeling/labelingmethod.h b/src/core/labeling/labelingmethod.h index 6d4bf6fbeaa44c6b5f2b351aeaaedacdcb96a1e0..e0b03080cb8aaba302f310e343bad18491a0c8c5 100644 --- a/src/core/labeling/labelingmethod.h +++ b/src/core/labeling/labelingmethod.h @@ -6,26 +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 + ******************************************************************************/ #ifndef LABELINGMETHOD_H #define LABELINGMETHOD_H @@ -41,21 +42,24 @@ typedef std::shared_ptr<LabelingMethod> LabelingMethodSp; class LabelingMethod { -public: - LabelingMethod(const QString & method_id); - LabelingMethod( const LabelingMethod & other); - ~LabelingMethod(); - LabelingMethodSp makeLabelingMethodSp() const; - Label * getLabel(const std::list<pappso::AaModificationP> & modification_set) const; - const QString & getXmlId() const; - void writeMassChroqMl(QXmlStreamWriter* output_stream) const; - const std::vector<Label *> & getLabelList() const; -private : - void parseMethod(QDomNode & method_node); - void parseLabel(QDomNode & method_node); -private: - const QString _xml_id; - std::vector<Label *> _label_list; + public: + LabelingMethod(const QString &method_id); + LabelingMethod(const LabelingMethod &other); + ~LabelingMethod(); + LabelingMethodSp makeLabelingMethodSp() const; + Label * + getLabel(const std::list<pappso::AaModificationP> &modification_set) const; + const QString &getXmlId() const; + void writeMassChroqMl(QXmlStreamWriter *output_stream) const; + const std::vector<Label *> &getLabelList() const; + + private: + void parseMethod(QDomNode &method_node); + void parseLabel(QDomNode &method_node); + + private: + const QString _xml_id; + std::vector<Label *> _label_list; }; #endif // LABELINGMETHOD_H diff --git a/src/core/msrun.h b/src/core/msrun.h index 08f04a8536662143bfc9da729f436c13659a29ef..742b3a0c48084e185c6a4fb305597d0a56bf950c 100644 --- a/src/core/msrun.h +++ b/src/core/msrun.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef MSRUN_H @@ -43,43 +44,43 @@ class MsRun; typedef std::shared_ptr<MsRun> MsRunSp; -class MsRun:public pappso::MsRunId +class MsRun : public pappso::MsRunId { -public: - MsRun(const QString & location); - MsRun(const MsRun& other); - ~MsRun(); - - - /** \brief set MS run statistics - * any statistics on this MS run file - */ - virtual void setMsRunStatistics(MsRunStatistics param, const QVariant& value); - - - /** \brief get MS run statistics - */ - virtual const QVariant getMsRunStatistics(MsRunStatistics param) const; - - /** \brief get MS run statistics map - */ - virtual const std::map<MsRunStatistics, QVariant> & getMsRunStatisticsMap() const; - - bool findMsRunFile(); - - pappso::MsRunReaderSp & getMsRunReaderSp(); - - void checkMsRunStatistics(); - - pappso::MsRunXicExtractorSp getMsRunXicExtractorSp(); - -private : - std::map<MsRunStatistics, QVariant> _param_stats; - - pappso::MsRunReaderSp _msrun_reader_sp; - - pappso::MsRunXicExtractorSp _xic_extractor_sp; - + public: + MsRun(const QString &location); + MsRun(const MsRun &other); + ~MsRun(); + + + /** \brief set MS run statistics + * any statistics on this MS run file + */ + virtual void setMsRunStatistics(MsRunStatistics param, const QVariant &value); + + + /** \brief get MS run statistics + */ + virtual const QVariant getMsRunStatistics(MsRunStatistics param) const; + + /** \brief get MS run statistics map + */ + virtual const std::map<MsRunStatistics, QVariant> & + getMsRunStatisticsMap() const; + + bool findMsRunFile(); + + pappso::MsRunReaderSp &getMsRunReaderSp(); + + void checkMsRunStatistics(); + + pappso::MsRunXicExtractorSp getMsRunXicExtractorSp(); + + private: + std::map<MsRunStatistics, QVariant> _param_stats; + + pappso::MsRunReaderSp _msrun_reader_sp; + + pappso::MsRunXicExtractorSp _xic_extractor_sp; }; #endif // MSRUN_H diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp index 911e1b71125f3564280b55d48536e82438d2522a..10c7e6049836c8238391142d329b2ee7db880c7c 100644 --- a/src/core/peptidematch.cpp +++ b/src/core/peptidematch.cpp @@ -1,75 +1,98 @@ /******************************************************************************* -* 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 "peptidematch.h" #include <pappsomspp/pappsoexception.h> -PeptideMatch::PeptideMatch() { +PeptideMatch::PeptideMatch() +{ } -PeptideMatch::PeptideMatch(const PeptideMatch & other) { - _start=other._start; - _p_peptide_evidence = other._p_peptide_evidence; +PeptideMatch::PeptideMatch(const PeptideMatch &other) +{ + _start = other._start; + _p_peptide_evidence = other._p_peptide_evidence; } -bool PeptideMatch::operator==(const PeptideMatch & other) const { - if ((_p_peptide_evidence == other._p_peptide_evidence) && (_start == other._start)) { - return true; +bool +PeptideMatch::operator==(const PeptideMatch &other) const +{ + if((_p_peptide_evidence == other._p_peptide_evidence) && + (_start == other._start)) + { + return true; } - return false; + return false; } -void PeptideMatch::setPeptideEvidenceSp(PeptideEvidenceSp sp_peptide_evidence) { - _p_peptide_evidence = sp_peptide_evidence.get(); +void +PeptideMatch::setPeptideEvidenceSp(PeptideEvidenceSp sp_peptide_evidence) +{ + _p_peptide_evidence = sp_peptide_evidence.get(); } -const PeptideEvidence * PeptideMatch::getPeptideEvidence() const { - return _p_peptide_evidence; +const PeptideEvidence * +PeptideMatch::getPeptideEvidence() const +{ + return _p_peptide_evidence; } -PeptideEvidence * PeptideMatch::getPeptideEvidence() { - return _p_peptide_evidence; +PeptideEvidence * +PeptideMatch::getPeptideEvidence() +{ + return _p_peptide_evidence; } -void PeptideMatch::setStart(unsigned int start) { - _start =start; +void +PeptideMatch::setStart(unsigned int start) +{ + _start = start; } -unsigned int PeptideMatch::getStart() const { - return _start; +unsigned int +PeptideMatch::getStart() const +{ + return _start; } -unsigned int PeptideMatch::getStop() const { - return _start+_p_peptide_evidence->getPeptideXtpSp().get()->size(); +unsigned int +PeptideMatch::getStop() const +{ + return _start + _p_peptide_evidence->getPeptideXtpSp().get()->size(); } -bool PeptideMatch::operator<(const PeptideMatch& r) const +bool +PeptideMatch::operator<(const PeptideMatch &r) const { - return std::tie(_start, _p_peptide_evidence) - < std::tie(r._start, r._p_peptide_evidence); // keep the same order + return std::tie(_start, _p_peptide_evidence) < + std::tie(r._start, r._p_peptide_evidence); // keep the same order } -bool PeptideMatch::containsPosition(unsigned int position) const { - if (position < _start) { - return false; +bool +PeptideMatch::containsPosition(unsigned int position) const +{ + if(position < _start) + { + return false; } - if (position < getStop()) { - return true; + if(position < getStop()) + { + return true; } - return false; - + return false; } diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h index 4dc8369a734fca76f7b22a9d69391d834de99a77..c14601374efce14aa2fa173118449344cb42631c 100644 --- a/src/core/peptidematch.h +++ b/src/core/peptidematch.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 PEPTIDEMATCH_H #define PEPTIDEMATCH_H @@ -28,41 +29,42 @@ class PeptideMatch { -public : - PeptideMatch(); - PeptideMatch(const PeptideMatch & other); - - bool operator==(const PeptideMatch & other) const; + public: + PeptideMatch(); + PeptideMatch(const PeptideMatch &other); + bool operator==(const PeptideMatch &other) const; - /** @brief set start position of this peptide inside the protein sequence - * @param start position in the protein amino acid sequence (starts at 0) - * */ - void setStart(unsigned int start); - /** @brief get start position of this peptide inside the protein sequence - * @return start position in the protein amino acid sequence (starts at 0) - * */ - unsigned int getStart() const; - /** @brief get stop position of this peptide inside the protein sequence - * @return stop position in the protein amino acid sequence (starts at 0) - * */ - unsigned int getStop() const; - /** @brief tells if this peptide contains a protein position - * the position is the amino acid position on the protein sequence (starts from 0) - * */ - bool containsPosition(unsigned int position) const; - - void setPeptideEvidenceSp(PeptideEvidenceSp sp_peptide_evidence); - const PeptideEvidence * getPeptideEvidence() const; - PeptideEvidence * getPeptideEvidence(); - - - bool operator<(const PeptideMatch& r) const; + /** @brief set start position of this peptide inside the protein sequence + * @param start position in the protein amino acid sequence (starts at 0) + * */ + void setStart(unsigned int start); + /** @brief get start position of this peptide inside the protein sequence + * @return start position in the protein amino acid sequence (starts at 0) + * */ + unsigned int getStart() const; + /** @brief get stop position of this peptide inside the protein sequence + * @return stop position in the protein amino acid sequence (starts at 0) + * */ + unsigned int getStop() const; -private : - unsigned int _start=0; - PeptideEvidence * _p_peptide_evidence=nullptr; + /** @brief tells if this peptide contains a protein position + * the position is the amino acid position on the protein sequence (starts + * from 0) + * */ + bool containsPosition(unsigned int position) const; + + void setPeptideEvidenceSp(PeptideEvidenceSp sp_peptide_evidence); + const PeptideEvidence *getPeptideEvidence() const; + PeptideEvidence *getPeptideEvidence(); + + + bool operator<(const PeptideMatch &r) const; + + private: + unsigned int _start = 0; + PeptideEvidence *_p_peptide_evidence = nullptr; }; #endif // PEPTIDEMATCH_H diff --git a/src/core/peptidextp.cpp b/src/core/peptidextp.cpp index 1c2abad5b06e07f92f2b61b739f57fd7ed7c23b8..d4dd5d93da24d12cfca77bf83f228631198e7647 100644 --- a/src/core/peptidextp.cpp +++ b/src/core/peptidextp.cpp @@ -1,112 +1,141 @@ /******************************************************************************* -* 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 "peptidextp.h" #include <QStringList> #include <set> -PeptideXtp::PeptideXtp(const QString & pepstr):pappso::Peptide(pepstr) +PeptideXtp::PeptideXtp(const QString &pepstr) : pappso::Peptide(pepstr) { - } -PeptideXtp::PeptideXtp(const PeptideXtp& other):pappso::Peptide(other) +PeptideXtp::PeptideXtp(const PeptideXtp &other) : pappso::Peptide(other) { - } PeptideXtp::~PeptideXtp() { - } -const QString PeptideXtp::getModifString() const { - QStringList modif_list; - unsigned int i=1; - for (const pappso::Aa & amino_acid:_aa_vec) { - std::list<pappso::AaModificationP> aa_modif_list = amino_acid.getModificationList(); - QStringList aamodif; - for (auto && aa_modif : aa_modif_list) { - if (!aa_modif->isInternal()) { - aamodif << QString::number(aa_modif->getMass(), 'f', 2); +const QString +PeptideXtp::getModifString() const +{ + QStringList modif_list; + unsigned int i = 1; + for(const pappso::Aa &amino_acid : _aa_vec) + { + std::list<pappso::AaModificationP> aa_modif_list = + amino_acid.getModificationList(); + QStringList aamodif; + for(auto &&aa_modif : aa_modif_list) + { + if(!aa_modif->isInternal()) + { + aamodif << QString::number(aa_modif->getMass(), 'f', 2); } } - aamodif.sort(); - QString mod_str(aamodif.join("|")); - if (!mod_str.isEmpty()) { - modif_list << QString("%1%2:%3").arg(i).arg(amino_acid.getLetter()).arg(mod_str); + aamodif.sort(); + QString mod_str(aamodif.join("|")); + if(!mod_str.isEmpty()) + { + modif_list << QString("%1%2:%3") + .arg(i) + .arg(amino_acid.getLetter()) + .arg(mod_str); } - i++; + i++; } - //return QString ("%1 %2").arg(modif_list.join(" ")).arg(this->toAbsoluteString()); - return modif_list.join(" "); + // return QString ("%1 %2").arg(modif_list.join(" + // ")).arg(this->toAbsoluteString()); + return modif_list.join(" "); } -PeptideXtpSp PeptideXtp::makePeptideXtpSp() const { - return std::make_shared<PeptideXtp>(*this); +PeptideXtpSp +PeptideXtp::makePeptideXtpSp() const +{ + return std::make_shared<PeptideXtp>(*this); } -pappso::mz PeptideXtp::getGroupingMass() const { - return getNativePeptideP()->getMass(); +pappso::mz +PeptideXtp::getGroupingMass() const +{ + return getNativePeptideP()->getMass(); } -void PeptideXtp::clearLabel() { - _sp_native_peptide = nullptr; - _p_label = nullptr; +void +PeptideXtp::clearLabel() +{ + _sp_native_peptide = nullptr; + _p_label = nullptr; } -const pappso::Peptide * PeptideXtp::getNativePeptideP() const { - if (_sp_native_peptide.get() == nullptr) { - return this; +const pappso::Peptide * +PeptideXtp::getNativePeptideP() const +{ + if(_sp_native_peptide.get() == nullptr) + { + return this; } - return _sp_native_peptide.get(); + return _sp_native_peptide.get(); } -bool PeptideXtp::replaceModification(pappso::AaModificationP oldmod, pappso::AaModificationP newmod) { - - pappso::Peptide::replaceAaModification(oldmod, newmod); - if (_sp_native_peptide.get() != nullptr) { - //_sp_native_peptide.get()->replaceAaModification(oldmod, newmod); +bool +PeptideXtp::replaceModification(pappso::AaModificationP oldmod, + pappso::AaModificationP newmod) +{ + + pappso::Peptide::replaceAaModification(oldmod, newmod); + if(_sp_native_peptide.get() != nullptr) + { + //_sp_native_peptide.get()->replaceAaModification(oldmod, newmod); } - } -void PeptideXtp::applyLabelingMethod(LabelingMethodSp labeling_method_sp) { - std::list<pappso::AaModificationP> modification_set; - for (const pappso::Aa & amino_acid:_aa_vec) { - std::list<pappso::AaModificationP> aa_modif_list = amino_acid.getModificationList(); - modification_set.insert(modification_set.begin(),aa_modif_list.begin(), aa_modif_list.end()); +void +PeptideXtp::applyLabelingMethod(LabelingMethodSp labeling_method_sp) +{ + std::list<pappso::AaModificationP> modification_set; + for(const pappso::Aa &amino_acid : _aa_vec) + { + std::list<pappso::AaModificationP> aa_modif_list = + amino_acid.getModificationList(); + modification_set.insert(modification_set.begin(), aa_modif_list.begin(), + aa_modif_list.end()); } - modification_set.unique(); - - _p_label = nullptr; - Label * p_label = labeling_method_sp.get()->getLabel(modification_set); - if (p_label != nullptr) { - _p_label = p_label; - _sp_native_peptide = _p_label->getLabeledPeptideSp(this); + modification_set.unique(); + + _p_label = nullptr; + Label *p_label = labeling_method_sp.get()->getLabel(modification_set); + if(p_label != nullptr) + { + _p_label = p_label; + _sp_native_peptide = _p_label->getLabeledPeptideSp(this); } } -const Label * PeptideXtp::getLabel() const { +const Label * +PeptideXtp::getLabel() const +{ return _p_label; } diff --git a/src/core/peptidextp.h b/src/core/peptidextp.h index 8353eb854dd3362ee511341fea786989e5fdc0be..a1539d679b13f41f1706604f76891703461afedf 100644 --- a/src/core/peptidextp.h +++ b/src/core/peptidextp.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 PEPTIDEXTP_H #define PEPTIDEXTP_H @@ -35,48 +36,48 @@ typedef std::shared_ptr<PeptideXtp> PeptideXtpSp; class PeptideXtp : public pappso::Peptide { -public: - PeptideXtp(const QString & pepstr); - PeptideXtp(const PeptideXtp& other); - ~PeptideXtp(); - - PeptideXtpSp makePeptideXtpSp() const; - - /** \brief get the theoretical mass to use for grouping - * This mass might be different than the true peptide mass to recognize that a tagged - * peptide with taget modification is a light, inter or heavy version of the same peptide - */ - pappso::mz getGroupingMass() const; - - const pappso::Peptide * getNativePeptideP() const; - - /** \brief human readable string that contains modifications - * */ - const QString getModifString() const; - - /** @brief replace modification in peptide - */ - bool replaceModification(pappso::AaModificationP oldmod, pappso::AaModificationP newmod); - - /** @brief reset label - * */ - void clearLabel(); - /** @brief try to apply any label from this labeling method - * */ - void applyLabelingMethod(LabelingMethodSp labeling_method_sp); - - /** @brief get label - * */ - const Label * getLabel() const; - -private: - /** \brief if the peptide is tagged, this is the native peptide without tags - */ - pappso::PeptideSp _sp_native_peptide = nullptr; - - Label * _p_label = nullptr; - - + public: + PeptideXtp(const QString &pepstr); + PeptideXtp(const PeptideXtp &other); + ~PeptideXtp(); + + PeptideXtpSp makePeptideXtpSp() const; + + /** \brief get the theoretical mass to use for grouping + * This mass might be different than the true peptide mass to recognize that a + * tagged peptide with taget modification is a light, inter or heavy version + * of the same peptide + */ + pappso::mz getGroupingMass() const; + + const pappso::Peptide *getNativePeptideP() const; + + /** \brief human readable string that contains modifications + * */ + const QString getModifString() const; + + /** @brief replace modification in peptide + */ + bool replaceModification(pappso::AaModificationP oldmod, + pappso::AaModificationP newmod); + + /** @brief reset label + * */ + void clearLabel(); + /** @brief try to apply any label from this labeling method + * */ + void applyLabelingMethod(LabelingMethodSp labeling_method_sp); + + /** @brief get label + * */ + const Label *getLabel() const; + + private: + /** \brief if the peptide is tagged, this is the native peptide without tags + */ + pappso::PeptideSp _sp_native_peptide = nullptr; + + Label *_p_label = nullptr; }; #endif // PEPTIDEXTP_H diff --git a/src/core/project.cpp b/src/core/project.cpp index 9beaae9a6d818bd42ca39fa7f0ad15781359aeb4..effd7a3af2d0ea19870b51d08fbbfbc0ffee3cad 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #include "project.h" #include "../input/xpipsaxhandler.h" #include "../input/xtpxpipsaxhandler.h" @@ -29,180 +30,262 @@ Project::Project() { - } Project::~Project() { - auto it = _identification_goup_list.begin(); - while (it != _identification_goup_list.end()) { - delete (*it); - it++; + auto it = _identification_goup_list.begin(); + while(it != _identification_goup_list.end()) + { + delete(*it); + it++; } } -bool Project::checkPsimodCompliance() const { - return _peptide_store.checkPsimodCompliance(); +bool +Project::checkPsimodCompliance() const +{ + return _peptide_store.checkPsimodCompliance(); } -void Project::readResultFile(QString filename) { - IdentificationDataSourceSp ident_source = _identification_data_source_store.getInstance(filename); +void +Project::readResultFile(QString filename) +{ + IdentificationDataSourceSp ident_source = + _identification_data_source_store.getInstance(filename); - ident_source.get()->parseTo(this); - qDebug() << "Project::readResultFile end"; + ident_source.get()->parseTo(this); + qDebug() << "Project::readResultFile end"; } -const ProjectMode Project::getProjectMode() const { - return _project_mode; +const ProjectMode +Project::getProjectMode() const +{ + return _project_mode; } -void Project::setProjectMode(ProjectMode mode) { - _project_mode = mode; +void +Project::setProjectMode(ProjectMode mode) +{ + _project_mode = mode; } -std::vector<IdentificationGroup *> Project::getIdentificationGroupList() { - return _identification_goup_list; +std::vector<IdentificationGroup *> +Project::getIdentificationGroupList() +{ + return _identification_goup_list; } -const std::vector<IdentificationGroup *> Project::getIdentificationGroupList() const { - return _identification_goup_list; +const std::vector<IdentificationGroup *> +Project::getIdentificationGroupList() const +{ + return _identification_goup_list; } -const GroupingType Project::getGroupingType() const { - return _grouping_type; +const GroupingType +Project::getGroupingType() const +{ + return _grouping_type; } -FastaFileStore & Project::getFastaFileStore() { - return _fasta_file_store; +FastaFileStore & +Project::getFastaFileStore() +{ + return _fasta_file_store; } -const FastaFileStore & Project::getFastaFileStore() const { - return _fasta_file_store; +const FastaFileStore & +Project::getFastaFileStore() const +{ + return _fasta_file_store; } -MsRunStore & Project::getMsRunStore() { - return _msrun_store; +MsRunStore & +Project::getMsRunStore() +{ + return _msrun_store; } -const MsRunStore & Project::getMsRunStore() const { - return _msrun_store; +const MsRunStore & +Project::getMsRunStore() const +{ + return _msrun_store; } -PeptideStore & Project::getPeptideStore() { - return _peptide_store; +PeptideStore & +Project::getPeptideStore() +{ + return _peptide_store; } -ProteinStore & Project::getProteinStore() { - return _protein_store; +ProteinStore & +Project::getProteinStore() +{ + return _protein_store; } -const ProteinStore & Project::getProteinStore() const { - return _protein_store; +const ProteinStore & +Project::getProteinStore() const +{ + return _protein_store; } -IdentificationDataSourceStore & Project::getIdentificationDataSourceStore() { - return _identification_data_source_store; +IdentificationDataSourceStore & +Project::getIdentificationDataSourceStore() +{ + return _identification_data_source_store; } -const IdentificationDataSourceStore & Project::getIdentificationDataSourceStore() const { - return _identification_data_source_store; +const IdentificationDataSourceStore & +Project::getIdentificationDataSourceStore() const +{ + return _identification_data_source_store; } -const AutomaticFilterParameters & Project::getAutomaticFilterParameters() const { - return _automatic_filter_parameters; +const AutomaticFilterParameters & +Project::getAutomaticFilterParameters() const +{ + return _automatic_filter_parameters; } -void Project::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { +void +Project::updateAutomaticFilters( + const AutomaticFilterParameters &automatic_filter_parameters) +{ - qDebug() << "Project::updateAutomaticFilters begin"; - _automatic_filter_parameters = automatic_filter_parameters; - for (auto & p_id_group : _identification_goup_list) { - p_id_group->updateAutomaticFilters(_automatic_filter_parameters); + qDebug() << "Project::updateAutomaticFilters begin"; + _automatic_filter_parameters = automatic_filter_parameters; + for(auto &p_id_group : _identification_goup_list) + { + p_id_group->updateAutomaticFilters(_automatic_filter_parameters); } - qDebug() << "Project::updateAutomaticFilters end"; + qDebug() << "Project::updateAutomaticFilters end"; } -ProjectSp Project::makeProjectSp() const { - return std::make_shared<Project>(*this); +ProjectSp +Project::makeProjectSp() const +{ + return std::make_shared<Project>(*this); } -IdentificationGroup* Project::newIdentificationGroup() { - _p_current_identification_group = new IdentificationGroup(this); - _identification_goup_list.push_back(_p_current_identification_group); - return _p_current_identification_group; +IdentificationGroup * +Project::newIdentificationGroup() +{ + _p_current_identification_group = new IdentificationGroup(this); + _identification_goup_list.push_back(_p_current_identification_group); + return _p_current_identification_group; } -void Project::readXpipFile(WorkMonitorInterface * p_monitor, QFileInfo xpip_fileinfo) { - qDebug() << "Project::readXpipFile begin"; - - XpipSaxHandler * parser_java_xpip = new XpipSaxHandler(p_monitor, this); - - QXmlSimpleReader simplereader; - simplereader.setContentHandler(parser_java_xpip); - simplereader.setErrorHandler(parser_java_xpip); +void +Project::readXpipFile(WorkMonitorInterface *p_monitor, QFileInfo xpip_fileinfo) +{ + qDebug() << "Project::readXpipFile begin"; - qDebug() << "Project::readXpipFile Read XPIP XML result file '" << xpip_fileinfo.absoluteFilePath() << "'"; + XpipSaxHandler *parser_java_xpip = new XpipSaxHandler(p_monitor, this); - QFile qfile(xpip_fileinfo.absoluteFilePath()); - QXmlInputSource xmlInputSource(&qfile); + QXmlSimpleReader simplereader; + simplereader.setContentHandler(parser_java_xpip); + simplereader.setErrorHandler(parser_java_xpip); - if (simplereader.parse(xmlInputSource)) { + qDebug() << "Project::readXpipFile Read XPIP XML result file '" + << xpip_fileinfo.absoluteFilePath() << "'"; - qfile.close(); - } else { - qDebug() << parser_java_xpip->errorString(); - // throw PappsoException( - // QObject::tr("error reading tandem XML result file :\n").append( - // parser->errorString())); + QFile qfile(xpip_fileinfo.absoluteFilePath()); + QXmlInputSource xmlInputSource(&qfile); - qfile.close(); + if(simplereader.parse(xmlInputSource)) + { - if (parser_java_xpip->isJavaXpip()) { - //delete parser_java_xpip; - throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(xpip_fileinfo.absoluteFilePath()).arg(parser_java_xpip->errorString())); + qfile.close(); + } + else + { + qDebug() << parser_java_xpip->errorString(); + // throw PappsoException( + // QObject::tr("error reading tandem XML result file :\n").append( + // parser->errorString())); + + qfile.close(); + + if(parser_java_xpip->isJavaXpip()) + { + // delete parser_java_xpip; + throw pappso::PappsoException( + QObject::tr("Error reading %1 XPIP file :\n %2") + .arg(xpip_fileinfo.absoluteFilePath()) + .arg(parser_java_xpip->errorString())); } - else { - XtpXpipSaxHandler * parser_xtp_xpip = new XtpXpipSaxHandler(p_monitor, this); + else + { + XtpXpipSaxHandler *parser_xtp_xpip = + new XtpXpipSaxHandler(p_monitor, this); - QXmlSimpleReader simplereaderb; - simplereaderb.setContentHandler(parser_xtp_xpip); - simplereaderb.setErrorHandler(parser_xtp_xpip); + QXmlSimpleReader simplereaderb; + simplereaderb.setContentHandler(parser_xtp_xpip); + simplereaderb.setErrorHandler(parser_xtp_xpip); - qDebug() << "Project::readXpipFile Read XPIP XML result file '" << xpip_fileinfo.absoluteFilePath() << "'"; + qDebug() << "Project::readXpipFile Read XPIP XML result file '" + << xpip_fileinfo.absoluteFilePath() << "'"; - QFile qfileb(xpip_fileinfo.absoluteFilePath()); - QXmlInputSource xmlInputSourceb(&qfileb); + QFile qfileb(xpip_fileinfo.absoluteFilePath()); + QXmlInputSource xmlInputSourceb(&qfileb); - if (simplereaderb.parse(xmlInputSourceb)) { - delete parser_xtp_xpip; - qfileb.close(); - } else { - if (parser_xtp_xpip->isXtpXpip()) { - throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(xpip_fileinfo.absoluteFilePath()).arg(parser_xtp_xpip->errorString())); + if(simplereaderb.parse(xmlInputSourceb)) + { + delete parser_xtp_xpip; + qfileb.close(); + } + else + { + if(parser_xtp_xpip->isXtpXpip()) + { + throw pappso::PappsoException( + QObject::tr("Error reading %1 XPIP file :\n %2") + .arg(xpip_fileinfo.absoluteFilePath()) + .arg(parser_xtp_xpip->errorString())); } - else { - qDebug() << parser_xtp_xpip->errorString(); - throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n it is not an XPIP file").arg(xpip_fileinfo.absoluteFilePath())); + else + { + qDebug() << parser_xtp_xpip->errorString(); + throw pappso::PappsoException( + QObject::tr( + "Error reading %1 XPIP file :\n it is not an XPIP file") + .arg(xpip_fileinfo.absoluteFilePath())); } } - } } - delete parser_java_xpip; + delete parser_java_xpip; } -void Project::startGrouping(WorkMonitorInterface * p_work_monitor) { - for (IdentificationGroup * p_id_group : _identification_goup_list) { - p_id_group->startGrouping(_grouping_type, p_work_monitor); +void +Project::startGrouping(WorkMonitorInterface *p_work_monitor) +{ + for(IdentificationGroup *p_id_group : _identification_goup_list) + { + p_id_group->startGrouping(_grouping_type, p_work_monitor); } } -void Project::setLabelingMethodSp(LabelingMethodSp labeling_method_sp) { - _labeling_method_sp = labeling_method_sp; - _peptide_store.setLabelingMethodSp(labeling_method_sp); +void +Project::setLabelingMethodSp(LabelingMethodSp labeling_method_sp) +{ + _labeling_method_sp = labeling_method_sp; + _peptide_store.setLabelingMethodSp(labeling_method_sp); } -LabelingMethodSp Project::getLabelingMethodSp() const { - return _labeling_method_sp; +LabelingMethodSp +Project::getLabelingMethodSp() const +{ + return _labeling_method_sp; } -bool Project::hasPtmExperiment() const { - if (getIdentificationGroupList().at(0)->getPtmGroupingExperiment() != nullptr) return true; - return false; +bool +Project::hasPtmExperiment() const +{ + if(getIdentificationGroupList().at(0)->getPtmGroupingExperiment() != nullptr) + return true; + return false; } -void Project::getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const { - for (const IdentificationGroup * p_ident_group: _identification_goup_list) { - p_ident_group->getSameXicPeptideEvidenceList(peptide_evidence_list, p_msrun, p_peptide, charge); +void +Project::getSameXicPeptideEvidenceList( + std::vector<const PeptideEvidence *> &peptide_evidence_list, + const MsRun *p_msrun, const PeptideXtp *p_peptide, unsigned int charge) const +{ + for(const IdentificationGroup *p_ident_group : _identification_goup_list) + { + p_ident_group->getSameXicPeptideEvidenceList(peptide_evidence_list, + p_msrun, p_peptide, charge); } } diff --git a/src/core/project.h b/src/core/project.h index 3710b3d3e51e5ba73f87c2c655ae8e2ad077170a..3fbbdd7ae6dadb78b96b14a3408423b6662f9515 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -1,29 +1,30 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef PROJECT_H #define PROJECT_H -#include<memory> +#include <memory> #include "identificationgroup.h" #include "automaticfilterparameters.h" #include "../utils/types.h" @@ -42,75 +43,79 @@ class ProteinMatch; class Project { -public: - Project(); - ~Project(); - - ProjectSp makeProjectSp() const; - ProteinStore & getProteinStore(); - PeptideStore & getPeptideStore(); - const ProteinStore & getProteinStore() const; - MsRunStore & getMsRunStore(); - const MsRunStore & getMsRunStore() const; - FastaFileStore & getFastaFileStore(); - const FastaFileStore & getFastaFileStore() const; - IdentificationDataSourceStore & getIdentificationDataSourceStore(); - const IdentificationDataSourceStore & getIdentificationDataSourceStore() const; - void readXpipFile(WorkMonitorInterface * p_monitor, QFileInfo xpip_source); - IdentificationGroup* newIdentificationGroup(); - - /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks - * */ - void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); - const AutomaticFilterParameters & getAutomaticFilterParameters() const; - void startGrouping(WorkMonitorInterface * p_work_monitor); - - const GroupingType getGroupingType() const; - const ProjectMode getProjectMode() const; - void setProjectMode(ProjectMode mode); - - std::vector<IdentificationGroup *> getIdentificationGroupList(); - const std::vector<IdentificationGroup *> getIdentificationGroupList() const; - void readResultFile(QString filename); - - /** @brief check that modifications are coded with PSI MOD accessions - */ - bool checkPsimodCompliance() const; - - /** @brief apply labeling method to all peptide match - * */ - void setLabelingMethodSp(LabelingMethodSp labeling_method_sp); - - /** @brief get labeling method shared pointer - * */ - LabelingMethodSp getLabelingMethodSp() const; - - bool hasPtmExperiment() const; - - /** @brief look for a peptide in the same XIC - * @param peptide_evidence_list the peptide evidence list to build - * @param p_msrun MSrun to look for - * @param p_peptide peptide to look for - * @param charge charge to look for - */ - void getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const; - -private : - LabelingMethodSp _labeling_method_sp; - ProjectMode _project_mode = ProjectMode::combined; - std::vector<IdentificationGroup *> _identification_goup_list; - IdentificationGroup* _p_current_identification_group = nullptr; - - AutomaticFilterParameters _automatic_filter_parameters; - - GroupingType _grouping_type = GroupingType::PeptideMass; - - ProteinStore _protein_store; - PeptideStore _peptide_store; - IdentificationDataSourceStore _identification_data_source_store; - MsRunStore _msrun_store; - FastaFileStore _fasta_file_store; - + public: + Project(); + ~Project(); + + ProjectSp makeProjectSp() const; + ProteinStore &getProteinStore(); + PeptideStore &getPeptideStore(); + const ProteinStore &getProteinStore() const; + MsRunStore &getMsRunStore(); + const MsRunStore &getMsRunStore() const; + FastaFileStore &getFastaFileStore(); + const FastaFileStore &getFastaFileStore() const; + IdentificationDataSourceStore &getIdentificationDataSourceStore(); + const IdentificationDataSourceStore &getIdentificationDataSourceStore() const; + void readXpipFile(WorkMonitorInterface *p_monitor, QFileInfo xpip_source); + IdentificationGroup *newIdentificationGroup(); + + /** @brief validate or invalidate peptides and proteins based automatic + * filters and manual checks + * */ + void updateAutomaticFilters( + const AutomaticFilterParameters &automatic_filter_parameters); + const AutomaticFilterParameters &getAutomaticFilterParameters() const; + void startGrouping(WorkMonitorInterface *p_work_monitor); + + const GroupingType getGroupingType() const; + const ProjectMode getProjectMode() const; + void setProjectMode(ProjectMode mode); + + std::vector<IdentificationGroup *> getIdentificationGroupList(); + const std::vector<IdentificationGroup *> getIdentificationGroupList() const; + void readResultFile(QString filename); + + /** @brief check that modifications are coded with PSI MOD accessions + */ + bool checkPsimodCompliance() const; + + /** @brief apply labeling method to all peptide match + * */ + void setLabelingMethodSp(LabelingMethodSp labeling_method_sp); + + /** @brief get labeling method shared pointer + * */ + LabelingMethodSp getLabelingMethodSp() const; + + bool hasPtmExperiment() const; + + /** @brief look for a peptide in the same XIC + * @param peptide_evidence_list the peptide evidence list to build + * @param p_msrun MSrun to look for + * @param p_peptide peptide to look for + * @param charge charge to look for + */ + void getSameXicPeptideEvidenceList( + std::vector<const PeptideEvidence *> &peptide_evidence_list, + const MsRun *p_msrun, const PeptideXtp *p_peptide, + unsigned int charge) const; + + private: + LabelingMethodSp _labeling_method_sp; + ProjectMode _project_mode = ProjectMode::combined; + std::vector<IdentificationGroup *> _identification_goup_list; + IdentificationGroup *_p_current_identification_group = nullptr; + + AutomaticFilterParameters _automatic_filter_parameters; + + GroupingType _grouping_type = GroupingType::PeptideMass; + + ProteinStore _protein_store; + PeptideStore _peptide_store; + IdentificationDataSourceStore _identification_data_source_store; + MsRunStore _msrun_store; + FastaFileStore _fasta_file_store; }; #endif // PROJECT_H diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index 464294f979e29a47bbb60e314cfb9d43b047c77e..908c11ca894097a359c2b6178f6038c9efb7036e 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.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 "proteinmatch.h" #include <pappsomspp/grouping/grpprotein.h> @@ -28,459 +29,717 @@ #include <cmath> -QColor ProteinMatch::_color_peptide_background = QColor("yellow"); +QColor ProteinMatch::_color_peptide_background = QColor("yellow"); QColor ProteinMatch::_color_highlighted_peptide_background = QColor("#ff7878"); ProteinMatch::ProteinMatch() { - } ProteinMatch::~ProteinMatch() { } -ValidationState ProteinMatch::getValidationState() const { - if (isGrouped()) { - return ValidationState::grouped; - } else if (isValidAndChecked()) { - return ValidationState::validAndChecked; - } else if (isValid()) { - return ValidationState::valid; +ValidationState +ProteinMatch::getValidationState() const +{ + if(isGrouped()) + { + return ValidationState::grouped; + } + else if(isValidAndChecked()) + { + return ValidationState::validAndChecked; + } + else if(isValid()) + { + return ValidationState::valid; } - return ValidationState::notValid; + return ValidationState::notValid; } -void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { - //qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _proxy_valid = false; - unsigned int number_of_valid_peptides =0; - bool cross_sample = automatic_filter_parameters.getFilterCrossSamplePeptideNumber(); - - if (cross_sample) { - number_of_valid_peptides= countSequenceLi(ValidationState::validAndChecked,nullptr); +void +ProteinMatch::updateAutomaticFilters( + const AutomaticFilterParameters &automatic_filter_parameters) +{ + // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _proxy_valid = false; + unsigned int number_of_valid_peptides = 0; + bool cross_sample = + automatic_filter_parameters.getFilterCrossSamplePeptideNumber(); + + if(cross_sample) + { + number_of_valid_peptides = + countSequenceLi(ValidationState::validAndChecked, nullptr); } - else { - std::set<const MsRun *> msrun_set; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match.getPeptideEvidence()->isValidAndChecked()) { - msrun_set.insert(p_peptide_match.getPeptideEvidence()->getMsRunP()); + else + { + std::set<const MsRun *> msrun_set; + for(auto &p_peptide_match : _peptide_match_list) + { + if(p_peptide_match.getPeptideEvidence()->isValidAndChecked()) + { + msrun_set.insert( + p_peptide_match.getPeptideEvidence()->getMsRunP()); } } - for (const MsRun * p_msrun : msrun_set) { - unsigned int count = countSequenceLi(ValidationState::validAndChecked,p_msrun); - if (count > number_of_valid_peptides) { - number_of_valid_peptides = count; + for(const MsRun *p_msrun : msrun_set) + { + unsigned int count = + countSequenceLi(ValidationState::validAndChecked, p_msrun); + if(count > number_of_valid_peptides) + { + number_of_valid_peptides = count; } } } - //qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - // qDebug() <<"ProteinMatch::updateAutomaticFilters begin 2" ; - if (number_of_valid_peptides == 0) { + // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + // qDebug() <<"ProteinMatch::updateAutomaticFilters begin 2" ; + if(number_of_valid_peptides == 0) + { - _proxy_valid = false; - } else { + _proxy_valid = false; + } + else + { - if (number_of_valid_peptides < automatic_filter_parameters.getFilterMinimumPeptidePerMatch()) { + if(number_of_valid_peptides < + automatic_filter_parameters.getFilterMinimumPeptidePerMatch()) + { } - else { - if (getEvalue() <= automatic_filter_parameters.getFilterProteinEvalue()) { - _proxy_valid = true; + else + { + if(getEvalue() <= + automatic_filter_parameters.getFilterProteinEvalue()) + { + _proxy_valid = true; } } } - //qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -const ProteinXtpSp & ProteinMatch::getProteinXtpSp() const { - return _protein_sp; +const ProteinXtpSp & +ProteinMatch::getProteinXtpSp() const +{ + return _protein_sp; } -void ProteinMatch::setProteinXtpSp(ProteinXtpSp protein_sp) { - _protein_sp = protein_sp; +void +ProteinMatch::setProteinXtpSp(ProteinXtpSp protein_sp) +{ + _protein_sp = protein_sp; } -bool ProteinMatch::isValid() const { - return _proxy_valid; +bool +ProteinMatch::isValid() const +{ + return _proxy_valid; } -bool ProteinMatch::isChecked() const { - return _checked; +bool +ProteinMatch::isChecked() const +{ + return _checked; } -bool ProteinMatch::isValidAndChecked() const { - return _proxy_valid && _checked; +bool +ProteinMatch::isValidAndChecked() const +{ + return _proxy_valid && _checked; } -bool ProteinMatch::isGrouped() const { - if (_sp_grp_protein.get() == nullptr) { - return false; +bool +ProteinMatch::isGrouped() const +{ + if(_sp_grp_protein.get() == nullptr) + { + return false; } - if (_sp_grp_protein.get()->getGroupNumber() == 0) { - return false; + if(_sp_grp_protein.get()->getGroupNumber() == 0) + { + return false; } - return true; + return true; } -void ProteinMatch::setChecked(bool arg1) { - _checked = arg1; +void +ProteinMatch::setChecked(bool arg1) +{ + _checked = arg1; } -void ProteinMatch::addPeptideMatch(const PeptideMatch & peptide_match) { - //qDebug() << "ProteinMatch::addPeptideMatch begin " << peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->toAbsoluteString(); - _peptide_match_list.push_back(peptide_match); +void +ProteinMatch::addPeptideMatch(const PeptideMatch &peptide_match) +{ + // qDebug() << "ProteinMatch::addPeptideMatch begin " << + // peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->toAbsoluteString(); + _peptide_match_list.push_back(peptide_match); } -std::vector<PeptideMatch> & ProteinMatch::getPeptideMatchList() { - return _peptide_match_list; +std::vector<PeptideMatch> & +ProteinMatch::getPeptideMatchList() +{ + return _peptide_match_list; } -const std::vector<PeptideMatch> & ProteinMatch::getPeptideMatchList() const { - return _peptide_match_list; +const std::vector<PeptideMatch> & +ProteinMatch::getPeptideMatchList() const +{ + return _peptide_match_list; } -void ProteinMatch::setGroupingExperiment(GroupingExperiment * p_grp_experiment) { - _sp_grp_protein = nullptr; - if ((isValidAndChecked() && (!_protein_sp.get()->isDecoy()))) { - _sp_grp_protein = p_grp_experiment->getGrpProteinSp(this); - - for (auto & p_peptide_match : _peptide_match_list) { - p_peptide_match.getPeptideEvidence()->setGrpPeptideSp(nullptr); - if (p_peptide_match.getPeptideEvidence()->isValidAndChecked()) { - p_peptide_match.getPeptideEvidence()->setGrpPeptideSp(p_grp_experiment->setGrpPeptide(_sp_grp_protein, p_peptide_match.getPeptideEvidence())); +void +ProteinMatch::setGroupingExperiment(GroupingExperiment *p_grp_experiment) +{ + _sp_grp_protein = nullptr; + if((isValidAndChecked() && (!_protein_sp.get()->isDecoy()))) + { + _sp_grp_protein = p_grp_experiment->getGrpProteinSp(this); + + for(auto &p_peptide_match : _peptide_match_list) + { + p_peptide_match.getPeptideEvidence()->setGrpPeptideSp(nullptr); + if(p_peptide_match.getPeptideEvidence()->isValidAndChecked()) + { + p_peptide_match.getPeptideEvidence()->setGrpPeptideSp( + p_grp_experiment->setGrpPeptide( + _sp_grp_protein, p_peptide_match.getPeptideEvidence())); } } - if (_protein_sp.get()->isContaminant()) { - p_grp_experiment->addPostGroupingGrpProteinSpRemoval(_sp_grp_protein); + if(_protein_sp.get()->isContaminant()) + { + p_grp_experiment->addPostGroupingGrpProteinSpRemoval(_sp_grp_protein); } - } } -const pappso::GrpProteinSp & ProteinMatch::getGrpProteinSp() const { - return _sp_grp_protein; +const pappso::GrpProteinSp & +ProteinMatch::getGrpProteinSp() const +{ + return _sp_grp_protein; } -void ProteinMatch::countPeptideMass(std::vector<pappso::GrpPeptide *> & count_peptide_mass, ValidationState state) const { - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { - count_peptide_mass.push_back(p_peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()); +void +ProteinMatch::countPeptideMass( + std::vector<pappso::GrpPeptide *> &count_peptide_mass, + ValidationState state) const +{ + for(auto &p_peptide_match : _peptide_match_list) + { + if(p_peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + count_peptide_mass.push_back( + p_peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()); } } } -void ProteinMatch::countPeptideMassSample(std::vector<size_t> & count_peptide_mass_sample, ValidationState state) const { - for (auto & p_peptide_match : _peptide_match_list) { - if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { - count_peptide_mass_sample.push_back(p_peptide_match.getPeptideEvidence()->getHashPeptideMassSample()); +void +ProteinMatch::countPeptideMassSample( + std::vector<size_t> &count_peptide_mass_sample, ValidationState state) const +{ + for(auto &p_peptide_match : _peptide_match_list) + { + if(p_peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + count_peptide_mass_sample.push_back( + p_peptide_match.getPeptideEvidence()->getHashPeptideMassSample()); } } } -std::vector<PeptideMatch> ProteinMatch::getPeptideMatchList(ValidationState state, const MsRun * p_msrun_id) const { - std::vector<PeptideMatch> peptide_match_list; - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { - if (p_msrun_id == nullptr) { - peptide_match_list.push_back(peptide_match); +std::vector<PeptideMatch> +ProteinMatch::getPeptideMatchList(ValidationState state, + const MsRun *p_msrun_id) const +{ + std::vector<PeptideMatch> peptide_match_list; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + if(p_msrun_id == nullptr) + { + peptide_match_list.push_back(peptide_match); } - else { - if (peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) { - peptide_match_list.push_back(peptide_match); + else + { + if(peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) + { + peptide_match_list.push_back(peptide_match); } } } } - //it should automatically use the move semantic : - return peptide_match_list; + // it should automatically use the move semantic : + return peptide_match_list; } -unsigned int ProteinMatch::countSampleScan(ValidationState state, const MsRun * p_msrun_id) const { - std::vector<std::size_t> count_sample_scan; - for (auto & peptide_match : _peptide_match_list) { - const PeptideEvidence * p_peptide_evidence = peptide_match.getPeptideEvidence(); - if (p_peptide_evidence->getValidationState() >= state) { - if(p_msrun_id == nullptr) { - count_sample_scan.push_back(p_peptide_evidence->getHashSampleScan()); +unsigned int +ProteinMatch::countSampleScan(ValidationState state, + const MsRun *p_msrun_id) const +{ + std::vector<std::size_t> count_sample_scan; + for(auto &peptide_match : _peptide_match_list) + { + const PeptideEvidence *p_peptide_evidence = + peptide_match.getPeptideEvidence(); + if(p_peptide_evidence->getValidationState() >= state) + { + if(p_msrun_id == nullptr) + { + count_sample_scan.push_back( + p_peptide_evidence->getHashSampleScan()); } - else { - if (p_peptide_evidence->getMsRunP() == p_msrun_id) { - count_sample_scan.push_back(p_peptide_evidence->getHashSampleScan()); + else + { + if(p_peptide_evidence->getMsRunP() == p_msrun_id) + { + count_sample_scan.push_back( + p_peptide_evidence->getHashSampleScan()); } } } } - std::sort(count_sample_scan.begin(), count_sample_scan.end()); - auto last = std::unique(count_sample_scan.begin(),count_sample_scan.end()); - return std::distance(count_sample_scan.begin(),last); + std::sort(count_sample_scan.begin(), count_sample_scan.end()); + auto last = std::unique(count_sample_scan.begin(), count_sample_scan.end()); + return std::distance(count_sample_scan.begin(), last); } -unsigned int ProteinMatch::countPeptideMatch(ValidationState state) const { - return std::count_if (_peptide_match_list.begin(), _peptide_match_list.end(), [state](const PeptideMatch & peptide_match) { - if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { - return true; +unsigned int +ProteinMatch::countPeptideMatch(ValidationState state) const +{ + return std::count_if( + _peptide_match_list.begin(), _peptide_match_list.end(), + [state](const PeptideMatch &peptide_match) { + if(peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + return true; } - else { - return false; + else + { + return false; } }); } -size_t ProteinMatch::countSequenceLi(ValidationState state, const MsRun * p_msrun_id) const { - //qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - std::set<QString> sequence_list; - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { - if(p_msrun_id != nullptr) { - //within sample - if (peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) { - sequence_list.insert(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); +size_t +ProteinMatch::countSequenceLi(ValidationState state, + const MsRun *p_msrun_id) const +{ + // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + std::set<QString> sequence_list; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + if(p_msrun_id != nullptr) + { + // within sample + if(peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) + { + sequence_list.insert(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequenceLi()); } } - else { - //overall samples - sequence_list.insert(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); + else + { + // overall samples + sequence_list.insert(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequenceLi()); } } } - //qDebug() <<"ProteinMatch::countValidAndCheckedPeptide end " << sequence_list.size(); - //qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - return sequence_list.size(); + // qDebug() <<"ProteinMatch::countValidAndCheckedPeptide end " << + // sequence_list.size(); qDebug() << __FILE__ << " " << __FUNCTION__ << " " << + // __LINE__; + return sequence_list.size(); } -unsigned int ProteinMatch::countDistinctMsSamples(ValidationState state) const { - std::set<QString> sequence_list; - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { - sequence_list.insert(QString("%1").arg(peptide_match.getPeptideEvidence()->getMsRunP()->getXmlId())); +unsigned int +ProteinMatch::countDistinctMsSamples(ValidationState state) const +{ + std::set<QString> sequence_list; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + sequence_list.insert(QString("%1").arg( + peptide_match.getPeptideEvidence()->getMsRunP()->getXmlId())); } } - return sequence_list.size(); + return sequence_list.size(); } -unsigned int ProteinMatch::countPeptideMassCharge(ValidationState state, const MsRun * sp_msrun_id) const { - std::set<QString> sequence_list; - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence()->getValidationState() >= state) { - if(sp_msrun_id != nullptr) { - //within sample - if (peptide_match.getPeptideEvidence()->getMsRunP() == sp_msrun_id) { - sequence_list.insert(QString("%1-%2-%3").arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getSequenceLi()).arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getMass()).arg(peptide_match.getPeptideEvidence()->getCharge())); +unsigned int +ProteinMatch::countPeptideMassCharge(ValidationState state, + const MsRun *sp_msrun_id) const +{ + std::set<QString> sequence_list; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + if(sp_msrun_id != nullptr) + { + // within sample + if(peptide_match.getPeptideEvidence()->getMsRunP() == sp_msrun_id) + { + sequence_list.insert( + QString("%1-%2-%3") + .arg(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getNativePeptideP() + ->getSequenceLi()) + .arg(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getNativePeptideP() + ->getMass()) + .arg(peptide_match.getPeptideEvidence()->getCharge())); } } - else { - //overall samples - sequence_list.insert(QString("%1-%2-%3").arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getSequenceLi()).arg(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNativePeptideP()->getMass()).arg(peptide_match.getPeptideEvidence()->getCharge())); + else + { + // overall samples + sequence_list.insert( + QString("%1-%2-%3") + .arg(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getNativePeptideP() + ->getSequenceLi()) + .arg(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getNativePeptideP() + ->getMass()) + .arg(peptide_match.getPeptideEvidence()->getCharge())); } } } - return sequence_list.size(); -} - -pappso::pappso_double ProteinMatch::getEvalue(const MsRun * sp_msrun_id) const { - return (std::pow ((double) 10.0,getLogEvalue(sp_msrun_id))); -} - -pappso::pappso_double ProteinMatch::getLogEvalue(const MsRun * sp_msrun_id) const { - std::map<QString, pappso::pappso_double> map_sequence_evalue; - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { - QString sequence(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()); - pappso::pappso_double evalue = peptide_match.getPeptideEvidence()->getEvalue(); - if(sp_msrun_id != nullptr) { - //within sample - if (peptide_match.getPeptideEvidence()->getMsRunP() == sp_msrun_id) { - auto ret = map_sequence_evalue.insert(std::pair<QString, pappso::pappso_double>(sequence, evalue)); - if (ret.second == false) { - if (ret.first->second > evalue) {//get best evalue for sequence - ret.first->second = evalue; + return sequence_list.size(); +} + +pappso::pappso_double +ProteinMatch::getEvalue(const MsRun *sp_msrun_id) const +{ + return (std::pow((double)10.0, getLogEvalue(sp_msrun_id))); +} + +pappso::pappso_double +ProteinMatch::getLogEvalue(const MsRun *sp_msrun_id) const +{ + std::map<QString, pappso::pappso_double> map_sequence_evalue; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence()->isValidAndChecked()) + { + QString sequence(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequence()); + pappso::pappso_double evalue = + peptide_match.getPeptideEvidence()->getEvalue(); + if(sp_msrun_id != nullptr) + { + // within sample + if(peptide_match.getPeptideEvidence()->getMsRunP() == sp_msrun_id) + { + auto ret = map_sequence_evalue.insert( + std::pair<QString, pappso::pappso_double>(sequence, + evalue)); + if(ret.second == false) + { + if(ret.first->second > evalue) + { // get best evalue for sequence + ret.first->second = evalue; } } } } - else { - //overall samples - auto ret = map_sequence_evalue.insert(std::pair<QString, pappso::pappso_double>(sequence, evalue)); - if (ret.second == false) { - if (ret.first->second > evalue) {//get best evalue for sequence - ret.first->second = evalue; + else + { + // overall samples + auto ret = map_sequence_evalue.insert( + std::pair<QString, pappso::pappso_double>(sequence, evalue)); + if(ret.second == false) + { + if(ret.first->second > evalue) + { // get best evalue for sequence + ret.first->second = evalue; } } } } } - pappso::pappso_double evalue_prot = 1; - for (auto && peptide_pair: map_sequence_evalue) { - evalue_prot += std::log10(peptide_pair.second); - //evalue_prot *= peptide_pair.second; + pappso::pappso_double evalue_prot = 1; + for(auto &&peptide_pair : map_sequence_evalue) + { + evalue_prot += std::log10(peptide_pair.second); + // evalue_prot *= peptide_pair.second; } - //return (std::pow ((double) 10.0,evalue_prot)); - return (evalue_prot); - + // return (std::pow ((double) 10.0,evalue_prot)); + return (evalue_prot); } -pappso::pappso_double ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum, const MsRun * p_msrun_id) const { - if (proto_nsaf_sum == 0) { - throw pappso::PappsoException(QObject::tr("Error computing NSAF for protein %1 :\nproto_nsaf_sum is null").arg(this->getProteinXtpSp().get()->getAccession())); +pappso::pappso_double +ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum, + const MsRun *p_msrun_id) const +{ + if(proto_nsaf_sum == 0) + { + throw pappso::PappsoException( + QObject::tr( + "Error computing NSAF for protein %1 :\nproto_nsaf_sum is null") + .arg(this->getProteinXtpSp().get()->getAccession())); } - return (getProtoNsaf(p_msrun_id)/proto_nsaf_sum); + return (getProtoNsaf(p_msrun_id) / proto_nsaf_sum); } -pappso::pappso_double ProteinMatch::getProtoNsaf(const MsRun * sp_msrun_id) const { - try { - if (_protein_sp.get()->size() < 1) { - throw pappso::PappsoException(QObject::tr("protein has no amino acid sequence")); - } - pappso::pappso_double proto_nsaf = (pappso::pappso_double) countSampleScan(ValidationState::validAndChecked ,sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->size(); - return proto_nsaf; - +pappso::pappso_double +ProteinMatch::getProtoNsaf(const MsRun *sp_msrun_id) const +{ + try + { + if(_protein_sp.get()->size() < 1) + { + throw pappso::PappsoException( + QObject::tr("protein has no amino acid sequence")); + } + pappso::pappso_double proto_nsaf = + (pappso::pappso_double)countSampleScan(ValidationState::validAndChecked, + sp_msrun_id) / + (pappso::pappso_double)_protein_sp.get()->size(); + return proto_nsaf; } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("Error computing proto NSAF for protein %1 :\n%2").arg(this->getProteinXtpSp().get()->getAccession()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("Error computing proto NSAF for protein %1 :\n%2") + .arg(this->getProteinXtpSp().get()->getAccession()) + .arg(error.qwhat())); } } -pappso::pappso_double ProteinMatch::getPAI(const MsRun * sp_msrun_id) const { - try { - pappso::pappso_double PAI = (pappso::pappso_double) countPeptideMassCharge(ValidationState::validAndChecked ,sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->countTrypticPeptidesForPAI(); - return PAI; - +pappso::pappso_double +ProteinMatch::getPAI(const MsRun *sp_msrun_id) const +{ + try + { + pappso::pappso_double PAI = + (pappso::pappso_double)countPeptideMassCharge( + ValidationState::validAndChecked, sp_msrun_id) / + (pappso::pappso_double)_protein_sp.get()->countTrypticPeptidesForPAI(); + return PAI; } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("Error computing PAI for protein %1 :\n%2").arg(this->getProteinXtpSp().get()->getAccession()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("Error computing PAI for protein %1 :\n%2") + .arg(this->getProteinXtpSp().get()->getAccession()) + .arg(error.qwhat())); } } -pappso::pappso_double ProteinMatch::getEmPAI(const MsRun * sp_msrun_id) const { - // compute emPAI, Ishihama 2005 - pappso::pappso_double value = std::pow(10.0, getPAI(sp_msrun_id)) - (pappso::pappso_double) 1.0; +pappso::pappso_double +ProteinMatch::getEmPAI(const MsRun *sp_msrun_id) const +{ + // compute emPAI, Ishihama 2005 + pappso::pappso_double value = + std::pow(10.0, getPAI(sp_msrun_id)) - (pappso::pappso_double)1.0; - return value; + return value; } -const QString ProteinMatch::getHtmlSequence(PeptideEvidence * peptide_evidence_to_locate) const +const QString +ProteinMatch::getHtmlSequence(PeptideEvidence *peptide_evidence_to_locate) const { - size_t prot_size = _protein_sp.get()->size(); - //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); - if (prot_size == 0) return 0; - bool cover_bool[prot_size] = {false}; - bool highlight_bool[prot_size] = {false}; - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence() == peptide_evidence_to_locate) { - size_t size = peptide_evidence_to_locate->getPeptideXtpSp().get()->size(); - size_t offset = peptide_match.getStart(); - if (offset >= 0) { - for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { - highlight_bool[offset] = true; + size_t prot_size = _protein_sp.get()->size(); + // qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " + // " << _protein_sp.get()-//>getSequence(); + if(prot_size == 0) + return 0; + bool cover_bool[prot_size] = {false}; + bool highlight_bool[prot_size] = {false}; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence() == peptide_evidence_to_locate) + { + size_t size = + peptide_evidence_to_locate->getPeptideXtpSp().get()->size(); + size_t offset = peptide_match.getStart(); + if(offset >= 0) + { + for(size_t i = 0; (i < size) && (offset < prot_size); + i++, offset++) + { + highlight_bool[offset] = true; } } } } - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { - size_t size = peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->size(); - size_t offset = peptide_match.getStart(); - if (offset >= 0) { - for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { - cover_bool[offset] = true; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence()->isValidAndChecked()) + { + size_t size = + peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->size(); + size_t offset = peptide_match.getStart(); + if(offset >= 0) + { + for(size_t i = 0; (i < size) && (offset < prot_size); + i++, offset++) + { + cover_bool[offset] = true; } } } } - QString sequence = getProteinXtpSp().get()->getSequence(); - QString sequence_html("<style type=\"text/css\">\nspan { margin: 0px;padding: 0px; }\n</style>"); - for (unsigned int i=0; i < prot_size; i++) { - if(highlight_bool[i]) { - sequence_html.append(QString("<span style=\"background-color:%2;\">%1").arg(sequence[i]).arg(_color_highlighted_peptide_background.name())); - i++; - for (; i < prot_size; i++) { - if(highlight_bool[i]) { - sequence_html.append(sequence[i]); + QString sequence = getProteinXtpSp().get()->getSequence(); + QString sequence_html( + "<style type=\"text/css\">\nspan { margin: 0px;padding: 0px; }\n</style>"); + for(unsigned int i = 0; i < prot_size; i++) + { + if(highlight_bool[i]) + { + sequence_html.append( + QString("<span style=\"background-color:%2;\">%1") + .arg(sequence[i]) + .arg(_color_highlighted_peptide_background.name())); + i++; + for(; i < prot_size; i++) + { + if(highlight_bool[i]) + { + sequence_html.append(sequence[i]); } - else { - sequence_html.append(QString("</span>")); - i--; - break; + else + { + sequence_html.append(QString("</span>")); + i--; + break; } } - sequence_html.append(QString("</span>")); + sequence_html.append(QString("</span>")); } - else if(cover_bool[i]) { - sequence_html.append(QString("<span style=\"background-color:%2;\">%1").arg(sequence[i]).arg(_color_peptide_background.name())); - i++; - for (; i < prot_size; i++) { - if (highlight_bool[i]) { - i--; - break; + else if(cover_bool[i]) + { + sequence_html.append( + QString("<span style=\"background-color:%2;\">%1") + .arg(sequence[i]) + .arg(_color_peptide_background.name())); + i++; + for(; i < prot_size; i++) + { + if(highlight_bool[i]) + { + i--; + break; } - if(cover_bool[i]) { - sequence_html.append(sequence[i]); + if(cover_bool[i]) + { + sequence_html.append(sequence[i]); } - else { - sequence_html.append(QString("</span>%1").arg(sequence[i])); - break; + else + { + sequence_html.append(QString("</span>%1").arg(sequence[i])); + break; } } - sequence_html.append(QString("</span>")); + sequence_html.append(QString("</span>")); } - else { - sequence_html.append(sequence[i]); + else + { + sequence_html.append(sequence[i]); } } - return sequence_html; -} - -pappso::pappso_double ProteinMatch::getCoverage() const { - size_t prot_size = _protein_sp.get()->size(); - //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); - if (prot_size == 0) return 0; - bool cover_bool[prot_size] = {false}; - for (auto & peptide_match : _peptide_match_list) { - if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { - size_t size = peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->size(); - size_t offset = peptide_match.getStart(); - if (offset >= 0) { - for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { - cover_bool[offset] = true; + return sequence_html; +} + +pappso::pappso_double +ProteinMatch::getCoverage() const +{ + size_t prot_size = _protein_sp.get()->size(); + // qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " + // " << _protein_sp.get()-//>getSequence(); + if(prot_size == 0) + return 0; + bool cover_bool[prot_size] = {false}; + for(auto &peptide_match : _peptide_match_list) + { + if(peptide_match.getPeptideEvidence()->isValidAndChecked()) + { + size_t size = + peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->size(); + size_t offset = peptide_match.getStart(); + if(offset >= 0) + { + for(size_t i = 0; (i < size) && (offset < prot_size); + i++, offset++) + { + cover_bool[offset] = true; } } } } - size_t count = 0; - for (size_t i=0; i < prot_size; i++) { - if(cover_bool[i]) count++; + size_t count = 0; + for(size_t i = 0; i < prot_size; i++) + { + if(cover_bool[i]) + count++; } - //qDebug() << "ProteinMatch::getCoverage count=" << count << " prot_size=" << prot_size; - return (((pappso::pappso_double)count)/ ((pappso::pappso_double)prot_size)); + // qDebug() << "ProteinMatch::getCoverage count=" << count << " prot_size=" << + // prot_size; + return (((pappso::pappso_double)count) / ((pappso::pappso_double)prot_size)); } -const GroupingGroupSp & ProteinMatch::getGroupingGroupSp() const { - return _sp_group; +const GroupingGroupSp & +ProteinMatch::getGroupingGroupSp() const +{ + return _sp_group; } -void ProteinMatch::setGroupInstance(GroupStore & group_store) { - _sp_group = nullptr; - if (_sp_grp_protein != nullptr) { - unsigned int group_number = _sp_grp_protein.get()->getGroupNumber(); - if (group_number > 0) { - _sp_group = group_store.getInstance(group_number); - _sp_group.get()->add(this); +void +ProteinMatch::setGroupInstance(GroupStore &group_store) +{ + _sp_group = nullptr; + if(_sp_grp_protein != nullptr) + { + unsigned int group_number = _sp_grp_protein.get()->getGroupNumber(); + if(group_number > 0) + { + _sp_group = group_store.getInstance(group_number); + _sp_group.get()->add(this); } } } -void ProteinMatch::collectPeptideEvidences(std::set<const PeptideEvidence *> & peptide_evidence_set, ValidationState state) const { - for (auto & peptide_match : _peptide_match_list) { - const PeptideEvidence * p_peptide_evidence = peptide_match.getPeptideEvidence(); - if (p_peptide_evidence->getValidationState() >= state) { - peptide_evidence_set.insert(p_peptide_evidence); +void +ProteinMatch::collectPeptideEvidences( + std::set<const PeptideEvidence *> &peptide_evidence_set, + ValidationState state) const +{ + for(auto &peptide_match : _peptide_match_list) + { + const PeptideEvidence *p_peptide_evidence = + peptide_match.getPeptideEvidence(); + if(p_peptide_evidence->getValidationState() >= state) + { + peptide_evidence_set.insert(p_peptide_evidence); } } } diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index d7e2db30d09e831b0782b5428860d541f8918130..015977cdbbb59ba570d0c1d7969b90d1515a6056 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.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 + ******************************************************************************/ #include <QColor> #include <vector> @@ -39,146 +40,166 @@ class IdentificationGroup; class ProteinMatch { - friend IdentificationGroup; -public: - ProteinMatch(); - ~ProteinMatch(); - - const ProteinXtpSp & getProteinXtpSp() const; - - /** @brief compute protein log10(Evalue) within samples - * */ - pappso::pappso_double getLogEvalue(const MsRun * sp_msrun_id = nullptr) const; - - /** @brief compute protein Evalue within samples - * */ - pappso::pappso_double getEvalue(const MsRun * sp_msrun_id = nullptr) const; - - - /** @brief protein coverage overall samples - * */ - pappso::pappso_double getCoverage() const; - - /** @brief get coverage sequence (html representation) - * @param peptide_match_to_locate pointer to optional peptide match to locate on protein sequence - **/ - const QString getHtmlSequence(PeptideEvidence * peptide_evidence_to_locate = nullptr) const; - - /** @brief compute proto NSAF within msrun : spectral abundance factor (SAF) - * Warning: this is not NSAF, just a part - * @param p_msrun_id pointer on the msrun to get NSAF. - * */ - pappso::pappso_double getProtoNsaf(const MsRun * p_msrun_id) const; - - /** @brief compute NSAF within msrun : normalized spectral abundance factor (NSAF) - * Florens L., Carozza M. J. C., Swanson S. K., et al. Analyzing chromatin remodeling complexes using shotgun proteomics and normalized spectral abundance factors. Methods. 2006;40(4):303–311. doi: 10.1016/j.ymeth.2006.07.028. - * https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1815300/ - * @param proto_nsaf_sum the sum of SAF of all proteins within the msrun - * @param p_msrun_id pointer on the msrun to get NSAF - * */ - pappso::pappso_double getNsaf(pappso::pappso_double proto_nsaf_sum, const MsRun * p_msrun_id) const; - - /** @brief compute Protein Abundance Index (PAI) within sample - * PAI computation (Rappsilber et al. 2002) - * */ - pappso::pappso_double getPAI(const MsRun * sp_msrun_id = nullptr) const; - - /** @brief compute emPAI within sample - * Ishihama 2005 - * */ - pappso::pappso_double getEmPAI(const MsRun * sp_msrun_id = nullptr) const; - - void setProteinXtpSp(ProteinXtpSp protein_sp); - void addPeptideMatch(const PeptideMatch & peptide_match); - std::vector<PeptideMatch> & getPeptideMatchList(); - const std::vector<PeptideMatch> & getPeptideMatchList() const; - - /** @brief get peptide match sublist with required validation state - * @param state the validation state to select - * @param sp_msrun_id the msrun to look for, if nullptr, then get peptide match overall MSruns - * */ - std::vector<PeptideMatch> getPeptideMatchList(ValidationState state, const MsRun * sp_msrun_id = nullptr) const; - - void setChecked(bool arg1); - - bool isChecked() const; - bool isValid() const; - bool isValidAndChecked() const; - bool isGrouped() const; - - ValidationState getValidationState() const; - - /** @brief count peptide match (psm) listed in this protein match - */ - unsigned int countPeptideMatch(ValidationState state) const; - - /** @brief count distinct sample + scans implied in this protein identification - */ - unsigned int countSampleScan(ValidationState state, const MsRun * p_msrun_id=nullptr) const; - - /** @brief count peptide (peptide+mass) - */ - void countPeptideMass(std::vector<pappso::GrpPeptide *> & count_peptide_mass, ValidationState state) const; - - /** @brief count peptide (peptide+mass+sample) - */ - void countPeptideMassSample(std::vector<size_t> & count_peptide_mass_sample, ValidationState state) const; - - const pappso::GrpProteinSp & getGrpProteinSp() const; - const GroupingGroupSp & getGroupingGroupSp() const; - - /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks - * */ - void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); - - - /** @brief collect distinct peptide evidences - */ - void collectPeptideEvidences(std::set<const PeptideEvidence *> & peptide_evidence_set, ValidationState state) const; - - /** @brief count distinct sequence taking into account equivalence between Leucine and Isoleucine - * @param state validation state of peptides to count - * @param p_msrun_id count within the specified sample - */ - size_t countSequenceLi(ValidationState state,const MsRun * p_msrun_id=nullptr) const; - - /** @brief count distinct peptide+mass+charge - * peptide is the peptide sequence LI (Leucine => Isoleucine) - * mass is the peptide mass, not considering labelled residues (if any) - * @param state validation state of peptides to count - * @param p_msrun_id count within the specified sample - */ - unsigned int countPeptideMassCharge(ValidationState state, const MsRun * sp_msrun_id=nullptr) const; - - /** @brief count distinct MS samples in which the protein is observed - * @param state validation state of peptides to count - */ - unsigned int countDistinctMsSamples(ValidationState state) const; -protected : - - void setGroupingExperiment(GroupingExperiment * p_grp_experiment); - - void setGroupInstance(GroupStore & group_store); - - -private: - static QColor _color_peptide_background; - static QColor _color_highlighted_peptide_background; - - - pappso::GrpProteinSp _sp_grp_protein; - GroupingGroupSp _sp_group; - - std::vector<PeptideMatch> _peptide_match_list; - ProteinXtpSp _protein_sp = nullptr; - /** @brief manually checked by user (true by default) - */ - bool _checked = true; - - /** @brief automatic filter result (false by default) - */ - bool _proxy_valid = false; - + friend IdentificationGroup; + + public: + ProteinMatch(); + ~ProteinMatch(); + + const ProteinXtpSp &getProteinXtpSp() const; + + /** @brief compute protein log10(Evalue) within samples + * */ + pappso::pappso_double getLogEvalue(const MsRun *sp_msrun_id = nullptr) const; + + /** @brief compute protein Evalue within samples + * */ + pappso::pappso_double getEvalue(const MsRun *sp_msrun_id = nullptr) const; + + + /** @brief protein coverage overall samples + * */ + pappso::pappso_double getCoverage() const; + + /** @brief get coverage sequence (html representation) + * @param peptide_match_to_locate pointer to optional peptide match to locate + *on protein sequence + **/ + const QString + getHtmlSequence(PeptideEvidence *peptide_evidence_to_locate = nullptr) const; + + /** @brief compute proto NSAF within msrun : spectral abundance factor (SAF) + * Warning: this is not NSAF, just a part + * @param p_msrun_id pointer on the msrun to get NSAF. + * */ + pappso::pappso_double getProtoNsaf(const MsRun *p_msrun_id) const; + + /** @brief compute NSAF within msrun : normalized spectral abundance factor + * (NSAF) Florens L., Carozza M. J. C., Swanson S. K., et al. Analyzing + * chromatin remodeling complexes using shotgun proteomics and normalized + * spectral abundance factors. Methods. 2006;40(4):303–311. + * doi: 10.1016/j.ymeth.2006.07.028. + * https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1815300/ + * @param proto_nsaf_sum the sum of SAF of all proteins within the msrun + * @param p_msrun_id pointer on the msrun to get NSAF + * */ + pappso::pappso_double getNsaf(pappso::pappso_double proto_nsaf_sum, + const MsRun *p_msrun_id) const; + + /** @brief compute Protein Abundance Index (PAI) within sample + * PAI computation (Rappsilber et al. 2002) + * */ + pappso::pappso_double getPAI(const MsRun *sp_msrun_id = nullptr) const; + + /** @brief compute emPAI within sample + * Ishihama 2005 + * */ + pappso::pappso_double getEmPAI(const MsRun *sp_msrun_id = nullptr) const; + + void setProteinXtpSp(ProteinXtpSp protein_sp); + void addPeptideMatch(const PeptideMatch &peptide_match); + std::vector<PeptideMatch> &getPeptideMatchList(); + const std::vector<PeptideMatch> &getPeptideMatchList() const; + + /** @brief get peptide match sublist with required validation state + * @param state the validation state to select + * @param sp_msrun_id the msrun to look for, if nullptr, then get peptide + * match overall MSruns + * */ + std::vector<PeptideMatch> + getPeptideMatchList(ValidationState state, + const MsRun *sp_msrun_id = nullptr) const; + + void setChecked(bool arg1); + + bool isChecked() const; + bool isValid() const; + bool isValidAndChecked() const; + bool isGrouped() const; + + ValidationState getValidationState() const; + + /** @brief count peptide match (psm) listed in this protein match + */ + unsigned int countPeptideMatch(ValidationState state) const; + + /** @brief count distinct sample + scans implied in this protein + * identification + */ + unsigned int countSampleScan(ValidationState state, + const MsRun *p_msrun_id = nullptr) const; + + /** @brief count peptide (peptide+mass) + */ + void countPeptideMass(std::vector<pappso::GrpPeptide *> &count_peptide_mass, + ValidationState state) const; + + /** @brief count peptide (peptide+mass+sample) + */ + void countPeptideMassSample(std::vector<size_t> &count_peptide_mass_sample, + ValidationState state) const; + + const pappso::GrpProteinSp &getGrpProteinSp() const; + const GroupingGroupSp &getGroupingGroupSp() const; + + /** @brief validate or invalidate peptides and proteins based automatic + * filters and manual checks + * */ + void updateAutomaticFilters( + const AutomaticFilterParameters &automatic_filter_parameters); + + + /** @brief collect distinct peptide evidences + */ + void collectPeptideEvidences( + std::set<const PeptideEvidence *> &peptide_evidence_set, + ValidationState state) const; + + /** @brief count distinct sequence taking into account equivalence between + * Leucine and Isoleucine + * @param state validation state of peptides to count + * @param p_msrun_id count within the specified sample + */ + size_t countSequenceLi(ValidationState state, + const MsRun *p_msrun_id = nullptr) const; + + /** @brief count distinct peptide+mass+charge + * peptide is the peptide sequence LI (Leucine => Isoleucine) + * mass is the peptide mass, not considering labelled residues (if any) + * @param state validation state of peptides to count + * @param p_msrun_id count within the specified sample + */ + unsigned int countPeptideMassCharge(ValidationState state, + const MsRun *sp_msrun_id = nullptr) const; + + /** @brief count distinct MS samples in which the protein is observed + * @param state validation state of peptides to count + */ + unsigned int countDistinctMsSamples(ValidationState state) const; + + protected: + void setGroupingExperiment(GroupingExperiment *p_grp_experiment); + + void setGroupInstance(GroupStore &group_store); + + + private: + static QColor _color_peptide_background; + static QColor _color_highlighted_peptide_background; + + + pappso::GrpProteinSp _sp_grp_protein; + GroupingGroupSp _sp_group; + + std::vector<PeptideMatch> _peptide_match_list; + ProteinXtpSp _protein_sp = nullptr; + /** @brief manually checked by user (true by default) + */ + bool _checked = true; + + /** @brief automatic filter result (false by default) + */ + bool _proxy_valid = false; }; #endif // PROTEINMATCH_H diff --git a/src/core/proteinxtp.cpp b/src/core/proteinxtp.cpp index 6a59f4e27e9228fa05c324bcef4b7f45961d1ddc..b77f1a0e8e7d88cd87b61a4a660e13de555d7401 100644 --- a/src/core/proteinxtp.cpp +++ b/src/core/proteinxtp.cpp @@ -1,245 +1,326 @@ /******************************************************************************* -* 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 "proteinxtp.h" #include <pappsomspp/protein/enzyme.h> #include <pappsomspp/pappsoexception.h> #include "../files/fastafile.h" -DbXref::DbXref() { +DbXref::DbXref() +{ } -DbXref::DbXref(ExternalDatabase database_in, const QString & accession_in):database(database_in), accession(accession_in) { +DbXref::DbXref(ExternalDatabase database_in, const QString &accession_in) + : database(database_in), accession(accession_in) +{ } -DbXref::DbXref(const DbXref & other):database(other.database), accession(other.accession) { +DbXref::DbXref(const DbXref &other) + : database(other.database), accession(other.accession) +{ } -const QUrl DbXref::getUrl() const { - QUrl url; - qDebug() << "DbXref::getUrl " << accession << " "<< (std::uint8_t)database; - switch (database) { - - case ExternalDatabase::AGI_LocusCode : - url.setUrl(QString("http://www.arabidopsis.org/servlets/TairObject?type=locus&name=%1").arg(accession)); +const QUrl +DbXref::getUrl() const +{ + QUrl url; + qDebug() << "DbXref::getUrl " << accession << " " << (std::uint8_t)database; + switch(database) + { + + case ExternalDatabase::AGI_LocusCode: + url.setUrl( + QString( + "http://www.arabidopsis.org/servlets/TairObject?type=locus&name=%1") + .arg(accession)); break; - case ExternalDatabase::NCBI_gi : - url.setUrl(QString("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=protein&dopt=GenBank&list_uids=%1").arg(accession)); + case ExternalDatabase::NCBI_gi: + url.setUrl( + QString( + "http://www.ncbi.nlm.nih.gov/entrez/" + "query.fcgi?cmd=Retrieve&db=protein&dopt=GenBank&list_uids=%1") + .arg(accession)); break; - case ExternalDatabase::SwissProt : + case ExternalDatabase::SwissProt: url.setUrl(QString("http://www.uniprot.org/uniprot/%1").arg(accession)); break; - case ExternalDatabase::TrEMBL : + case ExternalDatabase::TrEMBL: url.setUrl(QString("http://www.uniprot.org/uniprot/%1").arg(accession)); break; - case ExternalDatabase::ref : + case ExternalDatabase::ref: break; - case ExternalDatabase::OboPsiMod : - QString iri(QString("http://purl.obolibrary.org/obo/%1").arg(QString(accession).replace(":","_"))); - url.setUrl(QString("http://www.ebi.ac.uk/ols/ontologies/mod/terms?iri=%1").arg(iri)); + case ExternalDatabase::OboPsiMod: + QString iri(QString("http://purl.obolibrary.org/obo/%1") + .arg(QString(accession).replace(":", "_"))); + url.setUrl( + QString("http://www.ebi.ac.uk/ols/ontologies/mod/terms?iri=%1") + .arg(iri)); break; - } - qDebug() << "DbXref::getUrl end " << url; - return url; + qDebug() << "DbXref::getUrl end " << url; + return url; } -ProteinXtp::ProteinXtp():pappso::Protein() +ProteinXtp::ProteinXtp() : pappso::Protein() { - } -ProteinXtp::ProteinXtp(const ProteinXtp& other):pappso::Protein(other) +ProteinXtp::ProteinXtp(const ProteinXtp &other) : pappso::Protein(other) { - _is_decoy=other._is_decoy; - _is_contaminant=other._is_contaminant; - _p_sequence_database = other._p_sequence_database; - _p_fasta = other._p_fasta; - _dbxref_list = other._dbxref_list; + _is_decoy = other._is_decoy; + _is_contaminant = other._is_contaminant; + _p_sequence_database = other._p_sequence_database; + _p_fasta = other._p_fasta; + _dbxref_list = other._dbxref_list; } ProteinXtp::~ProteinXtp() { - } -bool ProteinXtp::operator==(const ProteinXtp& other) const +bool +ProteinXtp::operator==(const ProteinXtp &other) const { - return pappso::Protein::operator==(other); + return pappso::Protein::operator==(other); } -ProteinXtpSp ProteinXtp::makeProteinXtpSp() const { - return std::make_shared<ProteinXtp>(*this); +ProteinXtpSp +ProteinXtp::makeProteinXtpSp() const +{ + return std::make_shared<ProteinXtp>(*this); } -void ProteinXtp::setFastaFileP(const FastaFile * fasta_file) { - _p_fasta = fasta_file; +void +ProteinXtp::setFastaFileP(const FastaFile *fasta_file) +{ + _p_fasta = fasta_file; } -const FastaFile * ProteinXtp::getFastaFileP() const { - return _p_fasta; +const FastaFile * +ProteinXtp::getFastaFileP() const +{ + return _p_fasta; } -void ProteinXtp::setCompleteDescription(const QString & full_description) { - setAccession (full_description.simplified().section(" ", 0,0)); - setDescription (full_description.simplified().section(" ", 1)); +void +ProteinXtp::setCompleteDescription(const QString &full_description) +{ + setAccession(full_description.simplified().section(" ", 0, 0)); + setDescription(full_description.simplified().section(" ", 1)); } -void ProteinXtp::setIsContaminant(bool conta) { - _is_contaminant = conta; +void +ProteinXtp::setIsContaminant(bool conta) +{ + _is_contaminant = conta; } -void ProteinXtp::setIsDecoy(bool conta) { - _is_decoy = conta; +void +ProteinXtp::setIsDecoy(bool conta) +{ + _is_decoy = conta; } -bool ProteinXtp::isContaminant() const { - return _is_contaminant; +bool +ProteinXtp::isContaminant() const +{ + return _is_contaminant; } -bool ProteinXtp::isDecoy() const { - return _is_decoy; +bool +ProteinXtp::isDecoy() const +{ + return _is_decoy; } -QString ProteinXtp::getOnlyAminoAcidSequence() const { - QString sequence(this->getSequence()); - return sequence.replace(QRegExp("[^RNDBCEQZGHILKMFPSTWYVX]"),""); +QString +ProteinXtp::getOnlyAminoAcidSequence() const +{ + QString sequence(this->getSequence()); + return sequence.replace(QRegExp("[^RNDBCEQZGHILKMFPSTWYVX]"), ""); } -pappso::pappso_double ProteinXtp::getMass() const { - try { - //qDebug() << "ProteinXtp::getMass() begin " << getOnlyAminoAcidSequence().replace("[BZX]","E"); - // replace amino acid wildcard by E, just to give an random mass (assumed it is not perfect) - pappso::Peptide peptide(getOnlyAminoAcidSequence().replace(QRegExp("[BZX]"),"E")); - return peptide.getMass(); - +pappso::pappso_double +ProteinXtp::getMass() const +{ + try + { + // qDebug() << "ProteinXtp::getMass() begin " << + // getOnlyAminoAcidSequence().replace("[BZX]","E"); + // replace amino acid wildcard by E, just to give an random mass (assumed + // it is not perfect) + pappso::Peptide peptide( + getOnlyAminoAcidSequence().replace(QRegExp("[BZX]"), "E")); + return peptide.getMass(); } - catch (pappso::PappsoException error) { - qDebug() << "ProteinXtp::getMass() " << getOnlyAminoAcidSequence().replace(QRegExp("[BZX]"),"E"); - throw pappso::PappsoException(QObject::tr("Error computing mass for protein %1 :\n%2").arg(getAccession()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + qDebug() << "ProteinXtp::getMass() " + << getOnlyAminoAcidSequence().replace(QRegExp("[BZX]"), "E"); + throw pappso::PappsoException( + QObject::tr("Error computing mass for protein %1 :\n%2") + .arg(getAccession()) + .arg(error.qwhat())); } } -class DigestionHandler: public pappso::EnzymeProductInterface { -public: - void setPeptide(std::int8_t sequence_database_id, const pappso::ProteinSp & protein_sp, bool is_decoy, const QString& peptide, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme) override { - _peptide_list.append(peptide); - }; - - QStringList _peptide_list; +class DigestionHandler : public pappso::EnzymeProductInterface +{ + public: + void + setPeptide(std::int8_t sequence_database_id, + const pappso::ProteinSp &protein_sp, bool is_decoy, + const QString &peptide, unsigned int start, bool is_nter, + unsigned int missed_cleavage_number, bool semi_enzyme) override + { + _peptide_list.append(peptide); + }; + + QStringList _peptide_list; }; -unsigned int ProteinXtp::countTrypticPeptidesForPAI() const { - //qDebug() << "ProteinXtp::countTrypticPeptidesForPAI begin"; - try { - pappso::Enzyme kinase; - kinase.setMiscleavage(0); - kinase.setTakeOnlyFirstWildcard(true); - DigestionHandler digestion; - - pappso::ProteinSp protein = std::make_shared<const pappso::Protein>(this->getAccession(), this->getOnlyAminoAcidSequence()); - kinase.eat(0,protein,false,digestion); - - unsigned int count = 0; - for (const QString & peptide_str: digestion._peptide_list) { - pappso::Peptide peptide(peptide_str); - pappso::mz mass= peptide.getMass(); - if ((mass > 800) && (mass < 2500)) { - count ++; +unsigned int +ProteinXtp::countTrypticPeptidesForPAI() const +{ + // qDebug() << "ProteinXtp::countTrypticPeptidesForPAI begin"; + try + { + pappso::Enzyme kinase; + kinase.setMiscleavage(0); + kinase.setTakeOnlyFirstWildcard(true); + DigestionHandler digestion; + + pappso::ProteinSp protein = std::make_shared<const pappso::Protein>( + this->getAccession(), this->getOnlyAminoAcidSequence()); + kinase.eat(0, protein, false, digestion); + + unsigned int count = 0; + for(const QString &peptide_str : digestion._peptide_list) + { + pappso::Peptide peptide(peptide_str); + pappso::mz mass = peptide.getMass(); + if((mass > 800) && (mass < 2500)) + { + count++; } } - //qDebug() << "ProteinXtp::countTrypticPeptidesForPAI end"; - return count; - + // qDebug() << "ProteinXtp::countTrypticPeptidesForPAI end"; + return count; } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("Error in countTrypticPeptidesForPAI for protein %1 :\n%2").arg(getAccession()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("Error in countTrypticPeptidesForPAI for protein %1 :\n%2") + .arg(getAccession()) + .arg(error.qwhat())); } } -void ProteinXtp::parseAccession2dbxref() { - qDebug() << "ProteinXtp::parseAccession2dbxref begin" ; - QStringList access_list = getAccession().split("|"); - // if (access.length == 1) - QRegExp atg("^[Aa][Tt][MmCc1-5][Gg]\\d{5}\\.?\\d?$"); - QRegExp ncbi_gi("^[0-9]{5,8}$"); - QRegExp swiss_prot("^P[A-Z0-9]{5}$"); - QRegExp trembl("^[QOA][A-Z0-9]{5,10}$"); - QRegExp ref ("^[NZ]P\\_[0-9]{5,8}$"); - QString accession; - - for (unsigned int i=0; i < access_list.size(); i++) { - accession = access_list.at(i); - //qDebug() << "ProteinXtp::parseAccession2dbxref accession " << accession; - if (atg.indexIn(accession, 0) != -1) { - QStringList temp = accession.split("."); - _dbxref_list.push_back(DbXref(ExternalDatabase::AGI_LocusCode, temp.at(0))); - continue; +void +ProteinXtp::parseAccession2dbxref() +{ + qDebug() << "ProteinXtp::parseAccession2dbxref begin"; + QStringList access_list = getAccession().split("|"); + // if (access.length == 1) + QRegExp atg("^[Aa][Tt][MmCc1-5][Gg]\\d{5}\\.?\\d?$"); + QRegExp ncbi_gi("^[0-9]{5,8}$"); + QRegExp swiss_prot("^P[A-Z0-9]{5}$"); + QRegExp trembl("^[QOA][A-Z0-9]{5,10}$"); + QRegExp ref("^[NZ]P\\_[0-9]{5,8}$"); + QString accession; + + for(unsigned int i = 0; i < access_list.size(); i++) + { + accession = access_list.at(i); + // qDebug() << "ProteinXtp::parseAccession2dbxref accession " << + // accession; + if(atg.indexIn(accession, 0) != -1) + { + QStringList temp = accession.split("."); + _dbxref_list.push_back( + DbXref(ExternalDatabase::AGI_LocusCode, temp.at(0))); + continue; } - if (swiss_prot.indexIn(accession, 0) != -1) { - //qDebug() << "ProteinXtp::parseAccession2dbxref accession SwissProt " << accession; - _dbxref_list.push_back(DbXref(ExternalDatabase::SwissProt, accession)); - continue; + if(swiss_prot.indexIn(accession, 0) != -1) + { + // qDebug() << "ProteinXtp::parseAccession2dbxref accession SwissProt + // " << accession; + _dbxref_list.push_back( + DbXref(ExternalDatabase::SwissProt, accession)); + continue; } - if (trembl.indexIn(accession, 0) != -1) { - //qDebug() << "ProteinXtp::parseAccession2dbxref accession TrEMBL " << accession; - _dbxref_list.push_back(DbXref(ExternalDatabase::TrEMBL, accession)); - continue; + if(trembl.indexIn(accession, 0) != -1) + { + // qDebug() << "ProteinXtp::parseAccession2dbxref accession TrEMBL " + // << accession; + _dbxref_list.push_back(DbXref(ExternalDatabase::TrEMBL, accession)); + continue; } - if (ref.indexIn(accession, 0) != -1) { - _dbxref_list.push_back(DbXref(ExternalDatabase::ref, accession)); - continue; + if(ref.indexIn(accession, 0) != -1) + { + _dbxref_list.push_back(DbXref(ExternalDatabase::ref, accession)); + continue; } - if (i > 0) { - if ((access_list.at(i-1) == "sp")&&(accession.size() == 6)) { - _dbxref_list.push_back(DbXref(ExternalDatabase::SwissProt, accession)); + if(i > 0) + { + if((access_list.at(i - 1) == "sp") && (accession.size() == 6)) + { + _dbxref_list.push_back( + DbXref(ExternalDatabase::SwissProt, accession)); } - if ((access_list.at(i-1) == "tr")&&(accession.size() == 6)) { - _dbxref_list.push_back(DbXref(ExternalDatabase::TrEMBL, accession)); + if((access_list.at(i - 1) == "tr") && (accession.size() == 6)) + { + _dbxref_list.push_back( + DbXref(ExternalDatabase::TrEMBL, accession)); } - if ((access_list.at(i-1) == "gb")&&(ncbi_gi.indexIn(accession, 0) != -1)) { - _dbxref_list.push_back(DbXref(ExternalDatabase::NCBI_gi, accession)); + if((access_list.at(i - 1) == "gb") && + (ncbi_gi.indexIn(accession, 0) != -1)) + { + _dbxref_list.push_back( + DbXref(ExternalDatabase::NCBI_gi, accession)); } - } - if (_dbxref_list.size() > 1) { - _dbxref_list.sort([] (const DbXref & first, const DbXref & second) - { - return std::tie(first.database, first.accession) < std::tie(second.database, second.accession); - }); - _dbxref_list.unique([] (const DbXref & first, const DbXref & second) - { - return ( first.database == second.database ) && (first.accession == second.accession); - }); + if(_dbxref_list.size() > 1) + { + _dbxref_list.sort([](const DbXref &first, const DbXref &second) { + return std::tie(first.database, first.accession) < + std::tie(second.database, second.accession); + }); + _dbxref_list.unique([](const DbXref &first, const DbXref &second) { + return (first.database == second.database) && + (first.accession == second.accession); + }); } } - //qDebug() << "ProteinXtp::parseAccession2dbxref end" ; - + // qDebug() << "ProteinXtp::parseAccession2dbxref end" ; } -const std::list<DbXref> & ProteinXtp::getDbxrefList() const { - return _dbxref_list; +const std::list<DbXref> & +ProteinXtp::getDbxrefList() const +{ + return _dbxref_list; } diff --git a/src/core/proteinxtp.h b/src/core/proteinxtp.h index a49d39eb472258b5b707c50d559b41f0334d0ae8..a69832e41737e9f3cc74ea1029041df36c724503 100644 --- a/src/core/proteinxtp.h +++ b/src/core/proteinxtp.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 + ******************************************************************************/ #include <pappsomspp/protein/protein.h> #include <pappsomspp/types.h> @@ -33,13 +34,14 @@ class FastaFile; #ifndef PROTEIN_XTP_H #define PROTEIN_XTP_H -struct DbXref { - DbXref(); - DbXref(const DbXref & other); - DbXref(ExternalDatabase database_in, const QString & accession_in); - const QUrl getUrl() const; - ExternalDatabase database; - QString accession; +struct DbXref +{ + DbXref(); + DbXref(const DbXref &other); + DbXref(ExternalDatabase database_in, const QString &accession_in); + const QUrl getUrl() const; + ExternalDatabase database; + QString accession; }; class ProteinXtp; @@ -48,50 +50,51 @@ class ProteinXtp; */ typedef std::shared_ptr<ProteinXtp> ProteinXtpSp; -class ProteinXtp : public pappso::Protein { -public: - ProteinXtp(); - ProteinXtp(const ProteinXtp& other); - virtual ~ProteinXtp(); - bool operator==(const ProteinXtp& other) const; - - - ProteinXtpSp makeProteinXtpSp() const; - - /** @brief separates accession from description based on first space separator - */ - void setCompleteDescription(const QString & full_description); - - void setIsContaminant(bool conta); - void setIsDecoy(bool conta); - void setFastaFileP(const FastaFile * fasta_file); - const FastaFile * getFastaFileP() const; - bool isContaminant() const; - bool isDecoy() const; - unsigned int countTrypticPeptidesForPAI() const; - - /** @brief get only amino acid sequence - * clean sequence of other characters : * _ ... - */ - QString getOnlyAminoAcidSequence() const; - - /** @brief get protein mass in dalton - */ - pappso::pappso_double getMass() const; - - /** @brief look for external database accessions in accesion text - */ - void parseAccession2dbxref(); - - const std::list<DbXref> & getDbxrefList() const; - -private: - SequenceDatabase * _p_sequence_database; - bool _is_decoy=false; - bool _is_contaminant=false; - std::list<DbXref> _dbxref_list; - - const FastaFile * _p_fasta=nullptr; +class ProteinXtp : public pappso::Protein +{ + public: + ProteinXtp(); + ProteinXtp(const ProteinXtp &other); + virtual ~ProteinXtp(); + bool operator==(const ProteinXtp &other) const; + + + ProteinXtpSp makeProteinXtpSp() const; + + /** @brief separates accession from description based on first space separator + */ + void setCompleteDescription(const QString &full_description); + + void setIsContaminant(bool conta); + void setIsDecoy(bool conta); + void setFastaFileP(const FastaFile *fasta_file); + const FastaFile *getFastaFileP() const; + bool isContaminant() const; + bool isDecoy() const; + unsigned int countTrypticPeptidesForPAI() const; + + /** @brief get only amino acid sequence + * clean sequence of other characters : * _ ... + */ + QString getOnlyAminoAcidSequence() const; + + /** @brief get protein mass in dalton + */ + pappso::pappso_double getMass() const; + + /** @brief look for external database accessions in accesion text + */ + void parseAccession2dbxref(); + + const std::list<DbXref> &getDbxrefList() const; + + private: + SequenceDatabase *_p_sequence_database; + bool _is_decoy = false; + bool _is_contaminant = false; + std::list<DbXref> _dbxref_list; + + const FastaFile *_p_fasta = nullptr; }; #endif // PROTEIN_XTP_H diff --git a/src/core/sequencedatabase.cpp b/src/core/sequencedatabase.cpp index 9deb2a0c0bd49e16df6080b0a58943b093ca6a6a..54e474ea493e97d6c3d225afc70eebc68e66889e 100644 --- a/src/core/sequencedatabase.cpp +++ b/src/core/sequencedatabase.cpp @@ -1,34 +1,33 @@ /******************************************************************************* -* 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 "sequencedatabase.h" SequenceDatabase::SequenceDatabase() { - } SequenceDatabase::~SequenceDatabase() { - } diff --git a/src/core/sequencedatabase.h b/src/core/sequencedatabase.h index 4123ebd04bc2df426e71db37ae753b380873bfa5..9861374d130d3864fc29dffe6a29eb2935fb962e 100644 --- a/src/core/sequencedatabase.h +++ b/src/core/sequencedatabase.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 SEQUENCEDATABASE_H #define SEQUENCEDATABASE_H @@ -34,9 +35,9 @@ typedef std::shared_ptr<SequenceDatabase> SequenceDatabaseSp; class SequenceDatabase { -public: - SequenceDatabase(); - virtual ~SequenceDatabase(); + public: + SequenceDatabase(); + virtual ~SequenceDatabase(); }; #endif // SEQUENCEDATABASE_H diff --git a/src/core/tandem_run/tandembatchprocess.cpp b/src/core/tandem_run/tandembatchprocess.cpp index 0437c0a124db721f2694aedcd5284137f769bffb..ba9be3d7dc654f7e9b6655001f98c9fa7e798b1c 100644 --- a/src/core/tandem_run/tandembatchprocess.cpp +++ b/src/core/tandem_run/tandembatchprocess.cpp @@ -6,26 +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 "tandembatchprocess.h" #include <QProcess> @@ -35,235 +36,297 @@ #include <QTemporaryDir> #include "../../files/tandemparametersfile.h" -TandemBatchProcess::TandemBatchProcess(MainWindow * p_main_window, WorkMonitorInterface * p_monitor, const TandemRunBatch & tandem_run_batch) { - _p_main_window = p_main_window; - _tandem_run_batch = tandem_run_batch; - _p_monitor = p_monitor; - _tmp_database_file.setAutoRemove(true); - - //check that output directory is writeable : - QFileInfo fi_in_dir(_tandem_run_batch._output_directory); - if (fi_in_dir.isDir() && fi_in_dir.isWritable()) { - } else { - throw pappso::PappsoException(QObject::tr("output directory is not writable. Please check permissions on %1").arg(fi_in_dir.absoluteFilePath())); +TandemBatchProcess::TandemBatchProcess(MainWindow *p_main_window, + WorkMonitorInterface *p_monitor, + const TandemRunBatch &tandem_run_batch) +{ + _p_main_window = p_main_window; + _tandem_run_batch = tandem_run_batch; + _p_monitor = p_monitor; + _tmp_database_file.setAutoRemove(true); + + // check that output directory is writeable : + QFileInfo fi_in_dir(_tandem_run_batch._output_directory); + if(fi_in_dir.isDir() && fi_in_dir.isWritable()) + { + } + else + { + throw pappso::PappsoException( + QObject::tr( + "output directory is not writable. Please check permissions on %1") + .arg(fi_in_dir.absoluteFilePath())); } } -TandemBatchProcess::~TandemBatchProcess() { +TandemBatchProcess::~TandemBatchProcess() +{ } -bool TandemBatchProcess::shouldIstop() { - if (_p_main_window->stopWorkerThread()) { - return true; +bool +TandemBatchProcess::shouldIstop() +{ + if(_p_main_window->stopWorkerThread()) + { + return true; } - return false; + return false; } -void TandemBatchProcess::writeXmlDatabaseFile (QXmlStreamWriter * p_out) { - p_out->setAutoFormatting(true); - p_out->writeStartDocument("1.0"); - - //<?xml version="1.0" encoding="UTF-8"?> - //<bioml label="x! taxon-to-file matching list"> - p_out->writeStartElement("bioml"); - p_out->writeAttribute("label","x! taxon-to-file matching list"); - //<taxon label="usedefined"> - p_out->writeStartElement("taxon"); - p_out->writeAttribute("label","usedefined"); - //<file format="peptide" URL="/gorgone/pappso/jouy/users/Didier/fasta/20170608_Delastours/contaminants_standards.fasta"></file> - //<file format="peptide" URL="/gorgone/pappso/jouy/users/Didier/fasta/20170608_Delastours/Escherichia coli 27J42_WGS_ECOLI_1.fasta"></file> - for (QString fasta_file:_tandem_run_batch._fasta_file_list) { - p_out->writeStartElement("file"); - p_out->writeAttribute("format","peptide"); - p_out->writeAttribute("URL",fasta_file); - p_out->writeEndElement(); +void +TandemBatchProcess::writeXmlDatabaseFile(QXmlStreamWriter *p_out) +{ + p_out->setAutoFormatting(true); + p_out->writeStartDocument("1.0"); + + //<?xml version="1.0" encoding="UTF-8"?> + //<bioml label="x! taxon-to-file matching list"> + p_out->writeStartElement("bioml"); + p_out->writeAttribute("label", "x! taxon-to-file matching list"); + //<taxon label="usedefined"> + p_out->writeStartElement("taxon"); + p_out->writeAttribute("label", "usedefined"); + //<file format="peptide" + //URL="/gorgone/pappso/jouy/users/Didier/fasta/20170608_Delastours/contaminants_standards.fasta"></file> + //<file format="peptide" + //URL="/gorgone/pappso/jouy/users/Didier/fasta/20170608_Delastours/Escherichia + //coli 27J42_WGS_ECOLI_1.fasta"></file> + for(QString fasta_file : _tandem_run_batch._fasta_file_list) + { + p_out->writeStartElement("file"); + p_out->writeAttribute("format", "peptide"); + p_out->writeAttribute("URL", fasta_file); + p_out->writeEndElement(); } - //</taxon> - p_out->writeEndElement(); - //</bioml> - p_out->writeEndElement(); - p_out->writeEndDocument(); + //</taxon> + p_out->writeEndElement(); + //</bioml> + p_out->writeEndElement(); + p_out->writeEndDocument(); } -void TandemBatchProcess::prepareXmlDatabaseFile() { +void +TandemBatchProcess::prepareXmlDatabaseFile() +{ - if (_tmp_database_file.open()) + if(_tmp_database_file.open()) { - _xml_database_file = QFileInfo( _tmp_database_file.fileName()).absoluteFilePath(); - QXmlStreamWriter * p_out = new QXmlStreamWriter(); - p_out->setDevice(&_tmp_database_file); - writeXmlDatabaseFile(p_out); - _tmp_database_file.close(); - delete p_out; - } else + _xml_database_file = + QFileInfo(_tmp_database_file.fileName()).absoluteFilePath(); + QXmlStreamWriter *p_out = new QXmlStreamWriter(); + p_out->setDevice(&_tmp_database_file); + writeXmlDatabaseFile(p_out); + _tmp_database_file.close(); + delete p_out; + } + else { - throw pappso::PappsoException(QObject::tr("error : cannot open the XML database file : %1\n").arg(_tmp_database_file.fileName())); + throw pappso::PappsoException( + QObject::tr("error : cannot open the XML database file : %1\n") + .arg(_tmp_database_file.fileName())); } - } -void TandemBatchProcess::run() { - qDebug() << "TandemBatchProcess::run begin " << _tandem_run_batch._preset_file; - QTemporaryDir tmp_dir; - if (!tmp_dir.isValid()) { - // dir.path() returns the unique directory path - throw pappso::PappsoException(QObject::tr("problem creating temporary directory in %1\n").arg(tmp_dir.path())); +void +TandemBatchProcess::run() +{ + qDebug() << "TandemBatchProcess::run begin " + << _tandem_run_batch._preset_file; + QTemporaryDir tmp_dir; + if(!tmp_dir.isValid()) + { + // dir.path() returns the unique directory path + throw pappso::PappsoException( + QObject::tr("problem creating temporary directory in %1\n") + .arg(tmp_dir.path())); } - TandemParametersFile orig_parameter_file(_tandem_run_batch._preset_file); - _preset_file = QString("%1/%2").arg(tmp_dir.path()).arg(orig_parameter_file.getFilename()); + TandemParametersFile orig_parameter_file(_tandem_run_batch._preset_file); + _preset_file = + QString("%1/%2").arg(tmp_dir.path()).arg(orig_parameter_file.getFilename()); - TandemParametersFile new_parameter_file(_preset_file); - TandemParameters new_param = orig_parameter_file.getTandemParameters(); - // <note type="input" label="spectrum, threads">1</note> - new_param.setParamLabelValue("spectrum, threads",QString("%1").arg(_tandem_run_batch._number_of_threads)); - new_parameter_file.setTandemParameters(new_param); + TandemParametersFile new_parameter_file(_preset_file); + TandemParameters new_param = orig_parameter_file.getTandemParameters(); + // <note type="input" label="spectrum, threads">1</note> + new_param.setParamLabelValue( + "spectrum, threads", + QString("%1").arg(_tandem_run_batch._number_of_threads)); + new_parameter_file.setTandemParameters(new_param); - prepareXmlDatabaseFile(); + prepareXmlDatabaseFile(); - int i=0; - _p_monitor->setProgressMaximumValue(_tandem_run_batch._mz_file_list.size()); - for (QString mz_file : _tandem_run_batch._mz_file_list) { - if (shouldIstop()) { - throw pappso::PappsoException(QObject::tr("X!Tandem stopped by the user processing %1 sample").arg(mz_file)); + int i = 0; + _p_monitor->setProgressMaximumValue(_tandem_run_batch._mz_file_list.size()); + for(QString mz_file : _tandem_run_batch._mz_file_list) + { + if(shouldIstop()) + { + throw pappso::PappsoException( + QObject::tr("X!Tandem stopped by the user processing %1 sample") + .arg(mz_file)); } - _p_monitor->message(QObject::tr("running X!Tandem on %1\n").arg(mz_file), i); - runOne(mz_file); - i++; + _p_monitor->message(QObject::tr("running X!Tandem on %1\n").arg(mz_file), + i); + runOne(mz_file); + i++; } - _p_monitor->finished(QObject::tr("%1 X!Tandem job(s) finished").arg(_tandem_run_batch._mz_file_list.size())); - qDebug() << "TandemBatchProcess::run end" ; + _p_monitor->finished(QObject::tr("%1 X!Tandem job(s) finished") + .arg(_tandem_run_batch._mz_file_list.size())); + qDebug() << "TandemBatchProcess::run end"; } -void TandemBatchProcess::writeXmlInputFile (QXmlStreamWriter * p_out, const QString & mz_file) { - - QFileInfo mz_file_info(mz_file); - //<?xml version="1.0" encoding="UTF-8"?> - - p_out->setAutoFormatting(true); - p_out->writeStartDocument("1.0"); - - //<bioml label="20170405_Delastour_11.xml"> - p_out->writeStartElement("bioml"); - p_out->writeAttribute("label",mz_file_info.fileName()); - - //<note type="heading">Paths</note> - p_out->writeStartElement("note"); - p_out->writeAttribute("type","heading"); - p_out->writeCharacters("Paths"); - p_out->writeEndElement(); - - //<note type="input" label="list path, default parameters">/gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/QExactive_IAM_4CPU_Classic_ClassicAvecReversed..xml</note> - p_out->writeStartElement("note"); - p_out->writeAttribute("type","input"); - p_out->writeAttribute("label","list path, default parameters"); - p_out->writeCharacters(_preset_file); - p_out->writeEndElement(); - - //<note type="input" label="list path, taxonomy information">/gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/database.xml</note> - p_out->writeStartElement("note"); - p_out->writeAttribute("type","input"); - p_out->writeAttribute("label","list path, taxonomy information"); - p_out->writeCharacters(_xml_database_file); - p_out->writeEndElement(); - - - //<note type="input" label="spectrum, path">/gorgone/pappso/jouy/raw/2017_Qex/20170405_Delastours/20170405_Delastour_11.mzXML</note> - - p_out->writeStartElement("note"); - p_out->writeAttribute("type","input"); - p_out->writeAttribute("label","spectrum, path"); - p_out->writeCharacters(mz_file); - p_out->writeEndElement(); - - //<note type="heading">Protein general</note> - p_out->writeStartElement("note"); - p_out->writeAttribute("type","heading"); - p_out->writeCharacters("Protein general"); - p_out->writeEndElement(); - - //<note type="input" label="protein, taxon">usedefined</note> - p_out->writeStartElement("note"); - p_out->writeAttribute("type","input"); - p_out->writeAttribute("label","protein, taxon"); - p_out->writeCharacters("usedefined"); - p_out->writeEndElement(); - //<note type="heading">Output</note> - p_out->writeStartElement("note"); - p_out->writeAttribute("type","heading"); - p_out->writeCharacters("Output"); - p_out->writeEndElement(); - - //<note type="input" label="output, path">/gorgone/pappso/jouy/users/Didier/Xcal2017/2017_05_04_Delastours/Interrogation_souches_sequencees/Patient27/J42/20170405_Delastour_11.xml</note> - - p_out->writeStartElement("note"); - p_out->writeAttribute("type","input"); - p_out->writeAttribute("label","output, path"); - p_out->writeCharacters(QString("%1/%2.xml").arg(_tandem_run_batch._output_directory).arg(mz_file_info.baseName())); - p_out->writeEndElement(); - - //</bioml> - p_out->writeEndElement(); - - - p_out->writeEndDocument(); +void +TandemBatchProcess::writeXmlInputFile(QXmlStreamWriter *p_out, + const QString &mz_file) +{ + + QFileInfo mz_file_info(mz_file); + //<?xml version="1.0" encoding="UTF-8"?> + + p_out->setAutoFormatting(true); + p_out->writeStartDocument("1.0"); + + //<bioml label="20170405_Delastour_11.xml"> + p_out->writeStartElement("bioml"); + p_out->writeAttribute("label", mz_file_info.fileName()); + + //<note type="heading">Paths</note> + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "heading"); + p_out->writeCharacters("Paths"); + p_out->writeEndElement(); + + //<note type="input" label="list path, default + //parameters">/gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/QExactive_IAM_4CPU_Classic_ClassicAvecReversed..xml</note> + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "input"); + p_out->writeAttribute("label", "list path, default parameters"); + p_out->writeCharacters(_preset_file); + p_out->writeEndElement(); + + //<note type="input" label="list path, taxonomy + //information">/gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/database.xml</note> + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "input"); + p_out->writeAttribute("label", "list path, taxonomy information"); + p_out->writeCharacters(_xml_database_file); + p_out->writeEndElement(); + + + //<note type="input" label="spectrum, + //path">/gorgone/pappso/jouy/raw/2017_Qex/20170405_Delastours/20170405_Delastour_11.mzXML</note> + + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "input"); + p_out->writeAttribute("label", "spectrum, path"); + p_out->writeCharacters(mz_file); + p_out->writeEndElement(); + + //<note type="heading">Protein general</note> + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "heading"); + p_out->writeCharacters("Protein general"); + p_out->writeEndElement(); + + //<note type="input" label="protein, taxon">usedefined</note> + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "input"); + p_out->writeAttribute("label", "protein, taxon"); + p_out->writeCharacters("usedefined"); + p_out->writeEndElement(); + //<note type="heading">Output</note> + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "heading"); + p_out->writeCharacters("Output"); + p_out->writeEndElement(); + + //<note type="input" label="output, + //path">/gorgone/pappso/jouy/users/Didier/Xcal2017/2017_05_04_Delastours/Interrogation_souches_sequencees/Patient27/J42/20170405_Delastour_11.xml</note> + + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "input"); + p_out->writeAttribute("label", "output, path"); + p_out->writeCharacters(QString("%1/%2.xml") + .arg(_tandem_run_batch._output_directory) + .arg(mz_file_info.baseName())); + p_out->writeEndElement(); + + //</bioml> + p_out->writeEndElement(); + + + p_out->writeEndDocument(); } -void TandemBatchProcess::runOne(const QString & mz_file) { - QTemporaryFile xml_input_file; - xml_input_file.setAutoRemove(true); - if (xml_input_file.open()) +void +TandemBatchProcess::runOne(const QString &mz_file) +{ + QTemporaryFile xml_input_file; + xml_input_file.setAutoRemove(true); + if(xml_input_file.open()) { - QXmlStreamWriter * p_out = new QXmlStreamWriter(); - p_out->setDevice(&xml_input_file); + QXmlStreamWriter *p_out = new QXmlStreamWriter(); + p_out->setDevice(&xml_input_file); - writeXmlInputFile(p_out, mz_file); + writeXmlInputFile(p_out, mz_file); - xml_input_file.close(); - delete p_out; - } else + xml_input_file.close(); + delete p_out; + } + else { - throw pappso::PappsoException(QObject::tr("error : cannot open the XML X!Tandem input file : %1\n").arg(xml_input_file.fileName())); + throw pappso::PappsoException( + QObject::tr("error : cannot open the XML X!Tandem input file : %1\n") + .arg(xml_input_file.fileName())); } - QStringList arguments; + QStringList arguments; - arguments << xml_input_file.fileName(); + arguments << xml_input_file.fileName(); - QProcess * xt_process = new QProcess(); - //hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath()); - xt_process->start(_tandem_run_batch._tandem_bin_path, arguments); + QProcess *xt_process = new QProcess(); + // hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath()); + xt_process->start(_tandem_run_batch._tandem_bin_path, arguments); - if (!xt_process->waitForStarted()) { - throw pappso::PappsoException(QObject::tr("X!Tandem process failed to start")); + if(!xt_process->waitForStarted()) + { + throw pappso::PappsoException( + QObject::tr("X!Tandem process failed to start")); } - while(xt_process->waitForReadyRead(_max_xt_time_ms)) { - _p_monitor->appendText( xt_process->readAll().data()); - //data.append(xt_process->readAll()); - if (shouldIstop()) { - xt_process->kill(); - delete xt_process; - throw pappso::PappsoException(QObject::tr("X!Tandem stopped by the user processing %1 sample").arg(mz_file)); + while(xt_process->waitForReadyRead(_max_xt_time_ms)) + { + _p_monitor->appendText(xt_process->readAll().data()); + // data.append(xt_process->readAll()); + if(shouldIstop()) + { + xt_process->kill(); + delete xt_process; + throw pappso::PappsoException( + QObject::tr("X!Tandem stopped by the user processing %1 sample") + .arg(mz_file)); } } - /* - if (!xt_process->waitForFinished(_max_xt_time_ms)) { - throw pappso::PappsoException(QObject::tr("can't wait for X!Tandem process to finish : timeout at %1").arg(_max_xt_time_ms)); - } - */ - QByteArray result = xt_process->readAll(); - - QProcess::ExitStatus Status = xt_process->exitStatus(); - - delete xt_process; - if (Status != 0) + /* + if (!xt_process->waitForFinished(_max_xt_time_ms)) { + throw pappso::PappsoException(QObject::tr("can't wait for X!Tandem process + to finish : timeout at %1").arg(_max_xt_time_ms)); + } + */ + QByteArray result = xt_process->readAll(); + + QProcess::ExitStatus Status = xt_process->exitStatus(); + + delete xt_process; + if(Status != 0) { - // != QProcess::NormalExit - throw pappso::PappsoException(QObject::tr("error executing X!Tandem Status != 0 : %1 %2\n%3").arg(_tandem_run_batch._tandem_bin_path).arg(arguments.join(" ").arg(result.data()))); + // != QProcess::NormalExit + throw pappso::PappsoException( + QObject::tr("error executing X!Tandem Status != 0 : %1 %2\n%3") + .arg(_tandem_run_batch._tandem_bin_path) + .arg(arguments.join(" ").arg(result.data()))); } - } diff --git a/src/core/tandem_run/tandembatchprocess.h b/src/core/tandem_run/tandembatchprocess.h index 7502c4b64c094ea752b872625f9db9982e1548b8..beb8b13fa31c1d737788c10f075b296d42ce5f9e 100644 --- a/src/core/tandem_run/tandembatchprocess.h +++ b/src/core/tandem_run/tandembatchprocess.h @@ -6,26 +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 + ******************************************************************************/ #ifndef TANDEMBATCHPROCESS_H #define TANDEMBATCHPROCESS_H @@ -37,31 +38,32 @@ class TandemBatchProcess { -public: - TandemBatchProcess(MainWindow * p_main_window, WorkMonitorInterface * p_monitor, const TandemRunBatch & tandem_run_batch); - virtual ~TandemBatchProcess(); + public: + TandemBatchProcess(MainWindow *p_main_window, WorkMonitorInterface *p_monitor, + const TandemRunBatch &tandem_run_batch); + virtual ~TandemBatchProcess(); - virtual void run(); -protected: - void writeXmlDatabaseFile (QXmlStreamWriter * p_out); - void writeXmlInputFile (QXmlStreamWriter * p_out, const QString & mz_file); - virtual void prepareXmlDatabaseFile(); - bool shouldIstop(); -private: - void runOne(const QString & mz_file); + virtual void run(); -protected: - QString _preset_file; - TandemRunBatch _tandem_run_batch; - WorkMonitorInterface * _p_monitor; - QString _xml_database_file; - int _max_xt_time_ms = (60000 * 60 * 24); //1 day - -private: - - - QTemporaryFile _tmp_database_file; - MainWindow * _p_main_window=nullptr; + protected: + void writeXmlDatabaseFile(QXmlStreamWriter *p_out); + void writeXmlInputFile(QXmlStreamWriter *p_out, const QString &mz_file); + virtual void prepareXmlDatabaseFile(); + bool shouldIstop(); + + private: + void runOne(const QString &mz_file); + + protected: + QString _preset_file; + TandemRunBatch _tandem_run_batch; + WorkMonitorInterface *_p_monitor; + QString _xml_database_file; + int _max_xt_time_ms = (60000 * 60 * 24); // 1 day + + private: + QTemporaryFile _tmp_database_file; + MainWindow *_p_main_window = nullptr; }; #endif // TANDEMBATCHPROCESS_H diff --git a/src/core/tandem_run/tandemcondorprocess.h b/src/core/tandem_run/tandemcondorprocess.h index 492dea58f6f18c01f72935fca8ef34f01e6f3dbe..2f89dabaff0e357e184458ab9d21484652aacb4d 100644 --- a/src/core/tandem_run/tandemcondorprocess.h +++ b/src/core/tandem_run/tandemcondorprocess.h @@ -6,26 +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 + ******************************************************************************/ #ifndef TANDEMCONDORPROCESS_H #define TANDEMCONDORPROCESS_H @@ -33,36 +34,38 @@ #include "tandembatchprocess.h" #include <QTemporaryDir> -class TandemCondorProcess: public TandemBatchProcess +class TandemCondorProcess : public TandemBatchProcess { -public: - TandemCondorProcess(MainWindow * p_main_window, WorkMonitorInterface * p_monitor, const TandemRunBatch & tandem_run_batch); - virtual ~TandemCondorProcess(); + public: + TandemCondorProcess(MainWindow *p_main_window, + WorkMonitorInterface *p_monitor, + const TandemRunBatch &tandem_run_batch); + virtual ~TandemCondorProcess(); - virtual void prepareXmlDatabaseFile(); - virtual void run(); - - unsigned int getCondorJobSize() const; - void setCondorJobStatus(std::int8_t count_status[10]); - -private : - void parseCondorJobNumber(QString condor_job); - void surveyCondorJob(); - void getCondorJobState(); - void parseCondorQueue(QString & condor_q_xml); - void condorRemoveJob(); -private: - QTemporaryDir * _p_tmp_dir; - QString _condor_submit_command; - QString _condor_q_command; - QString _condor_rm_command; - - unsigned int _condor_cluster_number; - unsigned int _condor_job_size; - unsigned int _condor_request_memory; - unsigned int _condor_status_timer_millisecond= 1000; - unsigned int _condor_completed_jobs = 0; + virtual void prepareXmlDatabaseFile(); + virtual void run(); + unsigned int getCondorJobSize() const; + void setCondorJobStatus(std::int8_t count_status[10]); + + private: + void parseCondorJobNumber(QString condor_job); + void surveyCondorJob(); + void getCondorJobState(); + void parseCondorQueue(QString &condor_q_xml); + void condorRemoveJob(); + + private: + QTemporaryDir *_p_tmp_dir; + QString _condor_submit_command; + QString _condor_q_command; + QString _condor_rm_command; + + unsigned int _condor_cluster_number; + unsigned int _condor_job_size; + unsigned int _condor_request_memory; + unsigned int _condor_status_timer_millisecond = 1000; + unsigned int _condor_completed_jobs = 0; }; #endif // TANDECONDORPROCESS_H diff --git a/src/core/tandem_run/tandemparameters.cpp b/src/core/tandem_run/tandemparameters.cpp index 1a43c52679ae4efdc0b7f577748ea6fce3cf80f7..b20665b018599d4fdd615f0e5f9eef1f786ee756 100644 --- a/src/core/tandem_run/tandemparameters.cpp +++ b/src/core/tandem_run/tandemparameters.cpp @@ -6,136 +6,228 @@ */ /******************************************************************************* -* 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 "tandemparameters.h" #include <QDebug> #include <pappsomspp/exception/exceptionnotfound.h> #include <pappsomspp/exception/exceptionnotpossible.h> -TandemParameters::TandemParameters() { +TandemParameters::TandemParameters() +{ } -TandemParameters::~TandemParameters() { +TandemParameters::~TandemParameters() +{ } -TandemParameters::TandemParameters(const TandemParameters & other) { - qDebug() << "TandemParameters::TandemParameters copy begin"; - //_map_label_value = other._map_label_value; - _method_name = other._method_name; +TandemParameters::TandemParameters(const TandemParameters &other) +{ + qDebug() << "TandemParameters::TandemParameters copy begin"; + //_map_label_value = other._map_label_value; + _method_name = other._method_name; - QMap<QString, QString>::const_iterator i = other._map_label_value.constBegin(); - while (i != other._map_label_value.constEnd()) { - qDebug() << "TandemParameters::TandemParameters copy " << i.key() << " " << i.value(); - _map_label_value.insert(i.key(), i.value()); - i++; // added + QMap<QString, QString>::const_iterator i = + other._map_label_value.constBegin(); + while(i != other._map_label_value.constEnd()) + { + qDebug() << "TandemParameters::TandemParameters copy " << i.key() << " " + << i.value(); + _map_label_value.insert(i.key(), i.value()); + i++; // added } - qDebug() << "TandemParameters::TandemParameters copy end"; + qDebug() << "TandemParameters::TandemParameters copy end"; } -bool TandemParameters::equals(const TandemParameters & other) const { - if (_method_name != other._method_name) { - return false; +bool +TandemParameters::equals(const TandemParameters &other) const +{ + if(_method_name != other._method_name) + { + return false; } - if (_map_label_value.size() != other._map_label_value.size()) { - return false; + if(_map_label_value.size() != other._map_label_value.size()) + { + return false; } - QMap<QString, QString>::const_iterator i = _map_label_value.constBegin(); - while (i != _map_label_value.constEnd()) { - if(i.value() != other.getValue(i.key())) { - return false; + QMap<QString, QString>::const_iterator i = _map_label_value.constBegin(); + while(i != _map_label_value.constEnd()) + { + if(i.value() != other.getValue(i.key())) + { + return false; } - i++; // added + i++; // added } - return true; + return true; } -const QString TandemParameters::getLabelCategory(const QString & value) const { - return value.split(", ").at(0); +const QString +TandemParameters::getLabelCategory(const QString &value) const +{ + return value.split(", ").at(0); } -const QString & TandemParameters::getValue(const QString & label) const { - QMap<QString,QString>::const_iterator it = _map_label_value.constFind(label); - if (it == _map_label_value.end()) { - throw pappso::ExceptionNotFound(QObject::tr("X!Tandem preset label %1 not found in method %2").arg(label).arg(_method_name)); +const QString & +TandemParameters::getValue(const QString &label) const +{ + QMap<QString, QString>::const_iterator it = _map_label_value.constFind(label); + if(it == _map_label_value.end()) + { + throw pappso::ExceptionNotFound( + QObject::tr("X!Tandem preset label %1 not found in method %2") + .arg(label) + .arg(_method_name)); } - return it.value(); + return it.value(); } -void TandemParameters::setParamLabelValue(const QString & label, const QString & value) { - //list path - //<note type="input" label="list path, default parameters">/gorgone/pappso/tmp/temp_condor_job24872841484824316495370334631825647/QExactive_analysis_FDR_nosemi.xml</note> - //<note type="input" label="list path, taxonomy information">/gorgone/pappso/tmp/temp_condor_job24872841484824316495370334631825647/database.xml</note> - if (getLabelCategory(label) == "list path") { - return; +void +TandemParameters::setParamLabelValue(const QString &label, const QString &value) +{ + // list path + //<note type="input" label="list path, default + //parameters">/gorgone/pappso/tmp/temp_condor_job24872841484824316495370334631825647/QExactive_analysis_FDR_nosemi.xml</note> + //<note type="input" label="list path, taxonomy + //information">/gorgone/pappso/tmp/temp_condor_job24872841484824316495370334631825647/database.xml</note> + if(getLabelCategory(label) == "list path") + { + return; } - if (label == "spectrum, path") { - return; + if(label == "spectrum, path") + { + return; } - if ((label == "spectrum, parent monoisotopic mass error units") || (label == "spectrum, fragment monoisotopic mass error units")) { - if ((value != "Daltons") && (value != "ppm")) { - throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be Daltons or ppm (not %2)").arg(label).arg(value)); + if((label == "spectrum, parent monoisotopic mass error units") || + (label == "spectrum, fragment monoisotopic mass error units")) + { + if((value != "Daltons") && (value != "ppm")) + { + throw pappso::ExceptionNotPossible( + QObject::tr("%1 value must be Daltons or ppm (not %2)") + .arg(label) + .arg(value)); } } - if ((label == "spectrum, parent monoisotopic mass isotope error") || (label == "spectrum, use neutral loss window") || (label == "spectrum, use contrast angle") || (label == "protein, cleavage semi") || (label == "protein, quick acetyl") || (label == "protein, quick pyrolidone") || (label == "protein, stP bias") || (label == "scoring, cyclic permutation") || (label == "scoring, include reverse") || (label == "scoring, y ions") || (label == "scoring, b ions") || (label == "scoring, c ions") || (label == "scoring, z ions") || (label == "scoring, a ions") || (label == "scoring, x ions") || (label == "refine") || (label == "refine, use potential modifications for full refinement") || (label == "refine, cleavage semi") || (label == "refine, unanticipated cleavage")|| (label == "refine, spectrum synthesis")|| (label == "refine, point mutations") || (label == "output, mzid") || (label == "output, spectra") || (label == "spectrum, use noise suppression")) { - if ((value != "yes") && (value != "no")) { - throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be yes or no (not %2)").arg(label).arg(value)); + if((label == "spectrum, parent monoisotopic mass isotope error") || + (label == "spectrum, use neutral loss window") || + (label == "spectrum, use contrast angle") || + (label == "protein, cleavage semi") || + (label == "protein, quick acetyl") || + (label == "protein, quick pyrolidone") || (label == "protein, stP bias") || + (label == "scoring, cyclic permutation") || + (label == "scoring, include reverse") || (label == "scoring, y ions") || + (label == "scoring, b ions") || (label == "scoring, c ions") || + (label == "scoring, z ions") || (label == "scoring, a ions") || + (label == "scoring, x ions") || (label == "refine") || + (label == "refine, use potential modifications for full refinement") || + (label == "refine, cleavage semi") || + (label == "refine, unanticipated cleavage") || + (label == "refine, spectrum synthesis") || + (label == "refine, point mutations") || (label == "output, mzid") || + (label == "output, spectra") || + (label == "spectrum, use noise suppression")) + { + if((value != "yes") && (value != "no")) + { + throw pappso::ExceptionNotPossible( + QObject::tr("%1 value must be yes or no (not %2)") + .arg(label) + .arg(value)); } } - if ((label == "spectrum, parent monoisotopic mass error minus") || (label == "spectrum, parent monoisotopic mass error plus")|| (label == "spectrum, dynamic range") || (label == "spectrum, minimum parent m+h") || (label == "protein, cleavage C-terminal mass change")|| (label == "protein, cleavage N-terminal mass change") || (label == "protein, C-terminal residue modification mass") || (label == "protein, N-terminal residue modification mass") || (label == "refine, maximum valid expectation value")) { - bool ok; - value.toDouble(&ok); - if (!ok) {// not an integer - throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be a number (not %2)").arg(label).arg(value)); + if((label == "spectrum, parent monoisotopic mass error minus") || + (label == "spectrum, parent monoisotopic mass error plus") || + (label == "spectrum, dynamic range") || + (label == "spectrum, minimum parent m+h") || + (label == "protein, cleavage C-terminal mass change") || + (label == "protein, cleavage N-terminal mass change") || + (label == "protein, C-terminal residue modification mass") || + (label == "protein, N-terminal residue modification mass") || + (label == "refine, maximum valid expectation value")) + { + bool ok; + value.toDouble(&ok); + if(!ok) + { // not an integer + throw pappso::ExceptionNotPossible( + QObject::tr("%1 value must be a number (not %2)") + .arg(label) + .arg(value)); } } - if ((label == "spectrum, maximum parent charge") || (label == "spectrum, total peaks") || (label == "spectrum, minimum peaks") || (label == "spectrum, sequence batch size") || (label == "spectrum, threads") || (label == "scoring, minimum ion count") || (label == "scoring, maximum missed cleavage sites")) { - bool ok; - value.toInt(&ok); - if (!ok) {// not an integer - throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be an integer (not %2)").arg(label).arg(value)); + if((label == "spectrum, maximum parent charge") || + (label == "spectrum, total peaks") || + (label == "spectrum, minimum peaks") || + (label == "spectrum, sequence batch size") || + (label == "spectrum, threads") || + (label == "scoring, minimum ion count") || + (label == "scoring, maximum missed cleavage sites")) + { + bool ok; + value.toInt(&ok); + if(!ok) + { // not an integer + throw pappso::ExceptionNotPossible( + QObject::tr("%1 value must be an integer (not %2)") + .arg(label) + .arg(value)); } } - if (label == "spectrum, fragment mass type") { - if ((value != "monoisotopic") && (value != "average")) { - throw pappso::ExceptionNotPossible(QObject::tr("%1 value must be monoisotopic or average (not %2)").arg(label).arg(value)); + if(label == "spectrum, fragment mass type") + { + if((value != "monoisotopic") && (value != "average")) + { + throw pappso::ExceptionNotPossible( + QObject::tr("%1 value must be monoisotopic or average (not %2)") + .arg(label) + .arg(value)); } } - //text "protein, cleavage site" "protein, modified residue mass file" "residue, modification mass" || (label == "refine, potential N-terminus modifications") || (label == "refine, potential C-terminus modifications") - //spectrum, neutral loss mass - //spectrum, neutral loss window + // text "protein, cleavage site" "protein, modified residue mass file" + // "residue, modification mass" || (label == "refine, potential N-terminus + // modifications") || (label == "refine, potential C-terminus modifications") + // spectrum, neutral loss mass + // spectrum, neutral loss window - _map_label_value.insert(label, value); + _map_label_value.insert(label, value); } -void TandemParameters::setMethodName(const QString & method) { - _method_name = method; +void +TandemParameters::setMethodName(const QString &method) +{ + _method_name = method; } -const QString & TandemParameters::getMethodName() const { - return _method_name; +const QString & +TandemParameters::getMethodName() const +{ + return _method_name; } -const QMap<QString, QString> & TandemParameters::getMapLabelValue() const { - return _map_label_value; +const QMap<QString, QString> & +TandemParameters::getMapLabelValue() const +{ + return _map_label_value; } diff --git a/src/core/tandem_run/tandemparameters.h b/src/core/tandem_run/tandemparameters.h index 00ae6f2fb5e0afe6655a482481617048883d27fa..5a1b75074d454a5b61e4ac733bdbc4a1bd5a1ee2 100644 --- a/src/core/tandem_run/tandemparameters.h +++ b/src/core/tandem_run/tandemparameters.h @@ -6,26 +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 + ******************************************************************************/ #ifndef TANDEMPARAMETERS_H #define TANDEMPARAMETERS_H @@ -35,22 +36,24 @@ class TandemParameters { -public: - TandemParameters(); - TandemParameters(const TandemParameters & other); - virtual ~TandemParameters(); - - const QString & getValue(const QString & label) const; - void setMethodName(const QString & method); - const QString & getMethodName() const; - void setParamLabelValue(const QString & label, const QString & value); - const QMap<QString, QString> & getMapLabelValue() const; - bool equals(const TandemParameters & other) const; -private: - const QString getLabelCategory(const QString & value) const; -private: - QString _method_name; - QMap<QString, QString> _map_label_value; + public: + TandemParameters(); + TandemParameters(const TandemParameters &other); + virtual ~TandemParameters(); + + const QString &getValue(const QString &label) const; + void setMethodName(const QString &method); + const QString &getMethodName() const; + void setParamLabelValue(const QString &label, const QString &value); + const QMap<QString, QString> &getMapLabelValue() const; + bool equals(const TandemParameters &other) const; + + private: + const QString getLabelCategory(const QString &value) const; + + private: + QString _method_name; + QMap<QString, QString> _map_label_value; }; #endif // TANDEMPARAMETERS_H diff --git a/src/core/tandem_run/tandemrunbatch.cpp b/src/core/tandem_run/tandemrunbatch.cpp index 64a06a41a6e405fa8e5d0bd131ccf551f26181f7..6510b4c0b5b42788c5214e4580e74d4e6e3fcfb8 100644 --- a/src/core/tandem_run/tandemrunbatch.cpp +++ b/src/core/tandem_run/tandemrunbatch.cpp @@ -6,25 +6,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 "tandemrunbatch.h" diff --git a/src/core/tandem_run/tandemrunbatch.h b/src/core/tandem_run/tandemrunbatch.h index 64835956518636519f63c7d0f0f173ff4b46b41e..99ce0242ea8b541cd7b47732a28f2097aa1d52b0 100644 --- a/src/core/tandem_run/tandemrunbatch.h +++ b/src/core/tandem_run/tandemrunbatch.h @@ -6,26 +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 + ******************************************************************************/ #ifndef TANDEMRUNBATCH_H #define TANDEMRUNBATCH_H @@ -34,12 +35,12 @@ #include <QMetaType> struct TandemRunBatch { - QString _tandem_bin_path; - QStringList _mz_file_list; - QString _preset_file; - QStringList _fasta_file_list; - QString _output_directory; - unsigned int _number_of_threads=1; + QString _tandem_bin_path; + QStringList _mz_file_list; + QString _preset_file; + QStringList _fasta_file_list; + QString _output_directory; + unsigned int _number_of_threads = 1; }; -//Q_DECLARE_METATYPE(TandemRunBatch) +// Q_DECLARE_METATYPE(TandemRunBatch) #endif // TANDEMRUNBATCH_H diff --git a/src/files/fastafile.cpp b/src/files/fastafile.cpp index a4bbdef091656aa6522f037332f043c26406ce95..fe9e15ce0fc038d53aef966bac8e5a0c4374a73d 100644 --- a/src/files/fastafile.cpp +++ b/src/files/fastafile.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 "fastafile.h" #include <pappsomspp/fasta/fastareader.h> @@ -27,106 +28,149 @@ #include <QDebug> #include <pappsomspp/exception/exceptionnotfound.h> -class AccessionContaminantReader: public pappso::FastaHandlerInterface { -public: - AccessionContaminantReader (ProteinStore & protein_store) :_protein_store(protein_store) { - }; +class AccessionContaminantReader : public pappso::FastaHandlerInterface +{ + public: + AccessionContaminantReader(ProteinStore &protein_store) + : _protein_store(protein_store){}; + + void + setSequence(const QString &description, const QString &sequence) override + { + // qDebug() << "PeptideReader::setSequence " << description << " " + // <<sequence; + QStringList descr_split = description.simplified().split(" "); + QString accession = descr_split.at(0); + // qDebug() << "PeptideReader::setSequence " << accession << " " + // <<accession; + _protein_store.setContaminantAccession(accession); + }; - void setSequence(const QString& description, const QString& sequence) override { - //qDebug() << "PeptideReader::setSequence " << description << " " <<sequence; - QStringList descr_split = description.simplified().split(" "); - QString accession = descr_split.at(0); - //qDebug() << "PeptideReader::setSequence " << accession << " " <<accession; - _protein_store.setContaminantAccession(accession); - }; -private: - ProteinStore & _protein_store; + private: + ProteinStore &_protein_store; }; -class AccessionDecoyReader: public pappso::FastaHandlerInterface { -public: - AccessionDecoyReader (ProteinStore & protein_store) :_protein_store(protein_store) { - }; +class AccessionDecoyReader : public pappso::FastaHandlerInterface +{ + public: + AccessionDecoyReader(ProteinStore &protein_store) + : _protein_store(protein_store){}; + + void + setSequence(const QString &description, const QString &sequence) override + { + // qDebug() << "PeptideReader::setSequence " << description << " " + // <<sequence; + QStringList descr_split = description.simplified().split(" "); + QString accession = descr_split.at(0); + _protein_store.setDecoyAccession(accession); + }; - void setSequence(const QString& description, const QString& sequence) override { - //qDebug() << "PeptideReader::setSequence " << description << " " <<sequence; - QStringList descr_split = description.simplified().split(" "); - QString accession = descr_split.at(0); - _protein_store.setDecoyAccession(accession); - }; -private: - ProteinStore & _protein_store; + private: + ProteinStore &_protein_store; }; -FastaFile::FastaFile(const QString & fasta_source) : _fasta_source(fasta_source) +FastaFile::FastaFile(const QString &fasta_source) : _fasta_source(fasta_source) { - qDebug() << "FastaFile::FastaFile "<< fasta_source; + qDebug() << "FastaFile::FastaFile " << fasta_source; } -FastaFile::FastaFile(const QFileInfo & fasta_source): _fasta_source(fasta_source) +FastaFile::FastaFile(const QFileInfo &fasta_source) + : _fasta_source(fasta_source) { } -FastaFile::FastaFile(const FastaFile & other) : _fasta_source(other._fasta_source) +FastaFile::FastaFile(const FastaFile &other) + : _fasta_source(other._fasta_source) { - } FastaFile::~FastaFile() { - } -void FastaFile::setXmlId(const QString xmlid) { - _xml_id = xmlid; +void +FastaFile::setXmlId(const QString xmlid) +{ + _xml_id = xmlid; } -const QString & FastaFile::getXmlId() const { - return _xml_id; +const QString & +FastaFile::getXmlId() const +{ + return _xml_id; } -const QString FastaFile::getFilename() const { - return _fasta_source.fileName(); +const QString +FastaFile::getFilename() const +{ + return _fasta_source.fileName(); } -const QString FastaFile::getAbsoluteFilePath() const { - return _fasta_source.absoluteFilePath(); +const QString +FastaFile::getAbsoluteFilePath() const +{ + return _fasta_source.absoluteFilePath(); } -void FastaFile::setContaminants(ProteinStore & protein_store) const { - protein_store.addContaminantFastaFile(this); - if (_fasta_source.exists()) { - AccessionContaminantReader accession_reader(protein_store); - pappso::FastaReader reader(accession_reader); - QFile fasta_file(_fasta_source.absoluteFilePath()); - if (fasta_file.open(QIODevice::ReadOnly)) { - reader.parse(&fasta_file); - fasta_file.close(); +void +FastaFile::setContaminants(ProteinStore &protein_store) const +{ + protein_store.addContaminantFastaFile(this); + if(_fasta_source.exists()) + { + AccessionContaminantReader accession_reader(protein_store); + pappso::FastaReader reader(accession_reader); + QFile fasta_file(_fasta_source.absoluteFilePath()); + if(fasta_file.open(QIODevice::ReadOnly)) + { + reader.parse(&fasta_file); + fasta_file.close(); } - else { - qDebug() << "FastaFile::setContaminants "<< _fasta_source.absoluteFilePath() << " not open"; - throw pappso::ExceptionNotFound(QObject::tr("unable to open contaminant fasta file \"%1\"").arg(_fasta_source.absoluteFilePath())); + else + { + qDebug() << "FastaFile::setContaminants " + << _fasta_source.absoluteFilePath() << " not open"; + throw pappso::ExceptionNotFound( + QObject::tr("unable to open contaminant fasta file \"%1\"") + .arg(_fasta_source.absoluteFilePath())); } } - else { - qDebug() << "FastaFile::setContaminants "<< _fasta_source.absoluteFilePath() << " does not exists"; - throw pappso::ExceptionNotFound(QObject::tr("contaminant fasta file \"%1\" not found").arg(_fasta_source.absoluteFilePath())); + else + { + qDebug() << "FastaFile::setContaminants " + << _fasta_source.absoluteFilePath() << " does not exists"; + throw pappso::ExceptionNotFound( + QObject::tr("contaminant fasta file \"%1\" not found") + .arg(_fasta_source.absoluteFilePath())); } } -void FastaFile::setDecoys(ProteinStore & protein_store) const { - protein_store.addDecoyFastaFile(this); - if (_fasta_source.exists()) { - AccessionDecoyReader accession_reader(protein_store); - pappso::FastaReader reader(accession_reader); - QFile fasta_file(_fasta_source.absoluteFilePath()); - if (fasta_file.open(QIODevice::ReadOnly)) { - reader.parse(&fasta_file); - fasta_file.close(); +void +FastaFile::setDecoys(ProteinStore &protein_store) const +{ + protein_store.addDecoyFastaFile(this); + if(_fasta_source.exists()) + { + AccessionDecoyReader accession_reader(protein_store); + pappso::FastaReader reader(accession_reader); + QFile fasta_file(_fasta_source.absoluteFilePath()); + if(fasta_file.open(QIODevice::ReadOnly)) + { + reader.parse(&fasta_file); + fasta_file.close(); } - else { - qDebug() << "FastaFile::setDecoys "<< _fasta_source.absoluteFilePath() << " not open"; - throw pappso::ExceptionNotFound(QObject::tr("unable to open decoy fasta file \"%1\"").arg(_fasta_source.absoluteFilePath())); + else + { + qDebug() << "FastaFile::setDecoys " + << _fasta_source.absoluteFilePath() << " not open"; + throw pappso::ExceptionNotFound( + QObject::tr("unable to open decoy fasta file \"%1\"") + .arg(_fasta_source.absoluteFilePath())); } } - else { - qDebug() << "FastaFile::setDecoys "<< _fasta_source.absoluteFilePath() << " does not exists"; - throw pappso::ExceptionNotFound(QObject::tr("decoy fasta file \"%1\" not found").arg(_fasta_source.absoluteFilePath())); + else + { + qDebug() << "FastaFile::setDecoys " << _fasta_source.absoluteFilePath() + << " does not exists"; + throw pappso::ExceptionNotFound( + QObject::tr("decoy fasta file \"%1\" not found") + .arg(_fasta_source.absoluteFilePath())); } } diff --git a/src/files/fastafile.h b/src/files/fastafile.h index c398d3bdbcf0f16eb087bd19a29514688c00eb75..40a54c88e24dd4a876ac566b04f960963fec6db3 100644 --- a/src/files/fastafile.h +++ b/src/files/fastafile.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 FASTAFILE_H #define FASTAFILE_H @@ -33,32 +34,31 @@ typedef std::shared_ptr<FastaFile> FastaFileSp; class FastaFile { -public: - FastaFile(const QString & fasta_source); - FastaFile(const QFileInfo & fasta_source); - FastaFile(const FastaFile & other); - ~FastaFile(); + public: + FastaFile(const QString &fasta_source); + FastaFile(const QFileInfo &fasta_source); + FastaFile(const FastaFile &other); + ~FastaFile(); - - const QString getFilename() const; - const QString getAbsoluteFilePath() const; - - /** @brief read fasta file and set accessions as contaminants - * */ - void setContaminants(ProteinStore & protein_store) const; - - /** @brief read fasta file and set accessions as decoys - * */ - void setDecoys(ProteinStore & protein_store) const; - - - void setXmlId(const QString xmlid); - const QString & getXmlId() const; -private : - const QFileInfo _fasta_source; - QString _xml_id; + const QString getFilename() const; + const QString getAbsoluteFilePath() const; + /** @brief read fasta file and set accessions as contaminants + * */ + void setContaminants(ProteinStore &protein_store) const; + + /** @brief read fasta file and set accessions as decoys + * */ + void setDecoys(ProteinStore &protein_store) const; + + + void setXmlId(const QString xmlid); + const QString &getXmlId() const; + + private: + const QFileInfo _fasta_source; + QString _xml_id; }; Q_DECLARE_METATYPE(FastaFile *) diff --git a/src/files/tandemparametersfile.cpp b/src/files/tandemparametersfile.cpp index bd98d3f5b41b9acbc2c20d4c96581f9acc8284be..498ce27eefcec8eb87f7f7868045fb65e1fc852a 100644 --- a/src/files/tandemparametersfile.cpp +++ b/src/files/tandemparametersfile.cpp @@ -6,26 +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 "tandemparametersfile.h" #include <QXmlSimpleReader> @@ -35,145 +36,199 @@ #include <pappsomspp/exception/exceptionnotfound.h> #include "../input/xtandemparamsaxhandler.h" -TandemParametersFile::TandemParametersFile(const QString & fasta_source) : _param_source(fasta_source) +TandemParametersFile::TandemParametersFile(const QString &fasta_source) + : _param_source(fasta_source) { - qDebug() << "TandemParametersFile::TandemParametersFile "<< fasta_source; + qDebug() << "TandemParametersFile::TandemParametersFile " << fasta_source; } -TandemParametersFile::TandemParametersFile(const QFileInfo & fasta_source): _param_source(fasta_source) +TandemParametersFile::TandemParametersFile(const QFileInfo &fasta_source) + : _param_source(fasta_source) { } -TandemParametersFile::TandemParametersFile(const TandemParametersFile & other) : _param_source(other._param_source) +TandemParametersFile::TandemParametersFile(const TandemParametersFile &other) + : _param_source(other._param_source) { - } TandemParametersFile::~TandemParametersFile() { - } -const QString TandemParametersFile::getMethodName() const { - return _param_source.baseName(); +const QString +TandemParametersFile::getMethodName() const +{ + return _param_source.baseName(); } -const QString TandemParametersFile::getFilename() const { - return _param_source.fileName(); +const QString +TandemParametersFile::getFilename() const +{ + return _param_source.fileName(); } -const QDir TandemParametersFile::getAbsoluteDir() const { - return _param_source.absoluteDir(); +const QDir +TandemParametersFile::getAbsoluteDir() const +{ + return _param_source.absoluteDir(); } -const QString TandemParametersFile::getAbsoluteFilePath() const { - return _param_source.absoluteFilePath(); +const QString +TandemParametersFile::getAbsoluteFilePath() const +{ + return _param_source.absoluteFilePath(); } -bool TandemParametersFile::exists() const +bool +TandemParametersFile::exists() const { - return _param_source.exists(); + return _param_source.exists(); } -void TandemParametersFile::setDirectory(const QDir & directory) { - QFileInfo new_dir(QString("%1/%2").arg(directory.absolutePath()).arg(_param_source.fileName())); - _param_source = new_dir; +void +TandemParametersFile::setDirectory(const QDir &directory) +{ + QFileInfo new_dir(QString("%1/%2") + .arg(directory.absolutePath()) + .arg(_param_source.fileName())); + _param_source = new_dir; } -void TandemParametersFile::setTandemParameters(const TandemParameters & parameters) { +void +TandemParametersFile::setTandemParameters(const TandemParameters ¶meters) +{ - QFile xml_file(_param_source.absoluteFilePath()); - QFile new_file(QString("%1/%2.xml").arg(_param_source.absolutePath()).arg(parameters.getMethodName())); - try { - if (_param_source.absoluteFilePath() != QFileInfo( new_file).absoluteFilePath()) { - if (xml_file.exists()) { - //move if renamed - xml_file.remove(); + QFile xml_file(_param_source.absoluteFilePath()); + QFile new_file(QString("%1/%2.xml") + .arg(_param_source.absolutePath()) + .arg(parameters.getMethodName())); + try + { + if(_param_source.absoluteFilePath() != + QFileInfo(new_file).absoluteFilePath()) + { + if(xml_file.exists()) + { + // move if renamed + xml_file.remove(); + } + } + QXmlStreamWriter *p_out; + if(new_file.open(QIODevice::WriteOnly)) + { + + _param_source.setFile(new_file); + p_out = new QXmlStreamWriter(); + p_out->setDevice(&new_file); + writeXmlParametersFile(p_out, parameters); + new_file.close(); + delete p_out; + } + else + { + throw pappso::PappsoException( + QObject::tr( + "error : cannot open the XML X!Tandem parameter file : %1\n") + .arg(new_file.fileName())); } } - QXmlStreamWriter * p_out; - if (new_file.open(QIODevice::WriteOnly)) { - - _param_source.setFile(new_file); - p_out = new QXmlStreamWriter(); - p_out->setDevice(&new_file); - writeXmlParametersFile(p_out, parameters); - new_file.close(); - delete p_out; - } else + + catch(pappso::PappsoException &error_pappso) { - throw pappso::PappsoException(QObject::tr("error : cannot open the XML X!Tandem parameter file : %1\n").arg(new_file.fileName())); + throw pappso::PappsoException( + QObject::tr("error writing tandem preset file %1 : \n%2") + .arg(QFileInfo(new_file).absoluteFilePath()) + .arg(error_pappso.qwhat())); } + catch(std::exception &error) + { + throw pappso::PappsoException( + QObject::tr("error writing tandem preset file %1 : \n%2") + .arg(QFileInfo(new_file).absoluteFilePath()) + .arg(error.what())); } - - catch (pappso::PappsoException & error_pappso) { - throw pappso::PappsoException(QObject::tr("error writing tandem preset file %1 : \n%2").arg(QFileInfo( new_file).absoluteFilePath()).arg(error_pappso.qwhat())); - } - catch (std::exception & error) { - throw pappso::PappsoException(QObject::tr("error writing tandem preset file %1 : \n%2").arg(QFileInfo( new_file).absoluteFilePath()).arg(error.what())); - } - } -TandemParameters TandemParametersFile::getTandemParameters() const { - qDebug() << "TandemParametersFile::getTandemParameters begin"; - TandemParameters parameters; - XtandemParamSaxHandler * parser = new XtandemParamSaxHandler(¶meters); +TandemParameters +TandemParametersFile::getTandemParameters() const +{ + qDebug() << "TandemParametersFile::getTandemParameters begin"; + TandemParameters parameters; + XtandemParamSaxHandler *parser = new XtandemParamSaxHandler(¶meters); - QXmlSimpleReader simplereader; - simplereader.setContentHandler(parser); - simplereader.setErrorHandler(parser); + QXmlSimpleReader simplereader; + simplereader.setContentHandler(parser); + simplereader.setErrorHandler(parser); - qDebug() << "TandemParametersFile::getTandemParameters '" << _param_source.absoluteFilePath() << "'"; - parameters.setMethodName(getMethodName()); + qDebug() << "TandemParametersFile::getTandemParameters '" + << _param_source.absoluteFilePath() << "'"; + parameters.setMethodName(getMethodName()); - QFile qfile(_param_source.absoluteFilePath()); - QXmlInputSource xmlInputSource(&qfile); + QFile qfile(_param_source.absoluteFilePath()); + QXmlInputSource xmlInputSource(&qfile); - if (simplereader.parse(xmlInputSource)) { - qDebug() << "TandemParametersFile::getTandemParameters parse ok"; - qfile.close(); - delete parser; - } else { + if(simplereader.parse(xmlInputSource)) + { + qDebug() << "TandemParametersFile::getTandemParameters parse ok"; + qfile.close(); + delete parser; + } + else + { - qDebug() << "TandemParametersFile::getTandemParameters parse error"; - qfile.close(); + qDebug() << "TandemParametersFile::getTandemParameters parse error"; + qfile.close(); - throw pappso::PappsoException(QObject::tr("Error reading %1 X!Tandem preset file :\n %2").arg(_param_source.absoluteFilePath()).arg(parser->errorString())); - delete parser; + throw pappso::PappsoException( + QObject::tr("Error reading %1 X!Tandem preset file :\n %2") + .arg(_param_source.absoluteFilePath()) + .arg(parser->errorString())); + delete parser; } - return parameters; + return parameters; } -bool TandemParametersFile::isTandemPresetFile() const { +bool +TandemParametersFile::isTandemPresetFile() const +{ - if (this->exists()) { + if(this->exists()) + { - try { - TandemParameters param = getTandemParameters(); - param.getValue("spectrum, threads"); + try + { + TandemParameters param = getTandemParameters(); + param.getValue("spectrum, threads"); } - catch (pappso::ExceptionNotFound & error) { - return false; + catch(pappso::ExceptionNotFound &error) + { + return false; } - catch (pappso::PappsoException & error) { - return false; + catch(pappso::PappsoException &error) + { + return false; } - return true; + return true; } - return false; + return false; } -void TandemParametersFile::writeXmlParametersFile (QXmlStreamWriter * p_out, const TandemParameters & parameters) const { - p_out->setAutoFormatting(true); - p_out->writeStartDocument("1.0"); - - //<?xml version="1.0" encoding="UTF-8"?> - //<bioml label="example api document"> - //<note type="input" label="spectrum, parent monoisotopic mass error units">ppm</note> - //<note type="input" label="spectrum, parent monoisotopic mass error minus">10</note> - p_out->writeStartElement("bioml"); - p_out->writeAttribute("label","example api document"); - for (const QString & label :parameters.getMapLabelValue().keys()) { - p_out->writeStartElement("note"); - p_out->writeAttribute("type","input"); - p_out->writeAttribute("label",label); - p_out->writeCharacters(parameters.getMapLabelValue().value(label)); - p_out->writeEndElement(); +void +TandemParametersFile::writeXmlParametersFile( + QXmlStreamWriter *p_out, const TandemParameters ¶meters) const +{ + p_out->setAutoFormatting(true); + p_out->writeStartDocument("1.0"); + + //<?xml version="1.0" encoding="UTF-8"?> + //<bioml label="example api document"> + //<note type="input" label="spectrum, parent monoisotopic mass error + //units">ppm</note> <note type="input" label="spectrum, parent monoisotopic + //mass error minus">10</note> + p_out->writeStartElement("bioml"); + p_out->writeAttribute("label", "example api document"); + for(const QString &label : parameters.getMapLabelValue().keys()) + { + p_out->writeStartElement("note"); + p_out->writeAttribute("type", "input"); + p_out->writeAttribute("label", label); + p_out->writeCharacters(parameters.getMapLabelValue().value(label)); + p_out->writeEndElement(); } - //</bioml> - p_out->writeEndElement(); - p_out->writeEndDocument(); + //</bioml> + p_out->writeEndElement(); + p_out->writeEndDocument(); } diff --git a/src/files/tandemparametersfile.h b/src/files/tandemparametersfile.h index 73dcd62116dd079941b47bd123f6800500759d66..ae2e2f58fbedc19e8e26bb1e7e77296a84376609 100644 --- a/src/files/tandemparametersfile.h +++ b/src/files/tandemparametersfile.h @@ -6,26 +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 + ******************************************************************************/ #ifndef TANDEMPARAMETERSFILE_H #define TANDEMPARAMETERSFILE_H @@ -36,41 +37,41 @@ class TandemParametersFile { - -public: - TandemParametersFile(const QString & param_file); - TandemParametersFile(const QFileInfo & param_file); - TandemParametersFile(const TandemParametersFile & other); - ~TandemParametersFile(); - const QString getMethodName() const; - const QString getFilename() const; - const QDir getAbsoluteDir() const; - const QString getAbsoluteFilePath() const; - bool exists() const; - - /** @brief tells if this file is really a tandem preset file - */ - bool isTandemPresetFile() const; - - /** @brief read tandem parameters from XML file - */ - TandemParameters getTandemParameters() const; - - /** @brief write tandem parameters to XML file - */ - void setTandemParameters(const TandemParameters & parameters); - - /** @brief set param file directory - */ - void setDirectory(const QDir & directory); - -private : - void writeXmlParametersFile (QXmlStreamWriter * p_out, const TandemParameters & parameters) const; + public: + TandemParametersFile(const QString ¶m_file); + TandemParametersFile(const QFileInfo ¶m_file); + TandemParametersFile(const TandemParametersFile &other); + ~TandemParametersFile(); -private : - QFileInfo _param_source; + const QString getMethodName() const; + const QString getFilename() const; + const QDir getAbsoluteDir() const; + const QString getAbsoluteFilePath() const; + bool exists() const; + /** @brief tells if this file is really a tandem preset file + */ + bool isTandemPresetFile() const; + + /** @brief read tandem parameters from XML file + */ + TandemParameters getTandemParameters() const; + + /** @brief write tandem parameters to XML file + */ + void setTandemParameters(const TandemParameters ¶meters); + + /** @brief set param file directory + */ + void setDirectory(const QDir &directory); + + private: + void writeXmlParametersFile(QXmlStreamWriter *p_out, + const TandemParameters ¶meters) const; + + private: + QFileInfo _param_source; }; #endif // TANDEMPARAMETERSFILE_H diff --git a/src/files/xpipfile.cpp b/src/files/xpipfile.cpp index 2906563f44c8ff8241048b0df55e75e9d3f39780..88ed3382d3fb4964088b2381247da6b0977b95e3 100644 --- a/src/files/xpipfile.cpp +++ b/src/files/xpipfile.cpp @@ -1,51 +1,52 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #include "xpipfile.h" -XpipFile::XpipFile(const QUrl & xpip_source) : _xpip_source(xpip_source) +XpipFile::XpipFile(const QUrl &xpip_source) : _xpip_source(xpip_source) { - } -XpipFile::XpipFile(const QFileInfo & xpip_source): _xpip_source(xpip_source.absoluteFilePath()) +XpipFile::XpipFile(const QFileInfo &xpip_source) + : _xpip_source(xpip_source.absoluteFilePath()) { - qDebug() << "XpipFile::XpipFile begin " << _xpip_source.toString() << " " <<xpip_source.absoluteFilePath(); + qDebug() << "XpipFile::XpipFile begin " << _xpip_source.toString() << " " + << xpip_source.absoluteFilePath(); } -XpipFile::XpipFile(const XpipFile & other) : _xpip_source(other._xpip_source) +XpipFile::XpipFile(const XpipFile &other) : _xpip_source(other._xpip_source) { - } XpipFile::~XpipFile() { - } -ProjectSp XpipFile::getProjectSp(WorkMonitorInterface * p_monitor) const { - qDebug() << "XpipFile::getProjectSp begin " << _xpip_source.toString(); - ProjectSp project_sp = Project().makeProjectSp(); - - project_sp.get()->readXpipFile(p_monitor, QFileInfo(_xpip_source.toString())); +ProjectSp +XpipFile::getProjectSp(WorkMonitorInterface *p_monitor) const +{ + qDebug() << "XpipFile::getProjectSp begin " << _xpip_source.toString(); + ProjectSp project_sp = Project().makeProjectSp(); - return (project_sp); + project_sp.get()->readXpipFile(p_monitor, QFileInfo(_xpip_source.toString())); + return (project_sp); } diff --git a/src/files/xpipfile.h b/src/files/xpipfile.h index 566071a109aa172b003006809a7138d293d93da9..478dbf3b9d0782ed982cadef7f152eb16a17b5ec 100644 --- a/src/files/xpipfile.h +++ b/src/files/xpipfile.h @@ -1,24 +1,25 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef XPIPFILE_H #define XPIPFILE_H @@ -29,16 +30,16 @@ class XpipFile { -public: - XpipFile(const QUrl & xpip_source); - XpipFile(const QFileInfo & xpip_source); - XpipFile(const XpipFile & other); - ~XpipFile(); - - ProjectSp getProjectSp(WorkMonitorInterface * p_monitor) const; + public: + XpipFile(const QUrl &xpip_source); + XpipFile(const QFileInfo &xpip_source); + XpipFile(const XpipFile &other); + ~XpipFile(); -private : - const QUrl _xpip_source; + ProjectSp getProjectSp(WorkMonitorInterface *p_monitor) const; + + private: + const QUrl _xpip_source; }; #endif // XPIPFILE_H diff --git a/src/grouping/groupingexperiment.cpp b/src/grouping/groupingexperiment.cpp index 25509c7ea4dc53a3bcf0ee074aa01c0bfa8d3996..631773b96063f75b2d5f605e2b3737fdc419687a 100644 --- a/src/grouping/groupingexperiment.cpp +++ b/src/grouping/groupingexperiment.cpp @@ -1,45 +1,51 @@ /******************************************************************************* -* 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 "groupingexperiment.h" #include <pappsomspp/exception/exceptionnotimplemented.h> #include "groupingpeptidemass.h" -GroupingExperiment::GroupingExperiment(WorkMonitorInterface * p_work_monitor) +GroupingExperiment::GroupingExperiment(WorkMonitorInterface *p_work_monitor) { - _p_work_monitor = p_work_monitor; + _p_work_monitor = p_work_monitor; } GroupingExperiment::~GroupingExperiment() { - } -GroupingExperiment * GroupingExperiment::newInstance(const GroupingType & grouping_type, WorkMonitorInterface * p_work_monitor) { - if (grouping_type == GroupingType::PeptideMass) { - return new GroupingPeptideMass(p_work_monitor); +GroupingExperiment * +GroupingExperiment::newInstance(const GroupingType &grouping_type, + WorkMonitorInterface *p_work_monitor) +{ + if(grouping_type == GroupingType::PeptideMass) + { + return new GroupingPeptideMass(p_work_monitor); } - else { - throw pappso::ExceptionNotImplemented(QObject::tr("Grouping algorithm not yet implemented")); + else + { + throw pappso::ExceptionNotImplemented( + QObject::tr("Grouping algorithm not yet implemented")); } } diff --git a/src/grouping/groupingexperiment.h b/src/grouping/groupingexperiment.h index 0910407c3bcce9cd02cfcfc0b030911b9fd22f6e..040737c74efe0ad1873a6eac767f788a15f855fa 100644 --- a/src/grouping/groupingexperiment.h +++ b/src/grouping/groupingexperiment.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 + ******************************************************************************/ #include "../utils/types.h" @@ -34,20 +35,24 @@ class PeptideEvidence; class GroupingExperiment { -public: - GroupingExperiment(WorkMonitorInterface * p_work_monitor); - ~GroupingExperiment(); - - static GroupingExperiment * newInstance(const GroupingType & grouping_type, WorkMonitorInterface * p_work_monitor); - - virtual pappso::GrpProteinSp & getGrpProteinSp(ProteinMatch* p_protein_match) = 0; - virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideEvidence * p_peptide_evidence) = 0; - virtual void addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) = 0; - virtual void startGrouping()= 0; - -protected: - WorkMonitorInterface * _p_work_monitor; - + public: + GroupingExperiment(WorkMonitorInterface *p_work_monitor); + ~GroupingExperiment(); + + static GroupingExperiment *newInstance(const GroupingType &grouping_type, + WorkMonitorInterface *p_work_monitor); + + virtual pappso::GrpProteinSp & + getGrpProteinSp(ProteinMatch *p_protein_match) = 0; + virtual pappso::GrpPeptideSp & + setGrpPeptide(pappso::GrpProteinSp proteinSp, + PeptideEvidence *p_peptide_evidence) = 0; + virtual void + addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) = 0; + virtual void startGrouping() = 0; + + protected: + WorkMonitorInterface *_p_work_monitor; }; #endif // GROUPINGEXPERIMENT_H diff --git a/src/grouping/groupinggroup.cpp b/src/grouping/groupinggroup.cpp index e3d85a0950dc72fbb9a6e17b64dea39c70570701..f9db8e2c868d84be4b686c4381acd2388f1214cb 100644 --- a/src/grouping/groupinggroup.cpp +++ b/src/grouping/groupinggroup.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 "groupinggroup.h" #include <core/proteinmatch.h> @@ -30,164 +31,252 @@ GroupingGroup::GroupingGroup() { - } GroupingGroup::~GroupingGroup() { - } -const std::vector<std::pair<unsigned int, const PeptideEvidence *>> & GroupingGroup::getPairSgNumberPeptideEvidenceList() const { - return _pair_sg_number_peptide_evidence_list; +const std::vector<std::pair<unsigned int, const PeptideEvidence *>> & +GroupingGroup::getPairSgNumberPeptideEvidenceList() const +{ + return _pair_sg_number_peptide_evidence_list; } -unsigned int GroupingGroup::getGroupNumber() const { - return _group_number; +unsigned int +GroupingGroup::getGroupNumber() const +{ + return _group_number; } -unsigned int GroupingGroup::getNumberOfSubgroups() const { - return _number_of_subgroup; +unsigned int +GroupingGroup::getNumberOfSubgroups() const +{ + return _number_of_subgroup; } -const std::vector<const ProteinMatch *> & GroupingGroup::getProteinMatchList() const { - return _protein_match_list; +const std::vector<const ProteinMatch *> & +GroupingGroup::getProteinMatchList() const +{ + return _protein_match_list; } -std::vector<const PeptideEvidence *> GroupingGroup::getPeptideEvidenceList() const { - std::vector<const PeptideEvidence *> peptide_match_list; - for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { - peptide_match_list.push_back(pair_peptide_match.second); +std::vector<const PeptideEvidence *> +GroupingGroup::getPeptideEvidenceList() const +{ + std::vector<const PeptideEvidence *> peptide_match_list; + for(auto &&pair_peptide_match : _pair_sg_number_peptide_evidence_list) + { + peptide_match_list.push_back(pair_peptide_match.second); } - return peptide_match_list; + return peptide_match_list; } -const QStringList GroupingGroup::getSubgroupIdList(const PeptideEvidence * p_peptide_match) const { - std::set<unsigned int> subgroup_list; - pappso::GrpPeptide * p_grp_peptide = p_peptide_match->getGrpPeptideSp().get(); - if (p_grp_peptide != nullptr) { - for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { - if(pair_peptide_match.second->getGrpPeptideSp().get() == p_grp_peptide) { - subgroup_list.insert(pair_peptide_match.first); +const QStringList +GroupingGroup::getSubgroupIdList(const PeptideEvidence *p_peptide_match) const +{ + std::set<unsigned int> subgroup_list; + pappso::GrpPeptide *p_grp_peptide = p_peptide_match->getGrpPeptideSp().get(); + if(p_grp_peptide != nullptr) + { + for(auto &&pair_peptide_match : _pair_sg_number_peptide_evidence_list) + { + if(pair_peptide_match.second->getGrpPeptideSp().get() == + p_grp_peptide) + { + subgroup_list.insert(pair_peptide_match.first); } } } - QStringList sg_str_list; - for (unsigned int sgnum : subgroup_list) { - sg_str_list << QString("%1.%2").arg(pappso::Utils::getLexicalOrderedString(_group_number)).arg(pappso::Utils::getLexicalOrderedString(sgnum)); + QStringList sg_str_list; + for(unsigned int sgnum : subgroup_list) + { + sg_str_list << QString("%1.%2") + .arg( + pappso::Utils::getLexicalOrderedString(_group_number)) + .arg(pappso::Utils::getLexicalOrderedString(sgnum)); } - return sg_str_list; - + return sg_str_list; } -unsigned int GroupingGroup::countSubgroupPresence(const PeptideEvidence * p_peptide_evidence) const { - std::set<unsigned int> subgroup_list; - pappso::GrpPeptide * p_grp_peptide = p_peptide_evidence->getGrpPeptideSp().get(); - if (p_grp_peptide != nullptr) { - for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { - if(pair_peptide_match.second->getGrpPeptideSp().get() == p_grp_peptide) { - subgroup_list.insert(pair_peptide_match.first); +unsigned int +GroupingGroup::countSubgroupPresence( + const PeptideEvidence *p_peptide_evidence) const +{ + std::set<unsigned int> subgroup_list; + pappso::GrpPeptide *p_grp_peptide = + p_peptide_evidence->getGrpPeptideSp().get(); + if(p_grp_peptide != nullptr) + { + for(auto &&pair_peptide_match : _pair_sg_number_peptide_evidence_list) + { + if(pair_peptide_match.second->getGrpPeptideSp().get() == + p_grp_peptide) + { + subgroup_list.insert(pair_peptide_match.first); } } } - return subgroup_list.size(); + return subgroup_list.size(); } -std::size_t GroupingGroup::countSpecificSampleScan(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id) const { - if (_number_of_subgroup == 1) { - return p_protein_match->countSampleScan(state, p_msrun_id); +std::size_t +GroupingGroup::countSpecificSampleScan(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun_id) const +{ + if(_number_of_subgroup == 1) + { + return p_protein_match->countSampleScan(state, p_msrun_id); } - std::set<size_t> spectrum_list_in; - for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) { - if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { - if(p_msrun_id == nullptr) { - spectrum_list_in.insert(p_peptide_match.getPeptideEvidence()->getHashSampleScan()); + std::set<size_t> spectrum_list_in; + for(auto &&p_peptide_match : p_protein_match->getPeptideMatchList()) + { + if(p_peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + if(p_msrun_id == nullptr) + { + spectrum_list_in.insert( + p_peptide_match.getPeptideEvidence()->getHashSampleScan()); } - else { - if (p_peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) { - spectrum_list_in.insert(p_peptide_match.getPeptideEvidence()->getHashSampleScan()); + else + { + if(p_peptide_match.getPeptideEvidence()->getMsRunP() == + p_msrun_id) + { + spectrum_list_in.insert( + p_peptide_match.getPeptideEvidence()->getHashSampleScan()); } } } } - std::set<size_t> spectrum_list_out; - unsigned int sg_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); - for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { - if (pair_peptide_match.first != sg_number) { - spectrum_list_out.insert(pair_peptide_match.second->getHashSampleScan()); + std::set<size_t> spectrum_list_out; + unsigned int sg_number = + p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); + for(auto &&pair_peptide_match : _pair_sg_number_peptide_evidence_list) + { + if(pair_peptide_match.first != sg_number) + { + spectrum_list_out.insert( + pair_peptide_match.second->getHashSampleScan()); } } - std::size_t count = 0; - for (size_t sample_scan: spectrum_list_in) { - std::set<size_t>::const_iterator it = spectrum_list_out.find(sample_scan); - if (it == spectrum_list_out.end()) { - count++; + std::size_t count = 0; + for(size_t sample_scan : spectrum_list_in) + { + std::set<size_t>::const_iterator it = spectrum_list_out.find(sample_scan); + if(it == spectrum_list_out.end()) + { + count++; } } - return count; + return count; } -std::size_t GroupingGroup::countSpecificSequenceLi(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id) const { - if (_number_of_subgroup == 1) { - return p_protein_match->countSequenceLi(state); +std::size_t +GroupingGroup::countSpecificSequenceLi(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun_id) const +{ + if(_number_of_subgroup == 1) + { + return p_protein_match->countSequenceLi(state); } - std::set<QString> sequence_list_in; - for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) { - if (p_peptide_match.getPeptideEvidence()->getValidationState() >= state) { - if(p_msrun_id == nullptr) { - sequence_list_in.insert(p_peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); + std::set<QString> sequence_list_in; + for(auto &&p_peptide_match : p_protein_match->getPeptideMatchList()) + { + if(p_peptide_match.getPeptideEvidence()->getValidationState() >= state) + { + if(p_msrun_id == nullptr) + { + sequence_list_in.insert(p_peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequenceLi()); } - else { - if (p_peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) { - sequence_list_in.insert(p_peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi()); + else + { + if(p_peptide_match.getPeptideEvidence()->getMsRunP() == + p_msrun_id) + { + sequence_list_in.insert(p_peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequenceLi()); } } } } - std::set<QString> sequence_list_out; - unsigned int sg_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); - for (auto && pair_peptide_match :_pair_sg_number_peptide_evidence_list) { - if (pair_peptide_match.first != sg_number) { - sequence_list_out.insert(pair_peptide_match.second->getPeptideXtpSp().get()->getSequenceLi()); + std::set<QString> sequence_list_out; + unsigned int sg_number = + p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); + for(auto &&pair_peptide_match : _pair_sg_number_peptide_evidence_list) + { + if(pair_peptide_match.first != sg_number) + { + sequence_list_out.insert(pair_peptide_match.second->getPeptideXtpSp() + .get() + ->getSequenceLi()); } } - std::size_t count = 0; - for (const QString & sequence: sequence_list_in) { - std::set<QString>::const_iterator it = sequence_list_out.find(sequence); - if (it == sequence_list_out.end()) { - count++; + std::size_t count = 0; + for(const QString &sequence : sequence_list_in) + { + std::set<QString>::const_iterator it = sequence_list_out.find(sequence); + if(it == sequence_list_out.end()) + { + count++; } } - return count; + return count; } -unsigned int GroupingGroup::countProteinInSubgroup(unsigned int subgroup_number) const { - return std::count_if (_protein_match_list.begin(), _protein_match_list.end(), [subgroup_number](const ProteinMatch * p_protein_match) { - if (p_protein_match->getGrpProteinSp().get()->getSubGroupNumber() == subgroup_number) { - return true; +unsigned int +GroupingGroup::countProteinInSubgroup(unsigned int subgroup_number) const +{ + return std::count_if( + _protein_match_list.begin(), _protein_match_list.end(), + [subgroup_number](const ProteinMatch *p_protein_match) { + if(p_protein_match->getGrpProteinSp().get()->getSubGroupNumber() == + subgroup_number) + { + return true; } - else { - return false; + else + { + return false; } }); } -QString GroupingGroup::getProteinGroupingIdOfSubgroup(unsigned int subgroup_number) const { - return QString("%1.%2.a1").arg(pappso::Utils::getLexicalOrderedString(_group_number)).arg(pappso::Utils::getLexicalOrderedString(subgroup_number)); +QString +GroupingGroup::getProteinGroupingIdOfSubgroup( + unsigned int subgroup_number) const +{ + return QString("%1.%2.a1") + .arg(pappso::Utils::getLexicalOrderedString(_group_number)) + .arg(pappso::Utils::getLexicalOrderedString(subgroup_number)); } -void GroupingGroup::add(const ProteinMatch * p_protein_match) { - _group_number = p_protein_match->getGrpProteinSp().get()->getGroupNumber(); - _protein_match_list.push_back(p_protein_match); - if (p_protein_match->getGrpProteinSp().get()->getRank() == 1) { - _number_of_subgroup++; - unsigned int sg_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); +void +GroupingGroup::add(const ProteinMatch *p_protein_match) +{ + _group_number = p_protein_match->getGrpProteinSp().get()->getGroupNumber(); + _protein_match_list.push_back(p_protein_match); + if(p_protein_match->getGrpProteinSp().get()->getRank() == 1) + { + _number_of_subgroup++; + unsigned int sg_number = + p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); - for (auto && peptide_match :p_protein_match->getPeptideMatchList()) { - if (peptide_match.getPeptideEvidence()->isValidAndChecked()) { - _pair_sg_number_peptide_evidence_list.push_back(std::pair<unsigned int, const PeptideEvidence * >(sg_number, peptide_match.getPeptideEvidence())); + for(auto &&peptide_match : p_protein_match->getPeptideMatchList()) + { + if(peptide_match.getPeptideEvidence()->isValidAndChecked()) + { + _pair_sg_number_peptide_evidence_list.push_back( + std::pair<unsigned int, const PeptideEvidence *>( + sg_number, peptide_match.getPeptideEvidence())); } } } } - diff --git a/src/grouping/groupinggroup.h b/src/grouping/groupinggroup.h index 1789a683b2c2facdefb5c75049565e8757c024b0..5c2b006b0f1155985784adb03cf051e5f72a57ea 100644 --- a/src/grouping/groupinggroup.h +++ b/src/grouping/groupinggroup.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 GROUPINGGROUP_H #define GROUPINGGROUP_H @@ -38,54 +39,61 @@ typedef std::shared_ptr<GroupingGroup> GroupingGroupSp; class GroupingGroup { -public: - - GroupingGroup(); - ~GroupingGroup(); - - unsigned int getGroupNumber() const ; - - void add(const ProteinMatch * p_protein_match); - std::size_t countSpecificSampleScan(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id=nullptr) const; - std::size_t countSpecificSequenceLi(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id=nullptr) const; - - unsigned int getNumberOfSubgroups() const; - - /** @brief count proteins in subgroup - * */ - unsigned int countProteinInSubgroup(unsigned int subgroup_number) const; - - /** @brief count number of subgroups in which this peptide is present - * */ - unsigned int countSubgroupPresence(const PeptideEvidence * p_peptide_evidence) const; - - /** @brief subgroup identifier list in which this peptide is present - * */ - const QStringList getSubgroupIdList(const PeptideEvidence * p_peptide_evidence) const; - - /** @brief give the protein group id of the representant of a subgroup - * */ - QString getProteinGroupingIdOfSubgroup(unsigned int subgroup_number) const; - - - /** @brief get the list of protein match included in this group - * */ - const std::vector<const ProteinMatch *> & getProteinMatchList() const; - - /** @brief get the list of peptide evidence included in this group - * warning : it only contains the first protein representant in one subgroup - * use a double loop with getProteinMatchList to scan every peptide match - * */ - std::vector<const PeptideEvidence *> getPeptideEvidenceList() const; - - const std::vector<std::pair<unsigned int, const PeptideEvidence *>> & getPairSgNumberPeptideEvidenceList() const; - -private : - unsigned int _group_number=0; - unsigned int _number_of_subgroup=0; - std::vector<std::pair<unsigned int, const PeptideEvidence *>> _pair_sg_number_peptide_evidence_list; - - std::vector<const ProteinMatch *> _protein_match_list; + public: + GroupingGroup(); + ~GroupingGroup(); + + unsigned int getGroupNumber() const; + + void add(const ProteinMatch *p_protein_match); + std::size_t countSpecificSampleScan(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun_id = nullptr) const; + std::size_t countSpecificSequenceLi(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun_id = nullptr) const; + + unsigned int getNumberOfSubgroups() const; + + /** @brief count proteins in subgroup + * */ + unsigned int countProteinInSubgroup(unsigned int subgroup_number) const; + + /** @brief count number of subgroups in which this peptide is present + * */ + unsigned int + countSubgroupPresence(const PeptideEvidence *p_peptide_evidence) const; + + /** @brief subgroup identifier list in which this peptide is present + * */ + const QStringList + getSubgroupIdList(const PeptideEvidence *p_peptide_evidence) const; + + /** @brief give the protein group id of the representant of a subgroup + * */ + QString getProteinGroupingIdOfSubgroup(unsigned int subgroup_number) const; + + + /** @brief get the list of protein match included in this group + * */ + const std::vector<const ProteinMatch *> &getProteinMatchList() const; + + /** @brief get the list of peptide evidence included in this group + * warning : it only contains the first protein representant in one subgroup + * use a double loop with getProteinMatchList to scan every peptide match + * */ + std::vector<const PeptideEvidence *> getPeptideEvidenceList() const; + + const std::vector<std::pair<unsigned int, const PeptideEvidence *>> & + getPairSgNumberPeptideEvidenceList() const; + + private: + unsigned int _group_number = 0; + unsigned int _number_of_subgroup = 0; + std::vector<std::pair<unsigned int, const PeptideEvidence *>> + _pair_sg_number_peptide_evidence_list; + + std::vector<const ProteinMatch *> _protein_match_list; }; #endif // GROUPINGGROUP_H diff --git a/src/grouping/groupingpeptidemass.cpp b/src/grouping/groupingpeptidemass.cpp index c55d84bfcc950e27cf075c6dd47489bb87cd28f6..4e8e373f268855aa82cf2f3ef404773ba455e65c 100644 --- a/src/grouping/groupingpeptidemass.cpp +++ b/src/grouping/groupingpeptidemass.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 "groupingpeptidemass.h" #include "../core/proteinmatch.h" @@ -28,67 +29,105 @@ #include <pappsomspp/grouping/grpgroupingmonitor.h> -class GrpGroupingMonitor: public pappso::GrpGroupingMonitorInterface +class GrpGroupingMonitor : public pappso::GrpGroupingMonitorInterface { -public: - GrpGroupingMonitor(WorkMonitorInterface * p_work_monitor) { - _p_work_monitor = p_work_monitor; - }; - ~GrpGroupingMonitor() { - }; - virtual void startGrouping(std::size_t total_number_protein, std::size_t total_number_peptide) override { - _p_work_monitor->message(QObject::tr("grouping %1 proteins containing %2 unique peptides").arg(total_number_protein).arg(total_number_peptide)); - _total_number_proteins = total_number_protein; - }; - virtual void groupingProtein() override {}; - virtual void startRemovingNonInformativeSubGroupsInAllGroups(std::size_t total_number_group)override{ - _total_number_group = total_number_group; - }; - virtual void stopRemovingNonInformativeSubGroupsInAllGroups(std::size_t total_number_group)override{ - _total_number_group = total_number_group; - }; - virtual void removingNonInformativeSubGroupsInGroup()override{ - _p_work_monitor->message(QObject::tr("removing non informative subgroups in %1 groups representing %2 proteins").arg(_total_number_group).arg(_total_number_proteins)); - }; - virtual void startNumberingAllGroups(std::size_t total_number_group)override{ - _p_work_monitor->message(QObject::tr("numbering in %1 groups representing %2 proteins").arg(_total_number_group).arg(_total_number_proteins)); - }; - virtual void stopGrouping()override{}; -private: - WorkMonitorInterface * _p_work_monitor; - std::size_t _total_number_proteins; - std::size_t _total_number_group; + public: + GrpGroupingMonitor(WorkMonitorInterface *p_work_monitor) + { + _p_work_monitor = p_work_monitor; + }; + ~GrpGroupingMonitor(){}; + virtual void + startGrouping(std::size_t total_number_protein, + std::size_t total_number_peptide) override + { + _p_work_monitor->message( + QObject::tr("grouping %1 proteins containing %2 unique peptides") + .arg(total_number_protein) + .arg(total_number_peptide)); + _total_number_proteins = total_number_protein; + }; + virtual void groupingProtein() override{}; + virtual void + startRemovingNonInformativeSubGroupsInAllGroups( + std::size_t total_number_group) override + { + _total_number_group = total_number_group; + }; + virtual void + stopRemovingNonInformativeSubGroupsInAllGroups( + std::size_t total_number_group) override + { + _total_number_group = total_number_group; + }; + virtual void + removingNonInformativeSubGroupsInGroup() override + { + _p_work_monitor->message( + QObject::tr("removing non informative subgroups in %1 groups " + "representing %2 proteins") + .arg(_total_number_group) + .arg(_total_number_proteins)); + }; + virtual void + startNumberingAllGroups(std::size_t total_number_group) override + { + _p_work_monitor->message( + QObject::tr("numbering in %1 groups representing %2 proteins") + .arg(_total_number_group) + .arg(_total_number_proteins)); + }; + virtual void stopGrouping() override{}; + + private: + WorkMonitorInterface *_p_work_monitor; + std::size_t _total_number_proteins; + std::size_t _total_number_group; }; -GroupingPeptideMass::GroupingPeptideMass(WorkMonitorInterface * p_work_monitor): GroupingExperiment(p_work_monitor) +GroupingPeptideMass::GroupingPeptideMass(WorkMonitorInterface *p_work_monitor) + : GroupingExperiment(p_work_monitor) { - //_p_monitor = new pappso::GrpGroupingMonitor(); - _p_monitor = new GrpGroupingMonitor(_p_work_monitor); - _p_grp_experiment = new pappso::GrpExperiment(_p_monitor); - + //_p_monitor = new pappso::GrpGroupingMonitor(); + _p_monitor = new GrpGroupingMonitor(_p_work_monitor); + _p_grp_experiment = new pappso::GrpExperiment(_p_monitor); } GroupingPeptideMass::~GroupingPeptideMass() { - delete _p_grp_experiment; - delete _p_monitor; + delete _p_grp_experiment; + delete _p_monitor; } -pappso::GrpProteinSp & GroupingPeptideMass::getGrpProteinSp(ProteinMatch* p_protein_match) { - return _p_grp_experiment->getGrpProteinSp(p_protein_match->getProteinXtpSp().get()->getAccession(),p_protein_match->getProteinXtpSp().get()->getDescription()); +pappso::GrpProteinSp & +GroupingPeptideMass::getGrpProteinSp(ProteinMatch *p_protein_match) +{ + return _p_grp_experiment->getGrpProteinSp( + p_protein_match->getProteinXtpSp().get()->getAccession(), + p_protein_match->getProteinXtpSp().get()->getDescription()); } -pappso::GrpPeptideSp & GroupingPeptideMass::setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideEvidence * p_peptide_evidence) { +pappso::GrpPeptideSp & +GroupingPeptideMass::setGrpPeptide(pappso::GrpProteinSp proteinSp, + PeptideEvidence *p_peptide_evidence) +{ - return _p_grp_experiment->setGrpPeptide(proteinSp,p_peptide_evidence->getPeptideXtpSp().get()->getSequence(), p_peptide_evidence->getPeptideXtpSp().get()->getGroupingMass()); + return _p_grp_experiment->setGrpPeptide( + proteinSp, p_peptide_evidence->getPeptideXtpSp().get()->getSequence(), + p_peptide_evidence->getPeptideXtpSp().get()->getGroupingMass()); } -void GroupingPeptideMass::startGrouping() { - qDebug() << "GroupingPeptideMass::startGrouping begin"; - _p_grp_experiment->startGrouping(); - qDebug() << "GroupingPeptideMass::startGrouping end"; +void +GroupingPeptideMass::startGrouping() +{ + qDebug() << "GroupingPeptideMass::startGrouping begin"; + _p_grp_experiment->startGrouping(); + qDebug() << "GroupingPeptideMass::startGrouping end"; } -void GroupingPeptideMass::addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) { - _p_grp_experiment->addPostGroupingGrpProteinSpRemoval(sp_protein); +void +GroupingPeptideMass::addPostGroupingGrpProteinSpRemoval( + pappso::GrpProteinSp sp_protein) +{ + _p_grp_experiment->addPostGroupingGrpProteinSpRemoval(sp_protein); } diff --git a/src/grouping/groupingpeptidemass.h b/src/grouping/groupingpeptidemass.h index a1d1d4e4136cab76cfba42cb8e1e99ea87899bea..0b335f28e58f6880b78b99548588dfc22f16444c 100644 --- a/src/grouping/groupingpeptidemass.h +++ b/src/grouping/groupingpeptidemass.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 + ******************************************************************************/ #include "groupingexperiment.h" #ifndef GROUPINGPEPTIDEMASS_H @@ -27,25 +28,29 @@ class GrpGroupingMonitor; -class GroupingPeptideMass: public GroupingExperiment +class GroupingPeptideMass : public GroupingExperiment { - friend class GroupingExperiment; -public: + friend class GroupingExperiment; - virtual ~GroupingPeptideMass(); + public: + virtual ~GroupingPeptideMass(); - virtual pappso::GrpProteinSp & getGrpProteinSp(ProteinMatch* p_protein_match) override; - virtual pappso::GrpPeptideSp & setGrpPeptide(pappso::GrpProteinSp proteinSp, PeptideEvidence * p_peptide_evidence) override; - virtual void addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) override; + virtual pappso::GrpProteinSp & + getGrpProteinSp(ProteinMatch *p_protein_match) override; + virtual pappso::GrpPeptideSp & + setGrpPeptide(pappso::GrpProteinSp proteinSp, + PeptideEvidence *p_peptide_evidence) override; + virtual void + addPostGroupingGrpProteinSpRemoval(pappso::GrpProteinSp sp_protein) override; - virtual void startGrouping() override; + virtual void startGrouping() override; -protected : - GroupingPeptideMass(WorkMonitorInterface * p_work_monitor); + protected: + GroupingPeptideMass(WorkMonitorInterface *p_work_monitor); -private : - GrpGroupingMonitor * _p_monitor = nullptr; - pappso::GrpExperiment * _p_grp_experiment; + private: + GrpGroupingMonitor *_p_monitor = nullptr; + pappso::GrpExperiment *_p_grp_experiment; }; #endif // GROUPINGPEPTIDEMASS_H diff --git a/src/grouping/ptm/ptmgroupingexperiment.cpp b/src/grouping/ptm/ptmgroupingexperiment.cpp index c52b912c496d49ca5e64a687c8ce58dbd0501db2..903b26226f25877255e61e8dca6a0689fc306817 100644 --- a/src/grouping/ptm/ptmgroupingexperiment.cpp +++ b/src/grouping/ptm/ptmgroupingexperiment.cpp @@ -6,26 +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 "ptmgroupingexperiment.h" #include "../../grouping/ptm/ptmgroupingexperiment.h" @@ -33,182 +34,258 @@ PtmGroupingExperiment::PtmGroupingExperiment() { - /* - * accession MOD:00696 - name phosphorylated residue - PSI-MS label Phospho - PSI-MOD label PhosRes - diff mono 79.966331 - diff formula H 1 O 3 P 1 - - // dehydrated residue [MOD:00704] -18.010565 - accession MOD:00416 - name phosphorylation of an hydroxyl amino acid with prompt loss of phosphate - PSI-MS label Methyl - PSI-MOD label - diff mono -18.010565 - diff formula H -2 O -1 - - - public boolean is_phopho_modifs() { - if ((this.modvalue > 79.9) & (this.modvalue < 80.1)) - return true; - boolean serthre = false; - if (this.AA.equals("T")) - serthre = true; - else if (this.AA.equals("S")) - serthre = true; - if ((serthre) & (this.modvalue < -17.9) & (this.modvalue > -18.1)) - return true; - return false; - } - */ - -//phospho : - _modification_list.push_back({pappso::AaModification::getInstance("MOD:00696"), {}}); - _modification_list.push_back({pappso::AaModification::getInstance("MOD:00704"), {'S','T'}}); + /* + * accession MOD:00696 + name phosphorylated residue + PSI-MS label Phospho + PSI-MOD label PhosRes + diff mono 79.966331 + diff formula H 1 O 3 P 1 + + // dehydrated residue [MOD:00704] -18.010565 + accession MOD:00416 + name phosphorylation of an hydroxyl amino acid with prompt loss of phosphate + PSI-MS label Methyl + PSI-MOD label + diff mono -18.010565 + diff formula H -2 O -1 + + + public boolean is_phopho_modifs() { + if ((this.modvalue > 79.9) & (this.modvalue < 80.1)) + return true; + boolean serthre = false; + if (this.AA.equals("T")) + serthre = true; + else if (this.AA.equals("S")) + serthre = true; + if ((serthre) & (this.modvalue < -17.9) & (this.modvalue > -18.1)) + return true; + return false; + } + */ + + // phospho : + _modification_list.push_back( + {pappso::AaModification::getInstance("MOD:00696"), {}}); + _modification_list.push_back( + {pappso::AaModification::getInstance("MOD:00704"), {'S', 'T'}}); } PtmGroupingExperiment::~PtmGroupingExperiment() { - } -const std::vector<PtmIslandSubgroupSp> & PtmGroupingExperiment::getPtmIslandSubgroupList() const { - return _ptm_island_subgroup_list; +const std::vector<PtmIslandSubgroupSp> & +PtmGroupingExperiment::getPtmIslandSubgroupList() const +{ + return _ptm_island_subgroup_list; } -const std::vector<PtmIslandGroupSp> & PtmGroupingExperiment::getPtmIslandGroupList() const { - return _ptm_island_group_list; +const std::vector<PtmIslandGroupSp> & +PtmGroupingExperiment::getPtmIslandGroupList() const +{ + return _ptm_island_group_list; } -const std::vector<PtmIslandSp> & PtmGroupingExperiment::getPtmIslandList() const { - //qDebug() << "PtmGroupingExperiment::getPtmIslandList begin" << _ptm_island_list.size(); - return _ptm_island_list; +const std::vector<PtmIslandSp> & +PtmGroupingExperiment::getPtmIslandList() const +{ + // qDebug() << "PtmGroupingExperiment::getPtmIslandList begin" << + // _ptm_island_list.size(); + return _ptm_island_list; } -void PtmGroupingExperiment::numbering() { - std::sort(_ptm_island_group_list.begin(), _ptm_island_group_list.end(),[](const PtmIslandGroupSp a, const PtmIslandGroupSp b) - { - return *(a.get()) < *(b.get()); - }); +void +PtmGroupingExperiment::numbering() +{ + std::sort(_ptm_island_group_list.begin(), _ptm_island_group_list.end(), + [](const PtmIslandGroupSp a, const PtmIslandGroupSp b) { + return *(a.get()) < *(b.get()); + }); - unsigned int number=0; - for (PtmIslandGroupSp ptm_island_group:_ptm_island_group_list) { - number ++; - ptm_island_group.get()->setGroupNumber(number); + unsigned int number = 0; + for(PtmIslandGroupSp ptm_island_group : _ptm_island_group_list) + { + number++; + ptm_island_group.get()->setGroupNumber(number); } } -void PtmGroupingExperiment::startGrouping() { - //we have a list of ptm island subgroups to group : - for (PtmIslandSubgroupSp ptm_island_subgroup:_ptm_island_subgroup_list) { - if (std::none_of(_ptm_island_group_list.begin(), _ptm_island_group_list.end(), [ptm_island_subgroup](PtmIslandGroupSp element) { - return element.get()->mergePtmIslandSubgroupSp(ptm_island_subgroup); - })) { - //create a new group - _ptm_island_group_list.push_back(std::make_shared<PtmIslandGroup>(ptm_island_subgroup)); +void +PtmGroupingExperiment::startGrouping() +{ + // we have a list of ptm island subgroups to group : + for(PtmIslandSubgroupSp ptm_island_subgroup : _ptm_island_subgroup_list) + { + if(std::none_of(_ptm_island_group_list.begin(), + _ptm_island_group_list.end(), + [ptm_island_subgroup](PtmIslandGroupSp element) { + return element.get()->mergePtmIslandSubgroupSp( + ptm_island_subgroup); + })) + { + // create a new group + _ptm_island_group_list.push_back( + std::make_shared<PtmIslandGroup>(ptm_island_subgroup)); } } - numbering(); + numbering(); } -void PtmGroupingExperiment::addPtmIsland(PtmIslandSp ptm_island_sp) { - _ptm_island_list.push_back(ptm_island_sp); - if (std::none_of(_ptm_island_subgroup_list.begin(), _ptm_island_subgroup_list.end(), [ptm_island_sp](PtmIslandSubgroupSp element) { - return element.get()->mergePtmIslandSp(ptm_island_sp); - })) { - //create a new subgroup - _ptm_island_subgroup_list.push_back(std::make_shared<PtmIslandSubgroup>(ptm_island_sp)); +void +PtmGroupingExperiment::addPtmIsland(PtmIslandSp ptm_island_sp) +{ + _ptm_island_list.push_back(ptm_island_sp); + if(std::none_of(_ptm_island_subgroup_list.begin(), + _ptm_island_subgroup_list.end(), + [ptm_island_sp](PtmIslandSubgroupSp element) { + return element.get()->mergePtmIslandSp(ptm_island_sp); + })) + { + // create a new subgroup + _ptm_island_subgroup_list.push_back( + std::make_shared<PtmIslandSubgroup>(ptm_island_sp)); } - } -void PtmGroupingExperiment::setValidationState(ValidationState validation_state) { - _peptide_validation_state = validation_state; +void +PtmGroupingExperiment::setValidationState(ValidationState validation_state) +{ + _peptide_validation_state = validation_state; } -void PtmGroupingExperiment::addProteinMatch(const ProteinMatch* p_protein_match) { - if (p_protein_match->getValidationState() >= _peptide_validation_state) { - std::vector< unsigned int > ptm_position_list = getPtmPositions(p_protein_match); - std::vector<PtmIslandSp> ptm_island_list; - for (unsigned int position : ptm_position_list) { - ptm_island_list.push_back(std::make_shared<PtmIsland>(p_protein_match, position)); +void +PtmGroupingExperiment::addProteinMatch(const ProteinMatch *p_protein_match) +{ + if(p_protein_match->getValidationState() >= _peptide_validation_state) + { + std::vector<unsigned int> ptm_position_list = + getPtmPositions(p_protein_match); + std::vector<PtmIslandSp> ptm_island_list; + for(unsigned int position : ptm_position_list) + { + ptm_island_list.push_back( + std::make_shared<PtmIsland>(p_protein_match, position)); } - for (PeptideMatch & peptide_match: p_protein_match->getPeptideMatchList(_peptide_validation_state)) { - for (PtmIslandSp ptm_island_sp:ptm_island_list) { - ptm_island_sp.get()->addPeptideMatch(peptide_match); + for(PeptideMatch &peptide_match : + p_protein_match->getPeptideMatchList(_peptide_validation_state)) + { + for(PtmIslandSp ptm_island_sp : ptm_island_list) + { + ptm_island_sp.get()->addPeptideMatch(peptide_match); } } - std::vector< PtmIslandSp > protein_ptm_islands = mergePeptideMatchPtmIslandList(ptm_island_list); - //=> ptm island subgroups (same set of sample scan numbers) - for (PtmIslandSp ptm_island:protein_ptm_islands) { - addPtmIsland(ptm_island); + std::vector<PtmIslandSp> protein_ptm_islands = + mergePeptideMatchPtmIslandList(ptm_island_list); + //=> ptm island subgroups (same set of sample scan numbers) + for(PtmIslandSp ptm_island : protein_ptm_islands) + { + addPtmIsland(ptm_island); } } } -std::vector< PtmIslandSp > PtmGroupingExperiment::mergePeptideMatchPtmIslandList(std::vector< PtmIslandSp > ptm_island_list) { - std::vector< PtmIslandSp > new_ptm_island_list; +std::vector<PtmIslandSp> +PtmGroupingExperiment::mergePeptideMatchPtmIslandList( + std::vector<PtmIslandSp> ptm_island_list) +{ + std::vector<PtmIslandSp> new_ptm_island_list; - for (PtmIslandSp ptm_island_sp:ptm_island_list) { - //http://en.cppreference.com/w/cpp/algorithm/all_any_none_of - if (std::none_of(new_ptm_island_list.begin(), new_ptm_island_list.end(), [ptm_island_sp](PtmIslandSp element) { - return element.get()->merge(ptm_island_sp); - })) { - new_ptm_island_list.push_back(ptm_island_sp); + for(PtmIslandSp ptm_island_sp : ptm_island_list) + { + // http://en.cppreference.com/w/cpp/algorithm/all_any_none_of + if(std::none_of(new_ptm_island_list.begin(), new_ptm_island_list.end(), + [ptm_island_sp](PtmIslandSp element) { + return element.get()->merge(ptm_island_sp); + })) + { + new_ptm_island_list.push_back(ptm_island_sp); } } - return new_ptm_island_list; - + return new_ptm_island_list; } -unsigned int PtmGroupingExperiment::countPeptideMatchPtm(const PeptideMatch & peptide_match)const { - unsigned int number=0; - for (const ModificationAndAa & modification: _modification_list) { - if (modification.aa_list.size() == 0) { - number += peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getNumberOfModification(modification.modification); +unsigned int +PtmGroupingExperiment::countPeptideMatchPtm( + const PeptideMatch &peptide_match) const +{ + unsigned int number = 0; + for(const ModificationAndAa &modification : _modification_list) + { + if(modification.aa_list.size() == 0) + { + number += peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getNumberOfModification(modification.modification); } - else { - number += peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->countModificationOnAa(modification.modification, modification.aa_list); + else + { + number += peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->countModificationOnAa(modification.modification, + modification.aa_list); } } - return number; + return number; } -std::vector<unsigned int> PtmGroupingExperiment::getPtmPositions(const PeptideMatch & peptide_match) const { - std::vector<unsigned int> position_list; +std::vector<unsigned int> +PtmGroupingExperiment::getPtmPositions(const PeptideMatch &peptide_match) const +{ + std::vector<unsigned int> position_list; - for (const ModificationAndAa & modification: _modification_list) { - if (modification.aa_list.size() == 0) { - for (unsigned int position : peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getModificationPositionList(modification.modification)) { - position_list.push_back(position); + for(const ModificationAndAa &modification : _modification_list) + { + if(modification.aa_list.size() == 0) + { + for(unsigned int position : + peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getModificationPositionList(modification.modification)) + { + position_list.push_back(position); } } - else { - for (unsigned int position : peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getModificationPositionList(modification.modification, modification.aa_list)) { - position_list.push_back(position); + else + { + for(unsigned int position : + peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getModificationPositionList(modification.modification, + modification.aa_list)) + { + position_list.push_back(position); } } } - std::sort(position_list.begin(), position_list.end()); - auto last = std::unique(position_list.begin(), position_list.end()); - position_list.erase(last, position_list.end()); - return position_list; + std::sort(position_list.begin(), position_list.end()); + auto last = std::unique(position_list.begin(), position_list.end()); + position_list.erase(last, position_list.end()); + return position_list; } -std::vector<unsigned int> PtmGroupingExperiment::getPtmPositions(const ProteinMatch * protein_match) const { - std::vector<unsigned int> position_list; +std::vector<unsigned int> +PtmGroupingExperiment::getPtmPositions(const ProteinMatch *protein_match) const +{ + std::vector<unsigned int> position_list; - for (const PeptideMatch & peptide_match: protein_match->getPeptideMatchList(_peptide_validation_state)) { - unsigned int start = peptide_match.getStart(); - std::vector<unsigned int> positionb_list = this->getPtmPositions(peptide_match); - for (unsigned int position: positionb_list) { - position_list.push_back(start+position); + for(const PeptideMatch &peptide_match : + protein_match->getPeptideMatchList(_peptide_validation_state)) + { + unsigned int start = peptide_match.getStart(); + std::vector<unsigned int> positionb_list = + this->getPtmPositions(peptide_match); + for(unsigned int position : positionb_list) + { + position_list.push_back(start + position); } } - std::sort(position_list.begin(), position_list.end()); - auto last = std::unique(position_list.begin(), position_list.end()); - position_list.erase(last, position_list.end()); - return position_list; + std::sort(position_list.begin(), position_list.end()); + auto last = std::unique(position_list.begin(), position_list.end()); + position_list.erase(last, position_list.end()); + return position_list; } - diff --git a/src/grouping/ptm/ptmgroupingexperiment.h b/src/grouping/ptm/ptmgroupingexperiment.h index 541f1422fcb3e7dc0f4931ee34e586b357986874..686889bfd7a85f40960d0aed83b8b2669522cd58 100644 --- a/src/grouping/ptm/ptmgroupingexperiment.h +++ b/src/grouping/ptm/ptmgroupingexperiment.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMGROUPINGEXPERIMENT_H #define PTMGROUPINGEXPERIMENT_H @@ -37,53 +38,60 @@ #include "ptmislandgroup.h" class PtmSampleScan; -struct ModificationAndAa { - pappso::AaModificationP modification; - std::vector<char> aa_list; +struct ModificationAndAa +{ + pappso::AaModificationP modification; + std::vector<char> aa_list; }; class PtmGroupingExperiment { - friend PtmSampleScan; -public: - PtmGroupingExperiment(); - ~PtmGroupingExperiment(); + friend PtmSampleScan; + + public: + PtmGroupingExperiment(); + ~PtmGroupingExperiment(); + + /** @brief choose validation state of peptide to use in PTM grouping + * experiment + */ + void setValidationState(ValidationState validation_state); + void addProteinMatch(const ProteinMatch *p_protein_match); + void startGrouping(); + + /** @brief get the ptm island subgroup list + */ + const std::vector<PtmIslandSubgroupSp> &getPtmIslandSubgroupList() const; + + /** @brief get the ptm island group list + */ + const std::vector<PtmIslandGroupSp> &getPtmIslandGroupList() const; - /** @brief choose validation state of peptide to use in PTM grouping experiment - */ - void setValidationState(ValidationState validation_state); - void addProteinMatch(const ProteinMatch* p_protein_match); - void startGrouping(); + /** @brief get the ptm island list + */ + const std::vector<PtmIslandSp> &getPtmIslandList() const; - /** @brief get the ptm island subgroup list - */ - const std::vector<PtmIslandSubgroupSp> & getPtmIslandSubgroupList() const; + /** @brief count number of modifications in a PeptideMatch + * */ + unsigned int countPeptideMatchPtm(const PeptideMatch &peptide_match) const; + std::vector<unsigned int> + getPtmPositions(const PeptideMatch &peptide_match) const; - /** @brief get the ptm island group list - */ - const std::vector<PtmIslandGroupSp> & getPtmIslandGroupList() const; - - /** @brief get the ptm island list - */ - const std::vector<PtmIslandSp> & getPtmIslandList() const; - - /** @brief count number of modifications in a PeptideMatch - * */ - unsigned int countPeptideMatchPtm(const PeptideMatch & peptide_match)const; - std::vector<unsigned int> getPtmPositions(const PeptideMatch & peptide_match) const; + private: + std::vector<unsigned int> + getPtmPositions(const ProteinMatch *protein_match) const; -private: - std::vector<unsigned int> getPtmPositions(const ProteinMatch * protein_match) const; + std::vector<PtmIslandSp> + mergePeptideMatchPtmIslandList(vector<PtmIslandSp> ptm_island_list); + void addPtmIsland(PtmIslandSp ptm_island); + void numbering(); - std::vector< PtmIslandSp > mergePeptideMatchPtmIslandList(vector< PtmIslandSp > ptm_island_list); - void addPtmIsland(PtmIslandSp ptm_island); - void numbering(); -private: - std::list<ModificationAndAa> _modification_list; - ValidationState _peptide_validation_state = ValidationState::validAndChecked; - std::vector<PtmIslandSp> _ptm_island_list; - std::vector<PtmIslandSubgroupSp> _ptm_island_subgroup_list; - std::vector<PtmIslandGroupSp> _ptm_island_group_list; + private: + std::list<ModificationAndAa> _modification_list; + ValidationState _peptide_validation_state = ValidationState::validAndChecked; + std::vector<PtmIslandSp> _ptm_island_list; + std::vector<PtmIslandSubgroupSp> _ptm_island_subgroup_list; + std::vector<PtmIslandGroupSp> _ptm_island_group_list; }; #endif // PTMGROUPINGEXPERIMENT_H diff --git a/src/grouping/ptm/ptmisland.cpp b/src/grouping/ptm/ptmisland.cpp index 38878024962c12939450a4b5b44365acb42150cc..98c15f4a205e5caceccdb4c6a74da173cfb071b3 100644 --- a/src/grouping/ptm/ptmisland.cpp +++ b/src/grouping/ptm/ptmisland.cpp @@ -6,26 +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 "ptmisland.h" #include <pappsomspp/pappsoexception.h> @@ -35,164 +36,247 @@ #include <pappsomspp/utils.h> #include <set> -PtmIsland::PtmIsland(const ProteinMatch* p_protein_match, unsigned int position):_protein_match_p(p_protein_match) +PtmIsland::PtmIsland(const ProteinMatch *p_protein_match, unsigned int position) + : _protein_match_p(p_protein_match) { - _position_list.push_back(position); + _position_list.push_back(position); } -PtmIsland::PtmIsland(const PtmIsland & other):_protein_match_p(other._protein_match_p) { - _position_list = other._position_list; +PtmIsland::PtmIsland(const PtmIsland &other) + : _protein_match_p(other._protein_match_p) +{ + _position_list = other._position_list; } PtmIsland::~PtmIsland() { - } -unsigned int PtmIsland::getStart() const { - return _protein_start; +unsigned int +PtmIsland::getStart() const +{ + return _protein_start; } -unsigned int PtmIsland::size() const { - return _protein_stop - _protein_start; +unsigned int +PtmIsland::size() const +{ + return _protein_stop - _protein_start; } -unsigned int PtmIsland::countSampleScanMultiPtm(const PtmGroupingExperiment * p_ptm_grouping_experiment) const { - std::set<std::size_t> sample_scan_list; - for (auto & p_peptide_match : _peptide_match_list) { - if (p_ptm_grouping_experiment->countPeptideMatchPtm(p_peptide_match) > 1) { - sample_scan_list.insert(p_peptide_match.getPeptideEvidence()->getHashSampleScan()); +unsigned int +PtmIsland::countSampleScanMultiPtm( + const PtmGroupingExperiment *p_ptm_grouping_experiment) const +{ + std::set<std::size_t> sample_scan_list; + for(auto &p_peptide_match : _peptide_match_list) + { + if(p_ptm_grouping_experiment->countPeptideMatchPtm(p_peptide_match) > 1) + { + sample_scan_list.insert( + p_peptide_match.getPeptideEvidence()->getHashSampleScan()); } } - return sample_scan_list.size(); + return sample_scan_list.size(); } -unsigned int PtmIsland::countSequence() const { - std::set<QString> sequence_list; - for (auto & peptide_match : _peptide_match_list) { - sequence_list.insert(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()); +unsigned int +PtmIsland::countSequence() const +{ + std::set<QString> sequence_list; + for(auto &peptide_match : _peptide_match_list) + { + sequence_list.insert(peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequence()); } - //qDebug() <<"ProteinMatch::countValidAndCheckedPeptide end " << sequence_list.size(); - return sequence_list.size(); + // qDebug() <<"ProteinMatch::countValidAndCheckedPeptide end " << + // sequence_list.size(); + return sequence_list.size(); } -const PtmIslandSubgroup * PtmIsland::getPtmIslandSubroup() const { - return _ptm_island_subgroup_p; +const PtmIslandSubgroup * +PtmIsland::getPtmIslandSubroup() const +{ + return _ptm_island_subgroup_p; } -const std::vector<unsigned int> & PtmIsland::getPositionList() const { - return _position_list; +const std::vector<unsigned int> & +PtmIsland::getPositionList() const +{ + return _position_list; } -const QString PtmIsland::getGroupingId() const { - if(_prot_number==0) { - return ""; +const QString +PtmIsland::getGroupingId() const +{ + if(_prot_number == 0) + { + return ""; } - return QString("ptm%1%2%3").arg(pappso::Utils::getLexicalOrderedString(_ptm_island_subgroup_p->getPtmIslandGroup()->getGroupNumber())) - .arg(pappso::Utils::getLexicalOrderedString(_ptm_island_subgroup_p->getSubgroupNumber())).arg(pappso::Utils::getLexicalOrderedString(_prot_number)); + return QString("ptm%1%2%3") + .arg(pappso::Utils::getLexicalOrderedString( + _ptm_island_subgroup_p->getPtmIslandGroup()->getGroupNumber())) + .arg(pappso::Utils::getLexicalOrderedString( + _ptm_island_subgroup_p->getSubgroupNumber())) + .arg(pappso::Utils::getLexicalOrderedString(_prot_number)); } -void PtmIsland::setPtmIslandSubgroup(PtmIslandSubgroup* p_ptm_island_subgroup) { - _ptm_island_subgroup_p = p_ptm_island_subgroup; +void +PtmIsland::setPtmIslandSubgroup(PtmIslandSubgroup *p_ptm_island_subgroup) +{ + _ptm_island_subgroup_p = p_ptm_island_subgroup; } -void PtmIsland::setProteinNumber(unsigned int prot_number) { - _prot_number = prot_number; +void +PtmIsland::setProteinNumber(unsigned int prot_number) +{ + _prot_number = prot_number; } -const ProteinMatch * PtmIsland::getProteinMatch() const { - return _protein_match_p; +const ProteinMatch * +PtmIsland::getProteinMatch() const +{ + return _protein_match_p; } -std::vector<std::size_t> PtmIsland::getSampleScanSet() const { - std::vector<std::size_t> sample_scan_set; - for (const PeptideMatch & peptide_match:_peptide_match_list) { - sample_scan_set.push_back(peptide_match.getPeptideEvidence()->getHashSampleScan()); +std::vector<std::size_t> +PtmIsland::getSampleScanSet() const +{ + std::vector<std::size_t> sample_scan_set; + for(const PeptideMatch &peptide_match : _peptide_match_list) + { + sample_scan_set.push_back( + peptide_match.getPeptideEvidence()->getHashSampleScan()); } - std::sort(sample_scan_set.begin(), sample_scan_set.end()); - sample_scan_set.erase(std::unique(sample_scan_set.begin(), sample_scan_set.end()), sample_scan_set.end()); - return sample_scan_set; + std::sort(sample_scan_set.begin(), sample_scan_set.end()); + sample_scan_set.erase( + std::unique(sample_scan_set.begin(), sample_scan_set.end()), + sample_scan_set.end()); + return sample_scan_set; } -bool PtmIsland::containsPeptideMatch(const PeptideMatch & peptide_match) const { +bool +PtmIsland::containsPeptideMatch(const PeptideMatch &peptide_match) const +{ - return std::any_of(_peptide_match_list.begin(), _peptide_match_list.end(), [peptide_match](const PeptideMatch & element) { - return ( peptide_match == element); - }); + return std::any_of(_peptide_match_list.begin(), _peptide_match_list.end(), + [peptide_match](const PeptideMatch &element) { + return (peptide_match == element); + }); } -void PtmIsland::addPeptideMatch(const PeptideMatch & peptide_match) { - if (_position_list.size()==1) { - unsigned int position = _position_list[0]; - if (peptide_match.containsPosition(position)) { - if (_peptide_match_list.size() == 0) { - _protein_start = peptide_match.getStart(); +void +PtmIsland::addPeptideMatch(const PeptideMatch &peptide_match) +{ + if(_position_list.size() == 1) + { + unsigned int position = _position_list[0]; + if(peptide_match.containsPosition(position)) + { + if(_peptide_match_list.size() == 0) + { + _protein_start = peptide_match.getStart(); } - _peptide_match_list.push_back(peptide_match); - if (peptide_match.getStart() < _protein_start) { - _protein_start = peptide_match.getStart(); + _peptide_match_list.push_back(peptide_match); + if(peptide_match.getStart() < _protein_start) + { + _protein_start = peptide_match.getStart(); } - if (peptide_match.getStop() > _protein_stop) { - _protein_stop = peptide_match.getStop(); + if(peptide_match.getStop() > _protein_stop) + { + _protein_stop = peptide_match.getStop(); } } } - else { - throw pappso::PappsoException(QObject::tr("not able to add peptide match if _position_list.size()!=1 (%1)").arg(_position_list.size())); + else + { + throw pappso::PappsoException( + QObject::tr( + "not able to add peptide match if _position_list.size()!=1 (%1)") + .arg(_position_list.size())); } } -unsigned int PtmIsland::getProteinStartPosition() const { - return _protein_start; +unsigned int +PtmIsland::getProteinStartPosition() const +{ + return _protein_start; } -bool PtmIsland::merge(PtmIslandSp ptm_island_sp) { - if (std::none_of(_peptide_match_list.begin(), _peptide_match_list.end(), [ptm_island_sp](const PeptideMatch & element) { - return ptm_island_sp.get()->containsPeptideMatch(element); - })) { - return false; +bool +PtmIsland::merge(PtmIslandSp ptm_island_sp) +{ + if(std::none_of(_peptide_match_list.begin(), _peptide_match_list.end(), + [ptm_island_sp](const PeptideMatch &element) { + return ptm_island_sp.get()->containsPeptideMatch(element); + })) + { + return false; } - else { - //so we merge - _peptide_match_list.insert(_peptide_match_list.begin(),ptm_island_sp.get()->_peptide_match_list.begin(),ptm_island_sp.get()->_peptide_match_list.end()); - std::sort(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch & a, const PeptideMatch & b) - { - return (a.operator<(b)); - }); - auto last = std::unique(_peptide_match_list.begin(), _peptide_match_list.end()); - _peptide_match_list.erase(last, _peptide_match_list.end()); + else + { + // so we merge + _peptide_match_list.insert( + _peptide_match_list.begin(), + ptm_island_sp.get()->_peptide_match_list.begin(), + ptm_island_sp.get()->_peptide_match_list.end()); + std::sort(_peptide_match_list.begin(), _peptide_match_list.end(), + [](const PeptideMatch &a, const PeptideMatch &b) { + return (a.operator<(b)); + }); + auto last = + std::unique(_peptide_match_list.begin(), _peptide_match_list.end()); + _peptide_match_list.erase(last, _peptide_match_list.end()); - _position_list.insert(_position_list.begin(),ptm_island_sp.get()->_position_list.begin(),ptm_island_sp.get()->_position_list.end()); - std::sort(_position_list.begin(), _position_list.end()); - _position_list.erase(std::unique(_position_list.begin(), _position_list.end()), _position_list.end()); + _position_list.insert(_position_list.begin(), + ptm_island_sp.get()->_position_list.begin(), + ptm_island_sp.get()->_position_list.end()); + std::sort(_position_list.begin(), _position_list.end()); + _position_list.erase( + std::unique(_position_list.begin(), _position_list.end()), + _position_list.end()); - std::vector<PeptideMatch>::const_iterator it_result = std::max_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch & a, const PeptideMatch & b) - { - return (a.getStop() < b.getStop()); - }); - _protein_stop = it_result->getStop(); + std::vector<PeptideMatch>::const_iterator it_result = + std::max_element(_peptide_match_list.begin(), _peptide_match_list.end(), + [](const PeptideMatch &a, const PeptideMatch &b) { + return (a.getStop() < b.getStop()); + }); + _protein_stop = it_result->getStop(); - it_result = std::min_element(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch & a, const PeptideMatch & b) - { - return a.getStart() < b.getStart(); - }); - _protein_start = it_result->getStart(); - return true; + it_result = + std::min_element(_peptide_match_list.begin(), _peptide_match_list.end(), + [](const PeptideMatch &a, const PeptideMatch &b) { + return a.getStart() < b.getStart(); + }); + _protein_start = it_result->getStart(); + return true; } } -const std::vector<PeptideMatch> & PtmIsland::getPeptideMatchList() const { - return _peptide_match_list; +const std::vector<PeptideMatch> & +PtmIsland::getPeptideMatchList() const +{ + return _peptide_match_list; } -std::vector<PtmSampleScanSp> PtmIsland::getPtmSampleScanSpList() const { - qDebug() << "PtmIsland::getPtmSampleScanSpList begin" ; - std::vector<PtmSampleScanSp> sample_scan_list; - for (const PeptideMatch & peptide_match:_peptide_match_list) { +std::vector<PtmSampleScanSp> +PtmIsland::getPtmSampleScanSpList() const +{ + qDebug() << "PtmIsland::getPtmSampleScanSpList begin"; + std::vector<PtmSampleScanSp> sample_scan_list; + for(const PeptideMatch &peptide_match : _peptide_match_list) + { - std::vector<PtmSampleScanSp>::iterator it_ptm = sample_scan_list.begin(); - std::vector<PtmSampleScanSp>::iterator it_ptm_end = sample_scan_list.end(); - while ((it_ptm != it_ptm_end) && (it_ptm->get()->add(peptide_match) == false)) { - //peptide added - it_ptm++; + std::vector<PtmSampleScanSp>::iterator it_ptm = sample_scan_list.begin(); + std::vector<PtmSampleScanSp>::iterator it_ptm_end = + sample_scan_list.end(); + while((it_ptm != it_ptm_end) && + (it_ptm->get()->add(peptide_match) == false)) + { + // peptide added + it_ptm++; } - if (it_ptm == it_ptm_end) { - //peptide NOT added - sample_scan_list.push_back(std::make_shared<PtmSampleScan>(peptide_match)); + if(it_ptm == it_ptm_end) + { + // peptide NOT added + sample_scan_list.push_back( + std::make_shared<PtmSampleScan>(peptide_match)); } } - qDebug() << "PtmIsland::getPtmSampleScanSpList end" ; - return sample_scan_list; + qDebug() << "PtmIsland::getPtmSampleScanSpList end"; + return sample_scan_list; } diff --git a/src/grouping/ptm/ptmisland.h b/src/grouping/ptm/ptmisland.h index 7d66eaa3d7b341a536f30e7ab52de47412b35af8..a4b8985f9fdb375eaf94b1dc024da24db8859ebe 100644 --- a/src/grouping/ptm/ptmisland.h +++ b/src/grouping/ptm/ptmisland.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMISLAND_H #define PTMISLAND_H @@ -46,48 +47,50 @@ typedef std::shared_ptr<PtmIsland> PtmIslandSp; class PtmIsland { -public: - PtmIsland(const ProteinMatch* p_protein_match, unsigned int position); - PtmIsland(const PtmIsland & other); - ~PtmIsland(); - void addPeptideMatch(const PeptideMatch & peptide_match); - - /** @brief merge with the given ptm island if there is at least one common peptide match - * */ - bool merge(PtmIslandSp ptm_island_sp); - - bool containsPeptideMatch(const PeptideMatch & element) const; - std::vector<std::size_t> getSampleScanSet() const; - const ProteinMatch * getProteinMatch() const; - unsigned int getProteinStartPosition() const; - void setPtmIslandSubgroup(PtmIslandSubgroup* p_ptm_island_subgroup); - void setProteinNumber(unsigned int prot_number); - - - const QString getGroupingId() const; - const std::vector<unsigned int> & getPositionList() const; - const PtmIslandSubgroup * getPtmIslandSubroup() const; - unsigned int countSequence() const; - unsigned int countSampleScanMultiPtm(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; - - unsigned int getStart() const; - unsigned int size() const; - - std::vector<PtmSampleScanSp> getPtmSampleScanSpList() const; - - const std::vector<PeptideMatch> & getPeptideMatchList() const; - -private: - const ProteinMatch * _protein_match_p; - std::vector<PeptideMatch> _peptide_match_list; - //std::vector<std::size_t> _sample_scan_set; - std::vector<unsigned int> _position_list; - unsigned int _protein_stop=0; - unsigned int _protein_start=0; - /** @brief protein rank number in the PTM subgroup - * */ - unsigned int _prot_number=0; - PtmIslandSubgroup * _ptm_island_subgroup_p = nullptr; + public: + PtmIsland(const ProteinMatch *p_protein_match, unsigned int position); + PtmIsland(const PtmIsland &other); + ~PtmIsland(); + void addPeptideMatch(const PeptideMatch &peptide_match); + + /** @brief merge with the given ptm island if there is at least one common + * peptide match + * */ + bool merge(PtmIslandSp ptm_island_sp); + + bool containsPeptideMatch(const PeptideMatch &element) const; + std::vector<std::size_t> getSampleScanSet() const; + const ProteinMatch *getProteinMatch() const; + unsigned int getProteinStartPosition() const; + void setPtmIslandSubgroup(PtmIslandSubgroup *p_ptm_island_subgroup); + void setProteinNumber(unsigned int prot_number); + + + const QString getGroupingId() const; + const std::vector<unsigned int> &getPositionList() const; + const PtmIslandSubgroup *getPtmIslandSubroup() const; + unsigned int countSequence() const; + unsigned int countSampleScanMultiPtm( + const PtmGroupingExperiment *p_ptm_grouping_experiment) const; + + unsigned int getStart() const; + unsigned int size() const; + + std::vector<PtmSampleScanSp> getPtmSampleScanSpList() const; + + const std::vector<PeptideMatch> &getPeptideMatchList() const; + + private: + const ProteinMatch *_protein_match_p; + std::vector<PeptideMatch> _peptide_match_list; + // std::vector<std::size_t> _sample_scan_set; + std::vector<unsigned int> _position_list; + unsigned int _protein_stop = 0; + unsigned int _protein_start = 0; + /** @brief protein rank number in the PTM subgroup + * */ + unsigned int _prot_number = 0; + PtmIslandSubgroup *_ptm_island_subgroup_p = nullptr; }; #endif // PTMISLAND_H diff --git a/src/grouping/ptm/ptmislandgroup.cpp b/src/grouping/ptm/ptmislandgroup.cpp index cf79ed89d7249fa83658a3bcec6ff0d13ea543ae..0f3a2b3843cc90cc434e0dba4634b5a567ba7e09 100644 --- a/src/grouping/ptm/ptmislandgroup.cpp +++ b/src/grouping/ptm/ptmislandgroup.cpp @@ -6,106 +6,139 @@ */ /******************************************************************************* -* 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 "ptmislandgroup.h" PtmIslandGroup::PtmIslandGroup(PtmIslandSubgroupSp ptm_island_subgroup_sp) { - _ptm_island_subgroup_list.push_back(ptm_island_subgroup_sp); + _ptm_island_subgroup_list.push_back(ptm_island_subgroup_sp); } -PtmIslandGroup::PtmIslandGroup(const PtmIslandGroup& other) +PtmIslandGroup::PtmIslandGroup(const PtmIslandGroup &other) { - _ptm_island_subgroup_list = other._ptm_island_subgroup_list; + _ptm_island_subgroup_list = other._ptm_island_subgroup_list; } PtmIslandGroup::~PtmIslandGroup() { - } -QString PtmIslandGroup::getFirstAccession() const { - if (_ptm_island_subgroup_list.size() == 0) return QString(); - QStringList accession_list; - for (PtmIslandSubgroupSp ptm_island_subgroup:_ptm_island_subgroup_list) { - for (PtmIslandSp ptm_island: ptm_island_subgroup.get()->getPtmIslandList()) { - accession_list << ptm_island.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession(); +QString +PtmIslandGroup::getFirstAccession() const +{ + if(_ptm_island_subgroup_list.size() == 0) + return QString(); + QStringList accession_list; + for(PtmIslandSubgroupSp ptm_island_subgroup : _ptm_island_subgroup_list) + { + for(PtmIslandSp ptm_island : + ptm_island_subgroup.get()->getPtmIslandList()) + { + accession_list << ptm_island.get() + ->getProteinMatch() + ->getProteinXtpSp() + .get() + ->getAccession(); } } - accession_list.sort(); + accession_list.sort(); - return accession_list[0]; + return accession_list[0]; } -unsigned int PtmIslandGroup::getGroupNumber() const { - return _group_number; +unsigned int +PtmIslandGroup::getGroupNumber() const +{ + return _group_number; } -void PtmIslandGroup::setGroupNumber(unsigned int number) { - _group_number = number; - for (PtmIslandSubgroupSp ptm_island_subgroup:_ptm_island_subgroup_list) { - ptm_island_subgroup.get()->setPtmIslandGroup(this); - } - std::sort(_ptm_island_subgroup_list.begin(), _ptm_island_subgroup_list.end(), [](const PtmIslandSubgroupSp& a, const PtmIslandSubgroupSp& b) +void +PtmIslandGroup::setGroupNumber(unsigned int number) +{ + _group_number = number; + for(PtmIslandSubgroupSp ptm_island_subgroup : _ptm_island_subgroup_list) { - return (a.get()->getFirstPtmIsland()->getProteinStartPosition() < b.get()->getFirstPtmIsland()->getProteinStartPosition()); - }); + ptm_island_subgroup.get()->setPtmIslandGroup(this); + } + std::sort(_ptm_island_subgroup_list.begin(), _ptm_island_subgroup_list.end(), + [](const PtmIslandSubgroupSp &a, const PtmIslandSubgroupSp &b) { + return (a.get()->getFirstPtmIsland()->getProteinStartPosition() < + b.get()->getFirstPtmIsland()->getProteinStartPosition()); + }); - unsigned int sg_number=0; - for (PtmIslandSubgroupSp ptm_island_subgroup:_ptm_island_subgroup_list) { - sg_number ++; - ptm_island_subgroup.get()->setSubgroupNumber(sg_number); + unsigned int sg_number = 0; + for(PtmIslandSubgroupSp ptm_island_subgroup : _ptm_island_subgroup_list) + { + sg_number++; + ptm_island_subgroup.get()->setSubgroupNumber(sg_number); } } -bool PtmIslandGroup::operator<(const PtmIslandGroup& other) const { - //if (_ptm_island_subgroup_list.size() == other._ptm_island_subgroup_list.size()) { - if (maxCountSampleScan() == other.maxCountSampleScan()) { - return (getFirstAccession() < other.getFirstAccession()); +bool +PtmIslandGroup::operator<(const PtmIslandGroup &other) const +{ + // if (_ptm_island_subgroup_list.size() == + // other._ptm_island_subgroup_list.size()) { + if(maxCountSampleScan() == other.maxCountSampleScan()) + { + return (getFirstAccession() < other.getFirstAccession()); } - else { - return (maxCountSampleScan() > other.maxCountSampleScan()); + else + { + return (maxCountSampleScan() > other.maxCountSampleScan()); } - //} - //else { - // return (_ptm_island_subgroup_list.size() < other._ptm_island_subgroup_list.size()); - //} + //} + // else { + // return (_ptm_island_subgroup_list.size() < + // other._ptm_island_subgroup_list.size()); + //} } -unsigned int PtmIslandGroup::maxCountSampleScan() const { - std::vector<PtmIslandSubgroupSp>::const_iterator it_result = std::max_element(_ptm_island_subgroup_list.begin(), _ptm_island_subgroup_list.end(), [](const PtmIslandSubgroupSp & a, const PtmIslandSubgroupSp & b) - { - return (a.get()->countSampleScan() < b.get()->countSampleScan()); +unsigned int +PtmIslandGroup::maxCountSampleScan() const +{ + std::vector<PtmIslandSubgroupSp>::const_iterator it_result = std::max_element( + _ptm_island_subgroup_list.begin(), _ptm_island_subgroup_list.end(), + [](const PtmIslandSubgroupSp &a, const PtmIslandSubgroupSp &b) { + return (a.get()->countSampleScan() < b.get()->countSampleScan()); }); - return it_result->get()->countSampleScan(); + return it_result->get()->countSampleScan(); } -bool PtmIslandGroup::mergePtmIslandSubgroupSp(PtmIslandSubgroupSp ptm_island_subgroup_sp) { +bool +PtmIslandGroup::mergePtmIslandSubgroupSp( + PtmIslandSubgroupSp ptm_island_subgroup_sp) +{ - //http://en.cppreference.com/w/cpp/algorithm/all_any_none_of - if (std::any_of(_ptm_island_subgroup_list.begin(), _ptm_island_subgroup_list.end(), [ptm_island_subgroup_sp](PtmIslandSubgroupSp element) { - return element.get()->containsProteinMatchFrom( ptm_island_subgroup_sp.get()); - })) { - //accept this subgroup - _ptm_island_subgroup_list.push_back(ptm_island_subgroup_sp); - return true; + // http://en.cppreference.com/w/cpp/algorithm/all_any_none_of + if(std::any_of(_ptm_island_subgroup_list.begin(), + _ptm_island_subgroup_list.end(), + [ptm_island_subgroup_sp](PtmIslandSubgroupSp element) { + return element.get()->containsProteinMatchFrom( + ptm_island_subgroup_sp.get()); + })) + { + // accept this subgroup + _ptm_island_subgroup_list.push_back(ptm_island_subgroup_sp); + return true; } - return false; + return false; } diff --git a/src/grouping/ptm/ptmislandgroup.h b/src/grouping/ptm/ptmislandgroup.h index bb3702d1ffdd0c03aee4dad15f74e9014fdd2f37..26e98bf53e34234bf83e948d7f2ab180922c9424 100644 --- a/src/grouping/ptm/ptmislandgroup.h +++ b/src/grouping/ptm/ptmislandgroup.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMISLANDGROUP_H #define PTMISLANDGROUP_H @@ -42,23 +43,24 @@ typedef std::shared_ptr<PtmIslandGroup> PtmIslandGroupSp; class PtmIslandGroup { -public: - PtmIslandGroup(PtmIslandSubgroupSp ptm_island_subgroup_sp); - PtmIslandGroup(const PtmIslandGroup& other); - ~PtmIslandGroup(); - bool operator<(const PtmIslandGroup& other) const; - /** @brief merge with the given ptm island subgroup if at least one protein is shared - * */ - bool mergePtmIslandSubgroupSp(PtmIslandSubgroupSp ptm_island_subgroup_sp); - - unsigned int maxCountSampleScan() const; - QString getFirstAccession() const; - void setGroupNumber(unsigned int number); - unsigned int getGroupNumber() const; + public: + PtmIslandGroup(PtmIslandSubgroupSp ptm_island_subgroup_sp); + PtmIslandGroup(const PtmIslandGroup &other); + ~PtmIslandGroup(); + bool operator<(const PtmIslandGroup &other) const; + /** @brief merge with the given ptm island subgroup if at least one protein is + * shared + * */ + bool mergePtmIslandSubgroupSp(PtmIslandSubgroupSp ptm_island_subgroup_sp); -private : - std::vector<PtmIslandSubgroupSp> _ptm_island_subgroup_list; - unsigned int _group_number; + unsigned int maxCountSampleScan() const; + QString getFirstAccession() const; + void setGroupNumber(unsigned int number); + unsigned int getGroupNumber() const; + + private: + std::vector<PtmIslandSubgroupSp> _ptm_island_subgroup_list; + unsigned int _group_number; }; #endif // PTMISLANDGROUP_H diff --git a/src/grouping/ptm/ptmislandsubgroup.cpp b/src/grouping/ptm/ptmislandsubgroup.cpp index f1df0c12361c5cfad670f748f0d935fd3d5416d8..d43c016a88b6ab81de3aa763192dfd0517f50d6f 100644 --- a/src/grouping/ptm/ptmislandsubgroup.cpp +++ b/src/grouping/ptm/ptmislandsubgroup.cpp @@ -2,107 +2,140 @@ * \file grouping/ptm/ptmislandsubgroup.cpp * \date 29/5/2017 * \author Olivier Langella - * \brief object to group ptm islands sharing the same set of sample scans with different proteins + * \brief object to group ptm islands sharing the same set of sample scans with + * different proteins */ /******************************************************************************* -* 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 "ptmislandsubgroup.h" PtmIslandSubgroup::PtmIslandSubgroup(PtmIslandSp ptm_island_sp) { - _ptm_island_list.push_back(ptm_island_sp); - _sample_scan_set = ptm_island_sp.get()->getSampleScanSet(); + _ptm_island_list.push_back(ptm_island_sp); + _sample_scan_set = ptm_island_sp.get()->getSampleScanSet(); } -PtmIslandSubgroup::PtmIslandSubgroup(const PtmIslandSubgroup& other) +PtmIslandSubgroup::PtmIslandSubgroup(const PtmIslandSubgroup &other) { - _ptm_island_list = other._ptm_island_list; - _sample_scan_set = other._sample_scan_set; - + _ptm_island_list = other._ptm_island_list; + _sample_scan_set = other._sample_scan_set; } PtmIslandSubgroup::~PtmIslandSubgroup() { - } -const PtmIsland * PtmIslandSubgroup::getFirstPtmIsland() const { - return _ptm_island_list.begin()->get(); +const PtmIsland * +PtmIslandSubgroup::getFirstPtmIsland() const +{ + return _ptm_island_list.begin()->get(); } -const PtmIslandGroup * PtmIslandSubgroup::getPtmIslandGroup() const { - return _ptm_island_group_p; +const PtmIslandGroup * +PtmIslandSubgroup::getPtmIslandGroup() const +{ + return _ptm_island_group_p; } -unsigned int PtmIslandSubgroup::getSubgroupNumber() const { - return _subgroup_number; +unsigned int +PtmIslandSubgroup::getSubgroupNumber() const +{ + return _subgroup_number; } -void PtmIslandSubgroup::setSubgroupNumber(unsigned int number) { - _subgroup_number = number; +void +PtmIslandSubgroup::setSubgroupNumber(unsigned int number) +{ + _subgroup_number = number; - for (PtmIslandSp ptm_island:_ptm_island_list) { - ptm_island.get()->setPtmIslandSubgroup(this); - } - std::sort(_ptm_island_list.begin(), _ptm_island_list.end(), [](const PtmIslandSp& a, const PtmIslandSp& b) + for(PtmIslandSp ptm_island : _ptm_island_list) { - return (a.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession() < b.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession()); + ptm_island.get()->setPtmIslandSubgroup(this); + } + std::sort( + _ptm_island_list.begin(), _ptm_island_list.end(), + [](const PtmIslandSp &a, const PtmIslandSp &b) { + return ( + a.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession() < + b.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession()); }); - unsigned int prot_number=0; - for (PtmIslandSp ptm_island:_ptm_island_list) { - prot_number ++; - ptm_island.get()->setProteinNumber(prot_number); + unsigned int prot_number = 0; + for(PtmIslandSp ptm_island : _ptm_island_list) + { + prot_number++; + ptm_island.get()->setProteinNumber(prot_number); } } -void PtmIslandSubgroup::setPtmIslandGroup(PtmIslandGroup * p_ptm_island_group) { - _ptm_island_group_p = p_ptm_island_group; - std::sort(_ptm_island_list.begin(), _ptm_island_list.end(), [](const PtmIslandSp& a, const PtmIslandSp& b) - { - return (a.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession() < b.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession()); +void +PtmIslandSubgroup::setPtmIslandGroup(PtmIslandGroup *p_ptm_island_group) +{ + _ptm_island_group_p = p_ptm_island_group; + std::sort( + _ptm_island_list.begin(), _ptm_island_list.end(), + [](const PtmIslandSp &a, const PtmIslandSp &b) { + return ( + a.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession() < + b.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession()); }); } -const std::vector< PtmIslandSp > & PtmIslandSubgroup::getPtmIslandList() const { - return _ptm_island_list; +const std::vector<PtmIslandSp> & +PtmIslandSubgroup::getPtmIslandList() const +{ + return _ptm_island_list; } -unsigned int PtmIslandSubgroup::countSampleScan() const { - return _sample_scan_set.size(); +unsigned int +PtmIslandSubgroup::countSampleScan() const +{ + return _sample_scan_set.size(); } -bool PtmIslandSubgroup::containsProteinMatchFrom(PtmIslandSubgroup* ptm_island_subgroup_p) { - for (PtmIslandSp ptm_island_sp :_ptm_island_list) { - if (std::any_of(ptm_island_subgroup_p->_ptm_island_list.begin(), ptm_island_subgroup_p->_ptm_island_list.end(), [ptm_island_sp](PtmIslandSp element) { - return (element.get()->getProteinMatch() == ptm_island_sp.get()->getProteinMatch()); - })) { - return true; +bool +PtmIslandSubgroup::containsProteinMatchFrom( + PtmIslandSubgroup *ptm_island_subgroup_p) +{ + for(PtmIslandSp ptm_island_sp : _ptm_island_list) + { + if(std::any_of(ptm_island_subgroup_p->_ptm_island_list.begin(), + ptm_island_subgroup_p->_ptm_island_list.end(), + [ptm_island_sp](PtmIslandSp element) { + return (element.get()->getProteinMatch() == + ptm_island_sp.get()->getProteinMatch()); + })) + { + return true; } } - return false; + return false; } -bool PtmIslandSubgroup::mergePtmIslandSp(PtmIslandSp ptm_island_sp) { - if (_sample_scan_set == ptm_island_sp.get()->getSampleScanSet()) { - //merge - _ptm_island_list.push_back(ptm_island_sp); - return true; +bool +PtmIslandSubgroup::mergePtmIslandSp(PtmIslandSp ptm_island_sp) +{ + if(_sample_scan_set == ptm_island_sp.get()->getSampleScanSet()) + { + // merge + _ptm_island_list.push_back(ptm_island_sp); + return true; } - return false; + return false; } diff --git a/src/grouping/ptm/ptmislandsubgroup.h b/src/grouping/ptm/ptmislandsubgroup.h index 0f83c6df713ca9de89ebc80ca36667e85adaf9d9..92629a4e165f602a64caf2cf7b703ee99e0533cc 100644 --- a/src/grouping/ptm/ptmislandsubgroup.h +++ b/src/grouping/ptm/ptmislandsubgroup.h @@ -2,30 +2,32 @@ * \file grouping/ptm/ptmislandsubgroup.h * \date 29/5/2017 * \author Olivier Langella - * \brief object to group ptm islands sharing the same set of sample scans with different proteins + * \brief object to group ptm islands sharing the same set of sample scans with + * different proteins */ /******************************************************************************* -* 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 PTMISLANDSUBGROUP_H #define PTMISLANDSUBGROUP_H @@ -43,33 +45,32 @@ class PtmIslandGroup; class PtmIslandSubgroup { -public: - PtmIslandSubgroup(PtmIslandSp ptm_island_sp); - PtmIslandSubgroup(const PtmIslandSubgroup& other); - ~PtmIslandSubgroup(); + public: + PtmIslandSubgroup(PtmIslandSp ptm_island_sp); + PtmIslandSubgroup(const PtmIslandSubgroup &other); + ~PtmIslandSubgroup(); - /** @brief merge with the given ptm island if all sample scans are shared - * */ - bool mergePtmIslandSp(PtmIslandSp ptm_island_sp); - bool containsProteinMatchFrom(PtmIslandSubgroup* ptm_island_subgroup_p); - - unsigned int countSampleScan() const; - - const std::vector< PtmIslandSp > & getPtmIslandList() const; - - void setPtmIslandGroup(PtmIslandGroup * p_ptm_island_group); - - const PtmIsland * getFirstPtmIsland() const; - unsigned int getSubgroupNumber() const; - void setSubgroupNumber(unsigned int number); - const PtmIslandGroup * getPtmIslandGroup() const; + /** @brief merge with the given ptm island if all sample scans are shared + * */ + bool mergePtmIslandSp(PtmIslandSp ptm_island_sp); + bool containsProteinMatchFrom(PtmIslandSubgroup *ptm_island_subgroup_p); -private: - std::vector< PtmIslandSp > _ptm_island_list; - std::vector<std::size_t> _sample_scan_set; - PtmIslandGroup * _ptm_island_group_p = nullptr; - unsigned int _subgroup_number; + unsigned int countSampleScan() const; + const std::vector<PtmIslandSp> &getPtmIslandList() const; + + void setPtmIslandGroup(PtmIslandGroup *p_ptm_island_group); + + const PtmIsland *getFirstPtmIsland() const; + unsigned int getSubgroupNumber() const; + void setSubgroupNumber(unsigned int number); + const PtmIslandGroup *getPtmIslandGroup() const; + + private: + std::vector<PtmIslandSp> _ptm_island_list; + std::vector<std::size_t> _sample_scan_set; + PtmIslandGroup *_ptm_island_group_p = nullptr; + unsigned int _subgroup_number; }; #endif // PTMISLANDSUBGROUP_H diff --git a/src/grouping/ptm/ptmpeptide.cpp b/src/grouping/ptm/ptmpeptide.cpp index 498858ee91776256d4730719c05b67ca674741e7..9f07274cffbc68203d6ff6504bbafe6a91985190 100644 --- a/src/grouping/ptm/ptmpeptide.cpp +++ b/src/grouping/ptm/ptmpeptide.cpp @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "ptmpeptide.h" diff --git a/src/grouping/ptm/ptmpeptide.h b/src/grouping/ptm/ptmpeptide.h index 775a07474155f350e787f189f72b4f5b3c8a2aa5..e1f79e7b3a002ddc92246c7411ed31c8afbd66df 100644 --- a/src/grouping/ptm/ptmpeptide.h +++ b/src/grouping/ptm/ptmpeptide.h @@ -2,30 +2,32 @@ * \file core/grouping/ptm/ptmpeptide.h * \date 14/3/2018 * \author Olivier Langella - * \brief collection of PTM PeptideMatch sharing the same peptide sequence + mass + * \brief collection of PTM PeptideMatch sharing the same peptide sequence + + * mass */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 PTMPEPTIDE_H diff --git a/src/grouping/ptm/ptmsamplescan.cpp b/src/grouping/ptm/ptmsamplescan.cpp index d35d16908649f76777bad44a4ad0db237ef3516b..623eb6d9d4560d27fa637695c9394ef8f0afef56 100644 --- a/src/grouping/ptm/ptmsamplescan.cpp +++ b/src/grouping/ptm/ptmsamplescan.cpp @@ -6,146 +6,214 @@ */ /******************************************************************************* -* 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 "ptmsamplescan.h" #include "../../grouping/ptm/ptmgroupingexperiment.h" -QColor PtmSampleScan::_color_best = QColor("red"); +QColor PtmSampleScan::_color_best = QColor("red"); QColor PtmSampleScan::_color_other_best = QColor("#ff7878"); -QColor PtmSampleScan::_color_no_best = QColor("yellow"); +QColor PtmSampleScan::_color_no_best = QColor("yellow"); -PtmSampleScan::PtmSampleScan(const PeptideMatch & peptide_match) { - _peptide_match_list.push_back(peptide_match); +PtmSampleScan::PtmSampleScan(const PeptideMatch &peptide_match) +{ + _peptide_match_list.push_back(peptide_match); } -PtmSampleScan::PtmSampleScan(const PtmSampleScan& other) { - _peptide_match_list = other._peptide_match_list; +PtmSampleScan::PtmSampleScan(const PtmSampleScan &other) +{ + _peptide_match_list = other._peptide_match_list; } -PtmSampleScan::~PtmSampleScan() { +PtmSampleScan::~PtmSampleScan() +{ } -const PeptideMatch & PtmSampleScan::getRepresentativePeptideMatch() const { - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << _peptide_match_list.size(); - return _peptide_match_list[0]; +const PeptideMatch & +PtmSampleScan::getRepresentativePeptideMatch() const +{ + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << + // _peptide_match_list.size(); + return _peptide_match_list[0]; } -bool PtmSampleScan::add(const PeptideMatch & peptide_match) { - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; - if(getRepresentativePeptideMatch().getPeptideEvidence()->getHashSampleScan() != peptide_match.getPeptideEvidence()->getHashSampleScan()) { - return false; +bool +PtmSampleScan::add(const PeptideMatch &peptide_match) +{ + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; + if(getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getHashSampleScan() != + peptide_match.getPeptideEvidence()->getHashSampleScan()) + { + return false; } - - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; - if(getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getSequence() != peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()) { - return false; + + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; + if(getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequence() != + peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()) + { + return false; } - - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; - if(getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getMass() != peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getMass()) { - return false; + + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; + if(getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getMass() != + peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getMass()) + { + return false; } - _peptide_match_list.push_back(peptide_match); - - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; + _peptide_match_list.push_back(peptide_match); - //sort list - std::sort(_peptide_match_list.begin(),_peptide_match_list.end(),[](const PeptideMatch & first, const PeptideMatch & second) { - return (first.getPeptideEvidence()->getEvalue() < second.getPeptideEvidence()->getEvalue()) ; - }); + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ ; - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << true; - return true; -} + // sort list + std::sort(_peptide_match_list.begin(), _peptide_match_list.end(), + [](const PeptideMatch &first, const PeptideMatch &second) { + return (first.getPeptideEvidence()->getEvalue() < + second.getPeptideEvidence()->getEvalue()); + }); -std::vector<unsigned int> PtmSampleScan::getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const { - return p_ptm_grouping_experiment->getPtmPositions(getRepresentativePeptideMatch()); + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << + // true; + return true; } -std::vector<unsigned int> PtmSampleScan::getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const { - std::vector<unsigned int> position_list; +std::vector<unsigned int> +PtmSampleScan::getBestPtmPositionList( + const PtmGroupingExperiment *p_ptm_grouping_experiment) const +{ + return p_ptm_grouping_experiment->getPtmPositions( + getRepresentativePeptideMatch()); +} - for (const PeptideMatch & peptide_match: _peptide_match_list) { - std::vector<unsigned int> positionb_list = p_ptm_grouping_experiment->getPtmPositions(peptide_match); - for (unsigned int position: positionb_list) { - position_list.push_back(position); +std::vector<unsigned int> +PtmSampleScan::getObservedPtmPositionList( + const PtmGroupingExperiment *p_ptm_grouping_experiment) const +{ + std::vector<unsigned int> position_list; + + for(const PeptideMatch &peptide_match : _peptide_match_list) + { + std::vector<unsigned int> positionb_list = + p_ptm_grouping_experiment->getPtmPositions(peptide_match); + for(unsigned int position : positionb_list) + { + position_list.push_back(position); } } - std::sort(position_list.begin(), position_list.end()); - auto last = std::unique(position_list.begin(), position_list.end()); - position_list.erase(last, position_list.end()); - return position_list; + std::sort(position_list.begin(), position_list.end()); + auto last = std::unique(position_list.begin(), position_list.end()); + position_list.erase(last, position_list.end()); + return position_list; } -const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const +const QString +PtmSampleScan::getHtmlSequence( + const PtmGroupingExperiment *p_ptm_grouping_experiment) const { - const PeptideMatch & representative_peptide = getRepresentativePeptideMatch(); - size_t pep_size = representative_peptide.getPeptideEvidence()->getPeptideXtpSp().get()->size(); - //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); - if (pep_size == 0) return 0; - bool best_bool[pep_size] = {false}; - bool other_best_bool[pep_size] = {false}; - bool nobest_bool[pep_size] = {false}; - double best_evalue = representative_peptide.getPeptideEvidence()->getEvalue(); - - - for (auto & peptide_match : _peptide_match_list) { - bool is_best= false; - if (peptide_match.getPeptideEvidence()->getEvalue() == best_evalue) { - is_best= true; + const PeptideMatch &representative_peptide = getRepresentativePeptideMatch(); + size_t pep_size = representative_peptide.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->size(); + // qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " + // " << _protein_sp.get()-//>getSequence(); + if(pep_size == 0) + return 0; + bool best_bool[pep_size] = {false}; + bool other_best_bool[pep_size] = {false}; + bool nobest_bool[pep_size] = {false}; + double best_evalue = representative_peptide.getPeptideEvidence()->getEvalue(); + + + for(auto &peptide_match : _peptide_match_list) + { + bool is_best = false; + if(peptide_match.getPeptideEvidence()->getEvalue() == best_evalue) + { + is_best = true; } - std::vector<unsigned int> position_list = p_ptm_grouping_experiment->getPtmPositions(peptide_match); - for (unsigned int position :position_list) { - if (representative_peptide == peptide_match) { - best_bool[position] = true; + std::vector<unsigned int> position_list = + p_ptm_grouping_experiment->getPtmPositions(peptide_match); + for(unsigned int position : position_list) + { + if(representative_peptide == peptide_match) + { + best_bool[position] = true; } - else if (is_best) { - other_best_bool[position] = true; + else if(is_best) + { + other_best_bool[position] = true; } - else { - nobest_bool[position] = true; + else + { + nobest_bool[position] = true; } } } - QString sequence = representative_peptide.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence(); - QString sequence_html; - for (unsigned int i=0; i < pep_size; i++) { - if (best_bool[i]) { - sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_best.name())); + QString sequence = representative_peptide.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequence(); + QString sequence_html; + for(unsigned int i = 0; i < pep_size; i++) + { + if(best_bool[i]) + { + sequence_html.append(QString("<span style=\"color:%2;\">%1</span>") + .arg(sequence[i]) + .arg(_color_best.name())); } - else if (other_best_bool[i]) { - sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_other_best.name())); + else if(other_best_bool[i]) + { + sequence_html.append(QString("<span style=\"color:%2;\">%1</span>") + .arg(sequence[i]) + .arg(_color_other_best.name())); } - else if (nobest_bool[i]) { - sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_no_best.name())); + else if(nobest_bool[i]) + { + sequence_html.append(QString("<span style=\"color:%2;\">%1</span>") + .arg(sequence[i]) + .arg(_color_no_best.name())); } - else { - sequence_html.append(sequence[i]); + else + { + sequence_html.append(sequence[i]); } } - return sequence_html; + return sequence_html; } -std::vector<PeptideMatch> & PtmSampleScan::getPeptideMatchList() { - return _peptide_match_list; +std::vector<PeptideMatch> & +PtmSampleScan::getPeptideMatchList() +{ + return _peptide_match_list; } diff --git a/src/grouping/ptm/ptmsamplescan.h b/src/grouping/ptm/ptmsamplescan.h index 50427558790b6124407bb85b2d6f3c58b25798aa..46d0a576e9fbf115b4e1c087bfe5b2872e955833 100644 --- a/src/grouping/ptm/ptmsamplescan.h +++ b/src/grouping/ptm/ptmsamplescan.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMSAMPLESCAN_H #define PTMSAMPLESCAN_H @@ -43,32 +44,35 @@ typedef std::shared_ptr<PtmSampleScan> PtmSampleScanSp; class PtmSampleScan { -public: - PtmSampleScan(const PeptideMatch & peptide_match); - PtmSampleScan(const PtmSampleScan& other); - ~PtmSampleScan(); - - /** @brief get the best peptide Match (Evalue) - * peptide match are sorted in this sample/scan by Evalue - * The representative peptide match is the first in the sorted array - */ - const PeptideMatch & getRepresentativePeptideMatch() const; - bool add(const PeptideMatch & peptide_match); - std::vector<unsigned int> getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; - - /** @brief get all observed PTM positions for this sample/scan - * positions are intended in a peptide (not protein), from 0 (first amino acid) to size-1 (last amino acid) - */ - std::vector<unsigned int> getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; - const QString getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const; - std::vector<PeptideMatch> & getPeptideMatchList(); - -private: - std::vector<PeptideMatch> _peptide_match_list; - static QColor _color_best; - static QColor _color_other_best; - static QColor _color_no_best; + public: + PtmSampleScan(const PeptideMatch &peptide_match); + PtmSampleScan(const PtmSampleScan &other); + ~PtmSampleScan(); + /** @brief get the best peptide Match (Evalue) + * peptide match are sorted in this sample/scan by Evalue + * The representative peptide match is the first in the sorted array + */ + const PeptideMatch &getRepresentativePeptideMatch() const; + bool add(const PeptideMatch &peptide_match); + std::vector<unsigned int> getBestPtmPositionList( + const PtmGroupingExperiment *p_ptm_grouping_experiment) const; + + /** @brief get all observed PTM positions for this sample/scan + * positions are intended in a peptide (not protein), from 0 (first amino + * acid) to size-1 (last amino acid) + */ + std::vector<unsigned int> getObservedPtmPositionList( + const PtmGroupingExperiment *p_ptm_grouping_experiment) const; + const QString + getHtmlSequence(const PtmGroupingExperiment *p_ptm_grouping_experiment) const; + std::vector<PeptideMatch> &getPeptideMatchList(); + + private: + std::vector<PeptideMatch> _peptide_match_list; + static QColor _color_best; + static QColor _color_other_best; + static QColor _color_no_best; }; Q_DECLARE_METATYPE(PtmSampleScan *) diff --git a/src/gui/about_dialog/aboutdialog.cpp b/src/gui/about_dialog/aboutdialog.cpp index 8fa0094f5ce16f1f1dc893c0c258295cb9f20a43..1aefbcbc962dad0d5d8cad8b82210b27234741eb 100644 --- a/src/gui/about_dialog/aboutdialog.cpp +++ b/src/gui/about_dialog/aboutdialog.cpp @@ -1,51 +1,50 @@ /******************************************************************************* -* 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 "aboutdialog.h" #include <QDebug> #include "ui_about_dialog.h" -AboutDialog::AboutDialog(QWidget * parent): - QDialog(parent), - ui(new Ui::AboutDialog) +AboutDialog::AboutDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::AboutDialog) { - qDebug() << "AboutDialog::AboutDialog begin"; - ui->setupUi(this); - this->setModal(true); - + qDebug() << "AboutDialog::AboutDialog begin"; + ui->setupUi(this); + this->setModal(true); + #if QT_VERSION >= 0x050000 - // Qt5 code + // Qt5 code #else -// Qt4 code + // Qt4 code #endif - } AboutDialog::~AboutDialog() { - qDebug() << "AboutDialog::~AboutDialog"; - delete ui; - - qDebug() << "AboutDialog::~AboutDialog end"; + qDebug() << "AboutDialog::~AboutDialog"; + delete ui; + + qDebug() << "AboutDialog::~AboutDialog end"; } diff --git a/src/gui/about_dialog/aboutdialog.h b/src/gui/about_dialog/aboutdialog.h index 299a6b33188cbeb7086a1e387fbb8fcfa3f07462..fe2b90f2b675fff928daa1702965bd0c42070983 100644 --- a/src/gui/about_dialog/aboutdialog.h +++ b/src/gui/about_dialog/aboutdialog.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 ABOUTDIALOG_H #define ABOUTDIALOG_H @@ -27,21 +28,21 @@ #include <QDialog> -namespace Ui { -class AboutDialog; +namespace Ui +{ + class AboutDialog; } class AboutDialog : public QDialog { - Q_OBJECT - -public: - explicit AboutDialog(QWidget * parent); - ~AboutDialog(); + Q_OBJECT -private: - Ui::AboutDialog *ui; + public: + explicit AboutDialog(QWidget *parent); + ~AboutDialog(); + private: + Ui::AboutDialog *ui; }; #endif // ABOUTDIALOG_H diff --git a/src/gui/choose_modification_dialog/choosemodificationdialog.cpp b/src/gui/choose_modification_dialog/choosemodificationdialog.cpp index 3120ad714f45b11d3471ad89f93af2ba6d0dbde6..9d682cdc99739a62841e5bc3c59874097cf427bf 100644 --- a/src/gui/choose_modification_dialog/choosemodificationdialog.cpp +++ b/src/gui/choose_modification_dialog/choosemodificationdialog.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 "choosemodificationdialog.h" @@ -33,81 +34,100 @@ #include <pappsomspp/obo/filterobopsimodtermname.h> #include "../../utils/utils.h" -ChooseModificationDialog::ChooseModificationDialog(QWidget * parent): - QDialog(parent), - ui(new Ui::ChooseModificationDialog) +ChooseModificationDialog::ChooseModificationDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::ChooseModificationDialog) { - qDebug() << "ChooseModificationDialog::ChooseModificationDialog begin"; - ui->setupUi(this); - this->setModal(true); + qDebug() << "ChooseModificationDialog::ChooseModificationDialog begin"; + ui->setupUi(this); + this->setModal(true); - _p_modification_str_li = new QStandardItemModel(); - ui->modification_listview->setModel(_p_modification_str_li); - //param.setFilterCrossSamplePeptideNumber(settings.value("automatic_filter/cross_sample", "true").toBool()); + _p_modification_str_li = new QStandardItemModel(); + ui->modification_listview->setModel(_p_modification_str_li); + // param.setFilterCrossSamplePeptideNumber(settings.value("automatic_filter/cross_sample", + // "true").toBool()); #if QT_VERSION >= 0x050000 - // Qt5 code - connect(ui->modification_listview,&QListView::clicked,this,&ChooseModificationDialog::ItemClicked); - connect(ui->modification_listview,&QListView::doubleClicked,this,&ChooseModificationDialog::ItemDoubleClicked); + // Qt5 code + connect(ui->modification_listview, &QListView::clicked, this, + &ChooseModificationDialog::ItemClicked); + connect(ui->modification_listview, &QListView::doubleClicked, this, + &ChooseModificationDialog::ItemDoubleClicked); #else -// Qt4 code + // Qt4 code - connect(ui->modification_listview,SIGNAL(clicked(const QModelIndex)),this,SLOT(ItemClicked(QModelIndex))); - connect(ui->modification_listview,SIGNAL(doubleClicked(const QModelIndex)),this,SLOT(ItemDoubleClicked(QModelIndex))); + connect(ui->modification_listview, SIGNAL(clicked(const QModelIndex)), this, + SLOT(ItemClicked(QModelIndex))); + connect(ui->modification_listview, SIGNAL(doubleClicked(const QModelIndex)), + this, SLOT(ItemDoubleClicked(QModelIndex))); #endif - } ChooseModificationDialog::~ChooseModificationDialog() { - qDebug() << "ChooseModificationDialog::~ChooseModificationDialog"; - delete ui; - - qDebug() << "ChooseModificationDialog::~ChooseModificationDialog end"; -} - -void ChooseModificationDialog::setMassRange(const pappso::MassRange & massrange) { - - qDebug() << "ChooseModificationDialog::setMassRange " << massrange.toString(); - _selected_modification = nullptr; - _p_modification_str_li->removeRows(0,_p_modification_str_li->rowCount()); - pappso::FilterOboPsiModSink term_list; + qDebug() << "ChooseModificationDialog::~ChooseModificationDialog"; + delete ui; - pappso::OboPsiModHandlerInterface * last_men_standing = &term_list; - pappso::FilterOboPsiModTermDiffMono * p_filter_mass = nullptr; - //FilterOboPsiModTermLabel * p_filter_label = nullptr; - //FilterOboPsiModTermName * p_filter_name = nullptr; + qDebug() << "ChooseModificationDialog::~ChooseModificationDialog end"; +} - p_filter_mass = new pappso::FilterOboPsiModTermDiffMono(*last_men_standing, massrange); - pappso::OboPsiMod psimodb(*p_filter_mass); - for (pappso::OboPsiModTerm term : term_list.getOboPsiModTermList() ) { +void +ChooseModificationDialog::setMassRange(const pappso::MassRange &massrange) +{ - QStandardItem *item; - item = new QStandardItem(QString("[%1] %2").arg(term._accession).arg(term._name)); - item->setEditable(false); - _p_modification_str_li->appendRow(item); - item->setData(QVariant(QString("%1").arg(term._accession)),Qt::UserRole); + qDebug() << "ChooseModificationDialog::setMassRange " << massrange.toString(); + _selected_modification = nullptr; + _p_modification_str_li->removeRows(0, _p_modification_str_li->rowCount()); + pappso::FilterOboPsiModSink term_list; + + pappso::OboPsiModHandlerInterface *last_men_standing = &term_list; + pappso::FilterOboPsiModTermDiffMono *p_filter_mass = nullptr; + // FilterOboPsiModTermLabel * p_filter_label = nullptr; + // FilterOboPsiModTermName * p_filter_name = nullptr; + + p_filter_mass = + new pappso::FilterOboPsiModTermDiffMono(*last_men_standing, massrange); + pappso::OboPsiMod psimodb(*p_filter_mass); + for(pappso::OboPsiModTerm term : term_list.getOboPsiModTermList()) + { + + QStandardItem *item; + item = new QStandardItem( + QString("[%1] %2").arg(term._accession).arg(term._name)); + item->setEditable(false); + _p_modification_str_li->appendRow(item); + item->setData(QVariant(QString("%1").arg(term._accession)), Qt::UserRole); } } -void ChooseModificationDialog::ItemDoubleClicked (QModelIndex index ) +void +ChooseModificationDialog::ItemDoubleClicked(QModelIndex index) { - qDebug() << "ChooseModificationDialog::ItemClicked data=" << index.data().toString(); - qDebug() << "ChooseModificationDialog::ItemClicked acc=" << _p_modification_str_li->data(index,Qt::UserRole).toString(); - QDesktopServices::openUrl (Utils::getOlsUrl(_p_modification_str_li->data(index,Qt::UserRole).toString())) ; + qDebug() << "ChooseModificationDialog::ItemClicked data=" + << index.data().toString(); + qDebug() << "ChooseModificationDialog::ItemClicked acc=" + << _p_modification_str_li->data(index, Qt::UserRole).toString(); + QDesktopServices::openUrl(Utils::getOlsUrl( + _p_modification_str_li->data(index, Qt::UserRole).toString())); } -void ChooseModificationDialog::ItemClicked (QModelIndex index ) +void +ChooseModificationDialog::ItemClicked(QModelIndex index) { - qDebug() << "ChooseModificationDialog::ItemClicked data=" << index.data().toString(); - qDebug() << "ChooseModificationDialog::ItemClicked acc=" << _p_modification_str_li->data(index,Qt::UserRole).toString(); - qDebug() << "ChooseModificationDialog::ItemClicked str=" << _p_modification_str_li->data(index,Qt::DisplayRole).toString(); - pappso::AaModificationP modification = pappso::AaModification::getInstance(index.data(Qt::UserRole).toString()); - _selected_modification = modification; + qDebug() << "ChooseModificationDialog::ItemClicked data=" + << index.data().toString(); + qDebug() << "ChooseModificationDialog::ItemClicked acc=" + << _p_modification_str_li->data(index, Qt::UserRole).toString(); + qDebug() << "ChooseModificationDialog::ItemClicked str=" + << _p_modification_str_li->data(index, Qt::DisplayRole).toString(); + pappso::AaModificationP modification = + pappso::AaModification::getInstance(index.data(Qt::UserRole).toString()); + _selected_modification = modification; } -pappso::AaModificationP ChooseModificationDialog::getSelectedModification()const { - return _selected_modification; +pappso::AaModificationP +ChooseModificationDialog::getSelectedModification() const +{ + return _selected_modification; } diff --git a/src/gui/choose_modification_dialog/choosemodificationdialog.h b/src/gui/choose_modification_dialog/choosemodificationdialog.h index 83445bd8e2f6feb354443e41612944dbe0835a6c..32479c43f0df2f0580077b4b128a5ce536d9ee4d 100644 --- a/src/gui/choose_modification_dialog/choosemodificationdialog.h +++ b/src/gui/choose_modification_dialog/choosemodificationdialog.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 CHOOSEMODIFICATIONDIALOG_H #define CHOOSEMODIFICATIONDIALOG_H @@ -30,30 +31,30 @@ #include <pappsomspp/amino_acid/aamodification.h> -namespace Ui { -class ChooseModificationDialog; +namespace Ui +{ + class ChooseModificationDialog; } class ChooseModificationDialog : public QDialog { - Q_OBJECT + Q_OBJECT -public: - explicit ChooseModificationDialog(QWidget * parent); - ~ChooseModificationDialog(); + public: + explicit ChooseModificationDialog(QWidget *parent); + ~ChooseModificationDialog(); - void setMassRange(const pappso::MassRange & massrange); - public slots: - void ItemClicked (QModelIndex index ); - void ItemDoubleClicked (QModelIndex index ); - - pappso::AaModificationP getSelectedModification() const; + void setMassRange(const pappso::MassRange &massrange); + public slots: + void ItemClicked(QModelIndex index); + void ItemDoubleClicked(QModelIndex index); -private: - Ui::ChooseModificationDialog *ui; - QStandardItemModel * _p_modification_str_li=nullptr; - pappso::AaModificationP _selected_modification; + pappso::AaModificationP getSelectedModification() const; + private: + Ui::ChooseModificationDialog *ui; + QStandardItemModel *_p_modification_str_li = nullptr; + pappso::AaModificationP _selected_modification; }; #endif // CHOOSEMODIFICATIONDIALOG_H diff --git a/src/gui/edit_label_methods/editlabelmethods.cpp b/src/gui/edit_label_methods/editlabelmethods.cpp index e59a14685d002b2e19e753c89c3d58abbb3852df..738841833d8f7b7c7494483a8d518feb7d11eaed 100644 --- a/src/gui/edit_label_methods/editlabelmethods.cpp +++ b/src/gui/edit_label_methods/editlabelmethods.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 "editlabelmethods.h" #include "../project_view/projectwindow.h" @@ -28,82 +29,96 @@ #include <QDomDocument> #include <QMessageBox> -EditLabelMethods::EditLabelMethods(ProjectWindow *parent): - QDialog(), - ui(new Ui::EditLabelMethodView) +EditLabelMethods::EditLabelMethods(ProjectWindow *parent) + : QDialog(), ui(new Ui::EditLabelMethodView) { - ui->setupUi(this); - _project_window = parent; - _p_label_method_str_li = new QStandardItemModel(); - ui->method_list_view->setModel(_p_label_method_str_li); -this->setModal(true); + ui->setupUi(this); + _project_window = parent; + _p_label_method_str_li = new QStandardItemModel(); + ui->method_list_view->setModel(_p_label_method_str_li); + this->setModal(true); #if QT_VERSION >= 0x050000 - // Qt5 code - connect(ui->method_list_view,&QListView::clicked,this,&EditLabelMethods::ItemClicked); + // Qt5 code + connect(ui->method_list_view, &QListView::clicked, this, + &EditLabelMethods::ItemClicked); #else - connect(ui->method_list_view,SIGNAL(clicked(const QModelIndex)),this,SLOT(ItemClicked(QModelIndex))); + connect(ui->method_list_view, SIGNAL(clicked(const QModelIndex)), this, + SLOT(ItemClicked(QModelIndex))); #endif } -EditLabelMethods::~EditLabelMethods() { - - qDebug() << "EditLabelMethods::~EditLabelMethods"; - delete ui; - qDebug() << "EditLabelMethods::~EditLabelMethods end"; +EditLabelMethods::~EditLabelMethods() +{ + + qDebug() << "EditLabelMethods::~EditLabelMethods"; + delete ui; + qDebug() << "EditLabelMethods::~EditLabelMethods end"; } -void EditLabelMethods::setProjectSp(ProjectSp project_sp) { +void +EditLabelMethods::setProjectSp(ProjectSp project_sp) +{ - _project_sp = project_sp; - _p_label_method_str_li->removeRows(0,_p_label_method_str_li->rowCount()); - ui->ok_button->setDisabled(true); + _project_sp = project_sp; + _p_label_method_str_li->removeRows(0, _p_label_method_str_li->rowCount()); + ui->ok_button->setDisabled(true); - QDomDocument *dom = new QDomDocument("labeling_methods"); - QFile xml_doc(":/labeling/resources/catalog_label.xml"); - if(!xml_doc.open(QIODevice::ReadOnly)) + QDomDocument *dom = new QDomDocument("labeling_methods"); + QFile xml_doc(":/labeling/resources/catalog_label.xml"); + if(!xml_doc.open(QIODevice::ReadOnly)) { - //error - QMessageBox::warning(this,tr("error"),tr("error opening catalog_label resource file")); - return; + // error + QMessageBox::warning(this, tr("error"), + tr("error opening catalog_label resource file")); + return; } - if (!dom->setContent(&xml_doc)) { - xml_doc.close(); - QMessageBox::warning(this,tr("error"), tr("error setting catalog_label xml content")); - return; + if(!dom->setContent(&xml_doc)) + { + xml_doc.close(); + QMessageBox::warning(this, tr("error"), + tr("error setting catalog_label xml content")); + return; } - QDomNode child = dom->documentElement().firstChild(); - while (!child.isNull()) { - if (child.toElement().tagName() == "isotope_label_list") { - QStandardItem *item; - item = new QStandardItem(QString("%1").arg(child.toElement().attribute("id"))); - item->setEditable(false); - _p_label_method_str_li->appendRow(item); - item->setData(QVariant(QString("%1").arg(child.toElement().attribute("id"))),Qt::UserRole); + QDomNode child = dom->documentElement().firstChild(); + while(!child.isNull()) + { + if(child.toElement().tagName() == "isotope_label_list") + { + QStandardItem *item; + item = new QStandardItem( + QString("%1").arg(child.toElement().attribute("id"))); + item->setEditable(false); + _p_label_method_str_li->appendRow(item); + item->setData( + QVariant(QString("%1").arg(child.toElement().attribute("id"))), + Qt::UserRole); } - child = child.nextSibling(); + child = child.nextSibling(); } - - xml_doc.close(); - delete dom; + xml_doc.close(); + delete dom; } -void EditLabelMethods::ItemClicked (QModelIndex index ) +void +EditLabelMethods::ItemClicked(QModelIndex index) { - qDebug() << "EditLabelMethods::ItemClicked begin" << index.data().toString(); - ui->ok_button->setDisabled(false); - - LabelingMethod method(index.data().toString()); - - _sp_labeling_method = method.makeLabelingMethodSp(); + qDebug() << "EditLabelMethods::ItemClicked begin" << index.data().toString(); + ui->ok_button->setDisabled(false); + + LabelingMethod method(index.data().toString()); + + _sp_labeling_method = method.makeLabelingMethodSp(); } -LabelingMethodSp EditLabelMethods::getLabelingMethodSp() const { - //_project_sp.get()->setLabelingMethodSp(_sp_labeling_method); - return _sp_labeling_method; +LabelingMethodSp +EditLabelMethods::getLabelingMethodSp() const +{ + //_project_sp.get()->setLabelingMethodSp(_sp_labeling_method); + return _sp_labeling_method; } diff --git a/src/gui/edit_label_methods/editlabelmethods.h b/src/gui/edit_label_methods/editlabelmethods.h index 09f1afcf0f9e5067cdda2c24512902f91f4006f8..5b05b7b325c514f396a79c1603452bc418be570d 100644 --- a/src/gui/edit_label_methods/editlabelmethods.h +++ b/src/gui/edit_label_methods/editlabelmethods.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 EDITLABELMETHODS_H #define EDITLABELMETHODS_H @@ -32,30 +33,30 @@ class ProjectWindow; -namespace Ui { -class EditLabelMethodView; +namespace Ui +{ + class EditLabelMethodView; } -class EditLabelMethods: public QDialog { - Q_OBJECT -public: - - explicit EditLabelMethods(ProjectWindow * parent = 0); - ~EditLabelMethods(); - - void setProjectSp(ProjectSp project_sp); - LabelingMethodSp getLabelingMethodSp() const; - -public slots: - void ItemClicked (QModelIndex index ); - -private : - -private: - Ui::EditLabelMethodView *ui; - ProjectWindow * _project_window; - ProjectSp _project_sp; - QStandardItemModel * _p_label_method_str_li=nullptr; - LabelingMethodSp _sp_labeling_method; +class EditLabelMethods : public QDialog +{ + Q_OBJECT + public: + explicit EditLabelMethods(ProjectWindow *parent = 0); + ~EditLabelMethods(); + + void setProjectSp(ProjectSp project_sp); + LabelingMethodSp getLabelingMethodSp() const; + + public slots: + void ItemClicked(QModelIndex index); + + private: + private: + Ui::EditLabelMethodView *ui; + ProjectWindow *_project_window; + ProjectSp _project_sp; + QStandardItemModel *_p_label_method_str_li = nullptr; + LabelingMethodSp _sp_labeling_method; }; #endif // EDITLABELMETHODS_H diff --git a/src/gui/edit_modifications/editmodifications.cpp b/src/gui/edit_modifications/editmodifications.cpp index ad688acd01474b94077f8d34873e214d62518b46..8cfacd24f4eb3261cd04aa8faa064d18d44f51ab 100644 --- a/src/gui/edit_modifications/editmodifications.cpp +++ b/src/gui/edit_modifications/editmodifications.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 "editmodifications.h" #include "../project_view/projectwindow.h" @@ -28,139 +29,176 @@ #include "ui_edit_modifications.h" -EditModifications::EditModifications(ProjectWindow *parent): - QMainWindow(parent), - ui(new Ui::EditModificationView) +EditModifications::EditModifications(ProjectWindow *parent) + : QMainWindow(parent), ui(new Ui::EditModificationView) { - ui->setupUi(this); - _project_window = parent; - _p_modification_str_li = new QStandardItemModel(); - ui->modification_list_view->setModel(_p_modification_str_li); + ui->setupUi(this); + _project_window = parent; + _p_modification_str_li = new QStandardItemModel(); + ui->modification_list_view->setModel(_p_modification_str_li); - _p_browse_modification_dialog = new ChooseModificationDialog(this); + _p_browse_modification_dialog = new ChooseModificationDialog(this); #if QT_VERSION >= 0x050000 - // Qt5 code - connect(ui->modification_list_view,&QListView::clicked,this,&EditModifications::ItemClicked); - connect(ui->modification_list_view,&QListView::doubleClicked,this,&EditModifications::ItemDoubleClicked); - - connect(_p_browse_modification_dialog, &ChooseModificationDialog::accepted, this,&EditModifications::doAcceptedBrowseDialog); + // Qt5 code + connect(ui->modification_list_view, &QListView::clicked, this, + &EditModifications::ItemClicked); + connect(ui->modification_list_view, &QListView::doubleClicked, this, + &EditModifications::ItemDoubleClicked); + + connect(_p_browse_modification_dialog, &ChooseModificationDialog::accepted, + this, &EditModifications::doAcceptedBrowseDialog); #else - connect(ui->modification_list_view,SIGNAL(clicked(const QModelIndex)),this,SLOT(ItemClicked(QModelIndex))); - connect(ui->modification_list_view,SIGNAL(doubleClicked(const QModelIndex)),this,SLOT(ItemDoubleClicked(QModelIndex))); + connect(ui->modification_list_view, SIGNAL(clicked(const QModelIndex)), this, + SLOT(ItemClicked(QModelIndex))); + connect(ui->modification_list_view, SIGNAL(doubleClicked(const QModelIndex)), + this, SLOT(ItemDoubleClicked(QModelIndex))); - connect(_p_browse_modification_dialog, SIGNAL(accepted()), this,SLOT(doAcceptedBrowseDialog())); + connect(_p_browse_modification_dialog, SIGNAL(accepted()), this, + SLOT(doAcceptedBrowseDialog())); #endif } -EditModifications::~EditModifications() { - qDebug() << "EditModifications::~EditModifications"; - - delete ui; - //delete _project_window; - delete _p_browse_modification_dialog; - delete _p_modification_str_li; - qDebug() << "EditModifications::~EditModifications end"; +EditModifications::~EditModifications() +{ + qDebug() << "EditModifications::~EditModifications"; + delete ui; + // delete _project_window; + delete _p_browse_modification_dialog; + delete _p_modification_str_li; + qDebug() << "EditModifications::~EditModifications end"; } -void EditModifications::setProjectSp(ProjectSp project_sp) { - - _project_sp = project_sp; - ui->selected_modification_groupbox->setVisible(false); - _p_modification_str_li->removeRows(0,_p_modification_str_li->rowCount()); +void +EditModifications::setProjectSp(ProjectSp project_sp) +{ - std::set<pappso::AaModificationP> mod_list = project_sp.get()->getPeptideStore().getModificationCollection(); - //_p_modification_str_li->insertRows(0, mod_list.size()); - for (pappso::AaModificationP modification :mod_list) { - if (modification->isInternal()) { + _project_sp = project_sp; + ui->selected_modification_groupbox->setVisible(false); + _p_modification_str_li->removeRows(0, _p_modification_str_li->rowCount()); + + std::set<pappso::AaModificationP> mod_list = + project_sp.get()->getPeptideStore().getModificationCollection(); + //_p_modification_str_li->insertRows(0, mod_list.size()); + for(pappso::AaModificationP modification : mod_list) + { + if(modification->isInternal()) + { } - else { - QStandardItem *item; - item = new QStandardItem(QString("[%1] %2").arg(modification->getAccession()).arg(modification->getName())); - item->setEditable(false); - _p_modification_str_li->appendRow(item); - item->setData(QVariant(QString("%1").arg(modification->getAccession())),Qt::UserRole); + else + { + QStandardItem *item; + item = new QStandardItem(QString("[%1] %2") + .arg(modification->getAccession()) + .arg(modification->getName())); + item->setEditable(false); + _p_modification_str_li->appendRow(item); + item->setData( + QVariant(QString("%1").arg(modification->getAccession())), + Qt::UserRole); } } - } - -void EditModifications::ItemDoubleClicked (QModelIndex index ) +void +EditModifications::ItemDoubleClicked(QModelIndex index) { - qDebug() << "EditModifications::ItemClicked data=" << index.data().toString(); - qDebug() << "EditModifications::ItemClicked acc=" << _p_modification_str_li->data(index,Qt::UserRole).toString(); - QDesktopServices::openUrl (Utils::getOlsUrl(_p_modification_str_li->data(index,Qt::UserRole).toString())) ; + qDebug() << "EditModifications::ItemClicked data=" << index.data().toString(); + qDebug() << "EditModifications::ItemClicked acc=" + << _p_modification_str_li->data(index, Qt::UserRole).toString(); + QDesktopServices::openUrl(Utils::getOlsUrl( + _p_modification_str_li->data(index, Qt::UserRole).toString())); } -void EditModifications::ItemClicked (QModelIndex index ) +void +EditModifications::ItemClicked(QModelIndex index) { - qDebug() << "EditModifications::ItemClicked data=" << index.data().toString(); - qDebug() << "EditModifications::ItemClicked acc=" << _p_modification_str_li->data(index,Qt::UserRole).toString(); - qDebug() << "EditModifications::ItemClicked str=" << _p_modification_str_li->data(index,Qt::DisplayRole).toString(); - pappso::AaModificationP modification = pappso::AaModification::getInstance(index.data(Qt::UserRole).toString()); - setSelectedModification(modification); - setReplaceModification(nullptr); + qDebug() << "EditModifications::ItemClicked data=" << index.data().toString(); + qDebug() << "EditModifications::ItemClicked acc=" + << _p_modification_str_li->data(index, Qt::UserRole).toString(); + qDebug() << "EditModifications::ItemClicked str=" + << _p_modification_str_li->data(index, Qt::DisplayRole).toString(); + pappso::AaModificationP modification = + pappso::AaModification::getInstance(index.data(Qt::UserRole).toString()); + setSelectedModification(modification); + setReplaceModification(nullptr); } -void EditModifications::setReplaceModification (pappso::AaModificationP modification) +void +EditModifications::setReplaceModification(pappso::AaModificationP modification) { - _replace_modification = modification; - if (_replace_modification == nullptr) { - ui->replace_accession_label->setText(""); - ui->replace_description_label->setText(""); - ui->replace_delta_label->setText(""); + _replace_modification = modification; + if(_replace_modification == nullptr) + { + ui->replace_accession_label->setText(""); + ui->replace_description_label->setText(""); + ui->replace_delta_label->setText(""); } - else { - ui->replace_accession_label->setText(_replace_modification->getAccession()); - ui->replace_description_label->setText(_replace_modification->getName()); - ui->replace_delta_label->setText(QString::number(_replace_modification->getMass(), 'f', 10)); + else + { + ui->replace_accession_label->setText( + _replace_modification->getAccession()); + ui->replace_description_label->setText(_replace_modification->getName()); + ui->replace_delta_label->setText( + QString::number(_replace_modification->getMass(), 'f', 10)); } - } -void EditModifications::setSelectedModification (pappso::AaModificationP modification) +void +EditModifications::setSelectedModification(pappso::AaModificationP modification) { - qDebug() << "EditModifications::setSelectedModification acc=" << modification->getAccession(); - _selected_modification = modification; - ui->selected_modification_groupbox->setVisible(true); - ui->accession_label->setText(modification->getAccession()); - ui->description_label->setText(modification->getName()); - ui->delta_label->setText(QString::number(modification->getMass(), 'f', 10)); - + qDebug() << "EditModifications::setSelectedModification acc=" + << modification->getAccession(); + _selected_modification = modification; + ui->selected_modification_groupbox->setVisible(true); + ui->accession_label->setText(modification->getAccession()); + ui->description_label->setText(modification->getName()); + ui->delta_label->setText(QString::number(modification->getMass(), 'f', 10)); } -void EditModifications::doActionBrowse() { - qDebug() << "EditModifications::doActionBrowse begin"; - if (_selected_modification != nullptr) { - pappso::MassRange massrange(_selected_modification->getMass(), pappso::Precision::getDaltonInstance(0.05)); - _p_browse_modification_dialog->setMassRange(massrange); - _p_browse_modification_dialog->show(); - _p_browse_modification_dialog->raise(); - _p_browse_modification_dialog->activateWindow(); +void +EditModifications::doActionBrowse() +{ + qDebug() << "EditModifications::doActionBrowse begin"; + if(_selected_modification != nullptr) + { + pappso::MassRange massrange(_selected_modification->getMass(), + pappso::Precision::getDaltonInstance(0.05)); + _p_browse_modification_dialog->setMassRange(massrange); + _p_browse_modification_dialog->show(); + _p_browse_modification_dialog->raise(); + _p_browse_modification_dialog->activateWindow(); } - qDebug() << "EditModifications::doActionBrowse end"; + qDebug() << "EditModifications::doActionBrowse end"; } -void EditModifications::doActionReplace() { - qDebug() << "EditModifications::doActionReplace begin"; - if (_selected_modification != nullptr) { - if (_replace_modification != nullptr) { - _project_sp.get()->getPeptideStore().replaceModification(_selected_modification, _replace_modification); - - _project_window->doAutomaticFilterParametersChanged(_project_sp.get()->getAutomaticFilterParameters()); - setProjectSp(_project_sp); +void +EditModifications::doActionReplace() +{ + qDebug() << "EditModifications::doActionReplace begin"; + if(_selected_modification != nullptr) + { + if(_replace_modification != nullptr) + { + _project_sp.get()->getPeptideStore().replaceModification( + _selected_modification, _replace_modification); + + _project_window->doAutomaticFilterParametersChanged( + _project_sp.get()->getAutomaticFilterParameters()); + setProjectSp(_project_sp); } } - qDebug() << "EditModifications::doActionReplace end"; + qDebug() << "EditModifications::doActionReplace end"; } -void EditModifications::doAcceptedBrowseDialog() { - setReplaceModification(_p_browse_modification_dialog->getSelectedModification()); - +void +EditModifications::doAcceptedBrowseDialog() +{ + setReplaceModification( + _p_browse_modification_dialog->getSelectedModification()); } diff --git a/src/gui/edit_modifications/editmodifications.h b/src/gui/edit_modifications/editmodifications.h index 04a6dce6c0db1fb2486581eb89bc3660e3070405..36f0b1416084fd06e2dccb8ff6e9f6bf422ae184 100644 --- a/src/gui/edit_modifications/editmodifications.h +++ b/src/gui/edit_modifications/editmodifications.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 EDITMODIFICATIONS_H #define EDITMODIFICATIONS_H @@ -32,38 +33,40 @@ class ProjectWindow; -//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html -namespace Ui { -class EditModificationView; +// http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html +namespace Ui +{ + class EditModificationView; } -class EditModifications: public QMainWindow { - Q_OBJECT -public: +class EditModifications : public QMainWindow +{ + Q_OBJECT + public: + explicit EditModifications(ProjectWindow *parent = 0); + ~EditModifications(); - explicit EditModifications(ProjectWindow * parent = 0); - ~EditModifications(); + void setProjectSp(ProjectSp project_sp); - void setProjectSp(ProjectSp project_sp); + public slots: + void ItemClicked(QModelIndex index); + void ItemDoubleClicked(QModelIndex index); + private slots: + void doAcceptedBrowseDialog(); + void doActionReplace(); + void doActionBrowse(); -public slots: - void ItemClicked (QModelIndex index ); - void ItemDoubleClicked (QModelIndex index ); -private slots: - void doAcceptedBrowseDialog(); - void doActionReplace(); - void doActionBrowse(); -private : - void setSelectedModification (pappso::AaModificationP modification); - void setReplaceModification (pappso::AaModificationP modification); + private: + void setSelectedModification(pappso::AaModificationP modification); + void setReplaceModification(pappso::AaModificationP modification); -private: - Ui::EditModificationView *ui; - ProjectWindow * _project_window; - ProjectSp _project_sp; - ChooseModificationDialog * _p_browse_modification_dialog; - QStandardItemModel * _p_modification_str_li=nullptr; - pappso::AaModificationP _selected_modification; - pappso::AaModificationP _replace_modification; + private: + Ui::EditModificationView *ui; + ProjectWindow *_project_window; + ProjectSp _project_sp; + ChooseModificationDialog *_p_browse_modification_dialog; + QStandardItemModel *_p_modification_str_li = nullptr; + pappso::AaModificationP _selected_modification; + pappso::AaModificationP _replace_modification; }; #endif // EDITMODIFICATIONS_H diff --git a/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.cpp b/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.cpp index 8a94d4a5f803a3289cc155a98885f221e4ed8d2b..0f08ef9f348d833061c47b6a5ff9192c66af5bac 100644 --- a/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.cpp +++ b/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.cpp @@ -6,26 +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 "edittandempresetdialog.h" #include <QDebug> @@ -39,1006 +40,1280 @@ #include <QMessageBox> -EditTandemPresetDialog::EditTandemPresetDialog(QWidget * parent): - QDialog(parent), - ui(new Ui::EditTandemPresetView) +EditTandemPresetDialog::EditTandemPresetDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::EditTandemPresetView) { - qDebug() << "EditTandemPresetDialog::EditTandemPresetDialog begin"; - ui->setupUi(this); - this->setModal(true); + qDebug() << "EditTandemPresetDialog::EditTandemPresetDialog begin"; + ui->setupUi(this); + this->setModal(true); - ui->splitter->setStretchFactor(0, 1); + ui->splitter->setStretchFactor(0, 1); #if QT_VERSION >= 0x050000 - // Qt5 code + // Qt5 code #else -// Qt4 code + // Qt4 code #endif - qDebug() << "EditTandemPresetDialog::EditTandemPresetDialog end"; + qDebug() << "EditTandemPresetDialog::EditTandemPresetDialog end"; } EditTandemPresetDialog::~EditTandemPresetDialog() { - delete ui; - if (_p_tandem_preset_file != nullptr) { - delete _p_tandem_preset_file; + delete ui; + if(_p_tandem_preset_file != nullptr) + { + delete _p_tandem_preset_file; } } -void EditTandemPresetDialog::setTandemParametersFile(const TandemParametersFile & tandem_preset_file) { +void +EditTandemPresetDialog::setTandemParametersFile( + const TandemParametersFile &tandem_preset_file) +{ - if (tandem_preset_file.exists()) { - _p_tandem_preset_file = new TandemParametersFile( tandem_preset_file); - _preset_directory = _p_tandem_preset_file->getAbsoluteDir().absolutePath(); - _tandem_params = _p_tandem_preset_file->getTandemParameters(); - } else { - _p_tandem_preset_file = new TandemParametersFile(":/tandem/resources/model/QExactive_analysis_FDR_nosemi.xml"); - _tandem_params = _p_tandem_preset_file->getTandemParameters(); - QSettings settings; - _preset_directory = settings.value("path/tandemrun_preset_directory", "").toString(); - _p_tandem_preset_file->setDirectory(QDir(_preset_directory)); + if(tandem_preset_file.exists()) + { + _p_tandem_preset_file = new TandemParametersFile(tandem_preset_file); + _preset_directory = + _p_tandem_preset_file->getAbsoluteDir().absolutePath(); + _tandem_params = _p_tandem_preset_file->getTandemParameters(); + } + else + { + _p_tandem_preset_file = new TandemParametersFile( + ":/tandem/resources/model/QExactive_analysis_FDR_nosemi.xml"); + _tandem_params = _p_tandem_preset_file->getTandemParameters(); + QSettings settings; + _preset_directory = + settings.value("path/tandemrun_preset_directory", "").toString(); + _p_tandem_preset_file->setDirectory(QDir(_preset_directory)); } - fillPresetComboBox(); - populate(); + fillPresetComboBox(); + populate(); } -void EditTandemPresetDialog::doCopy() { - ui->method_name_line_edit->setText("untitled"); - readUi(); - if (_p_tandem_preset_file == nullptr) { +void +EditTandemPresetDialog::doCopy() +{ + ui->method_name_line_edit->setText("untitled"); + readUi(); + if(_p_tandem_preset_file == nullptr) + { - throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr")); + throw pappso::PappsoException( + QObject::tr("_p_tandem_preset_file == nullptr")); } - else { - delete _p_tandem_preset_file; + else + { + delete _p_tandem_preset_file; } - _p_tandem_preset_file = new TandemParametersFile(QString("%1/untitled.xml").arg(_preset_directory)); + _p_tandem_preset_file = + new TandemParametersFile(QString("%1/untitled.xml").arg(_preset_directory)); } -void EditTandemPresetDialog::doSelectDir() { - try { +void +EditTandemPresetDialog::doSelectDir() +{ + try + { - QString directory = QFileDialog::getExistingDirectory(this,tr("Choose preset directory"),_preset_directory ); + QString directory = QFileDialog::getExistingDirectory( + this, tr("Choose preset directory"), _preset_directory); - QFileInfo my_dir(directory); - if (!directory.isEmpty() && ! directory.isNull()) { - if (!my_dir.isWritable()) { - throw pappso::PappsoException(QObject::tr("this directory is not writable, check permissions (%1)").arg(my_dir.absoluteFilePath())); + QFileInfo my_dir(directory); + if(!directory.isEmpty() && !directory.isNull()) + { + if(!my_dir.isWritable()) + { + throw pappso::PappsoException( + QObject::tr( + "this directory is not writable, check permissions (%1)") + .arg(my_dir.absoluteFilePath())); } - _preset_directory = directory; - fillPresetComboBox(); + _preset_directory = directory; + fillPresetComboBox(); } - } - catch (pappso::PappsoException & error) { - QMessageBox::warning(this,tr("Error :"), tr("Error choosing preset directory : %1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + QMessageBox::warning( + this, tr("Error :"), + tr("Error choosing preset directory : %1").arg(error.qwhat())); } } -void EditTandemPresetDialog::doSave() { - readUi(); - if (_p_tandem_preset_file == nullptr) { - throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr")); +void +EditTandemPresetDialog::doSave() +{ + readUi(); + if(_p_tandem_preset_file == nullptr) + { + throw pappso::PappsoException( + QObject::tr("_p_tandem_preset_file == nullptr")); } - _p_tandem_preset_file->setDirectory(QDir(_preset_directory)); - _p_tandem_preset_file->setTandemParameters(_tandem_params); - fillPresetComboBox(); - populate(); + _p_tandem_preset_file->setDirectory(QDir(_preset_directory)); + _p_tandem_preset_file->setTandemParameters(_tandem_params); + fillPresetComboBox(); + populate(); } -void EditTandemPresetDialog::doLoad() { - int index = ui->preset_combo_box->currentIndex(); - if ( index != -1 ) { // -1 for not found - TandemParametersFile * p_tandem_preset_file = new TandemParametersFile( - ui->preset_combo_box->itemData(index).value<QString>()); - if (p_tandem_preset_file->isTandemPresetFile()) { - if (_p_tandem_preset_file == nullptr) { - throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr")); +void +EditTandemPresetDialog::doLoad() +{ + int index = ui->preset_combo_box->currentIndex(); + if(index != -1) + { // -1 for not found + TandemParametersFile *p_tandem_preset_file = new TandemParametersFile( + ui->preset_combo_box->itemData(index).value<QString>()); + if(p_tandem_preset_file->isTandemPresetFile()) + { + if(_p_tandem_preset_file == nullptr) + { + throw pappso::PappsoException( + QObject::tr("_p_tandem_preset_file == nullptr")); } - else { - delete _p_tandem_preset_file; + else + { + delete _p_tandem_preset_file; } - _p_tandem_preset_file = p_tandem_preset_file; - _tandem_params = _p_tandem_preset_file->getTandemParameters(); - populate(); + _p_tandem_preset_file = p_tandem_preset_file; + _tandem_params = _p_tandem_preset_file->getTandemParameters(); + populate(); } - else { - QMessageBox::warning(this,tr("Error :"), tr("%1 is not an X!Tandem parameter file").arg(p_tandem_preset_file->getAbsoluteFilePath())); + else + { + QMessageBox::warning( + this, tr("Error :"), + tr("%1 is not an X!Tandem parameter file") + .arg(p_tandem_preset_file->getAbsoluteFilePath())); } } } -const TandemParametersFile & EditTandemPresetDialog::getTandemParametersFile() const { - if (_p_tandem_preset_file == nullptr) { - throw pappso::PappsoException(QObject::tr("_p_tandem_preset_file == nullptr")); +const TandemParametersFile & +EditTandemPresetDialog::getTandemParametersFile() const +{ + if(_p_tandem_preset_file == nullptr) + { + throw pappso::PappsoException( + QObject::tr("_p_tandem_preset_file == nullptr")); } - if (!_p_tandem_preset_file->exists()) { - throw pappso::PappsoException(QObject::tr("preset file %1 does not exists").arg(_p_tandem_preset_file->getAbsoluteFilePath())); + if(!_p_tandem_preset_file->exists()) + { + throw pappso::PappsoException( + QObject::tr("preset file %1 does not exists") + .arg(_p_tandem_preset_file->getAbsoluteFilePath())); } - return *_p_tandem_preset_file; + return *_p_tandem_preset_file; } -void EditTandemPresetDialog::fillPresetComboBox() { - ui->preset_combo_box->clear(); - QString default_preset_name = _tandem_params.getMethodName(); +void +EditTandemPresetDialog::fillPresetComboBox() +{ + ui->preset_combo_box->clear(); + QString default_preset_name = _tandem_params.getMethodName(); - QDir preset_dir(_preset_directory); - QStringList filters; - filters << "*.xml"; - preset_dir.setNameFilters(filters); - for (QFileInfo file_info: preset_dir.entryInfoList() ) { - ui->preset_combo_box->addItem(file_info.baseName(), QVariant(file_info.absoluteFilePath())); + QDir preset_dir(_preset_directory); + QStringList filters; + filters << "*.xml"; + preset_dir.setNameFilters(filters); + for(QFileInfo file_info : preset_dir.entryInfoList()) + { + ui->preset_combo_box->addItem(file_info.baseName(), + QVariant(file_info.absoluteFilePath())); } - int index = ui->preset_combo_box->findText(default_preset_name); - if ( index != -1 ) { // -1 for not found - ui->preset_combo_box->setCurrentIndex(index); + int index = ui->preset_combo_box->findText(default_preset_name); + if(index != -1) + { // -1 for not found + ui->preset_combo_box->setCurrentIndex(index); } - } -void EditTandemPresetDialog::doEdit(QString value) { - QObject *senderObj = sender(); - QString senderObjName = senderObj->objectName(); - qDebug() << "EditTandemPresetDialog::doEdit begin " << senderObjName << " " << value; - qDebug() << "EditTandemPresetDialog::doEdit end " << senderObjName; +void +EditTandemPresetDialog::doEdit(QString value) +{ + QObject *senderObj = sender(); + QString senderObjName = senderObj->objectName(); + qDebug() << "EditTandemPresetDialog::doEdit begin " << senderObjName << " " + << value; + qDebug() << "EditTandemPresetDialog::doEdit end " << senderObjName; } -void EditTandemPresetDialog::doHelp() { - QObject *senderObj = sender(); - QString senderObjName = senderObj->objectName(); - qDebug() << "EditTandemPresetDialog::doHelp begin " << senderObjName; - QFile html_doc; - if(senderObjName == "spmmeu_push_button") +void +EditTandemPresetDialog::doHelp() +{ + QObject *senderObj = sender(); + QString senderObjName = senderObj->objectName(); + qDebug() << "EditTandemPresetDialog::doHelp begin " << senderObjName; + QFile html_doc; + if(senderObjName == "spmmeu_push_button") { - //spmmeu.html - html_doc.setFileName(":/tandem/resources/html_doc/spmmeu.html"); + // spmmeu.html + html_doc.setFileName(":/tandem/resources/html_doc/spmmeu.html"); } - if(senderObjName == "smpc_push_button") + if(senderObjName == "smpc_push_button") { - //spmmeu.html - html_doc.setFileName(":/tandem/resources/html_doc/smpc.html"); + // spmmeu.html + html_doc.setFileName(":/tandem/resources/html_doc/smpc.html"); } - if(senderObjName == "spmmem_push_button") + if(senderObjName == "spmmem_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/spmmem.html"); + html_doc.setFileName(":/tandem/resources/html_doc/spmmem.html"); } - if(senderObjName == "spmmep_push_button") + if(senderObjName == "spmmep_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/spmmep.html"); + html_doc.setFileName(":/tandem/resources/html_doc/spmmep.html"); } - if(senderObjName == "spmmie_push_button") + if(senderObjName == "spmmie_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/spmmie.html"); + html_doc.setFileName(":/tandem/resources/html_doc/spmmie.html"); } - if(senderObjName == "sfmt_push_button") + if(senderObjName == "sfmt_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sfmt.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sfmt.html"); } - if(senderObjName == "sfmmeu_push_button") + if(senderObjName == "sfmmeu_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sfmmeu.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sfmmeu.html"); } - if(senderObjName == "sfmme_push_button") + if(senderObjName == "sfmme_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sfmme.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sfmme.html"); } - if(senderObjName == "sunlw_push_button") + if(senderObjName == "sunlw_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sunlw.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sunlw.html"); } - if(senderObjName == "snlm_push_button") + if(senderObjName == "snlm_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/snlm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/snlm.html"); } - if(senderObjName == "snlw_push_button") + if(senderObjName == "snlw_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/snlw.html"); + html_doc.setFileName(":/tandem/resources/html_doc/snlw.html"); } - if(senderObjName == "suns_push_button") + if(senderObjName == "suns_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/suns.html"); + html_doc.setFileName(":/tandem/resources/html_doc/suns.html"); } - if(senderObjName == "sdr_push_button") + if(senderObjName == "sdr_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sdr.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sdr.html"); } - if(senderObjName == "stp_push_button") + if(senderObjName == "stp_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/stp.html"); + html_doc.setFileName(":/tandem/resources/html_doc/stp.html"); } - if(senderObjName == "smp_push_button") + if(senderObjName == "smp_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/smp.html"); + html_doc.setFileName(":/tandem/resources/html_doc/smp.html"); } - if(senderObjName == "smfmz_push_button") + if(senderObjName == "smfmz_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/smfmz.html"); + html_doc.setFileName(":/tandem/resources/html_doc/smfmz.html"); } - if(senderObjName == "smpmh_push_button") + if(senderObjName == "smpmh_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/smpmh.html"); + html_doc.setFileName(":/tandem/resources/html_doc/smpmh.html"); } - if(senderObjName == "spsbs_push_button") + if(senderObjName == "spsbs_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/spsbs.html"); + html_doc.setFileName(":/tandem/resources/html_doc/spsbs.html"); } - if(senderObjName == "suca_push_button") + if(senderObjName == "suca_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/suca.html"); + html_doc.setFileName(":/tandem/resources/html_doc/suca.html"); } - if(senderObjName == "st_push_button") + if(senderObjName == "st_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/st.html"); + html_doc.setFileName(":/tandem/resources/html_doc/st.html"); } - if(senderObjName == "pcs_push_button") + if(senderObjName == "pcs_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pcs.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pcs.html"); } - if(senderObjName == "pcsemi_push_button") + if(senderObjName == "pcsemi_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pcsemi.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pcsemi.html"); } - if(senderObjName == "pcctmc_push_button") + if(senderObjName == "pcctmc_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pcctmc.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pcctmc.html"); } - if(senderObjName == "pcntmc_push_button") + if(senderObjName == "pcntmc_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pcntmc.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pcntmc.html"); } - if(senderObjName == "pctrmm_push_button") + if(senderObjName == "pctrmm_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pctrmm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pctrmm.html"); } - if(senderObjName == "pntrmm_push_button") + if(senderObjName == "pntrmm_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pntrmm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pntrmm.html"); } - if(senderObjName == "pqa_push_button") + if(senderObjName == "pqa_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pqa.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pqa.html"); } - if(senderObjName == "pqp_push_button") + if(senderObjName == "pqp_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pqp.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pqp.html"); } - if(senderObjName == "pstpb_push_button") + if(senderObjName == "pstpb_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pstpb.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pstpb.html"); } - if(senderObjName == "pmrmf_push_button") + if(senderObjName == "pmrmf_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/pmrmf.html"); + html_doc.setFileName(":/tandem/resources/html_doc/pmrmf.html"); } - if ((senderObjName == "rmm_push_button") || (senderObjName == "rmm1_push_button") || (senderObjName == "rmm2_push_button")) + if((senderObjName == "rmm_push_button") || + (senderObjName == "rmm1_push_button") || + (senderObjName == "rmm2_push_button")) { - html_doc.setFileName(":/tandem/resources/html_doc/rmm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rmm.html"); } - if ((senderObjName == "rpmm_push_button") || (senderObjName == "rpmm1_push_button") || (senderObjName == "rpmm2_push_button")) + if((senderObjName == "rpmm_push_button") || + (senderObjName == "rpmm1_push_button") || + (senderObjName == "rpmm2_push_button")) { - html_doc.setFileName(":/tandem/resources/html_doc/rpmm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rpmm.html"); } - if ((senderObjName == "rpmmotif_push_button") || (senderObjName == "rpmmotif1_push_button") || (senderObjName == "rpmmotif2_push_button")) + if((senderObjName == "rpmmotif_push_button") || + (senderObjName == "rpmmotif1_push_button") || + (senderObjName == "rpmmotif2_push_button")) { - html_doc.setFileName(":/tandem/resources/html_doc/rpmmotif.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rpmmotif.html"); } - if(senderObjName == "smic_push_button") + if(senderObjName == "smic_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/smic.html"); + html_doc.setFileName(":/tandem/resources/html_doc/smic.html"); } - if(senderObjName == "smmcs_push_button") + if(senderObjName == "smmcs_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/smmcs.html"); + html_doc.setFileName(":/tandem/resources/html_doc/smmcs.html"); } - if(senderObjName == "scp_push_button") + if(senderObjName == "scp_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/scp.html"); + html_doc.setFileName(":/tandem/resources/html_doc/scp.html"); } - if(senderObjName == "sir_push_button") + if(senderObjName == "sir_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sir.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sir.html"); } - if(senderObjName == "syi_push_button") + if(senderObjName == "syi_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/syi.html"); + html_doc.setFileName(":/tandem/resources/html_doc/syi.html"); } - if(senderObjName == "sbi_push_button") + if(senderObjName == "sbi_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sbi.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sbi.html"); } - if(senderObjName == "sci_push_button") + if(senderObjName == "sci_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sci.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sci.html"); } - if(senderObjName == "szi_push_button") + if(senderObjName == "szi_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/szi.html"); + html_doc.setFileName(":/tandem/resources/html_doc/szi.html"); } - if(senderObjName == "sai_push_button") + if(senderObjName == "sai_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sai.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sai.html"); } - if(senderObjName == "sxi_push_button") + if(senderObjName == "sxi_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/sxi.html"); + html_doc.setFileName(":/tandem/resources/html_doc/sxi.html"); } - if(senderObjName == "refine_push_button") + if(senderObjName == "refine_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/refine.html"); + html_doc.setFileName(":/tandem/resources/html_doc/refine.html"); } - if(senderObjName == "rmvev_push_button") + if(senderObjName == "rmvev_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/rmvev.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rmvev.html"); } - if(senderObjName == "refpntm_push_button") + if(senderObjName == "refpntm_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/refpntm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/refpntm.html"); } - if(senderObjName == "refpctm_push_button") + if(senderObjName == "refpctm_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/refpctm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/refpctm.html"); } - if ((senderObjName == "refmm_push_button")|| (senderObjName == "refmm1_push_button")|| (senderObjName == "refmm2_push_button")) + if((senderObjName == "refmm_push_button") || + (senderObjName == "refmm1_push_button") || + (senderObjName == "refmm2_push_button")) { - html_doc.setFileName(":/tandem/resources/html_doc/refmm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/refmm.html"); } - if ((senderObjName == "refpmm_push_button")|| (senderObjName == "refpmm1_push_button")|| (senderObjName == "refpmm2_push_button")) + if((senderObjName == "refpmm_push_button") || + (senderObjName == "refpmm1_push_button") || + (senderObjName == "refpmm2_push_button")) { - html_doc.setFileName(":/tandem/resources/html_doc/refpmm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/refpmm.html"); } - if ((senderObjName == "refpmmotif_push_button")|| (senderObjName == "refpmmotif1_push_button")|| (senderObjName == "refpmmotif2_push_button")) + if((senderObjName == "refpmmotif_push_button") || + (senderObjName == "refpmmotif1_push_button") || + (senderObjName == "refpmmotif2_push_button")) { - html_doc.setFileName(":/tandem/resources/html_doc/refpmmotif.html"); + html_doc.setFileName(":/tandem/resources/html_doc/refpmmotif.html"); } - if(senderObjName == "rupmffr_push_button") + if(senderObjName == "rupmffr_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/rupmffr.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rupmffr.html"); } - if(senderObjName == "rcsemi_push_button") + if(senderObjName == "rcsemi_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/rcsemi.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rcsemi.html"); } - if(senderObjName == "ruc_push_button") + if(senderObjName == "ruc_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/ruc.html"); + html_doc.setFileName(":/tandem/resources/html_doc/ruc.html"); } - if(senderObjName == "rss_push_button") + if(senderObjName == "rss_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/rss.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rss.html"); } - if(senderObjName == "rpm_push_button") + if(senderObjName == "rpm_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/rpm.html"); + html_doc.setFileName(":/tandem/resources/html_doc/rpm.html"); } - if ((senderObjName == "omvev_push_button") || (senderObjName == "omvpev_push_button")) + if((senderObjName == "omvev_push_button") || + (senderObjName == "omvpev_push_button")) { - html_doc.setFileName(":/tandem/resources/html_doc/omvev.html"); + html_doc.setFileName(":/tandem/resources/html_doc/omvev.html"); } - if (senderObjName == "oresu_push_button") + if(senderObjName == "oresu_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/oresu.html"); + html_doc.setFileName(":/tandem/resources/html_doc/oresu.html"); } - if (senderObjName == "osrb_push_button") + if(senderObjName == "osrb_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/osrb.html"); + html_doc.setFileName(":/tandem/resources/html_doc/osrb.html"); } - if (senderObjName == "oprot_push_button") + if(senderObjName == "oprot_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/oprot.html"); + html_doc.setFileName(":/tandem/resources/html_doc/oprot.html"); } - if (senderObjName == "oseq_push_button") + if(senderObjName == "oseq_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/oseq.html"); + html_doc.setFileName(":/tandem/resources/html_doc/oseq.html"); } - if (senderObjName == "oosc_push_button") + if(senderObjName == "oosc_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/oosc.html"); + html_doc.setFileName(":/tandem/resources/html_doc/oosc.html"); } - if (senderObjName == "ospec_push_button") + if(senderObjName == "ospec_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/ospec.html"); + html_doc.setFileName(":/tandem/resources/html_doc/ospec.html"); } - if (senderObjName == "opara_push_button") + if(senderObjName == "opara_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/opara.html"); + html_doc.setFileName(":/tandem/resources/html_doc/opara.html"); } - if (senderObjName == "ohist_push_button") + if(senderObjName == "ohist_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/ohist.html"); + html_doc.setFileName(":/tandem/resources/html_doc/ohist.html"); } - if (senderObjName == "ohcw_push_button") + if(senderObjName == "ohcw_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/ohcw.html"); + html_doc.setFileName(":/tandem/resources/html_doc/ohcw.html"); } - if (senderObjName == "oph_push_button") + if(senderObjName == "oph_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/oph.html"); + html_doc.setFileName(":/tandem/resources/html_doc/oph.html"); } - if (senderObjName == "oxp_push_button") + if(senderObjName == "oxp_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/oxp.html"); + html_doc.setFileName(":/tandem/resources/html_doc/oxp.html"); } - if (senderObjName == "mzid_push_button") + if(senderObjName == "mzid_push_button") { - html_doc.setFileName(":/tandem/resources/html_doc/mzid.html"); + html_doc.setFileName(":/tandem/resources/html_doc/mzid.html"); } - if (html_doc.open(QFile::ReadOnly | QFile::Text)) { - QTextStream in(&html_doc); - ui->doc_plain_text_edit->setHtml(in.readAll()); - qDebug() << "EditTandemPresetDialog::doHelp doc " << in.readAll(); + if(html_doc.open(QFile::ReadOnly | QFile::Text)) + { + QTextStream in(&html_doc); + ui->doc_plain_text_edit->setHtml(in.readAll()); + qDebug() << "EditTandemPresetDialog::doHelp doc " << in.readAll(); } - else { - qDebug() << "EditTandemPresetDialog::doHelp doc not found"; + else + { + qDebug() << "EditTandemPresetDialog::doHelp doc not found"; } - qDebug() << "EditTandemPresetDialog::doHelp end " << senderObjName; + qDebug() << "EditTandemPresetDialog::doHelp end " << senderObjName; } -void EditTandemPresetDialog::readUi() { - try { - _tandem_params.setMethodName(ui->method_name_line_edit->text()); - _tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error units", "Daltons"); - if (ui->spmmeu_ppm_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error units", "ppm"); +void +EditTandemPresetDialog::readUi() +{ + try + { + _tandem_params.setMethodName(ui->method_name_line_edit->text()); + _tandem_params.setParamLabelValue( + "spectrum, parent monoisotopic mass error units", "Daltons"); + if(ui->spmmeu_ppm_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue( + "spectrum, parent monoisotopic mass error units", "ppm"); } - _tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error minus", ui->parent_ion_lower_window_edit->text()); + _tandem_params.setParamLabelValue( + "spectrum, parent monoisotopic mass error minus", + ui->parent_ion_lower_window_edit->text()); - _tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass error plus", ui->parent_ion_upper_window_edit->text()); + _tandem_params.setParamLabelValue( + "spectrum, parent monoisotopic mass error plus", + ui->parent_ion_upper_window_edit->text()); - _tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass isotope error", "no"); - if (ui->spmmie_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("spectrum, parent monoisotopic mass isotope error", "yes"); + _tandem_params.setParamLabelValue( + "spectrum, parent monoisotopic mass isotope error", "no"); + if(ui->spmmie_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue( + "spectrum, parent monoisotopic mass isotope error", "yes"); } - _tandem_params.setParamLabelValue("spectrum, maximum parent charge", ui->smpc_edit->text()); + _tandem_params.setParamLabelValue("spectrum, maximum parent charge", + ui->smpc_edit->text()); - _tandem_params.setParamLabelValue("spectrum, fragment mass type", ui->sfmt_combo_box->currentText()); + _tandem_params.setParamLabelValue("spectrum, fragment mass type", + ui->sfmt_combo_box->currentText()); - _tandem_params.setParamLabelValue("spectrum, fragment monoisotopic mass error units", "Daltons"); - if (ui->sfmmeu_ppm_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("spectrum, fragment monoisotopic mass error units", "ppm"); + _tandem_params.setParamLabelValue( + "spectrum, fragment monoisotopic mass error units", "Daltons"); + if(ui->sfmmeu_ppm_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue( + "spectrum, fragment monoisotopic mass error units", "ppm"); } - _tandem_params.setParamLabelValue("spectrum, fragment monoisotopic mass error", ui->sfmme_edit->text()); - _tandem_params.setParamLabelValue("spectrum, use neutral loss window", "no"); - if (ui->sunlw_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("spectrum, use neutral loss window", "yes"); + _tandem_params.setParamLabelValue( + "spectrum, fragment monoisotopic mass error", ui->sfmme_edit->text()); + _tandem_params.setParamLabelValue("spectrum, use neutral loss window", + "no"); + if(ui->sunlw_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("spectrum, use neutral loss window", + "yes"); } - _tandem_params.setParamLabelValue("spectrum, neutral loss mass", ui->snlm_edit->text()); - _tandem_params.setParamLabelValue("spectrum, neutral loss window", ui->snlw_edit->text()); - _tandem_params.setParamLabelValue("spectrum, use noise suppression", "no"); - if (ui->suns_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("spectrum, use noise suppression", "yes"); + _tandem_params.setParamLabelValue("spectrum, neutral loss mass", + ui->snlm_edit->text()); + _tandem_params.setParamLabelValue("spectrum, neutral loss window", + ui->snlw_edit->text()); + _tandem_params.setParamLabelValue("spectrum, use noise suppression", + "no"); + if(ui->suns_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("spectrum, use noise suppression", + "yes"); } - _tandem_params.setParamLabelValue("spectrum, dynamic range", ui->sdr_edit->text()); - _tandem_params.setParamLabelValue("spectrum, total peaks", ui->stp_edit->text()); - _tandem_params.setParamLabelValue("spectrum, minimum peaks", ui->smp_edit->text()); - _tandem_params.setParamLabelValue("spectrum, minimum fragment mz", ui->smfmz_edit->text()); - _tandem_params.setParamLabelValue("spectrum, minimum parent m+h", ui->smpmh_edit->text()); - _tandem_params.setParamLabelValue("spectrum, sequence batch size", ui->spsbs_edit->text()); - _tandem_params.setParamLabelValue("spectrum, use contrast angle", "no"); - if (ui->suca_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("spectrum, use contrast angle", "yes"); + _tandem_params.setParamLabelValue("spectrum, dynamic range", + ui->sdr_edit->text()); + _tandem_params.setParamLabelValue("spectrum, total peaks", + ui->stp_edit->text()); + _tandem_params.setParamLabelValue("spectrum, minimum peaks", + ui->smp_edit->text()); + _tandem_params.setParamLabelValue("spectrum, minimum fragment mz", + ui->smfmz_edit->text()); + _tandem_params.setParamLabelValue("spectrum, minimum parent m+h", + ui->smpmh_edit->text()); + _tandem_params.setParamLabelValue("spectrum, sequence batch size", + ui->spsbs_edit->text()); + _tandem_params.setParamLabelValue("spectrum, use contrast angle", "no"); + if(ui->suca_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("spectrum, use contrast angle", + "yes"); } - _tandem_params.setParamLabelValue("spectrum, threads", ui->st_edit->text()); + _tandem_params.setParamLabelValue("spectrum, threads", + ui->st_edit->text()); - _tandem_params.setParamLabelValue("protein, cleavage site", ui->pcs_edit->text()); - _tandem_params.setParamLabelValue("protein, cleavage semi", "no"); - if (ui->pcsemi_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("protein, cleavage semi", "yes"); + _tandem_params.setParamLabelValue("protein, cleavage site", + ui->pcs_edit->text()); + _tandem_params.setParamLabelValue("protein, cleavage semi", "no"); + if(ui->pcsemi_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("protein, cleavage semi", "yes"); } - _tandem_params.setParamLabelValue("protein, cleavage C-terminal mass change", ui->pcctmc_edit->text()); - _tandem_params.setParamLabelValue("protein, cleavage N-terminal mass change", ui->pcntmc_edit->text()); - _tandem_params.setParamLabelValue("protein, quick acetyl", "no"); - if (ui->pqa_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("protein, quick acetyl", "yes"); + _tandem_params.setParamLabelValue( + "protein, cleavage C-terminal mass change", ui->pcctmc_edit->text()); + _tandem_params.setParamLabelValue( + "protein, cleavage N-terminal mass change", ui->pcntmc_edit->text()); + _tandem_params.setParamLabelValue("protein, quick acetyl", "no"); + if(ui->pqa_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("protein, quick acetyl", "yes"); } - _tandem_params.setParamLabelValue("protein, quick pyrolidone", "no"); - if (ui->pqp_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("protein, quick pyrolidone", "yes"); + _tandem_params.setParamLabelValue("protein, quick pyrolidone", "no"); + if(ui->pqp_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("protein, quick pyrolidone", "yes"); } - _tandem_params.setParamLabelValue("protein, stP bias", "no"); - if (ui->pstpb_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("protein, stP bias", "yes"); + _tandem_params.setParamLabelValue("protein, stP bias", "no"); + if(ui->pstpb_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("protein, stP bias", "yes"); } - _tandem_params.setParamLabelValue("protein, modified residue mass file", ui->pmrmf_edit->text()); - - - - _tandem_params.setParamLabelValue("residue, modification mass", ui->rmm_edit->text()); - _tandem_params.setParamLabelValue("residue, modification mass 1", ui->rmm1_edit->text()); - _tandem_params.setParamLabelValue("residue, modification mass 2", ui->rmm2_edit->text()); - _tandem_params.setParamLabelValue("residue, potential modification mass", ui->rpmm_edit->text()); - _tandem_params.setParamLabelValue("residue, potential modification mass 1", ui->rpmm1_edit->text()); - _tandem_params.setParamLabelValue("residue, potential modification mass 2", ui->rpmm2_edit->text()); - _tandem_params.setParamLabelValue("residue, potential modification motif", ui->rpmmotif_edit->text()); - _tandem_params.setParamLabelValue("residue, potential modification motif 1", ui->rpmmotif1_edit->text()); - _tandem_params.setParamLabelValue("residue, potential modification motif 2", ui->rpmmotif2_edit->text()); - _tandem_params.setParamLabelValue("scoring, maximum missed cleavage sites", ui->smmcs_edit->text()); - _tandem_params.setParamLabelValue("scoring, cyclic permutation", "no"); - if (ui->scp_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, cyclic permutation", "yes"); + _tandem_params.setParamLabelValue("protein, modified residue mass file", + ui->pmrmf_edit->text()); + + + _tandem_params.setParamLabelValue("residue, modification mass", + ui->rmm_edit->text()); + _tandem_params.setParamLabelValue("residue, modification mass 1", + ui->rmm1_edit->text()); + _tandem_params.setParamLabelValue("residue, modification mass 2", + ui->rmm2_edit->text()); + _tandem_params.setParamLabelValue("residue, potential modification mass", + ui->rpmm_edit->text()); + _tandem_params.setParamLabelValue( + "residue, potential modification mass 1", ui->rpmm1_edit->text()); + _tandem_params.setParamLabelValue( + "residue, potential modification mass 2", ui->rpmm2_edit->text()); + _tandem_params.setParamLabelValue("residue, potential modification motif", + ui->rpmmotif_edit->text()); + _tandem_params.setParamLabelValue( + "residue, potential modification motif 1", ui->rpmmotif1_edit->text()); + _tandem_params.setParamLabelValue( + "residue, potential modification motif 2", ui->rpmmotif2_edit->text()); + _tandem_params.setParamLabelValue( + "scoring, maximum missed cleavage sites", ui->smmcs_edit->text()); + _tandem_params.setParamLabelValue("scoring, cyclic permutation", "no"); + if(ui->scp_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, cyclic permutation", + "yes"); } - _tandem_params.setParamLabelValue("scoring, include reverse", "no"); - if (ui->sir_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, include reverse", "yes"); + _tandem_params.setParamLabelValue("scoring, include reverse", "no"); + if(ui->sir_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, include reverse", "yes"); } - _tandem_params.setParamLabelValue("scoring, minimum ion count", ui->smic_edit->text()); + _tandem_params.setParamLabelValue("scoring, minimum ion count", + ui->smic_edit->text()); - _tandem_params.setParamLabelValue("scoring, y ions", "no"); - if (ui->syi_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, y ions", "yes"); + _tandem_params.setParamLabelValue("scoring, y ions", "no"); + if(ui->syi_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, y ions", "yes"); } - _tandem_params.setParamLabelValue("scoring, b ions", "no"); - if (ui->sbi_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, b ions", "yes"); + _tandem_params.setParamLabelValue("scoring, b ions", "no"); + if(ui->sbi_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, b ions", "yes"); } - _tandem_params.setParamLabelValue("scoring, c ions", "no"); - if (ui->sci_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, c ions", "yes"); + _tandem_params.setParamLabelValue("scoring, c ions", "no"); + if(ui->sci_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, c ions", "yes"); } - _tandem_params.setParamLabelValue("scoring, z ions", "no"); - if (ui->szi_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, z ions", "yes"); + _tandem_params.setParamLabelValue("scoring, z ions", "no"); + if(ui->szi_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, z ions", "yes"); } - _tandem_params.setParamLabelValue("scoring, a ions", "no"); - if (ui->sai_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, a ions", "yes"); + _tandem_params.setParamLabelValue("scoring, a ions", "no"); + if(ui->sai_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, a ions", "yes"); } - _tandem_params.setParamLabelValue("scoring, x ions", "no"); - if (ui->sxi_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("scoring, x ions", "yes"); + _tandem_params.setParamLabelValue("scoring, x ions", "no"); + if(ui->sxi_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("scoring, x ions", "yes"); } - _tandem_params.setParamLabelValue("refine", "no"); - if (ui->refine_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("refine", "yes"); + _tandem_params.setParamLabelValue("refine", "no"); + if(ui->refine_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("refine", "yes"); } - _tandem_params.setParamLabelValue("refine, maximum valid expectation value", ui->rmvev_edit->text()); - - _tandem_params.setParamLabelValue("refine, potential N-terminus modifications", ui->refpntm_edit->text()); - _tandem_params.setParamLabelValue("refine, potential C-terminus modifications", ui->refpctm_edit->text()); - _tandem_params.setParamLabelValue("refine, modification mass", ui->refmm_edit->text()); - _tandem_params.setParamLabelValue("refine, modification mass 1", ui->refmm1_edit->text()); - _tandem_params.setParamLabelValue("refine, modification mass 2", ui->refmm2_edit->text()); - _tandem_params.setParamLabelValue("refine, potential modification mass", ui->refpmm_edit->text()); - _tandem_params.setParamLabelValue("refine, potential modification mass 1", ui->refpmm1_edit->text()); - _tandem_params.setParamLabelValue("refine, potential modification mass 2", ui->refpmm2_edit->text()); - _tandem_params.setParamLabelValue("refine, potential modification motif", ui->refpmmotif_edit->text()); - _tandem_params.setParamLabelValue("refine, potential modification motif 1", ui->refpmmotif1_edit->text()); - _tandem_params.setParamLabelValue("refine, potential modification motif 2", ui->refpmmotif2_edit->text()); - _tandem_params.setParamLabelValue("refine, use potential modifications for full refinement", "no"); - if (ui->rupmffr_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("refine, use potential modifications for full refinement", "yes"); + _tandem_params.setParamLabelValue( + "refine, maximum valid expectation value", ui->rmvev_edit->text()); + + _tandem_params.setParamLabelValue( + "refine, potential N-terminus modifications", ui->refpntm_edit->text()); + _tandem_params.setParamLabelValue( + "refine, potential C-terminus modifications", ui->refpctm_edit->text()); + _tandem_params.setParamLabelValue("refine, modification mass", + ui->refmm_edit->text()); + _tandem_params.setParamLabelValue("refine, modification mass 1", + ui->refmm1_edit->text()); + _tandem_params.setParamLabelValue("refine, modification mass 2", + ui->refmm2_edit->text()); + _tandem_params.setParamLabelValue("refine, potential modification mass", + ui->refpmm_edit->text()); + _tandem_params.setParamLabelValue("refine, potential modification mass 1", + ui->refpmm1_edit->text()); + _tandem_params.setParamLabelValue("refine, potential modification mass 2", + ui->refpmm2_edit->text()); + _tandem_params.setParamLabelValue("refine, potential modification motif", + ui->refpmmotif_edit->text()); + _tandem_params.setParamLabelValue( + "refine, potential modification motif 1", ui->refpmmotif1_edit->text()); + _tandem_params.setParamLabelValue( + "refine, potential modification motif 2", ui->refpmmotif2_edit->text()); + _tandem_params.setParamLabelValue( + "refine, use potential modifications for full refinement", "no"); + if(ui->rupmffr_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue( + "refine, use potential modifications for full refinement", "yes"); } - _tandem_params.setParamLabelValue("refine, cleavage semi", "no"); - if (ui->rcsemi_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("refine, cleavage semi", "yes"); + _tandem_params.setParamLabelValue("refine, cleavage semi", "no"); + if(ui->rcsemi_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("refine, cleavage semi", "yes"); } - _tandem_params.setParamLabelValue("refine, unanticipated cleavage", "no"); - if (ui->ruc_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("refine, unanticipated cleavage", "yes"); + _tandem_params.setParamLabelValue("refine, unanticipated cleavage", "no"); + if(ui->ruc_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("refine, unanticipated cleavage", + "yes"); } - _tandem_params.setParamLabelValue("refine, spectrum synthesis", "no"); - if (ui->rss_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("refine, spectrum synthesis", "yes"); + _tandem_params.setParamLabelValue("refine, spectrum synthesis", "no"); + if(ui->rss_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("refine, spectrum synthesis", + "yes"); } - _tandem_params.setParamLabelValue("refine, point mutations", "no"); - if (ui->rpm_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("refine, point mutations", "yes"); + _tandem_params.setParamLabelValue("refine, point mutations", "no"); + if(ui->rpm_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("refine, point mutations", "yes"); } - _tandem_params.setParamLabelValue("output, maximum valid expectation value", ui->omvev_edit->text()); + _tandem_params.setParamLabelValue( + "output, maximum valid expectation value", ui->omvev_edit->text()); - _tandem_params.setParamLabelValue("output, maximum valid protein expectation value", ui->omvpev_edit->text()); + _tandem_params.setParamLabelValue( + "output, maximum valid protein expectation value", + ui->omvpev_edit->text()); - _tandem_params.setParamLabelValue("output, results", "valid"); - if (ui->oresu_all_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("output, results", "all"); + _tandem_params.setParamLabelValue("output, results", "valid"); + if(ui->oresu_all_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("output, results", "all"); } - if (ui->oresu_stochastic_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("output, results", "stochastic"); + if(ui->oresu_stochastic_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("output, results", "stochastic"); } - _tandem_params.setParamLabelValue("output, spectra", "no"); - if (ui->ospec_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("output, spectra", "yes"); + _tandem_params.setParamLabelValue("output, spectra", "no"); + if(ui->ospec_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("output, spectra", "yes"); } - _tandem_params.setParamLabelValue("output, histogram column width", "30"); + _tandem_params.setParamLabelValue("output, histogram column width", "30"); - _tandem_params.setParamLabelValue("output, xsl path", ui->oxp_edit->text()); - _tandem_params.setParamLabelValue("output, mzid", "no"); - if (ui->mzid_yes_radio_button->isChecked()) { - _tandem_params.setParamLabelValue("output, mzid", "yes"); + _tandem_params.setParamLabelValue("output, xsl path", + ui->oxp_edit->text()); + _tandem_params.setParamLabelValue("output, mzid", "no"); + if(ui->mzid_yes_radio_button->isChecked()) + { + _tandem_params.setParamLabelValue("output, mzid", "yes"); } - } - catch (pappso::PappsoException & error) { - QMessageBox::warning(this,tr("Error in parameters :"), error.qwhat()); + catch(pappso::PappsoException &error) + { + QMessageBox::warning(this, tr("Error in parameters :"), error.qwhat()); } } -void EditTandemPresetDialog::populate() { - qDebug() << "EditTandemPresetDialog::populate begin"; - try { - ui->method_name_line_edit->setText(_tandem_params.getMethodName()); - /* - * <note type="input" label="spectrum, parent monoisotopic mass error units">ppm</note> - * */ - ui->spmmeu_daltons_radio_button->setChecked(true); - ui->spmmeu_ppm_radio_button->setChecked(false); - if ( _tandem_params.getValue("spectrum, parent monoisotopic mass error units") == "ppm" ) { // -1 for not found - ui->spmmeu_daltons_radio_button->setChecked(false); - ui->spmmeu_ppm_radio_button->setChecked(true); +void +EditTandemPresetDialog::populate() +{ + qDebug() << "EditTandemPresetDialog::populate begin"; + try + { + ui->method_name_line_edit->setText(_tandem_params.getMethodName()); + /* + * <note type="input" label="spectrum, parent monoisotopic mass error + * units">ppm</note> + * */ + ui->spmmeu_daltons_radio_button->setChecked(true); + ui->spmmeu_ppm_radio_button->setChecked(false); + if(_tandem_params.getValue( + "spectrum, parent monoisotopic mass error units") == "ppm") + { // -1 for not found + ui->spmmeu_daltons_radio_button->setChecked(false); + ui->spmmeu_ppm_radio_button->setChecked(true); } - //<note type="input" label="spectrum, parent monoisotopic mass error minus">10</note> - ui->parent_ion_lower_window_edit->setText(_tandem_params.getValue("spectrum, parent monoisotopic mass error minus")); - //<note type="input" label="spectrum, parent monoisotopic mass error plus">10</note> - ui->parent_ion_upper_window_edit->setText(_tandem_params.getValue("spectrum, parent monoisotopic mass error plus")); - //<note type="input" label="spectrum, parent monoisotopic mass isotope error">yes</note> - ui->spmmie_yes_radio_button->setChecked(true); - ui->spmmie_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("spectrum, parent monoisotopic mass isotope error") == "no" ) { // -1 for not found - ui->spmmie_yes_radio_button->setChecked(false); - ui->spmmie_no_radio_button->setChecked(true); + //<note type="input" label="spectrum, parent monoisotopic mass error + //minus">10</note> + ui->parent_ion_lower_window_edit->setText(_tandem_params.getValue( + "spectrum, parent monoisotopic mass error minus")); + //<note type="input" label="spectrum, parent monoisotopic mass error + //plus">10</note> + ui->parent_ion_upper_window_edit->setText(_tandem_params.getValue( + "spectrum, parent monoisotopic mass error plus")); + //<note type="input" label="spectrum, parent monoisotopic mass isotope + //error">yes</note> + ui->spmmie_yes_radio_button->setChecked(true); + ui->spmmie_no_radio_button->setChecked(false); + if(_tandem_params.getValue( + "spectrum, parent monoisotopic mass isotope error") == "no") + { // -1 for not found + ui->spmmie_yes_radio_button->setChecked(false); + ui->spmmie_no_radio_button->setChecked(true); } - //<note type="input" label="spectrum, maximum parent charge">4</note> - ui->smpc_edit->setText(_tandem_params.getValue("spectrum, maximum parent charge")); - - //<note type="input" label="spectrum, fragment mass type">monoisotopic</note> - auto index = ui->sfmt_combo_box->findText("monoisotopic"); - if ( index != -1 ) { // -1 for not found - ui->sfmt_combo_box->setCurrentIndex(index); + //<note type="input" label="spectrum, maximum parent charge">4</note> + ui->smpc_edit->setText( + _tandem_params.getValue("spectrum, maximum parent charge")); + + //<note type="input" label="spectrum, fragment mass + //type">monoisotopic</note> + auto index = ui->sfmt_combo_box->findText("monoisotopic"); + if(index != -1) + { // -1 for not found + ui->sfmt_combo_box->setCurrentIndex(index); } - //<note type="input" label="spectrum, fragment monoisotopic mass error units">Daltons</note> - ui->sfmmeu_daltons_radio_button->setChecked(true); - ui->sfmmeu_ppm_radio_button->setChecked(false); - if ( _tandem_params.getValue("spectrum, fragment monoisotopic mass error units") == "ppm" ) { // -1 for not found - ui->sfmmeu_daltons_radio_button->setChecked(false); - ui->sfmmeu_ppm_radio_button->setChecked(true); + //<note type="input" label="spectrum, fragment monoisotopic mass error + //units">Daltons</note> + ui->sfmmeu_daltons_radio_button->setChecked(true); + ui->sfmmeu_ppm_radio_button->setChecked(false); + if(_tandem_params.getValue( + "spectrum, fragment monoisotopic mass error units") == "ppm") + { // -1 for not found + ui->sfmmeu_daltons_radio_button->setChecked(false); + ui->sfmmeu_ppm_radio_button->setChecked(true); } - //<note type="input" label="spectrum, fragment monoisotopic mass error">0.02</note> - ui->sfmme_edit->setText(_tandem_params.getValue("spectrum, fragment monoisotopic mass error")); + //<note type="input" label="spectrum, fragment monoisotopic mass + //error">0.02</note> + ui->sfmme_edit->setText( + _tandem_params.getValue("spectrum, fragment monoisotopic mass error")); - //<note type="input" label="spectrum, use neutral loss window">yes</note> - ui->sunlw_yes_radio_button->setChecked(true); - ui->sunlw_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("spectrum, use neutral loss window") == "no" ) { // -1 for not found - ui->sunlw_yes_radio_button->setChecked(false); - ui->sunlw_no_radio_button->setChecked(true); + //<note type="input" label="spectrum, use neutral loss window">yes</note> + ui->sunlw_yes_radio_button->setChecked(true); + ui->sunlw_no_radio_button->setChecked(false); + if(_tandem_params.getValue("spectrum, use neutral loss window") == "no") + { // -1 for not found + ui->sunlw_yes_radio_button->setChecked(false); + ui->sunlw_no_radio_button->setChecked(true); } - - //<note type="input" label="spectrum, neutral loss mass">18.01057</note> - ui->snlm_edit->setText(_tandem_params.getValue("spectrum, neutral loss mass")); - //<note type="input" label="spectrum, neutral loss window">0.02</note> - ui->snlw_edit->setText(_tandem_params.getValue("spectrum, neutral loss window")); - //<note type="input" label="spectrum, use noise suppression">yes</note> - ui->suns_yes_radio_button->setChecked(true); - ui->suns_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("spectrum, use noise suppression") == "no" ) { // -1 for not found - ui->suns_yes_radio_button->setChecked(false); - ui->suns_no_radio_button->setChecked(true); + //<note type="input" label="spectrum, neutral loss mass">18.01057</note> + ui->snlm_edit->setText( + _tandem_params.getValue("spectrum, neutral loss mass")); + //<note type="input" label="spectrum, neutral loss window">0.02</note> + ui->snlw_edit->setText( + _tandem_params.getValue("spectrum, neutral loss window")); + //<note type="input" label="spectrum, use noise suppression">yes</note> + ui->suns_yes_radio_button->setChecked(true); + ui->suns_no_radio_button->setChecked(false); + if(_tandem_params.getValue("spectrum, use noise suppression") == "no") + { // -1 for not found + ui->suns_yes_radio_button->setChecked(false); + ui->suns_no_radio_button->setChecked(true); } - //<note type="input" label="spectrum, dynamic range">100.0</note> - ui->sdr_edit->setText(_tandem_params.getValue("spectrum, dynamic range")); + //<note type="input" label="spectrum, dynamic range">100.0</note> + ui->sdr_edit->setText(_tandem_params.getValue("spectrum, dynamic range")); - //<note type="input" label="spectrum, total peaks">100</note> - ui->stp_edit->setText(_tandem_params.getValue("spectrum, total peaks")); + //<note type="input" label="spectrum, total peaks">100</note> + ui->stp_edit->setText(_tandem_params.getValue("spectrum, total peaks")); - ui->smp_edit->setText(_tandem_params.getValue("spectrum, minimum peaks")); + ui->smp_edit->setText(_tandem_params.getValue("spectrum, minimum peaks")); - //<note type="input" label="spectrum, minimum fragment mz">150.0</note> - ui->smfmz_edit->setText(_tandem_params.getValue("spectrum, minimum fragment mz")); - //<note type="input" label="spectrum, minimum parent m+h">500.0</note> - ui->smpmh_edit->setText(_tandem_params.getValue("spectrum, minimum parent m+h")); + //<note type="input" label="spectrum, minimum fragment mz">150.0</note> + ui->smfmz_edit->setText( + _tandem_params.getValue("spectrum, minimum fragment mz")); + //<note type="input" label="spectrum, minimum parent m+h">500.0</note> + ui->smpmh_edit->setText( + _tandem_params.getValue("spectrum, minimum parent m+h")); - //<note type="input" label="spectrum, sequence batch size">1000</note> - ui->spsbs_edit->setText(_tandem_params.getValue("spectrum, sequence batch size")); - //<note type="input" label="spectrum, use contrast angle">no</note> - ui->suca_yes_radio_button->setChecked(true); - ui->suca_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("spectrum, use contrast angle") == "no" ) { // -1 for not found - ui->suca_yes_radio_button->setChecked(false); - ui->suca_no_radio_button->setChecked(true); + //<note type="input" label="spectrum, sequence batch size">1000</note> + ui->spsbs_edit->setText( + _tandem_params.getValue("spectrum, sequence batch size")); + //<note type="input" label="spectrum, use contrast angle">no</note> + ui->suca_yes_radio_button->setChecked(true); + ui->suca_no_radio_button->setChecked(false); + if(_tandem_params.getValue("spectrum, use contrast angle") == "no") + { // -1 for not found + ui->suca_yes_radio_button->setChecked(false); + ui->suca_no_radio_button->setChecked(true); } - //<note type="input" label="spectrum, threads">1</note> - ui->st_edit->setText(_tandem_params.getValue("spectrum, threads")); + //<note type="input" label="spectrum, threads">1</note> + ui->st_edit->setText(_tandem_params.getValue("spectrum, threads")); - //<note type="input" label="protein, cleavage site">[RK]|{P}</note> - ui->pcs_edit->setText(_tandem_params.getValue("protein, cleavage site")); - //<note type="input" label="protein, cleavage semi">no</note> - ui->pcsemi_yes_radio_button->setChecked(true); - ui->pcsemi_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("protein, cleavage semi") == "no" ) { // -1 for not found - ui->pcsemi_yes_radio_button->setChecked(false); - ui->pcsemi_no_radio_button->setChecked(true); + //<note type="input" label="protein, cleavage site">[RK]|{P}</note> + ui->pcs_edit->setText(_tandem_params.getValue("protein, cleavage site")); + //<note type="input" label="protein, cleavage semi">no</note> + ui->pcsemi_yes_radio_button->setChecked(true); + ui->pcsemi_no_radio_button->setChecked(false); + if(_tandem_params.getValue("protein, cleavage semi") == "no") + { // -1 for not found + ui->pcsemi_yes_radio_button->setChecked(false); + ui->pcsemi_no_radio_button->setChecked(true); } - //<note type="input" label="protein, cleavage C-terminal mass change">+17.00305</note> - ui->pcctmc_edit->setText(_tandem_params.getValue("protein, cleavage C-terminal mass change")); - //<note type="input" label="protein, cleavage N-terminal mass change">+1.00794</note> - ui->pcntmc_edit->setText(_tandem_params.getValue("protein, cleavage N-terminal mass change")); - - //<note type="input" label="protein, C-terminal residue modification mass">0.0</note> - ui->pctrmm_edit->setText(_tandem_params.getValue("protein, C-terminal residue modification mass")); - //<note type="input" label="protein, N-terminal residue modification mass">0.0</note> - ui->pntrmm_edit->setText(_tandem_params.getValue("protein, N-terminal residue modification mass")); - - //<note type="input" label="protein, quick acetyl">yes</note> - ui->pqa_yes_radio_button->setChecked(true); - ui->pqa_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("protein, quick acetyl") == "no" ) { // -1 for not found - ui->pqa_yes_radio_button->setChecked(false); - ui->pqa_no_radio_button->setChecked(true); + //<note type="input" label="protein, cleavage C-terminal mass + //change">+17.00305</note> + ui->pcctmc_edit->setText( + _tandem_params.getValue("protein, cleavage C-terminal mass change")); + //<note type="input" label="protein, cleavage N-terminal mass + //change">+1.00794</note> + ui->pcntmc_edit->setText( + _tandem_params.getValue("protein, cleavage N-terminal mass change")); + + //<note type="input" label="protein, C-terminal residue modification + //mass">0.0</note> + ui->pctrmm_edit->setText(_tandem_params.getValue( + "protein, C-terminal residue modification mass")); + //<note type="input" label="protein, N-terminal residue modification + //mass">0.0</note> + ui->pntrmm_edit->setText(_tandem_params.getValue( + "protein, N-terminal residue modification mass")); + + //<note type="input" label="protein, quick acetyl">yes</note> + ui->pqa_yes_radio_button->setChecked(true); + ui->pqa_no_radio_button->setChecked(false); + if(_tandem_params.getValue("protein, quick acetyl") == "no") + { // -1 for not found + ui->pqa_yes_radio_button->setChecked(false); + ui->pqa_no_radio_button->setChecked(true); } - //<note type="input" label="protein, quick pyrolidone">yes</note> - ui->pqp_yes_radio_button->setChecked(true); - ui->pqp_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("protein, quick pyrolidone") == "no" ) { // -1 for not found - ui->pqp_yes_radio_button->setChecked(false); - ui->pqp_no_radio_button->setChecked(true); + //<note type="input" label="protein, quick pyrolidone">yes</note> + ui->pqp_yes_radio_button->setChecked(true); + ui->pqp_no_radio_button->setChecked(false); + if(_tandem_params.getValue("protein, quick pyrolidone") == "no") + { // -1 for not found + ui->pqp_yes_radio_button->setChecked(false); + ui->pqp_no_radio_button->setChecked(true); } - //<note type="input" label="protein, stP bias">yes</note> - ui->pstpb_yes_radio_button->setChecked(true); - ui->pstpb_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("protein, stP bias") == "no" ) { // -1 for not found - ui->pstpb_yes_radio_button->setChecked(false); - ui->pstpb_no_radio_button->setChecked(true); + //<note type="input" label="protein, stP bias">yes</note> + ui->pstpb_yes_radio_button->setChecked(true); + ui->pstpb_no_radio_button->setChecked(false); + if(_tandem_params.getValue("protein, stP bias") == "no") + { // -1 for not found + ui->pstpb_yes_radio_button->setChecked(false); + ui->pstpb_no_radio_button->setChecked(true); } - //<note type="input" label="protein, modified residue mass file"></note> - ui->pmrmf_edit->setText(_tandem_params.getValue("protein, modified residue mass file")); - - //<note type="input" label="residue, modification mass">57.02146@C</note> - ui->rmm_edit->setText(_tandem_params.getValue("residue, modification mass")); - - //<note type="input" label="residue, modification mass 1"></note> - ui->rmm1_edit->setText(_tandem_params.getValue("residue, modification mass 1")); - //<note type="input" label="residue, modification mass 2"></note> - ui->rmm2_edit->setText(_tandem_params.getValue("residue, modification mass 2")); - - - //<note type="input" label="residue, potential modification mass">15.99491@M</note> - ui->rpmm_edit->setText(_tandem_params.getValue("residue, potential modification mass")); - //<note type="input" label="residue, potential modification mass 1"></note> - ui->rpmm1_edit->setText(_tandem_params.getValue("residue, potential modification mass 1")); - //<note type="input" label="residue, potential modification mass 2"></note> - ui->rpmm2_edit->setText(_tandem_params.getValue("residue, potential modification mass 2")); - //<note type="input" label="residue, potential modification motif"></note> - ui->rpmmotif_edit->setText(_tandem_params.getValue("residue, potential modification motif")); - //<note type="input" label="residue, potential modification motif 1"></note> - ui->rpmmotif1_edit->setText(_tandem_params.getValue("residue, potential modification motif 1")); - //<note type="input" label="residue, potential modification motif 2"></note> - ui->rpmmotif2_edit->setText(_tandem_params.getValue("residue, potential modification motif 2")); - - //<note type="input" label="scoring, minimum ion count">4</note> - ui->smic_edit->setText(_tandem_params.getValue("scoring, minimum ion count")); - //<note type="input" label="scoring, maximum missed cleavage sites">1</note> - ui->smmcs_edit->setText(_tandem_params.getValue("scoring, maximum missed cleavage sites")); - //<note type="input" label="scoring, cyclic permutation">yes</note> - ui->scp_yes_radio_button->setChecked(true); - ui->scp_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, cyclic permutation") == "no" ) { // -1 for not found - ui->scp_yes_radio_button->setChecked(false); - ui->scp_no_radio_button->setChecked(true); + //<note type="input" label="protein, modified residue mass file"></note> + ui->pmrmf_edit->setText( + _tandem_params.getValue("protein, modified residue mass file")); + + //<note type="input" label="residue, modification mass">57.02146@C</note> + ui->rmm_edit->setText( + _tandem_params.getValue("residue, modification mass")); + + //<note type="input" label="residue, modification mass 1"></note> + ui->rmm1_edit->setText( + _tandem_params.getValue("residue, modification mass 1")); + //<note type="input" label="residue, modification mass 2"></note> + ui->rmm2_edit->setText( + _tandem_params.getValue("residue, modification mass 2")); + + + //<note type="input" label="residue, potential modification + //mass">15.99491@M</note> + ui->rpmm_edit->setText( + _tandem_params.getValue("residue, potential modification mass")); + //<note type="input" label="residue, potential modification mass + //1"></note> + ui->rpmm1_edit->setText( + _tandem_params.getValue("residue, potential modification mass 1")); + //<note type="input" label="residue, potential modification mass + //2"></note> + ui->rpmm2_edit->setText( + _tandem_params.getValue("residue, potential modification mass 2")); + //<note type="input" label="residue, potential modification motif"></note> + ui->rpmmotif_edit->setText( + _tandem_params.getValue("residue, potential modification motif")); + //<note type="input" label="residue, potential modification motif + //1"></note> + ui->rpmmotif1_edit->setText( + _tandem_params.getValue("residue, potential modification motif 1")); + //<note type="input" label="residue, potential modification motif + //2"></note> + ui->rpmmotif2_edit->setText( + _tandem_params.getValue("residue, potential modification motif 2")); + + //<note type="input" label="scoring, minimum ion count">4</note> + ui->smic_edit->setText( + _tandem_params.getValue("scoring, minimum ion count")); + //<note type="input" label="scoring, maximum missed cleavage + //sites">1</note> + ui->smmcs_edit->setText( + _tandem_params.getValue("scoring, maximum missed cleavage sites")); + //<note type="input" label="scoring, cyclic permutation">yes</note> + ui->scp_yes_radio_button->setChecked(true); + ui->scp_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, cyclic permutation") == "no") + { // -1 for not found + ui->scp_yes_radio_button->setChecked(false); + ui->scp_no_radio_button->setChecked(true); } - //<note type="input" label="scoring, include reverse">yes</note> - ui->sir_yes_radio_button->setChecked(true); - ui->sir_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, include reverse") == "no" ) { // -1 for not found - ui->sir_yes_radio_button->setChecked(false); - ui->sir_no_radio_button->setChecked(true); + //<note type="input" label="scoring, include reverse">yes</note> + ui->sir_yes_radio_button->setChecked(true); + ui->sir_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, include reverse") == "no") + { // -1 for not found + ui->sir_yes_radio_button->setChecked(false); + ui->sir_no_radio_button->setChecked(true); } - //<note type="input" label="scoring, y ions">yes</note> - ui->syi_yes_radio_button->setChecked(true); - ui->syi_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, y ions") == "no" ) { // -1 for not found - ui->syi_yes_radio_button->setChecked(false); - ui->syi_no_radio_button->setChecked(true); + //<note type="input" label="scoring, y ions">yes</note> + ui->syi_yes_radio_button->setChecked(true); + ui->syi_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, y ions") == "no") + { // -1 for not found + ui->syi_yes_radio_button->setChecked(false); + ui->syi_no_radio_button->setChecked(true); } - //<note type="input" label="scoring, b ions">yes</note> - ui->sbi_yes_radio_button->setChecked(true); - ui->sbi_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, b ions") == "no" ) { // -1 for not found - ui->sbi_yes_radio_button->setChecked(false); - ui->sbi_no_radio_button->setChecked(true); + //<note type="input" label="scoring, b ions">yes</note> + ui->sbi_yes_radio_button->setChecked(true); + ui->sbi_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, b ions") == "no") + { // -1 for not found + ui->sbi_yes_radio_button->setChecked(false); + ui->sbi_no_radio_button->setChecked(true); } - //<note type="input" label="scoring, c ions">no</note> - ui->sci_yes_radio_button->setChecked(true); - ui->sci_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, c ions") == "no" ) { // -1 for not found - ui->sci_yes_radio_button->setChecked(false); - ui->sci_no_radio_button->setChecked(true); + //<note type="input" label="scoring, c ions">no</note> + ui->sci_yes_radio_button->setChecked(true); + ui->sci_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, c ions") == "no") + { // -1 for not found + ui->sci_yes_radio_button->setChecked(false); + ui->sci_no_radio_button->setChecked(true); } - //<note type="input" label="scoring, z ions">no</note> - ui->szi_yes_radio_button->setChecked(true); - ui->szi_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, z ions") == "no" ) { // -1 for not found - ui->szi_yes_radio_button->setChecked(false); - ui->szi_no_radio_button->setChecked(true); + //<note type="input" label="scoring, z ions">no</note> + ui->szi_yes_radio_button->setChecked(true); + ui->szi_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, z ions") == "no") + { // -1 for not found + ui->szi_yes_radio_button->setChecked(false); + ui->szi_no_radio_button->setChecked(true); } - //<note type="input" label="scoring, a ions">no</note> - ui->sai_yes_radio_button->setChecked(true); - ui->sai_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, a ions") == "no" ) { // -1 for not found - ui->sai_yes_radio_button->setChecked(false); - ui->sai_no_radio_button->setChecked(true); + //<note type="input" label="scoring, a ions">no</note> + ui->sai_yes_radio_button->setChecked(true); + ui->sai_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, a ions") == "no") + { // -1 for not found + ui->sai_yes_radio_button->setChecked(false); + ui->sai_no_radio_button->setChecked(true); } - //<note type="input" label="scoring, x ions">no</note> - ui->sxi_yes_radio_button->setChecked(true); - ui->sxi_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("scoring, x ions") == "no" ) { // -1 for not found - ui->sxi_yes_radio_button->setChecked(false); - ui->sxi_no_radio_button->setChecked(true); + //<note type="input" label="scoring, x ions">no</note> + ui->sxi_yes_radio_button->setChecked(true); + ui->sxi_no_radio_button->setChecked(false); + if(_tandem_params.getValue("scoring, x ions") == "no") + { // -1 for not found + ui->sxi_yes_radio_button->setChecked(false); + ui->sxi_no_radio_button->setChecked(true); } - //<note type="input" label="refine">yes</note> - ui->refine_yes_radio_button->setChecked(true); - ui->refine_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("refine") == "no" ) { // -1 for not found - ui->refine_yes_radio_button->setChecked(false); - ui->refine_no_radio_button->setChecked(true); + //<note type="input" label="refine">yes</note> + ui->refine_yes_radio_button->setChecked(true); + ui->refine_no_radio_button->setChecked(false); + if(_tandem_params.getValue("refine") == "no") + { // -1 for not found + ui->refine_yes_radio_button->setChecked(false); + ui->refine_no_radio_button->setChecked(true); } - //<note type="input" label="refine, maximum valid expectation value">0.01</note> - ui->rmvev_edit->setText(_tandem_params.getValue("refine, maximum valid expectation value")); - - //<note type="input" label="refine, potential N-terminus modifications">+42.01056@[</note> - ui->refpntm_edit->setText(_tandem_params.getValue("refine, potential N-terminus modifications")); - //<note type="input" label="refine, potential C-terminus modifications"></note> - ui->refpctm_edit->setText(_tandem_params.getValue("refine, potential C-terminus modifications")); - //<note type="input" label="refine, modification mass">57.02146@C</note> - ui->refmm_edit->setText(_tandem_params.getValue("refine, modification mass")); - //<note type="input" label="refine, modification mass 1"></note> - ui->refmm1_edit->setText(_tandem_params.getValue("refine, modification mass 1")); - //<note type="input" label="refine, modification mass 2"></note> - ui->refmm2_edit->setText(_tandem_params.getValue("refine, modification mass 2")); - //<note type="input" label="refine, potential modification mass">15.99491@M</note> - ui->refpmm_edit->setText(_tandem_params.getValue("refine, potential modification mass")); - //<note type="input" label="refine, potential modification mass 1"></note> - ui->refpmm1_edit->setText(_tandem_params.getValue("refine, potential modification mass 1")); - //<note type="input" label="refine, potential modification mass 2"></note> - ui->refpmm2_edit->setText(_tandem_params.getValue("refine, potential modification mass 2")); - //<note type="input" label="refine, potential modification motif"></note> - ui->refpmmotif_edit->setText(_tandem_params.getValue("refine, potential modification motif")); - //<note type="input" label="refine, potential modification motif 1"></note> - ui->refpmmotif1_edit->setText(_tandem_params.getValue("refine, potential modification motif 1")); - //<note type="input" label="refine, potential modification motif 2"></note> - ui->refpmmotif2_edit->setText(_tandem_params.getValue("refine, potential modification motif 2")); - //<note type="input" label="refine, use potential modifications for full refinement">yes</note> - ui->rupmffr_yes_radio_button->setChecked(true); - ui->rupmffr_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("refine, use potential modifications for full refinement") == "no" ) { // -1 for not found - ui->rupmffr_yes_radio_button->setChecked(false); - ui->rupmffr_no_radio_button->setChecked(true); + //<note type="input" label="refine, maximum valid expectation + //value">0.01</note> + ui->rmvev_edit->setText( + _tandem_params.getValue("refine, maximum valid expectation value")); + + //<note type="input" label="refine, potential N-terminus + //modifications">+42.01056@[</note> + ui->refpntm_edit->setText( + _tandem_params.getValue("refine, potential N-terminus modifications")); + //<note type="input" label="refine, potential C-terminus + //modifications"></note> + ui->refpctm_edit->setText( + _tandem_params.getValue("refine, potential C-terminus modifications")); + //<note type="input" label="refine, modification mass">57.02146@C</note> + ui->refmm_edit->setText( + _tandem_params.getValue("refine, modification mass")); + //<note type="input" label="refine, modification mass 1"></note> + ui->refmm1_edit->setText( + _tandem_params.getValue("refine, modification mass 1")); + //<note type="input" label="refine, modification mass 2"></note> + ui->refmm2_edit->setText( + _tandem_params.getValue("refine, modification mass 2")); + //<note type="input" label="refine, potential modification + //mass">15.99491@M</note> + ui->refpmm_edit->setText( + _tandem_params.getValue("refine, potential modification mass")); + //<note type="input" label="refine, potential modification mass 1"></note> + ui->refpmm1_edit->setText( + _tandem_params.getValue("refine, potential modification mass 1")); + //<note type="input" label="refine, potential modification mass 2"></note> + ui->refpmm2_edit->setText( + _tandem_params.getValue("refine, potential modification mass 2")); + //<note type="input" label="refine, potential modification motif"></note> + ui->refpmmotif_edit->setText( + _tandem_params.getValue("refine, potential modification motif")); + //<note type="input" label="refine, potential modification motif + //1"></note> + ui->refpmmotif1_edit->setText( + _tandem_params.getValue("refine, potential modification motif 1")); + //<note type="input" label="refine, potential modification motif + //2"></note> + ui->refpmmotif2_edit->setText( + _tandem_params.getValue("refine, potential modification motif 2")); + //<note type="input" label="refine, use potential modifications for full + //refinement">yes</note> + ui->rupmffr_yes_radio_button->setChecked(true); + ui->rupmffr_no_radio_button->setChecked(false); + if(_tandem_params.getValue( + "refine, use potential modifications for full refinement") == "no") + { // -1 for not found + ui->rupmffr_yes_radio_button->setChecked(false); + ui->rupmffr_no_radio_button->setChecked(true); } - //<note type="input" label="refine, cleavage semi">no</note> - ui->rcsemi_yes_radio_button->setChecked(true); - ui->rcsemi_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("refine, cleavage semi") == "no" ) { // -1 for not found - ui->rcsemi_yes_radio_button->setChecked(false); - ui->rcsemi_no_radio_button->setChecked(true); + //<note type="input" label="refine, cleavage semi">no</note> + ui->rcsemi_yes_radio_button->setChecked(true); + ui->rcsemi_no_radio_button->setChecked(false); + if(_tandem_params.getValue("refine, cleavage semi") == "no") + { // -1 for not found + ui->rcsemi_yes_radio_button->setChecked(false); + ui->rcsemi_no_radio_button->setChecked(true); } - //<note type="input" label="refine, unanticipated cleavage">no</note> - ui->ruc_yes_radio_button->setChecked(true); - ui->ruc_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("refine, unanticipated cleavage") == "no" ) { // -1 for not found - ui->ruc_yes_radio_button->setChecked(false); - ui->ruc_no_radio_button->setChecked(true); + //<note type="input" label="refine, unanticipated cleavage">no</note> + ui->ruc_yes_radio_button->setChecked(true); + ui->ruc_no_radio_button->setChecked(false); + if(_tandem_params.getValue("refine, unanticipated cleavage") == "no") + { // -1 for not found + ui->ruc_yes_radio_button->setChecked(false); + ui->ruc_no_radio_button->setChecked(true); } - //<note type="input" label="refine, spectrum synthesis">yes</note> - ui->rss_yes_radio_button->setChecked(true); - ui->rss_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("refine, spectrum synthesis") == "no" ) { // -1 for not found - ui->rss_yes_radio_button->setChecked(false); - ui->rss_no_radio_button->setChecked(true); + //<note type="input" label="refine, spectrum synthesis">yes</note> + ui->rss_yes_radio_button->setChecked(true); + ui->rss_no_radio_button->setChecked(false); + if(_tandem_params.getValue("refine, spectrum synthesis") == "no") + { // -1 for not found + ui->rss_yes_radio_button->setChecked(false); + ui->rss_no_radio_button->setChecked(true); } - //<note type="input" label="refine, point mutations">no</note> - ui->rpm_yes_radio_button->setChecked(true); - ui->rpm_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("refine, point mutations") == "no" ) { // -1 for not found - ui->rpm_yes_radio_button->setChecked(false); - ui->rpm_no_radio_button->setChecked(true); + //<note type="input" label="refine, point mutations">no</note> + ui->rpm_yes_radio_button->setChecked(true); + ui->rpm_no_radio_button->setChecked(false); + if(_tandem_params.getValue("refine, point mutations") == "no") + { // -1 for not found + ui->rpm_yes_radio_button->setChecked(false); + ui->rpm_no_radio_button->setChecked(true); } - //<note type="input" label="output, maximum valid expectation value">0.05</note> - ui->omvev_edit->setText(_tandem_params.getValue("output, maximum valid expectation value")); - //<note type="input" label="output, maximum valid protein expectation value">0.05</note> - ui->omvpev_edit->setText(_tandem_params.getValue("output, maximum valid protein expectation value")); - //<note type="input" label="output, results">valid</note> - ui->oresu_all_radio_button->setChecked(false); - ui->oresu_valid_radio_button->setChecked(true); - ui->oresu_stochastic_radio_button->setChecked(false); - if ( _tandem_params.getValue("output, results") == "all" ) { // -1 for not found - ui->oresu_all_radio_button->setChecked(true); - ui->oresu_valid_radio_button->setChecked(false); - ui->oresu_stochastic_radio_button->setChecked(false); + //<note type="input" label="output, maximum valid expectation + //value">0.05</note> + ui->omvev_edit->setText( + _tandem_params.getValue("output, maximum valid expectation value")); + //<note type="input" label="output, maximum valid protein expectation + //value">0.05</note> + ui->omvpev_edit->setText(_tandem_params.getValue( + "output, maximum valid protein expectation value")); + //<note type="input" label="output, results">valid</note> + ui->oresu_all_radio_button->setChecked(false); + ui->oresu_valid_radio_button->setChecked(true); + ui->oresu_stochastic_radio_button->setChecked(false); + if(_tandem_params.getValue("output, results") == "all") + { // -1 for not found + ui->oresu_all_radio_button->setChecked(true); + ui->oresu_valid_radio_button->setChecked(false); + ui->oresu_stochastic_radio_button->setChecked(false); } - if ( _tandem_params.getValue("output, results") == "stochastic" ) { // -1 for not found - ui->oresu_all_radio_button->setChecked(false); - ui->oresu_valid_radio_button->setChecked(false); - ui->oresu_stochastic_radio_button->setChecked(true); + if(_tandem_params.getValue("output, results") == "stochastic") + { // -1 for not found + ui->oresu_all_radio_button->setChecked(false); + ui->oresu_valid_radio_button->setChecked(false); + ui->oresu_stochastic_radio_button->setChecked(true); } - //<note type="input" label="output, sort results by">spectrum</note> - //<note type="input" label="output, proteins">yes</note> - //<note type="input" label="output, sequences">yes</note> - //<note type="input" label="output, one sequence copy">yes</note> - //<note type="input" label="output, spectra">yes</note> - ui->ospec_yes_radio_button->setChecked(true); - ui->ospec_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("output, spectra") == "no" ) { // -1 for not found - ui->ospec_yes_radio_button->setChecked(false); - ui->ospec_no_radio_button->setChecked(true); + //<note type="input" label="output, sort results by">spectrum</note> + //<note type="input" label="output, proteins">yes</note> + //<note type="input" label="output, sequences">yes</note> + //<note type="input" label="output, one sequence copy">yes</note> + //<note type="input" label="output, spectra">yes</note> + ui->ospec_yes_radio_button->setChecked(true); + ui->ospec_no_radio_button->setChecked(false); + if(_tandem_params.getValue("output, spectra") == "no") + { // -1 for not found + ui->ospec_yes_radio_button->setChecked(false); + ui->ospec_no_radio_button->setChecked(true); } - //<note type="input" label="output, parameters">yes</note> - //<note type="input" label="output, performance">yes</note> - //<note type="input" label="output, histograms">yes</note> - //<note type="input" label="output, histogram column width">30</note> - //<note type="input" label="output, path hashing">no</note> - //<note type="input" label="output, xsl path">tandem-style.xsl</note> - ui->oxp_edit->setText(_tandem_params.getValue("output, xsl path")); - //<note type="input" label="output, mzid">no</note> - ui->mzid_yes_radio_button->setChecked(true); - ui->mzid_no_radio_button->setChecked(false); - if ( _tandem_params.getValue("output, mzid") == "no" ) { // -1 for not found - ui->mzid_yes_radio_button->setChecked(false); - ui->mzid_no_radio_button->setChecked(true); + //<note type="input" label="output, parameters">yes</note> + //<note type="input" label="output, performance">yes</note> + //<note type="input" label="output, histograms">yes</note> + //<note type="input" label="output, histogram column width">30</note> + //<note type="input" label="output, path hashing">no</note> + //<note type="input" label="output, xsl path">tandem-style.xsl</note> + ui->oxp_edit->setText(_tandem_params.getValue("output, xsl path")); + //<note type="input" label="output, mzid">no</note> + ui->mzid_yes_radio_button->setChecked(true); + ui->mzid_no_radio_button->setChecked(false); + if(_tandem_params.getValue("output, mzid") == "no") + { // -1 for not found + ui->mzid_yes_radio_button->setChecked(false); + ui->mzid_no_radio_button->setChecked(true); } } - catch (pappso::ExceptionNotFound & error) { - QMessageBox::warning(this,tr("Parameter not found :"), error.qwhat()); + catch(pappso::ExceptionNotFound &error) + { + QMessageBox::warning(this, tr("Parameter not found :"), error.qwhat()); } - catch (pappso::PappsoException & error) { - QMessageBox::warning(this,tr("Error in parameters :"), error.qwhat()); + catch(pappso::PappsoException &error) + { + QMessageBox::warning(this, tr("Error in parameters :"), error.qwhat()); } - qDebug() << "EditTandemPresetDialog::populate end"; + qDebug() << "EditTandemPresetDialog::populate end"; } -void EditTandemPresetDialog::done(int r) +void +EditTandemPresetDialog::done(int r) { - if(QDialog::Accepted == r) // ok was pressed + if(QDialog::Accepted == r) // ok was pressed { - readUi(); - if (!_p_tandem_preset_file->exists()) { - QMessageBox::warning(this, - tr("Save parameters"), tr("Parameters file does not exists.\nPlease save it before pressing ok or cancel edition")); - return; + readUi(); + if(!_p_tandem_preset_file->exists()) + { + QMessageBox::warning( + this, tr("Save parameters"), + tr("Parameters file does not exists.\nPlease save it before " + "pressing ok or cancel edition")); + return; } - TandemParameters ref_params = _p_tandem_preset_file->getTandemParameters(); - if(ref_params.equals(_tandem_params)) // validate the data somehow + TandemParameters ref_params = + _p_tandem_preset_file->getTandemParameters(); + if(ref_params.equals(_tandem_params)) // validate the data somehow { - QDialog::done(r); - return; + QDialog::done(r); + return; } - else + else { - QMessageBox::warning(this, - tr("Save parameters"), tr("Parameters modified but not saved.\nPlease save it before pressing ok or cancel edition")); - return; + QMessageBox::warning( + this, tr("Save parameters"), + tr("Parameters modified but not saved.\nPlease save it before " + "pressing ok or cancel edition")); + return; } } - else // cancel, close or exc was pressed + else // cancel, close or exc was pressed { - QDialog::done(r); - return; + QDialog::done(r); + return; } } diff --git a/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.h b/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.h index 509b3d58991f5e126df14fa3b977b0ff1f797335..fffcef16775658a557d0f997f20e5605de315601 100644 --- a/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.h +++ b/src/gui/edit_tandem_preset_dialog/edittandempresetdialog.h @@ -6,69 +6,72 @@ */ /******************************************************************************* -* 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 EDITTANDEMPRESETDIALOG_H #define EDITTANDEMPRESETDIALOG_H #include "../../files/tandemparametersfile.h" -#include<QDialog> +#include <QDialog> -namespace Ui { -class EditTandemPresetView; +namespace Ui +{ + class EditTandemPresetView; } -class EditTandemPresetDialog: public QDialog +class EditTandemPresetDialog : public QDialog { - Q_OBJECT + Q_OBJECT + + public: + explicit EditTandemPresetDialog(QWidget *parent); + ~EditTandemPresetDialog(); + + void setTandemParametersFile(const TandemParametersFile &tandem_preset_file); + + const TandemParametersFile &getTandemParametersFile() const; + + protected: + void done(int r) override; -public: - explicit EditTandemPresetDialog(QWidget * parent); - ~EditTandemPresetDialog(); - - void setTandemParametersFile(const TandemParametersFile & tandem_preset_file); - - const TandemParametersFile & getTandemParametersFile() const; - -protected: - void done(int r) override; + public slots: + void doHelp(); + void doSave(); + void doCopy(); + void doEdit(QString value); + void doLoad(); + void doSelectDir(); -public slots: - void doHelp (); - void doSave(); - void doCopy(); - void doEdit(QString value); - void doLoad(); - void doSelectDir(); -private: - void fillPresetComboBox(); - void populate(); - void readUi(); + private: + void fillPresetComboBox(); + void populate(); + void readUi(); -private: - Ui::EditTandemPresetView *ui; - TandemParametersFile * _p_tandem_preset_file = nullptr; - TandemParameters _tandem_params; - QString _preset_directory; + private: + Ui::EditTandemPresetView *ui; + TandemParametersFile *_p_tandem_preset_file = nullptr; + TandemParameters _tandem_params; + QString _preset_directory; }; #endif // EDITTANDEMPRESETDIALOG_H diff --git a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp index 60ec8e679e5f2fe95129034b0bfbac944cc6e1ac..28231401cb20cc3660b4486f1489cbfff8598eee 100644 --- a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp +++ b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp @@ -1,229 +1,286 @@ /******************************************************************************* -* 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 "ui_export_spreadsheet_dialog.h" #include "exportspreadsheetdialog.h" #include <QDebug> #include <QSettings> -ExportSpreadsheetDialog::ExportSpreadsheetDialog(QWidget * parent): - QDialog(parent), - ui(new Ui::ExportSpreadsheetDialog) +ExportSpreadsheetDialog::ExportSpreadsheetDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::ExportSpreadsheetDialog) { - qDebug() << "ExportSpreadsheetDialog::ExportSpreadsheetDialog begin"; - ui->setupUi(this); - this->setModal(true); + qDebug() << "ExportSpreadsheetDialog::ExportSpreadsheetDialog begin"; + ui->setupUi(this); + this->setModal(true); + QSettings settings; - QSettings settings; - - ui->groups_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/groups", "true").toBool()) { - ui->groups_checkbox->setCheckState(Qt::Checked); + ui->groups_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/groups", "true").toBool()) + { + ui->groups_checkbox->setCheckState(Qt::Checked); } - //ui->simple_checkbox->setVisible(false); - //ui->simple_checkbox->setCheckState(Qt::Unchecked); - //if (settings.value("export_ods/simple", "false").toBool()) { - // ui->simple_checkbox->setCheckState(Qt::Checked); - //} - ui->protein_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/proteins", "true").toBool()) { - ui->protein_checkbox->setCheckState(Qt::Checked); + // ui->simple_checkbox->setVisible(false); + // ui->simple_checkbox->setCheckState(Qt::Unchecked); + // if (settings.value("export_ods/simple", "false").toBool()) { + // ui->simple_checkbox->setCheckState(Qt::Checked); + //} + ui->protein_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/proteins", "true").toBool()) + { + ui->protein_checkbox->setCheckState(Qt::Checked); } - ui->peptide_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/peptides", "true").toBool()) { - ui->peptide_checkbox->setCheckState(Qt::Checked); + ui->peptide_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/peptides", "true").toBool()) + { + ui->peptide_checkbox->setCheckState(Qt::Checked); } - ui->spectra_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/spectra", "true").toBool()) { - ui->spectra_checkbox->setCheckState(Qt::Checked); + ui->spectra_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/spectra", "true").toBool()) + { + ui->spectra_checkbox->setCheckState(Qt::Checked); } - ui->peptidepos_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/peptidepos", "true").toBool()) { - ui->peptidepos_checkbox->setCheckState(Qt::Checked); + ui->peptidepos_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/peptidepos", "true").toBool()) + { + ui->peptidepos_checkbox->setCheckState(Qt::Checked); } - ui->comparspectra_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/comparspectra", "true").toBool()) { - ui->comparspectra_checkbox->setCheckState(Qt::Checked); + ui->comparspectra_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/comparspectra", "true").toBool()) + { + ui->comparspectra_checkbox->setCheckState(Qt::Checked); } - ui->comparspecificspectra_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/comparspecificspectra", "true").toBool()) { - ui->comparspecificspectra_checkbox->setCheckState(Qt::Checked); + ui->comparspecificspectra_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/comparspecificspectra", "true").toBool()) + { + ui->comparspecificspectra_checkbox->setCheckState(Qt::Checked); } - ui->comparuniquesequence_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/comparuniquesequence", "true").toBool()) { - ui->comparuniquesequence_checkbox->setCheckState(Qt::Checked); + ui->comparuniquesequence_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/comparuniquesequence", "true").toBool()) + { + ui->comparuniquesequence_checkbox->setCheckState(Qt::Checked); } - ui->comparspecificuniquesequence_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/comparspecificuniquesequence", "true").toBool()) { - ui->comparspecificuniquesequence_checkbox->setCheckState(Qt::Checked); + ui->comparspecificuniquesequence_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/comparspecificuniquesequence", "true").toBool()) + { + ui->comparspecificuniquesequence_checkbox->setCheckState(Qt::Checked); } - ui->comparpai_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/comparpai", "true").toBool()) { - ui->comparpai_checkbox->setCheckState(Qt::Checked); + ui->comparpai_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/comparpai", "true").toBool()) + { + ui->comparpai_checkbox->setCheckState(Qt::Checked); } - ui->comparempai_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/comparempai", "true").toBool()) { - ui->comparempai_checkbox->setCheckState(Qt::Checked); + ui->comparempai_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/comparempai", "true").toBool()) + { + ui->comparempai_checkbox->setCheckState(Qt::Checked); } - ui->comparnsaf_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/comparnsaf", "true").toBool()) { - ui->comparnsaf_checkbox->setCheckState(Qt::Checked); + ui->comparnsaf_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/comparnsaf", "true").toBool()) + { + ui->comparnsaf_checkbox->setCheckState(Qt::Checked); } - ui->samples_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/samples", "true").toBool()) { - ui->samples_checkbox->setCheckState(Qt::Checked); + ui->samples_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/samples", "true").toBool()) + { + ui->samples_checkbox->setCheckState(Qt::Checked); } - ui->ptmislands_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/ptmislands", "true").toBool()) { - ui->ptmislands_checkbox->setCheckState(Qt::Checked); + ui->ptmislands_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/ptmislands", "true").toBool()) + { + ui->ptmislands_checkbox->setCheckState(Qt::Checked); } - ui->ptmspectra_checkbox->setCheckState(Qt::Unchecked); - if (settings.value("export_ods/ptmspectra", "true").toBool()) { - ui->ptmspectra_checkbox->setCheckState(Qt::Checked); + ui->ptmspectra_checkbox->setCheckState(Qt::Unchecked); + if(settings.value("export_ods/ptmspectra", "true").toBool()) + { + ui->ptmspectra_checkbox->setCheckState(Qt::Checked); } - //param.setFilterCrossSamplePeptideNumber(settings.value("automatic_filter/cross_sample", "true").toBool()); + // param.setFilterCrossSamplePeptideNumber(settings.value("automatic_filter/cross_sample", + // "true").toBool()); #if QT_VERSION >= 0x050000 // Qt5 code #else -// Qt4 code + // Qt4 code #endif - qDebug() << "ExportSpreadsheetDialog::ExportSpreadsheetDialog end"; + qDebug() << "ExportSpreadsheetDialog::ExportSpreadsheetDialog end"; } ExportSpreadsheetDialog::~ExportSpreadsheetDialog() { - delete ui; + delete ui; } -void ExportSpreadsheetDialog::doPeptides(bool simple) { +void +ExportSpreadsheetDialog::doPeptides(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/peptides", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/peptides", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doProteins(bool simple) { +void +ExportSpreadsheetDialog::doProteins(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/proteins", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/proteins", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doSamples(bool simple) { +void +ExportSpreadsheetDialog::doSamples(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/samples", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/samples", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doSpectra(bool simple) { +void +ExportSpreadsheetDialog::doSpectra(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/spectra", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/spectra", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doComparSpectra(bool simple) { +void +ExportSpreadsheetDialog::doComparSpectra(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/comparspectra", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/comparspectra", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doComparSpecificSpectra(bool simple) { +void +ExportSpreadsheetDialog::doComparSpecificSpectra(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/comparspecificspectra", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/comparspecificspectra", + QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doComparUniqueSequence(bool simple) { +void +ExportSpreadsheetDialog::doComparUniqueSequence(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/comparuniquesequence", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/comparuniquesequence", + QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doComparSpecificUniqueSequence(bool simple) { +void +ExportSpreadsheetDialog::doComparSpecificUniqueSequence(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/comparspecificuniquesequence", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/comparspecificuniquesequence", + QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doComparEmpai(bool simple) { +void +ExportSpreadsheetDialog::doComparEmpai(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/comparempai", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/comparempai", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doComparPai(bool simple) { +void +ExportSpreadsheetDialog::doComparPai(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/comparpai", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/comparpai", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doComparNsaf(bool simple) { +void +ExportSpreadsheetDialog::doComparNsaf(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/comparnsaf", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/comparnsaf", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doPeptidePos(bool simple) { +void +ExportSpreadsheetDialog::doPeptidePos(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/peptidepos", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/peptidepos", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doGroups(bool simple) { +void +ExportSpreadsheetDialog::doGroups(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/groups", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/groups", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doSimpleProteinPeptideList(bool simple) { +void +ExportSpreadsheetDialog::doSimpleProteinPeptideList(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/simple", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/simple", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doProteinList(bool simple) { +void +ExportSpreadsheetDialog::doProteinList(bool simple) +{ - QSettings settings; - settings.setValue("export_ods/proteins", QString("%1").arg(simple)); + QSettings settings; + settings.setValue("export_ods/proteins", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doPtmIslands(bool simple) { - QSettings settings; - settings.setValue("export_ods/ptmislands", QString("%1").arg(simple)); +void +ExportSpreadsheetDialog::doPtmIslands(bool simple) +{ + QSettings settings; + settings.setValue("export_ods/ptmislands", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::doPtmSpectra(bool simple) { - QSettings settings; - settings.setValue("export_ods/ptmspectra", QString("%1").arg(simple)); +void +ExportSpreadsheetDialog::doPtmSpectra(bool simple) +{ + QSettings settings; + settings.setValue("export_ods/ptmspectra", QString("%1").arg(simple)); } -void ExportSpreadsheetDialog::setProject(const Project * p_project) { +void +ExportSpreadsheetDialog::setProject(const Project *p_project) +{ - if (p_project->getProjectMode() == ProjectMode::individual) { - ui->compar_groupbox->setDisabled(true); + if(p_project->getProjectMode() == ProjectMode::individual) + { + ui->compar_groupbox->setDisabled(true); } - else { - ui->compar_groupbox->setDisabled(false); + else + { + ui->compar_groupbox->setDisabled(false); } - if (p_project->hasPtmExperiment()) { - ui->ptm_groupbox->setEnabled(true); + if(p_project->hasPtmExperiment()) + { + ui->ptm_groupbox->setEnabled(true); } - else { - ui->ptm_groupbox->setEnabled(false); + else + { + ui->ptm_groupbox->setEnabled(false); } - } diff --git a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.h b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.h index 0214e871e9fb28895658429659930b5f9c44b44e..f03559d09d5b992dddbc7bd14ab69a11c1ced9ad 100644 --- a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.h +++ b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.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 EXPORTSPREADSHEETDIALOG_H #define EXPORTSPREADSHEETDIALOG_H @@ -30,44 +31,44 @@ #include "../../core/project.h" -namespace Ui { -class ExportSpreadsheetDialog; +namespace Ui +{ + class ExportSpreadsheetDialog; } class ExportSpreadsheetDialog : public QDialog { - Q_OBJECT + Q_OBJECT -public: - explicit ExportSpreadsheetDialog(QWidget * parent); - ~ExportSpreadsheetDialog(); + public: + explicit ExportSpreadsheetDialog(QWidget *parent); + ~ExportSpreadsheetDialog(); - void setProject(const Project * p_project); + void setProject(const Project *p_project); -public slots: - void doSimpleProteinPeptideList(bool simple); - void doProteinList(bool simple); - void doGroups(bool simple); - void doPeptidePos(bool simple); - void doComparEmpai(bool simple); - void doComparNsaf(bool simple); - void doComparPai(bool simple); - void doComparSpecificUniqueSequence(bool simple); - void doComparUniqueSequence(bool simple); - void doComparSpecificSpectra(bool simple); - void doComparSpectra(bool simple); - void doSamples(bool simple); - void doSpectra(bool simple); - void doPeptides(bool simple); - void doProteins(bool simple); - void doPtmIslands(bool simple); - void doPtmSpectra(bool simple); - -signals: + public slots: + void doSimpleProteinPeptideList(bool simple); + void doProteinList(bool simple); + void doGroups(bool simple); + void doPeptidePos(bool simple); + void doComparEmpai(bool simple); + void doComparNsaf(bool simple); + void doComparPai(bool simple); + void doComparSpecificUniqueSequence(bool simple); + void doComparUniqueSequence(bool simple); + void doComparSpecificSpectra(bool simple); + void doComparSpectra(bool simple); + void doSamples(bool simple); + void doSpectra(bool simple); + void doPeptides(bool simple); + void doProteins(bool simple); + void doPtmIslands(bool simple); + void doPtmSpectra(bool simple); -private: - Ui::ExportSpreadsheetDialog *ui; + signals: + private: + Ui::ExportSpreadsheetDialog *ui; }; #endif // EXPORTSPREADSHEETDIALOG_H diff --git a/src/gui/load_results_dialog/loadresultsdialog.cpp b/src/gui/load_results_dialog/loadresultsdialog.cpp index 5843021bd48bfad38011bd44ea5569bd749685b9..a83d1f34d03b9228f6c56cb03f4d22b350e4343f 100644 --- a/src/gui/load_results_dialog/loadresultsdialog.cpp +++ b/src/gui/load_results_dialog/loadresultsdialog.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 "loadresultsdialog.h" #include "ui_load_results_dialog.h" @@ -30,81 +31,104 @@ #include <pappsomspp/pappsoexception.h> -LoadResultsDialog::LoadResultsDialog(QWidget * parent): - QDialog(parent), - ui(new Ui::LoadResultsDialog) +LoadResultsDialog::LoadResultsDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::LoadResultsDialog) { - qDebug() << "LoadResultsDialog::LoadResultsDialog begin"; - ui->setupUi(this); - this->setModal(true); - _p_file_list = new QStringListModel(); - - QSettings settings; - AutomaticFilterParameters param = ui->automatic_filter_widget->getAutomaticFilterParameters(); - param.setFilterCrossSamplePeptideNumber(settings.value("automatic_filter/cross_sample", "true").toBool()); - param.setFilterMinimumPeptidePerMatch((unsigned int) settings.value("automatic_filter/peptide_number", "2").toInt()); - param.setFilterPeptideEvalue(settings.value("automatic_filter/peptide_evalue", "0.05").toDouble()); - param.setFilterProteinEvalue(settings.value("automatic_filter/protein_evalue", "0.01").toDouble()); - ui->automatic_filter_widget->setAutomaticFilterParameters(param); - + qDebug() << "LoadResultsDialog::LoadResultsDialog begin"; + ui->setupUi(this); + this->setModal(true); + _p_file_list = new QStringListModel(); + + QSettings settings; + AutomaticFilterParameters param = + ui->automatic_filter_widget->getAutomaticFilterParameters(); + param.setFilterCrossSamplePeptideNumber( + settings.value("automatic_filter/cross_sample", "true").toBool()); + param.setFilterMinimumPeptidePerMatch( + (unsigned int)settings.value("automatic_filter/peptide_number", "2") + .toInt()); + param.setFilterPeptideEvalue( + settings.value("automatic_filter/peptide_evalue", "0.05").toDouble()); + param.setFilterProteinEvalue( + settings.value("automatic_filter/protein_evalue", "0.01").toDouble()); + ui->automatic_filter_widget->setAutomaticFilterParameters(param); #if QT_VERSION >= 0x050000 - // Qt5 code + // Qt5 code #else -// Qt4 code + // Qt4 code #endif - qDebug() << "LoadResultsDialog::LoadResultsDialog end"; + qDebug() << "LoadResultsDialog::LoadResultsDialog end"; } LoadResultsDialog::~LoadResultsDialog() { - delete _p_file_list; - delete ui; + delete _p_file_list; + delete ui; } -bool LoadResultsDialog::isIndividual() const { - if (ui->individual_radio->isChecked()) { - return true; +bool +LoadResultsDialog::isIndividual() const +{ + if(ui->individual_radio->isChecked()) + { + return true; } } -QStringList LoadResultsDialog::getFileList() const { - return _p_file_list->stringList(); +QStringList +LoadResultsDialog::getFileList() const +{ + return _p_file_list->stringList(); } -AutomaticFilterParameters LoadResultsDialog::getAutomaticFilterParameters() const { - return ui->automatic_filter_widget->getAutomaticFilterParameters(); +AutomaticFilterParameters +LoadResultsDialog::getAutomaticFilterParameters() const +{ + return ui->automatic_filter_widget->getAutomaticFilterParameters(); } -void LoadResultsDialog::clearFileList() { - _p_file_list->removeRows( 0, _p_file_list->rowCount() ); +void +LoadResultsDialog::clearFileList() +{ + _p_file_list->removeRows(0, _p_file_list->rowCount()); } -void LoadResultsDialog::chooseFiles() { - try { - QSettings settings; - QString default_location = settings.value("path/identificationfiles", "").toString(); - - QStringList filenames = QFileDialog::getOpenFileNames(this,tr("identification files"),default_location, - tr("X!Tandem, Mascot DAT or mzIdentML files (*.xml *.mzid *.dat *.pepxml *.pepXML);;all files (*)") ); - - if (filenames.size() > 0) { - settings.setValue("path/identificationfiles", QFileInfo(filenames[0]).absolutePath()); +void +LoadResultsDialog::chooseFiles() +{ + try + { + QSettings settings; + QString default_location = + settings.value("path/identificationfiles", "").toString(); + + QStringList filenames = QFileDialog::getOpenFileNames( + this, tr("identification files"), default_location, + tr("X!Tandem, Mascot DAT or mzIdentML files (*.xml *.mzid *.dat " + "*.pepxml *.pepXML);;all files (*)")); + + if(filenames.size() > 0) + { + settings.setValue("path/identificationfiles", + QFileInfo(filenames[0]).absolutePath()); } - QStringList file_list = _p_file_list->stringList(); - file_list.append(filenames); - _p_file_list->setStringList(file_list); - ui->file_list_view->setModel(_p_file_list); - + QStringList file_list = _p_file_list->stringList(); + file_list.append(filenames); + _p_file_list->setStringList(file_list); + ui->file_list_view->setModel(_p_file_list); } - catch (pappso::PappsoException & error) { - //QMessageBox::warning(this, - // tr("Error choosing identification result files : %1").arg(error.qwhat()), error); + catch(pappso::PappsoException &error) + { + // QMessageBox::warning(this, + // tr("Error choosing identification result files : + // %1").arg(error.qwhat()), error); } } -void LoadResultsDialog::setProjectContaminants(Project * p_project) const { - ui->contaminant_widget->setProjectContaminants(p_project); +void +LoadResultsDialog::setProjectContaminants(Project *p_project) const +{ + ui->contaminant_widget->setProjectContaminants(p_project); } - diff --git a/src/gui/load_results_dialog/loadresultsdialog.h b/src/gui/load_results_dialog/loadresultsdialog.h index c4b7c9440b9ef053d20cfec430326232713ae352..613e058c2f3d273e1a51cb210692da82f4b2660e 100644 --- a/src/gui/load_results_dialog/loadresultsdialog.h +++ b/src/gui/load_results_dialog/loadresultsdialog.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 LOADRESULTSDIALOG_H #define LOADRESULTSDIALOG_H @@ -30,33 +31,33 @@ #include "../../core/project.h" -namespace Ui { -class LoadResultsDialog; +namespace Ui +{ + class LoadResultsDialog; } class LoadResultsDialog : public QDialog { - Q_OBJECT - -public: - explicit LoadResultsDialog(QWidget * parent); - ~LoadResultsDialog(); + Q_OBJECT - AutomaticFilterParameters getAutomaticFilterParameters() const; - QStringList getFileList() const; - bool isIndividual() const; - void setProjectContaminants(Project * p_project) const; -public slots: - void chooseFiles(); - void clearFileList(); + public: + explicit LoadResultsDialog(QWidget *parent); + ~LoadResultsDialog(); -signals: + AutomaticFilterParameters getAutomaticFilterParameters() const; + QStringList getFileList() const; + bool isIndividual() const; + void setProjectContaminants(Project *p_project) const; + public slots: + void chooseFiles(); + void clearFileList(); -private: - Ui::LoadResultsDialog *ui; - QStringListModel * _p_file_list; + signals: + private: + Ui::LoadResultsDialog *ui; + QStringListModel *_p_file_list; }; #endif // LOADRESULTSDIALOG_H diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 48d803e001abfdd596c1e4ae940b904c23c9d858..ee7bc639fd2815433814c06162028e4e957ad8d4 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #include <QSettings> #include <QFileDialog> @@ -36,527 +37,662 @@ #include "workerthread.h" #include "output/xpip.h" -MainWindow::MainWindow(QWidget *parent): - QMainWindow(parent), - ui(new Ui::Main) +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Main) { - _p_app = QCoreApplication::instance(); - ui->setupUi(this); - setWindowTitle(QString("%1 %2").arg(SOFTWARE_NAME).arg(XTPCPP_VERSION)); - setWindowIcon(QIcon(":/xtpcpp_icon/resources/xtandempipeline_icon.svg")); + _p_app = QCoreApplication::instance(); + ui->setupUi(this); + setWindowTitle(QString("%1 %2").arg(SOFTWARE_NAME).arg(XTPCPP_VERSION)); + setWindowIcon(QIcon(":/xtpcpp_icon/resources/xtandempipeline_icon.svg")); - WorkerThread *worker = new WorkerThread(this); - worker->moveToThread(&_worker_thread); - _worker_thread.start(); + WorkerThread *worker = new WorkerThread(this); + worker->moveToThread(&_worker_thread); + _worker_thread.start(); - _p_load_results_dialog = new LoadResultsDialog(this); - _p_export_spreadsheet_dialog = new ExportSpreadsheetDialog(this); - _p_waiting_message_dialog = new WaitingMessageDialog(this); - _p_tandem_run_dialog = new TandemRunDialog(this); + _p_load_results_dialog = new LoadResultsDialog(this); + _p_export_spreadsheet_dialog = new ExportSpreadsheetDialog(this); + _p_waiting_message_dialog = new WaitingMessageDialog(this); + _p_tandem_run_dialog = new TandemRunDialog(this); - _project_window = new ProjectWindow(this); + _project_window = new ProjectWindow(this); - ui->menu_export_files->setDisabled(true); - ui->centralwidget->layout()->addWidget(_project_window); - _project_window->hide(); - ui->action_save_project->setDisabled(true); - ui->default_display_widget->show(); - //_protein_list_window = new ProteinListWindow(this); - //QDockWidget *dock = new QDockWidget(tr("Protein List"), this); - //dock->setWidget(_protein_list_window); - //addDockWidget(Qt::RightDockWidgetArea, dock); + ui->menu_export_files->setDisabled(true); + ui->centralwidget->layout()->addWidget(_project_window); + _project_window->hide(); + ui->action_save_project->setDisabled(true); + ui->default_display_widget->show(); + //_protein_list_window = new ProteinListWindow(this); + // QDockWidget *dock = new QDockWidget(tr("Protein List"), this); + // dock->setWidget(_protein_list_window); + // addDockWidget(Qt::RightDockWidgetArea, dock); - qRegisterMetaType<ProjectSp>("ProjectSp"); - qRegisterMetaType<AutomaticFilterParameters>("AutomaticFilterParameters"); - qRegisterMetaType<GroupingType>("GroupingType"); + qRegisterMetaType<ProjectSp>("ProjectSp"); + qRegisterMetaType<AutomaticFilterParameters>("AutomaticFilterParameters"); + qRegisterMetaType<GroupingType>("GroupingType"); #if QT_VERSION >= 0x050000 - // Qt5 code - connect(_p_tandem_run_dialog, &TandemRunDialog::accepted, this, &MainWindow::doAcceptedTandemRunDialog); - connect(_p_load_results_dialog, &LoadResultsDialog::accepted, this,&MainWindow::doAcceptedLoadResultDialog); - connect(_p_export_spreadsheet_dialog, &ExportSpreadsheetDialog::accepted, this,&MainWindow::doAcceptedExportSpreadsheetDialog); + // Qt5 code + connect(_p_tandem_run_dialog, &TandemRunDialog::accepted, this, + &MainWindow::doAcceptedTandemRunDialog); + connect(_p_load_results_dialog, &LoadResultsDialog::accepted, this, + &MainWindow::doAcceptedLoadResultDialog); + connect(_p_export_spreadsheet_dialog, &ExportSpreadsheetDialog::accepted, + this, &MainWindow::doAcceptedExportSpreadsheetDialog); #else -// Qt4 code + // Qt4 code - connect(_p_tandem_run_dialog, SIGNAL(accepted()), this,SLOT(doAcceptedTandemRunDialog())); - connect(_p_load_results_dialog, SIGNAL(accepted()), this,SLOT(doAcceptedLoadResultDialog())); - connect(_p_export_spreadsheet_dialog, SIGNAL(accepted()), this,SLOT(doAcceptedExportSpreadsheetDialog())); + connect(_p_tandem_run_dialog, SIGNAL(accepted()), this, + SLOT(doAcceptedTandemRunDialog())); + connect(_p_load_results_dialog, SIGNAL(accepted()), this, + SLOT(doAcceptedLoadResultDialog())); + connect(_p_export_spreadsheet_dialog, SIGNAL(accepted()), this, + SLOT(doAcceptedExportSpreadsheetDialog())); #endif } MainWindow::~MainWindow() { - qDebug() << "MainWindow::~MainWindow"; - _worker_thread.quit(); - _worker_thread.wait(); - //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; - delete ui; - //delete _project_window; - delete _p_load_results_dialog; - delete _p_export_spreadsheet_dialog; - delete _p_waiting_message_dialog; - qDebug() << "MainWindow::~MainWindow end"; - -} - -bool MainWindow::stopWorkerThread() { - return _p_waiting_message_dialog->stopWorkerThread(); + qDebug() << "MainWindow::~MainWindow"; + _worker_thread.quit(); + _worker_thread.wait(); + // if (_p_ms_data_file != nullptr) delete _p_ms_data_file; + delete ui; + // delete _project_window; + delete _p_load_results_dialog; + delete _p_export_spreadsheet_dialog; + delete _p_waiting_message_dialog; + qDebug() << "MainWindow::~MainWindow end"; +} + +bool +MainWindow::stopWorkerThread() +{ + return _p_waiting_message_dialog->stopWorkerThread(); } -void MainWindow::closeEvent(QCloseEvent * event) { - if (true) { - event->accept(); - } else { - event->ignore(); +void +MainWindow::closeEvent(QCloseEvent *event) +{ + if(true) + { + event->accept(); + } + else + { + event->ignore(); } } -void MainWindow::viewError(QString error) { - hideWaitingMessage(); - QMessageBox::warning(this, - tr("Oops! an error occurred in XTPCPP. Dont Panic :"), error); +void +MainWindow::viewError(QString error) +{ + hideWaitingMessage(); + QMessageBox::warning( + this, tr("Oops! an error occurred in XTPCPP. Dont Panic :"), error); } -void MainWindow::doDisplayJobFinished(QString message) { - qDebug() << "MainWindow::doDisplayJobFinished " << message; - hideWaitingMessage(); - QMessageBox::information(this, - tr("job finished"), message); - - +void +MainWindow::doDisplayJobFinished(QString message) +{ + qDebug() << "MainWindow::doDisplayJobFinished " << message; + hideWaitingMessage(); + QMessageBox::information(this, tr("job finished"), message); } -void MainWindow::doDisplayLoadingMessage(QString message) { - qDebug() << "MainWindow::doDisplayLoadingMessage " << message; - _p_waiting_message_dialog->message(message); - ui->statusbar->showMessage(message); +void +MainWindow::doDisplayLoadingMessage(QString message) +{ + qDebug() << "MainWindow::doDisplayLoadingMessage " << message; + _p_waiting_message_dialog->message(message); + ui->statusbar->showMessage(message); } -void MainWindow::doDisplayLoadingMessagePercent(QString message, int value) { - qDebug() << "MainWindow::doDisplayLoadingMessagePercent " << message << " " << value; - _p_waiting_message_dialog->message(message, value); - ui->statusbar->showMessage(message); +void +MainWindow::doDisplayLoadingMessagePercent(QString message, int value) +{ + qDebug() << "MainWindow::doDisplayLoadingMessagePercent " << message << " " + << value; + _p_waiting_message_dialog->message(message, value); + ui->statusbar->showMessage(message); } -void MainWindow::doWorkerSetText(QString text) { - _p_waiting_message_dialog->setText(text); +void +MainWindow::doWorkerSetText(QString text) +{ + _p_waiting_message_dialog->setText(text); } -void MainWindow::doWorkerAppendText(char * text) { - _p_waiting_message_dialog->appendText(text); +void +MainWindow::doWorkerAppendText(char *text) +{ + _p_waiting_message_dialog->appendText(text); } -void MainWindow::doActionQuit() { - qDebug() << "MainWindow::doActionQuit begin"; - this->close(); +void +MainWindow::doActionQuit() +{ + qDebug() << "MainWindow::doActionQuit begin"; + this->close(); } -void MainWindow::doAcceptedExportSpreadsheetDialog() { - qDebug() << "MainWindow::doAcceptedExportSpreadsheetDialog begin"; - try { - QSettings settings; - QString default_location = settings.value("path/export_ods", "").toString(); - - QString filename = QFileDialog::getSaveFileName(this, tr("Save ODS file"), - QString("%1/untitled.ods").arg(default_location), - tr("Open Document Spreadsheet (*.ods)")); - - if (filename.isEmpty()) { - return; +void +MainWindow::doAcceptedExportSpreadsheetDialog() +{ + qDebug() << "MainWindow::doAcceptedExportSpreadsheetDialog begin"; + try + { + QSettings settings; + QString default_location = + settings.value("path/export_ods", "").toString(); + + QString filename = QFileDialog::getSaveFileName( + this, tr("Save ODS file"), + QString("%1/untitled.ods").arg(default_location), + tr("Open Document Spreadsheet (*.ods)")); + + if(filename.isEmpty()) + { + return; } - settings.setValue("path/export_ods", QFileInfo(filename).absolutePath()); + settings.setValue("path/export_ods", QFileInfo(filename).absolutePath()); - showWaitingMessage(tr("writing %1 ODS file").arg(QFileInfo(filename).fileName())); - emit operateWritingOdsFile(filename, _project_sp); - //emit operateXpipFile(filename); + showWaitingMessage( + tr("writing %1 ODS file").arg(QFileInfo(filename).fileName())); + emit operateWritingOdsFile(filename, _project_sp); + // emit operateXpipFile(filename); } - catch (pappso::PappsoException & error) { - viewError(tr("Error while writing ODS file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError(tr("Error while writing ODS file :\n%1").arg(error.qwhat())); } - qDebug() << "MainWindow::doAcceptedExportSpreadsheetDialog end"; + qDebug() << "MainWindow::doAcceptedExportSpreadsheetDialog end"; } -void MainWindow::doAcceptedTandemRunDialog() +void +MainWindow::doAcceptedTandemRunDialog() { - qDebug() << "MainWindow::doAcceptedTandemRunDialog begin"; - showWaitingMessage(tr("Running X!Tandem")); - emit operateRunningXtandem(_p_tandem_run_dialog->getTandemRunBatch()); - qDebug() << "MainWindow::doAcceptedTandemRunDialog end"; -} - -void MainWindow::doAcceptedLoadResultDialog() { - qDebug() << "MainWindow::doAcceptedLoadResultDialog begin"; - AutomaticFilterParameters param = _p_load_results_dialog->getAutomaticFilterParameters(); - QSettings settings; - settings.setValue("automatic_filter/cross_sample", QString("%1").arg(param.getFilterCrossSamplePeptideNumber())); - settings.setValue("automatic_filter/peptide_number", QString("%1").arg(param.getFilterMinimumPeptidePerMatch())); - settings.setValue("automatic_filter/peptide_evalue", QString("%1").arg(param.getFilterPeptideEvalue())); - settings.setValue("automatic_filter/protein_evalue", QString("%1").arg(param.getFilterProteinEvalue())); - - QStringList file_list = _p_load_results_dialog->getFileList(); - bool is_individual = _p_load_results_dialog->isIndividual(); - - showWaitingMessage(tr("Loading files")); - emit operateLoadingResults(is_individual, param, file_list); - qDebug() << "MainWindow::doAcceptedLoadResultDialog end"; + qDebug() << "MainWindow::doAcceptedTandemRunDialog begin"; + showWaitingMessage(tr("Running X!Tandem")); + emit operateRunningXtandem(_p_tandem_run_dialog->getTandemRunBatch()); + qDebug() << "MainWindow::doAcceptedTandemRunDialog end"; } -void MainWindow::doOperationFailed(QString error) { - hideWaitingMessage(); - viewError(error); +void +MainWindow::doAcceptedLoadResultDialog() +{ + qDebug() << "MainWindow::doAcceptedLoadResultDialog begin"; + AutomaticFilterParameters param = + _p_load_results_dialog->getAutomaticFilterParameters(); + QSettings settings; + settings.setValue( + "automatic_filter/cross_sample", + QString("%1").arg(param.getFilterCrossSamplePeptideNumber())); + settings.setValue("automatic_filter/peptide_number", + QString("%1").arg(param.getFilterMinimumPeptidePerMatch())); + settings.setValue("automatic_filter/peptide_evalue", + QString("%1").arg(param.getFilterPeptideEvalue())); + settings.setValue("automatic_filter/protein_evalue", + QString("%1").arg(param.getFilterProteinEvalue())); + + QStringList file_list = _p_load_results_dialog->getFileList(); + bool is_individual = _p_load_results_dialog->isIndividual(); + + showWaitingMessage(tr("Loading files")); + emit operateLoadingResults(is_individual, param, file_list); + qDebug() << "MainWindow::doAcceptedLoadResultDialog end"; +} + +void +MainWindow::doOperationFailed(QString error) +{ + hideWaitingMessage(); + viewError(error); } -void MainWindow::doOperationFinished() { - hideWaitingMessage(); +void +MainWindow::doOperationFinished() +{ + hideWaitingMessage(); } -void MainWindow::doGroupingFinished() { - hideWaitingMessage(); - _project_window->setProjectSp(_project_sp); - +void +MainWindow::doGroupingFinished() +{ + hideWaitingMessage(); + _project_window->setProjectSp(_project_sp); } -void MainWindow::doLoadingResultsReady(ProjectSp project_sp) { - qDebug() << "MainWindow::doLoadingResultsReady begin"; - if (_p_load_results_dialog != nullptr) { - _p_load_results_dialog->setProjectContaminants(project_sp.get()); +void +MainWindow::doLoadingResultsReady(ProjectSp project_sp) +{ + qDebug() << "MainWindow::doLoadingResultsReady begin"; + if(_p_load_results_dialog != nullptr) + { + _p_load_results_dialog->setProjectContaminants(project_sp.get()); } - doProjectReady(project_sp); - qDebug() << "MainWindow::doLoadingResultsReady end"; + doProjectReady(project_sp); + qDebug() << "MainWindow::doLoadingResultsReady end"; } -void MainWindow::doProjectReady(ProjectSp project_sp) { +void +MainWindow::doProjectReady(ProjectSp project_sp) +{ - qDebug() << "MainWindow::doProjectReady begin"; - qDebug() << "MainWindow::doProjectReady begin a " << project_sp.get()->getFastaFileStore().getFastaFileList().size() ; - _project_sp = project_sp; + qDebug() << "MainWindow::doProjectReady begin"; + qDebug() << "MainWindow::doProjectReady begin a " + << project_sp.get()->getFastaFileStore().getFastaFileList().size(); + _project_sp = project_sp; - qDebug() << "MainWindow::doProjectReady begin b " << _project_sp.get()->getFastaFileStore().getFastaFileList().size() ; + qDebug() << "MainWindow::doProjectReady begin b " + << _project_sp.get()->getFastaFileStore().getFastaFileList().size(); - showWaitingMessage(tr("grouping proteins")); - emit operateGrouping(project_sp); + showWaitingMessage(tr("grouping proteins")); + emit operateGrouping(project_sp); - ui->menu_export_files->setDisabled(false); - ui->menu_edit->setDisabled(false); + ui->menu_export_files->setDisabled(false); + ui->menu_edit->setDisabled(false); - _project_window->show(); - ui->default_display_widget->hide(); - ui->action_save_project->setDisabled(false); + _project_window->show(); + ui->default_display_widget->hide(); + ui->action_save_project->setDisabled(false); - qDebug() << "MainWindow::doProjectReady end"; + qDebug() << "MainWindow::doProjectReady end"; } -void MainWindow::doActionLabelingMethods () { - _project_window->editLabelingMethods(); +void +MainWindow::doActionLabelingMethods() +{ + _project_window->editLabelingMethods(); } -void MainWindow::doActionModifications() { - _project_window->editModifications(); +void +MainWindow::doActionModifications() +{ + _project_window->editModifications(); } -void MainWindow::doProjectNotReady(QString error) { - viewError(error); +void +MainWindow::doProjectNotReady(QString error) +{ + viewError(error); } -void MainWindow::doActionTandemRun() { - _p_tandem_run_dialog->show(); - _p_tandem_run_dialog->raise(); - _p_tandem_run_dialog->activateWindow(); +void +MainWindow::doActionTandemRun() +{ + _p_tandem_run_dialog->show(); + _p_tandem_run_dialog->raise(); + _p_tandem_run_dialog->activateWindow(); } -void MainWindow::loadResults() { - - _p_load_results_dialog->show(); - _p_load_results_dialog->raise(); - _p_load_results_dialog->activateWindow(); +void +MainWindow::loadResults() +{ + _p_load_results_dialog->show(); + _p_load_results_dialog->raise(); + _p_load_results_dialog->activateWindow(); } -void MainWindow::hideWaitingMessage() { +void +MainWindow::hideWaitingMessage() +{ - _p_waiting_message_dialog->hide(); - ui->statusbar->showMessage(""); + _p_waiting_message_dialog->hide(); + ui->statusbar->showMessage(""); } -void MainWindow::showWaitingMessage(const QString title) { - _p_waiting_message_dialog->setWindowTitle(title); - _p_waiting_message_dialog->show(); - _p_waiting_message_dialog->raise(); - _p_waiting_message_dialog->activateWindow(); - +void +MainWindow::showWaitingMessage(const QString title) +{ + _p_waiting_message_dialog->setWindowTitle(title); + _p_waiting_message_dialog->show(); + _p_waiting_message_dialog->raise(); + _p_waiting_message_dialog->activateWindow(); } -void MainWindow::selectXpipFile() { - try { - QSettings settings; - QString default_location = settings.value("path/xpipfile", "").toString(); +void +MainWindow::selectXpipFile() +{ + try + { + QSettings settings; + QString default_location = settings.value("path/xpipfile", "").toString(); - QString filename = QFileDialog::getOpenFileName(this, - tr("Open XPIP File"), default_location, - tr("xpip files (*.xpip);;all files (*)")); + QString filename = QFileDialog::getOpenFileName( + this, tr("Open XPIP File"), default_location, + tr("xpip files (*.xpip);;all files (*)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/xpipfile", QFileInfo(filename).absolutePath()); - showWaitingMessage(tr("Loading %1 XPIP file").arg(QFileInfo(filename).fileName())); - emit operateXpipFile(filename); + settings.setValue("path/xpipfile", QFileInfo(filename).absolutePath()); + showWaitingMessage( + tr("Loading %1 XPIP file").arg(QFileInfo(filename).fileName())); + emit operateXpipFile(filename); } - catch (pappso::PappsoException & error) { - viewError(tr("Error while reading XPIP file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError(tr("Error while reading XPIP file :\n%1").arg(error.qwhat())); } - } -void MainWindow::doActionSaveProject() { - try { - //QMessageBox::warning(this, - // tr("Experimental feature"), "WARNING : project files export is not ready"); - QSettings settings; - QString default_location = settings.value("path/xpipfile", "").toString(); +void +MainWindow::doActionSaveProject() +{ + try + { + // QMessageBox::warning(this, + // tr("Experimental feature"), "WARNING : project + // files export is not ready"); + QSettings settings; + QString default_location = settings.value("path/xpipfile", "").toString(); - QString filename = QFileDialog::getSaveFileName(this, tr("Save XPIP file"), - QString("%1/untitled.xpip").arg(default_location), - tr("XPIP (*.xpip)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save XPIP file"), + QString("%1/untitled.xpip").arg(default_location), tr("XPIP (*.xpip)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/xpipfile", QFileInfo(filename).absolutePath()); - showWaitingMessage(tr("Writing %1 XPIP file").arg(QFileInfo(filename).fileName())); - emit operateWritingXpipFile(filename, _project_sp); - + settings.setValue("path/xpipfile", QFileInfo(filename).absolutePath()); + showWaitingMessage( + tr("Writing %1 XPIP file").arg(QFileInfo(filename).fileName())); + emit operateWritingXpipFile(filename, _project_sp); } - catch (pappso::PappsoException & error) { - viewError(tr("Error while writing XPIP file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError(tr("Error while writing XPIP file :\n%1").arg(error.qwhat())); } - } -void MainWindow::doActionSpreadsheet() { - qDebug() << "MainWindow::doActionSpreadsheet begin"; - try { - if (_project_sp.get() != nullptr) { - _p_export_spreadsheet_dialog->setProject(_project_sp.get()); +void +MainWindow::doActionSpreadsheet() +{ + qDebug() << "MainWindow::doActionSpreadsheet begin"; + try + { + if(_project_sp.get() != nullptr) + { + _p_export_spreadsheet_dialog->setProject(_project_sp.get()); } - _p_export_spreadsheet_dialog->show(); - _p_export_spreadsheet_dialog->raise(); - _p_export_spreadsheet_dialog->activateWindow(); + _p_export_spreadsheet_dialog->show(); + _p_export_spreadsheet_dialog->raise(); + _p_export_spreadsheet_dialog->activateWindow(); } - catch (pappso::PappsoException & error) { - viewError(tr("Error doActionSpreadsheet :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError(tr("Error doActionSpreadsheet :\n%1").arg(error.qwhat())); } - qDebug() << "MainWindow::doActionSpreadsheet end"; + qDebug() << "MainWindow::doActionSpreadsheet end"; } -void MainWindow::doActionSpectralCountingMcq() +void +MainWindow::doActionSpectralCountingMcq() { - qDebug() << "MainWindow::doActionSpectralCountingMcq begin"; + qDebug() << "MainWindow::doActionSpectralCountingMcq begin"; - QSettings settings; - QString default_location = settings.value("path/scmcqfile", "").toString(); + QSettings settings; + QString default_location = settings.value("path/scmcqfile", "").toString(); - QString filename = QFileDialog::getSaveFileName(this, tr("Save spectral count TSV file"), - QString("%1/untitled.tsv").arg(default_location), - tr("TSV (*.tsv)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save spectral count TSV file"), + QString("%1/untitled.tsv").arg(default_location), tr("TSV (*.tsv)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/scmcqfile", QFileInfo(filename).absolutePath()); + settings.setValue("path/scmcqfile", QFileInfo(filename).absolutePath()); - showWaitingMessage(tr("Writing %1 spectral count file for MassChroqR").arg(QFileInfo(filename).fileName())); - emit operateWritingMcqrSpectralCountFile(filename, _project_sp); + showWaitingMessage(tr("Writing %1 spectral count file for MassChroqR") + .arg(QFileInfo(filename).fileName())); + emit operateWritingMcqrSpectralCountFile(filename, _project_sp); - qDebug() << "MainWindow::doActionSpectralCountingMcq end"; + qDebug() << "MainWindow::doActionSpectralCountingMcq end"; } -void MainWindow::doActionFasta() { - try { +void +MainWindow::doActionFasta() +{ + try + { - QSettings settings; - QString default_location = settings.value("path/fastafile", "").toString(); + QSettings settings; + QString default_location = + settings.value("path/fastafile", "").toString(); - QString filename = QFileDialog::getSaveFileName(this, tr("Save FASTA file"), - QString("%1/untitled.fasta").arg(default_location), - tr("FASTA (*.fasta)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save FASTA file"), + QString("%1/untitled.fasta").arg(default_location), + tr("FASTA (*.fasta)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/fastafile", QFileInfo(filename).absolutePath()); - - - - QFile outFile; - outFile.setFileName(filename); - outFile.open(QIODevice::WriteOnly); - QTextStream * p_outputStream = new QTextStream(&outFile); - - - pappso::FastaOutputStream fasta_output(*p_outputStream); - - for (IdentificationGroup * identification:_project_sp.get()->getIdentificationGroupList()) { - for (ProteinMatch * protein_match : identification->getProteinMatchList()) { - if (protein_match->getValidationState() >= ValidationState::grouped) { - pappso::Protein protein(QString("%1 %2").arg(protein_match->getProteinXtpSp().get()->getAccession()).arg(protein_match->getProteinXtpSp().get()->getDescription()),protein_match->getProteinXtpSp().get()->getSequence()); - fasta_output.writeProtein(protein); + settings.setValue("path/fastafile", QFileInfo(filename).absolutePath()); + + + QFile outFile; + outFile.setFileName(filename); + outFile.open(QIODevice::WriteOnly); + QTextStream *p_outputStream = new QTextStream(&outFile); + + + pappso::FastaOutputStream fasta_output(*p_outputStream); + + for(IdentificationGroup *identification : + _project_sp.get()->getIdentificationGroupList()) + { + for(ProteinMatch *protein_match : + identification->getProteinMatchList()) + { + if(protein_match->getValidationState() >= + ValidationState::grouped) + { + pappso::Protein protein( + QString("%1 %2") + .arg( + protein_match->getProteinXtpSp().get()->getAccession()) + .arg(protein_match->getProteinXtpSp() + .get() + ->getDescription()), + protein_match->getProteinXtpSp().get()->getSequence()); + fasta_output.writeProtein(protein); } } } - p_outputStream->flush(); - delete p_outputStream; - outFile.close(); - //emit operateXpipFile(filename); + p_outputStream->flush(); + delete p_outputStream; + outFile.close(); + // emit operateXpipFile(filename); } - catch (pappso::PappsoException & error) { - viewError(tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError( + tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); } } -void MainWindow::doActionMassChroQ() { - qDebug() << "MainWindow::doActionMassChroQ begin"; - try { - _project_sp.get()->checkPsimodCompliance(); +void +MainWindow::doActionMassChroQ() +{ + qDebug() << "MainWindow::doActionMassChroQ begin"; + try + { + _project_sp.get()->checkPsimodCompliance(); - QSettings settings; - QString default_location = settings.value("path/mcqfile", "").toString(); + QSettings settings; + QString default_location = settings.value("path/mcqfile", "").toString(); - QString filename = QFileDialog::getSaveFileName(this, tr("Save MassChroqML file"), - QString("%1/untitled.masschroqml").arg(default_location), - tr("MassChroqML (*.masschroqml)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save MassChroqML file"), + QString("%1/untitled.masschroqml").arg(default_location), + tr("MassChroqML (*.masschroqml)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/mcqfile", QFileInfo(filename).absolutePath()); + settings.setValue("path/mcqfile", QFileInfo(filename).absolutePath()); - showWaitingMessage(tr("Writing %1 MassChroqML file").arg(QFileInfo(filename).fileName())); - emit operateWritingMassChroqFile(filename, _project_sp); - //emit operateXpipFile(filename); + showWaitingMessage( + tr("Writing %1 MassChroqML file").arg(QFileInfo(filename).fileName())); + emit operateWritingMassChroqFile(filename, _project_sp); + // emit operateXpipFile(filename); } - catch (pappso::PappsoException & error) { - viewError(tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError( + tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); } - qDebug() << "MainWindow::doActionMassChroQ end"; + qDebug() << "MainWindow::doActionMassChroQ end"; } -void MainWindow::doActionMassChroqPRM() { - qDebug() << "MainWindow::doActionMassChroqPRM begin"; - try { - _project_sp.get()->checkPsimodCompliance(); +void +MainWindow::doActionMassChroqPRM() +{ + qDebug() << "MainWindow::doActionMassChroqPRM begin"; + try + { + _project_sp.get()->checkPsimodCompliance(); - QSettings settings; - QString default_location = settings.value("path/mcqprmfile", "").toString(); + QSettings settings; + QString default_location = + settings.value("path/mcqprmfile", "").toString(); - QString filename = QFileDialog::getSaveFileName(this, tr("Save MassChroqPRM file"), - QString("%1/untitled.masschroqprm").arg(default_location), - tr("MassChroqPRM (*.masschroqprm)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save MassChroqPRM file"), + QString("%1/untitled.masschroqprm").arg(default_location), + tr("MassChroqPRM (*.masschroqprm)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/mcqprmfile", QFileInfo(filename).absolutePath()); + settings.setValue("path/mcqprmfile", QFileInfo(filename).absolutePath()); - showWaitingMessage(tr("Writing %1 MassChroqPRM file").arg(QFileInfo(filename).fileName())); - emit operateWritingMassChroqPrmFile(filename, _project_sp); - //emit operateXpipFile(filename); + showWaitingMessage( + tr("Writing %1 MassChroqPRM file").arg(QFileInfo(filename).fileName())); + emit operateWritingMassChroqPrmFile(filename, _project_sp); + // emit operateXpipFile(filename); } - catch (pappso::PappsoException & error) { - viewError(tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError( + tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); } - qDebug() << "MainWindow::doActionMassChroqPRM end"; + qDebug() << "MainWindow::doActionMassChroqPRM end"; } -void MainWindow::doActionProticDb() { - qDebug() << "MainWindow::doActionProticDb begin"; - try { - _project_sp.get()->checkPsimodCompliance(); +void +MainWindow::doActionProticDb() +{ + qDebug() << "MainWindow::doActionProticDb begin"; + try + { + _project_sp.get()->checkPsimodCompliance(); - QSettings settings; - QString default_location = settings.value("path/proticfile", "").toString(); + QSettings settings; + QString default_location = + settings.value("path/proticfile", "").toString(); - QString filename = QFileDialog::getSaveFileName(this, tr("Save PROTICdbML file"), - QString("%1/untitled.proticdbml").arg(default_location), - tr("PROTICdbML (*.proticdbml)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save PROTICdbML file"), + QString("%1/untitled.proticdbml").arg(default_location), + tr("PROTICdbML (*.proticdbml)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/proticfile", QFileInfo(filename).absolutePath()); + settings.setValue("path/proticfile", QFileInfo(filename).absolutePath()); - showWaitingMessage(tr("Writing %1 PROTICdbML file").arg(QFileInfo(filename).fileName())); - emit operateWritingProticFile(filename, _project_sp); - //emit operateXpipFile(filename); + showWaitingMessage( + tr("Writing %1 PROTICdbML file").arg(QFileInfo(filename).fileName())); + emit operateWritingProticFile(filename, _project_sp); + // emit operateXpipFile(filename); } - catch (pappso::PappsoException & error) { - viewError(tr("Error while writing PROTICdbML file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + viewError( + tr("Error while writing PROTICdbML file :\n%1").arg(error.qwhat())); } - qDebug() << "MainWindow::doActionProticDb end"; + qDebug() << "MainWindow::doActionProticDb end"; } -void MainWindow::doActionAbout() { - qDebug() << "MainWindow::doActionAbout begin"; - if (_p_about_dialog == nullptr) { - _p_about_dialog = new AboutDialog(this); +void +MainWindow::doActionAbout() +{ + qDebug() << "MainWindow::doActionAbout begin"; + if(_p_about_dialog == nullptr) + { + _p_about_dialog = new AboutDialog(this); } - _p_about_dialog->show(); - _p_about_dialog->raise(); - _p_about_dialog->activateWindow(); + _p_about_dialog->show(); + _p_about_dialog->raise(); + _p_about_dialog->activateWindow(); - qDebug() << "MainWindow::doActionAbout end"; + qDebug() << "MainWindow::doActionAbout end"; } - - // 10ms after the application starts this method will run // all QT messaging is running at this point so threads, signals and slots // will all work as expected. -void MainWindow::run() +void +MainWindow::run() { - QTextStream errorStream(stderr, QIODevice::WriteOnly); + QTextStream errorStream(stderr, QIODevice::WriteOnly); - try { - qDebug() << "MainWindow::run() begin"; - QCommandLineParser parser; + try + { + qDebug() << "MainWindow::run() begin"; + QCommandLineParser parser; - //throw pappso::PappsoException("test"); - parser.setApplicationDescription(QString(SOFTWARE_NAME).append(" ").append(XTPCPP_VERSION)); - parser.addHelpOption(); - parser.addVersionOption(); - parser.addPositionalArgument("XPIP project file", QCoreApplication::translate("main", "Project file to open.")); + // throw pappso::PappsoException("test"); + parser.setApplicationDescription( + QString(SOFTWARE_NAME).append(" ").append(XTPCPP_VERSION)); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument( + "XPIP project file", + QCoreApplication::translate("main", "Project file to open.")); - qDebug() << "MainWindow::run() 1"; + qDebug() << "MainWindow::run() 1"; - // Process the actual command line arguments given by the user - parser.process(*_p_app); + // Process the actual command line arguments given by the user + parser.process(*_p_app); - QStringList xpip_list = parser.positionalArguments(); - if (xpip_list.size() > 0) { - showWaitingMessage(tr("Loading %1 XPIP file").arg(xpip_list.at(0))); - emit operateXpipFile(xpip_list.at(0)); + QStringList xpip_list = parser.positionalArguments(); + if(xpip_list.size() > 0) + { + showWaitingMessage(tr("Loading %1 XPIP file").arg(xpip_list.at(0))); + emit operateXpipFile(xpip_list.at(0)); } - } - catch (pappso::PappsoException& error) + catch(pappso::PappsoException &error) { - viewError(tr("Oops! an error occurred in X!TandemPipeline. Dont Panic :\n%1").arg(error.qwhat())); + viewError( + tr("Oops! an error occurred in X!TandemPipeline. Dont Panic :\n%1") + .arg(error.qwhat())); } - catch (std::exception& error) + catch(std::exception &error) { - viewError(tr("Oops! an error occurred in X!TandemPipeline. Dont Panic :\n%1").arg(error.what())); + viewError( + tr("Oops! an error occurred in X!TandemPipeline. Dont Panic :\n%1") + .arg(error.what())); } - - } diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 3aed2e9b0eefc7f8c6f3eb8f23467cbafca51314..e3dde336e878d55e5ffe043872c6c07c6f093a57 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef MAINWINDOW_H @@ -41,95 +42,95 @@ #include "core/tandem_run/tandemrunbatch.h" - -namespace Ui { -class Main; +namespace Ui +{ + class Main; } -class MainWindow: public QMainWindow { - Q_OBJECT - -public: - - explicit MainWindow(QWidget * parent = 0); - ~MainWindow(); - - /** @brief tells if the worker should stop running his job - * @param bool true asks to stop - */ - bool stopWorkerThread(); - -public slots: - void run(); - void loadResults(); - void selectXpipFile(); - void doActionAbout(); - void doActionQuit(); - void doActionFasta(); - void doActionMassChroQ(); - void doActionMassChroqPRM(); - void doActionProticDb(); - void doActionLabelingMethods(); - void doActionTandemRun(); - void doActionSpreadsheet(); - void doActionModifications(); - void doActionSaveProject(); - void doDisplayLoadingMessage(QString message); - void doDisplayLoadingMessagePercent(QString message, int value); - void doDisplayJobFinished(QString message); - void doWorkerAppendText(char *); - void doWorkerSetText(QString); - void doProjectReady(ProjectSp project_sp); - void doLoadingResultsReady(ProjectSp project_sp); - void doProjectNotReady(QString error); - void doAcceptedLoadResultDialog(); - void doAcceptedTandemRunDialog(); - void doAcceptedExportSpreadsheetDialog(); - void doOperationFailed(QString); - void doOperationFinished(); - void doGroupingFinished(); - void doActionSpectralCountingMcq(); - //void peptideEdited(QString peptideStr); - // void setColor(const QColor &color); - // void setShape(Shape shape); -signals: - //void peptideChanged(pappso::PeptideSp peptide); - void operateXpipFile(QString xpip_file); - void operateLoadingResults(bool is_individual, AutomaticFilterParameters param, QStringList file_list); - void operateWritingXpipFile(QString filename, ProjectSp project_sp); - void operateWritingOdsFile(QString filename, ProjectSp project_sp); - void operateWritingMassChroqFile(QString filename, ProjectSp project_sp); - void operateWritingMassChroqPrmFile(QString filename, ProjectSp project_sp); - void operateWritingProticFile(QString filename, ProjectSp project_sp); - void operateWritingMcqrSpectralCountFile(QString filename, ProjectSp project_sp); - void operateGrouping(ProjectSp project_sp); - void operateRunningXtandem(TandemRunBatch tandem_run_batch); - -protected: - - void closeEvent(QCloseEvent *event) override; - void setProjectSp(ProjectSp project_sp); - - -private: - - void showWaitingMessage(const QString title); - void hideWaitingMessage(); - void viewError(QString error); - -private : - QCoreApplication * _p_app; - Ui::Main *ui; - QThread _worker_thread; - ProjectSp _project_sp=nullptr; - - ProjectWindow * _project_window=nullptr; - LoadResultsDialog * _p_load_results_dialog=nullptr; - ExportSpreadsheetDialog * _p_export_spreadsheet_dialog; - WaitingMessageDialog * _p_waiting_message_dialog; - AboutDialog * _p_about_dialog=nullptr; - TandemRunDialog * _p_tandem_run_dialog=nullptr; - +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + + /** @brief tells if the worker should stop running his job + * @param bool true asks to stop + */ + bool stopWorkerThread(); + + public slots: + void run(); + void loadResults(); + void selectXpipFile(); + void doActionAbout(); + void doActionQuit(); + void doActionFasta(); + void doActionMassChroQ(); + void doActionMassChroqPRM(); + void doActionProticDb(); + void doActionLabelingMethods(); + void doActionTandemRun(); + void doActionSpreadsheet(); + void doActionModifications(); + void doActionSaveProject(); + void doDisplayLoadingMessage(QString message); + void doDisplayLoadingMessagePercent(QString message, int value); + void doDisplayJobFinished(QString message); + void doWorkerAppendText(char *); + void doWorkerSetText(QString); + void doProjectReady(ProjectSp project_sp); + void doLoadingResultsReady(ProjectSp project_sp); + void doProjectNotReady(QString error); + void doAcceptedLoadResultDialog(); + void doAcceptedTandemRunDialog(); + void doAcceptedExportSpreadsheetDialog(); + void doOperationFailed(QString); + void doOperationFinished(); + void doGroupingFinished(); + void doActionSpectralCountingMcq(); + // void peptideEdited(QString peptideStr); + // void setColor(const QColor &color); + // void setShape(Shape shape); + signals: + // void peptideChanged(pappso::PeptideSp peptide); + void operateXpipFile(QString xpip_file); + void operateLoadingResults(bool is_individual, + AutomaticFilterParameters param, + QStringList file_list); + void operateWritingXpipFile(QString filename, ProjectSp project_sp); + void operateWritingOdsFile(QString filename, ProjectSp project_sp); + void operateWritingMassChroqFile(QString filename, ProjectSp project_sp); + void operateWritingMassChroqPrmFile(QString filename, ProjectSp project_sp); + void operateWritingProticFile(QString filename, ProjectSp project_sp); + void operateWritingMcqrSpectralCountFile(QString filename, + ProjectSp project_sp); + void operateGrouping(ProjectSp project_sp); + void operateRunningXtandem(TandemRunBatch tandem_run_batch); + + protected: + void closeEvent(QCloseEvent *event) override; + void setProjectSp(ProjectSp project_sp); + + + private: + void showWaitingMessage(const QString title); + void hideWaitingMessage(); + void viewError(QString error); + + private: + QCoreApplication *_p_app; + Ui::Main *ui; + QThread _worker_thread; + ProjectSp _project_sp = nullptr; + + ProjectWindow *_project_window = nullptr; + LoadResultsDialog *_p_load_results_dialog = nullptr; + ExportSpreadsheetDialog *_p_export_spreadsheet_dialog; + WaitingMessageDialog *_p_waiting_message_dialog; + AboutDialog *_p_about_dialog = nullptr; + TandemRunDialog *_p_tandem_run_dialog = nullptr; }; #endif // MAINWINDOW_H diff --git a/src/gui/peptide_detail_view/peptidewindow.cpp b/src/gui/peptide_detail_view/peptidewindow.cpp index 9e8591291ce5fdc56aa8add50c3e7bb9a4556d6e..c4fcb4abb31a89b19adc27c22c6ea0b3e5e3ab84 100644 --- a/src/gui/peptide_detail_view/peptidewindow.cpp +++ b/src/gui/peptide_detail_view/peptidewindow.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 "peptidewindow.h" #include "../project_view/projectwindow.h" @@ -37,317 +38,424 @@ #include <QSpacerItem> -void SpectrumSpLoaderThread::doLoadSpectrumSp (PeptideEvidence * p_peptide_evidence) { - qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp begin"; - pappso::SpectrumSp spectrum; - try { - spectrum = p_peptide_evidence->getIdentificationDataSource()->getSpectrumSp(p_peptide_evidence->getScan()); - emit spectrumSpReady(spectrum, QString(""), QString("")); +void +SpectrumSpLoaderThread::doLoadSpectrumSp(PeptideEvidence *p_peptide_evidence) +{ + qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp begin"; + pappso::SpectrumSp spectrum; + try + { + spectrum = + p_peptide_evidence->getIdentificationDataSource()->getSpectrumSp( + p_peptide_evidence->getScan()); + emit spectrumSpReady(spectrum, QString(""), QString("")); } - catch (pappso::ExceptionNotFound & error) { - qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp error " << error.qwhat(); - emit spectrumSpReady(spectrum, error.qwhat(), QString("")); + catch(pappso::ExceptionNotFound &error) + { + qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp error " + << error.qwhat(); + emit spectrumSpReady(spectrum, error.qwhat(), QString("")); } - catch (pappso::PappsoException & error) { - qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp error " << error.qwhat(); - emit spectrumSpReady(spectrum, QString(""), error.qwhat()); + catch(pappso::PappsoException &error) + { + qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp error " + << error.qwhat(); + emit spectrumSpReady(spectrum, QString(""), error.qwhat()); } - catch (std::exception & error) { - qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp error " << error.what(); - emit spectrumSpReady(spectrum, QString(""), QString(error.what())); + catch(std::exception &error) + { + qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp error " + << error.what(); + emit spectrumSpReady(spectrum, QString(""), QString(error.what())); } - qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp end"; + qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp end"; } -PeptideWindow::PeptideWindow(ProjectWindow *parent): - QMainWindow(parent), - ui(new Ui::PeptideDetailView) +PeptideWindow::PeptideWindow(ProjectWindow *parent) + : QMainWindow(parent), ui(new Ui::PeptideDetailView) { - qDebug() << "PeptideWindow::PeptideWindow begin"; - _p_project_window = parent; - ui->setupUi(this); - /* - */ - SpectrumSpLoaderThread * worker = new SpectrumSpLoaderThread; - worker->moveToThread(&_spectrum_loader_thread); - _spectrum_loader_thread.start(); + qDebug() << "PeptideWindow::PeptideWindow begin"; + _p_project_window = parent; + ui->setupUi(this); + /* + */ + SpectrumSpLoaderThread *worker = new SpectrumSpLoaderThread; + worker->moveToThread(&_spectrum_loader_thread); + _spectrum_loader_thread.start(); - QSettings settings; - QString precision_str = settings.value("peptideview/precision", "0.2 dalton").toString(); + QSettings settings; + QString precision_str = + settings.value("peptideview/precision", "0.2 dalton").toString(); - _p_precision = pappso::Precision::fromString(precision_str); + _p_precision = pappso::Precision::fromString(precision_str); - ui->file_not_found->setVisible(false); + ui->file_not_found->setVisible(false); - _mz_label = new QLabel(""); - ui->statusbar->addWidget(_mz_label); - QWidget * p_spacer = new QWidget(); - p_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - ui->statusbar->addWidget(p_spacer); - _peak_label = new QLabel(""); - ui->statusbar->addWidget(_peak_label); - _ion_label = new QLabel(""); - ui->statusbar->addWidget(_ion_label); + _mz_label = new QLabel(""); + ui->statusbar->addWidget(_mz_label); + QWidget *p_spacer = new QWidget(); + p_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + ui->statusbar->addWidget(p_spacer); + _peak_label = new QLabel(""); + ui->statusbar->addWidget(_peak_label); + _ion_label = new QLabel(""); + ui->statusbar->addWidget(_ion_label); - ui->spectrum_widget->setMaximumIsotopeNumber(3); - ui->spectrum_widget->setMaximumIsotopeRank(6); + ui->spectrum_widget->setMaximumIsotopeNumber(3); + ui->spectrum_widget->setMaximumIsotopeRank(6); #if QT_VERSION >= 0x050000 - // Qt5 code - connect (_p_project_window, &ProjectWindow::identificationGroupGrouped, this,&PeptideWindow::doIdentificationGroupGrouped); - - connect (this, &PeptideWindow::loadSpectrumSp, worker,&SpectrumSpLoaderThread::doLoadSpectrumSp); - connect (worker, &SpectrumSpLoaderThread::spectrumSpReady, this,&PeptideWindow::doSpectrumSpReady); - connect (ui->spectrum_widget,&pappso::SpectrumWidget::mzChanged, this, &PeptideWindow::setMz); - connect (ui->spectrum_widget,&pappso::SpectrumWidget::peakChanged, this, &PeptideWindow::setPeak); - connect (ui->spectrum_widget,&pappso::SpectrumWidget::ionChanged, this, &PeptideWindow::setIon); + // Qt5 code + connect(_p_project_window, &ProjectWindow::identificationGroupGrouped, this, + &PeptideWindow::doIdentificationGroupGrouped); + + connect(this, &PeptideWindow::loadSpectrumSp, worker, + &SpectrumSpLoaderThread::doLoadSpectrumSp); + connect(worker, &SpectrumSpLoaderThread::spectrumSpReady, this, + &PeptideWindow::doSpectrumSpReady); + connect(ui->spectrum_widget, &pappso::SpectrumWidget::mzChanged, this, + &PeptideWindow::setMz); + connect(ui->spectrum_widget, &pappso::SpectrumWidget::peakChanged, this, + &PeptideWindow::setPeak); + connect(ui->spectrum_widget, &pappso::SpectrumWidget::ionChanged, this, + &PeptideWindow::setIon); #else -// Qt4 code - connect (_p_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - - connect (this, SIGNAL(loadSpectrumSp(PeptideMatch *)), worker,SLOT(doLoadSpectrumSp(PeptideMatch *))); - connect (worker, SIGNAL(spectrumSpReady(pappso::SpectrumSp, QString, QString)), this,SLOT(doSpectrumSpReady(pappso::SpectrumSp, QString, QString))); - connect (_p_spectrum_overlay,SIGNAL(mzChanged(double)), this, SLOT(setMz(double))); - //connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); + // Qt4 code + connect(_p_project_window, + SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this, + SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + + connect(this, SIGNAL(loadSpectrumSp(PeptideMatch *)), worker, + SLOT(doLoadSpectrumSp(PeptideMatch *))); + connect(worker, SIGNAL(spectrumSpReady(pappso::SpectrumSp, QString, QString)), + this, SLOT(doSpectrumSpReady(pappso::SpectrumSp, QString, QString))); + connect(_p_spectrum_overlay, SIGNAL(mzChanged(double)), this, + SLOT(setMz(double))); + // connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, + // SLOT(updateStatusBar())); #endif - qDebug() << "PeptideWindow::PeptideWindow end"; + qDebug() << "PeptideWindow::PeptideWindow end"; } PeptideWindow::~PeptideWindow() { - delete ui; + delete ui; } -void PeptideWindow::setIon(pappso::PeakIonIsotopeMatch ion) { - QString plusstr = "+"; - plusstr = plusstr.repeated(ion.getCharge()); - _ion_label->setText(QString("%1%2%3 (+%4) - th. isotope ratio %5%").arg(ion.getPeptideFragmentIonSp().get()->getPeptideIonName()).arg(ion.getPeptideFragmentIonSp().get()->size()).arg(plusstr).arg(ion.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber()).arg((int)(ion.getPeptideNaturalIsotopeAverageSp().get()->getIntensityRatio()*100))); - - +void +PeptideWindow::setIon(pappso::PeakIonIsotopeMatch ion) +{ + QString plusstr = "+"; + plusstr = plusstr.repeated(ion.getCharge()); + _ion_label->setText( + QString("%1%2%3 (+%4) - th. isotope ratio %5%") + .arg(ion.getPeptideFragmentIonSp().get()->getPeptideIonName()) + .arg(ion.getPeptideFragmentIonSp().get()->size()) + .arg(plusstr) + .arg(ion.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber()) + .arg((int)(ion.getPeptideNaturalIsotopeAverageSp() + .get() + ->getIntensityRatio() * + 100))); } -void PeptideWindow::setPeak(const pappso::Peak * p_peak_match) { - qDebug() << "PeptideWindow::setPeak begin" << p_peak_match; - if (p_peak_match == nullptr) { - _peak_label->setText(QString("no peak")); - _ion_label->setText(""); +void +PeptideWindow::setPeak(const pappso::Peak *p_peak_match) +{ + qDebug() << "PeptideWindow::setPeak begin" << p_peak_match; + if(p_peak_match == nullptr) + { + _peak_label->setText(QString("no peak")); + _ion_label->setText(""); } - else { - _peak_label->setText(QString("peak mz=%1 intensity=%2").arg(QString::number(p_peak_match->mz, 'g', 10)).arg(p_peak_match->intensity)); + else + { + _peak_label->setText(QString("peak mz=%1 intensity=%2") + .arg(QString::number(p_peak_match->mz, 'g', 10)) + .arg(p_peak_match->intensity)); } } -void PeptideWindow::setMz(double mz) { - if (mz >0 ) { - _mz_label->setText(QString("mz=%1").arg(QString::number(mz, 'g', 10))); +void +PeptideWindow::setMz(double mz) +{ + if(mz > 0) + { + _mz_label->setText(QString("mz=%1").arg(QString::number(mz, 'g', 10))); } - else { - _mz_label->setText(""); + else + { + _mz_label->setText(""); } } -void PeptideWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { - updateDisplay(); +void +PeptideWindow::doIdentificationGroupGrouped( + IdentificationGroup *p_identification_group) +{ + updateDisplay(); } -void PeptideWindow::updateDisplay() { - try { - ui->sequence_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->toString()); - ui->mz_label->setText(QString("%1").arg(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge()))); - ui->z_label->setText(QString("%1").arg(_p_peptide_evidence->getCharge())); - ui->scan_label->setText(QString("%1").arg(_p_peptide_evidence->getScan())); - ui->sample_label->setText(_p_peptide_evidence->getMsRunP()->getSampleName()); - ui->modification_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); - ui->hyperscore_label->setText(_p_peptide_evidence->getParam(PeptideEvidenceParam::tandem_hyperscore).toString()); - ui->evalue_label->setText(QString::number(_p_peptide_evidence->getEvalue(), 'g', 4)); - ui->mh_label->setText(QString::number(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(1), 'f', 4)); - ui->mz_label->setText(QString::number(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge()), 'f', 4)); - ui->expmz_label->setText(QString::number(_p_peptide_evidence->getExperimentalMz(), 'f', 4)); - ui->delta_label->setText(QString::number(_p_peptide_evidence->getDeltaMass(), 'g', 4)); - ui->retention_time_label->setText(QString::number(_p_peptide_evidence->getRetentionTime(), 'f', 2)); - ui->retention_time_min_label->setText(QString::number(_p_peptide_evidence->getRetentionTime()/60, 'f', 2)); - - +void +PeptideWindow::updateDisplay() +{ + try + { + ui->sequence_label->setText( + _p_peptide_evidence->getPeptideXtpSp().get()->toString()); + ui->mz_label->setText( + QString("%1").arg(_p_peptide_evidence->getPeptideXtpSp().get()->getMz( + _p_peptide_evidence->getCharge()))); + ui->z_label->setText(QString("%1").arg(_p_peptide_evidence->getCharge())); + ui->scan_label->setText( + QString("%1").arg(_p_peptide_evidence->getScan())); + ui->sample_label->setText( + _p_peptide_evidence->getMsRunP()->getSampleName()); + ui->modification_label->setText( + _p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); + ui->hyperscore_label->setText( + _p_peptide_evidence->getParam(PeptideEvidenceParam::tandem_hyperscore) + .toString()); + ui->evalue_label->setText( + QString::number(_p_peptide_evidence->getEvalue(), 'g', 4)); + ui->mh_label->setText(QString::number( + _p_peptide_evidence->getPeptideXtpSp().get()->getMz(1), 'f', 4)); + ui->mz_label->setText( + QString::number(_p_peptide_evidence->getPeptideXtpSp().get()->getMz( + _p_peptide_evidence->getCharge()), + 'f', 4)); + ui->expmz_label->setText( + QString::number(_p_peptide_evidence->getExperimentalMz(), 'f', 4)); + ui->delta_label->setText( + QString::number(_p_peptide_evidence->getDeltaMass(), 'g', 4)); + ui->retention_time_label->setText( + QString::number(_p_peptide_evidence->getRetentionTime(), 'f', 2)); + ui->retention_time_min_label->setText( + QString::number(_p_peptide_evidence->getRetentionTime() / 60, 'f', 2)); } - catch (pappso::PappsoException exception_pappso) { - QMessageBox::warning(this, - tr("Unable to display peptide details :"), exception_pappso.qwhat()); + catch(pappso::PappsoException exception_pappso) + { + QMessageBox::warning(this, tr("Unable to display peptide details :"), + exception_pappso.qwhat()); } - catch (std::exception exception_std) { - QMessageBox::warning(this, - tr("Unable to display peptide details :"), exception_std.what()); + catch(std::exception exception_std) + { + QMessageBox::warning(this, tr("Unable to display peptide details :"), + exception_std.what()); } - } -void PeptideWindow::chooseDefaultMzDataDir() { - QSettings settings; - QString default_location = settings.value("path/mzdatadir", "").toString(); +void +PeptideWindow::chooseDefaultMzDataDir() +{ + QSettings settings; + QString default_location = settings.value("path/mzdatadir", "").toString(); - QString filename = QFileDialog::getExistingDirectory(this, - tr("Choose default mz data directory"), default_location, - QFileDialog::ShowDirsOnly); + QString filename = QFileDialog::getExistingDirectory( + this, tr("Choose default mz data directory"), default_location, + QFileDialog::ShowDirsOnly); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - QString path = QFileInfo(filename).absoluteFilePath(); - settings.setValue("path/mzdatadir", path); - ui->mz_data_dir_label->setText(path); - + QString path = QFileInfo(filename).absoluteFilePath(); + settings.setValue("path/mzdatadir", path); + ui->mz_data_dir_label->setText(path); - qDebug() << "PeptideWindow::chooseDefaultMzDataDir begin"; - ui->file_not_found->setVisible(false); - ui->xic_button->setEnabled(true); - ui->spectrum_widget->setVisible(true); - emit loadSpectrumSp(_p_peptide_evidence); - ui->statusbar->showMessage(tr("loading spectrum")); + qDebug() << "PeptideWindow::chooseDefaultMzDataDir begin"; + ui->file_not_found->setVisible(false); + ui->xic_button->setEnabled(true); + ui->spectrum_widget->setVisible(true); + emit loadSpectrumSp(_p_peptide_evidence); + ui->statusbar->showMessage(tr("loading spectrum")); } -void PeptideWindow::openInPeptideViewer() { - QSettings settings; - QString program = settings.value("application/peptideviewer", "/usr/bin/pt-peptideviewer").toString(); - QStringList arguments; - arguments << _p_peptide_evidence->getPeptideXtpSp().get()->toString() << QString("%1").arg(_p_peptide_evidence->getCharge()) << _p_peptide_evidence->getMsRunP()->getFilename() << QString("%1").arg(_p_peptide_evidence->getScan()); - - qDebug() << "PeptideWindow::openInPeptideViewer " << program << " " << arguments.join(" "); - QProcess *myProcess = new QProcess(this); - myProcess->start(program, arguments); +void +PeptideWindow::openInPeptideViewer() +{ + QSettings settings; + QString program = + settings.value("application/peptideviewer", "/usr/bin/pt-peptideviewer") + .toString(); + QStringList arguments; + arguments << _p_peptide_evidence->getPeptideXtpSp().get()->toString() + << QString("%1").arg(_p_peptide_evidence->getCharge()) + << _p_peptide_evidence->getMsRunP()->getFilename() + << QString("%1").arg(_p_peptide_evidence->getScan()); + + qDebug() << "PeptideWindow::openInPeptideViewer " << program << " " + << arguments.join(" "); + QProcess *myProcess = new QProcess(this); + myProcess->start(program, arguments); } -void PeptideWindow::openInXicViewer() { - _p_project_window->openInXicViewer(_p_peptide_evidence); +void +PeptideWindow::openInXicViewer() +{ + _p_project_window->openInXicViewer(_p_peptide_evidence); } -void PeptideWindow::doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, QString fatal_error) { - qDebug() << "PeptideWindow::doSpectrumSpReady begin error=" << error << " fatal_error=" << fatal_error; - if ((error.isEmpty()) && (fatal_error.isEmpty())) { - ui->statusbar->showMessage(tr("")); - ui->file_not_found->setVisible(false); - ui->spectrum_widget->setVisible(true); - ui->xic_button->setEnabled(true); - - ui->spectrum_widget->setMsLevel(2); - ui->spectrum_widget->setSpectrumSp(spectrum_sp); - qDebug() << "PeptideWindow::doSpectrumSpReady plot"; - ui->spectrum_widget->plot(); - qDebug() << "PeptideWindow::doSpectrumSpReady rescale"; - ui->spectrum_widget->rescale(); - _spectrum_is_ready = true; - +void +PeptideWindow::doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, + QString fatal_error) +{ + qDebug() << "PeptideWindow::doSpectrumSpReady begin error=" << error + << " fatal_error=" << fatal_error; + if((error.isEmpty()) && (fatal_error.isEmpty())) + { + ui->statusbar->showMessage(tr("")); + ui->file_not_found->setVisible(false); + ui->spectrum_widget->setVisible(true); + ui->xic_button->setEnabled(true); + + ui->spectrum_widget->setMsLevel(2); + ui->spectrum_widget->setSpectrumSp(spectrum_sp); + qDebug() << "PeptideWindow::doSpectrumSpReady plot"; + ui->spectrum_widget->plot(); + qDebug() << "PeptideWindow::doSpectrumSpReady rescale"; + ui->spectrum_widget->rescale(); + _spectrum_is_ready = true; } - if (!error.isEmpty()) { - //not found + if(!error.isEmpty()) + { + // not found - ui->statusbar->showMessage(tr("spectrum not found")); - QSettings settings; - QString path = settings.value("path/mzdatadir", "").toString(); + ui->statusbar->showMessage(tr("spectrum not found")); + QSettings settings; + QString path = settings.value("path/mzdatadir", "").toString(); - ui->mz_data_dir_label->setText(path); + ui->mz_data_dir_label->setText(path); - ui->file_not_found->setVisible(true); - ui->spectrum_widget->setVisible(false); - ui->xic_button->setEnabled(false); - _spectrum_is_ready = false; + ui->file_not_found->setVisible(true); + ui->spectrum_widget->setVisible(false); + ui->xic_button->setEnabled(false); + _spectrum_is_ready = false; } - if (!fatal_error.isEmpty()) { - //fatal_error - - QMessageBox::warning(this, - tr("Oops! an error occurred in XTPCPP. Dont Panic :"), fatal_error); - ui->statusbar->showMessage(tr("ERROR reading spectrum")); - QSettings settings; - QString path = settings.value("path/mzdatadir", "").toString(); - - ui->mz_data_dir_label->setText(path); - - ui->file_not_found->setVisible(true); - ui->spectrum_widget->setVisible(false); - _spectrum_is_ready = false; + if(!fatal_error.isEmpty()) + { + // fatal_error + + QMessageBox::warning( + this, tr("Oops! an error occurred in XTPCPP. Dont Panic :"), + fatal_error); + ui->statusbar->showMessage(tr("ERROR reading spectrum")); + QSettings settings; + QString path = settings.value("path/mzdatadir", "").toString(); + + ui->mz_data_dir_label->setText(path); + + ui->file_not_found->setVisible(true); + ui->spectrum_widget->setVisible(false); + _spectrum_is_ready = false; } - qDebug() << "PeptideWindow::doSpectrumSpReady end"; - + qDebug() << "PeptideWindow::doSpectrumSpReady end"; } -void PeptideWindow::setPeptideEvidence(PeptideEvidence * p_peptide_evidence) { - qDebug() << "PeptideWindow::setPeptideEvidence begin " << p_peptide_evidence; - _p_peptide_evidence = p_peptide_evidence; - _spectrum_is_ready = false; - - qDebug() << "PeptideWindow::setPeptideEvidence 1"; - - ui->file_not_found->setVisible(false); - ui->spectrum_widget->setVisible(true); - ui->statusbar->showMessage(tr("loading spectrum")); - - qDebug() << "PeptideWindow::setPeptideEvidence 2"; - pappso::PeptideSp peptide = _p_peptide_evidence->getPeptideXtpSp(); - qDebug() << "PeptideWindow::setPeptideEvidence 3"; - ui->spectrum_widget->setMs2Precision(_p_precision); - ui->spectrum_widget->setPeptideCharge(_p_peptide_evidence->getCharge()); - ui->spectrum_widget->setPeptideSp(peptide); - - qDebug() << "PeptideWindow::setPeptideEvidence 4"; - //ui->spectrum_widget->plot(); - - updateDisplay(); - qDebug() << "PeptideWindow::setPeptideEvidence emit loadSpectrumSp(_p_peptide_match)"; - emit loadSpectrumSp(_p_peptide_evidence); - qDebug() << "PeptideWindow::setPeptideEvidence end"; +void +PeptideWindow::setPeptideEvidence(PeptideEvidence *p_peptide_evidence) +{ + qDebug() << "PeptideWindow::setPeptideEvidence begin " << p_peptide_evidence; + _p_peptide_evidence = p_peptide_evidence; + _spectrum_is_ready = false; + + qDebug() << "PeptideWindow::setPeptideEvidence 1"; + + ui->file_not_found->setVisible(false); + ui->spectrum_widget->setVisible(true); + ui->statusbar->showMessage(tr("loading spectrum")); + + qDebug() << "PeptideWindow::setPeptideEvidence 2"; + pappso::PeptideSp peptide = _p_peptide_evidence->getPeptideXtpSp(); + qDebug() << "PeptideWindow::setPeptideEvidence 3"; + ui->spectrum_widget->setMs2Precision(_p_precision); + ui->spectrum_widget->setPeptideCharge(_p_peptide_evidence->getCharge()); + ui->spectrum_widget->setPeptideSp(peptide); + + qDebug() << "PeptideWindow::setPeptideEvidence 4"; + // ui->spectrum_widget->plot(); + + updateDisplay(); + qDebug() << "PeptideWindow::setPeptideEvidence emit " + "loadSpectrumSp(_p_peptide_match)"; + emit loadSpectrumSp(_p_peptide_evidence); + qDebug() << "PeptideWindow::setPeptideEvidence end"; } -void PeptideWindow::doMsmsPrecisionChanged(pappso::PrecisionP precision) { +void +PeptideWindow::doMsmsPrecisionChanged(pappso::PrecisionP precision) +{ - qDebug() << "PeptideWindow::doMsmsPrecisionChanged begin " << precision->toString(); - QSettings settings; - _p_precision = precision; - ui->spectrum_widget->setMs2Precision(_p_precision); - qDebug() << "PeptideWindow::doMsmsPrecisionUnitChanged plot "; - ui->spectrum_widget->plot(); + qDebug() << "PeptideWindow::doMsmsPrecisionChanged begin " + << precision->toString(); + QSettings settings; + _p_precision = precision; + ui->spectrum_widget->setMs2Precision(_p_precision); + qDebug() << "PeptideWindow::doMsmsPrecisionUnitChanged plot "; + ui->spectrum_widget->plot(); - settings.setValue("peptideview/precision", precision->toString()); + settings.setValue("peptideview/precision", precision->toString()); - qDebug() << "PeptideWindow::doMsmsPrecisionUnitChanged end "; + qDebug() << "PeptideWindow::doMsmsPrecisionUnitChanged end "; } -void PeptideWindow::doSaveSvg() { - - try { - QSettings settings; - QString default_location = settings.value("path/export_svg", "").toString(); - - QString proposed_filename = QString("%1/%2_%3.svg").arg(default_location).arg(_p_peptide_evidence->getMsRunP()->getSampleName()).arg(_p_peptide_evidence->getScan()); +void +PeptideWindow::doSaveSvg() +{ - if (_p_peptide_evidence->getValidationState() == ValidationState::grouped) { - proposed_filename = QString("%1/%2_%3_%4.svg").arg(default_location).arg(_p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()).arg(_p_peptide_evidence->getMsRunP()->getSampleName()).arg(_p_peptide_evidence->getScan()); + try + { + QSettings settings; + QString default_location = + settings.value("path/export_svg", "").toString(); + + QString proposed_filename = + QString("%1/%2_%3.svg") + .arg(default_location) + .arg(_p_peptide_evidence->getMsRunP()->getSampleName()) + .arg(_p_peptide_evidence->getScan()); + + if(_p_peptide_evidence->getValidationState() == ValidationState::grouped) + { + proposed_filename = + QString("%1/%2_%3_%4.svg") + .arg(default_location) + .arg( + _p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()) + .arg(_p_peptide_evidence->getMsRunP()->getSampleName()) + .arg(_p_peptide_evidence->getScan()); } - QString filename = QFileDialog::getSaveFileName(this, tr("Save SVG file"), - proposed_filename, - tr("Scalable Vector Graphic (*.svg)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save SVG file"), proposed_filename, + tr("Scalable Vector Graphic (*.svg)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/export_svg", QFileInfo(filename).absolutePath()); + settings.setValue("path/export_svg", QFileInfo(filename).absolutePath()); - ui->spectrum_widget->toSvgFile(filename,tr("%1 SVG spectrum generator").arg(SOFTWARE_NAME), tr("This is an annotated SVG spectrum"), QSize(1200,500) ); - //emit operateXpipFile(filename); + ui->spectrum_widget->toSvgFile( + filename, tr("%1 SVG spectrum generator").arg(SOFTWARE_NAME), + tr("This is an annotated SVG spectrum"), QSize(1200, 500)); + // emit operateXpipFile(filename); } - catch (pappso::PappsoException & error) { - QMessageBox::warning(this, - tr("Error trying to save spectrum to SVG file :"), error.qwhat()); + catch(pappso::PappsoException &error) + { + QMessageBox::warning( + this, tr("Error trying to save spectrum to SVG file :"), error.qwhat()); } } diff --git a/src/gui/peptide_detail_view/peptidewindow.h b/src/gui/peptide_detail_view/peptidewindow.h index c165f164957649720ae2e4a072626d3073cd3fa1..cfc6e33a866a6b970232e131c751be087d14b80b 100644 --- a/src/gui/peptide_detail_view/peptidewindow.h +++ b/src/gui/peptide_detail_view/peptidewindow.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 PEPTIDEWINDOW_H #define PEPTIDEWINDOW_H @@ -35,72 +36,71 @@ class ProjectWindow; -namespace Ui { -class PeptideDetailView; +namespace Ui +{ + class PeptideDetailView; } class SpectrumSpLoaderThread : public QObject { - Q_OBJECT -public: - - -public slots: - void doLoadSpectrumSp(PeptideEvidence * p_peptide_evidence); - -signals: - void spectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, QString fatal_error); + Q_OBJECT + public: + public slots: + void doLoadSpectrumSp(PeptideEvidence *p_peptide_evidence); -protected: - - void closeEvent(QCloseEvent *event); + signals: + void spectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, + QString fatal_error); + protected: + void closeEvent(QCloseEvent *event); }; -class PeptideWindow: public QMainWindow { - Q_OBJECT - -public: - - explicit PeptideWindow(ProjectWindow * parent = 0); - ~PeptideWindow(); - void setPeptideEvidence(PeptideEvidence * p_peptide_evidence); - -public slots: - void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group); - void setMz(double); - void setPeak(const pappso::Peak * p_peak_match); - void setIon(pappso::PeakIonIsotopeMatch ion); - -signals: - void loadSpectrumSp(PeptideEvidence * p_peptide_evidence); - -protected slots: - void doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, QString fatal_error); - void doMsmsPrecisionChanged(pappso::PrecisionP); - void doSaveSvg(); - void chooseDefaultMzDataDir(); - void openInPeptideViewer(); - void openInXicViewer(); -protected : - void updateDisplay(); - -private: - - QThread _spectrum_loader_thread; - QLabel * _mz_label; - QLabel * _peak_label; - QLabel * _ion_label; - - Ui::PeptideDetailView *ui; - ProjectWindow * _p_project_window; - PeptideEvidence * _p_peptide_evidence = nullptr; - pappso::PrecisionP _p_precision; - - bool _spectrum_is_ready=false; - +class PeptideWindow : public QMainWindow +{ + Q_OBJECT + + public: + explicit PeptideWindow(ProjectWindow *parent = 0); + ~PeptideWindow(); + void setPeptideEvidence(PeptideEvidence *p_peptide_evidence); + + public slots: + void + doIdentificationGroupGrouped(IdentificationGroup *p_identification_group); + void setMz(double); + void setPeak(const pappso::Peak *p_peak_match); + void setIon(pappso::PeakIonIsotopeMatch ion); + + signals: + void loadSpectrumSp(PeptideEvidence *p_peptide_evidence); + + protected slots: + void doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, + QString fatal_error); + void doMsmsPrecisionChanged(pappso::PrecisionP); + void doSaveSvg(); + void chooseDefaultMzDataDir(); + void openInPeptideViewer(); + void openInXicViewer(); + + protected: + void updateDisplay(); + + private: + QThread _spectrum_loader_thread; + QLabel *_mz_label; + QLabel *_peak_label; + QLabel *_ion_label; + + Ui::PeptideDetailView *ui; + ProjectWindow *_p_project_window; + PeptideEvidence *_p_peptide_evidence = nullptr; + pappso::PrecisionP _p_precision; + + bool _spectrum_is_ready = false; }; #endif // PEPTIDEWINDOW_H diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h index aa2bea21b3fb15621b2e04ef6d2918dc9d52a8da..82addadd8757bfac6d28c98547af3114c3eef8ee 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.h +++ b/src/gui/peptide_list_view/peptidetablemodel.h @@ -68,7 +68,7 @@ enum class PeptideListColumn : std::int8_t msgfplus_energy = 30, ///< MS:1002051 "MS-GF energy score." [PSI:PI] msgfplus_SpecEValue = 31, ///< MS:1002052 "MS-GF spectral E-value." [PSI:PI] msgfplus_EValue = 32, ///< MS:1002053 "MS-GF E-value." [PSI:PI] - msgfplus_isotope_error = 33, ///< MS:1002053 "MS-GF E-value." [PSI:PI] + msgfplus_isotope_error = 33, ///< MS:1002053 "MS-GF E-value." [PSI:PI] comet_xcorr = 34, ///< MS:1002252 "The Comet result 'XCorr'." [PSI:PI] comet_deltacn = 35, ///< MS:1002253 "The Comet result 'DeltaCn'." [PSI:PI] comet_deltacnstar = diff --git a/src/gui/peptide_list_view/peptidetableproxymodel.cpp b/src/gui/peptide_list_view/peptidetableproxymodel.cpp index 6099b50b0b160d7c3b1dff58c784da6eb51d2cfd..3993cd41216919b5d97d242828271b8d9e6a68f6 100644 --- a/src/gui/peptide_list_view/peptidetableproxymodel.cpp +++ b/src/gui/peptide_list_view/peptidetableproxymodel.cpp @@ -43,10 +43,7 @@ PeptideTableProxyModel::PeptideTableProxyModel( for(std::size_t i = 0; i < _column_display.size(); i++) { _column_display[i] = - settings - .value(QString("peptide_list_columns/c%1") - .arg(i), - "true") + settings.value(QString("peptide_list_columns/c%1").arg(i), "true") .toBool(); } _mass_delegate = new MassItemDelegate(_p_peptide_list_window); @@ -380,9 +377,8 @@ PeptideTableProxyModel::setPeptideListColumnDisplay(PeptideListColumn column, << toggled; beginResetModel(); QSettings settings; - settings.setValue(QString("peptide_list_columns/c%1") - .arg((std::int8_t) column), - toggled); + settings.setValue( + QString("peptide_list_columns/c%1").arg((std::int8_t)column), toggled); _column_display[(std::int8_t)column] = toggled; endResetModel(); diff --git a/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp b/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp index 23304334f1d7211bc05602016cc2273c7b4af9e6..ac279cfd175267a5f3910cf46ca4e66874a5a4ad 100644 --- a/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp +++ b/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp @@ -1,86 +1,108 @@ /******************************************************************************* -* 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 "identificationgroupwidget.h" #include "ui_identification_group_widget.h" #include <QDebug> -IdentificationGroupWidget::IdentificationGroupWidget(QWidget * parent): - QWidget(parent), - ui(new Ui::IdentificationGroupWidget) +IdentificationGroupWidget::IdentificationGroupWidget(QWidget *parent) + : QWidget(parent), ui(new Ui::IdentificationGroupWidget) { - ui->setupUi(this); - qDebug() << "IdentificationGroupWidget::IdentificationGroupWidget begin"; + ui->setupUi(this); + qDebug() << "IdentificationGroupWidget::IdentificationGroupWidget begin"; - qDebug() << "IdentificationGroupWidget::IdentificationGroupWidget end"; + qDebug() << "IdentificationGroupWidget::IdentificationGroupWidget end"; } IdentificationGroupWidget::~IdentificationGroupWidget() { - qDebug() << "IdentificationGroupWidget::~IdentificationGroupWidget"; - delete ui; - qDebug() << "IdentificationGroupWidget::~IdentificationGroupWidget end"; + qDebug() << "IdentificationGroupWidget::~IdentificationGroupWidget"; + delete ui; + qDebug() << "IdentificationGroupWidget::~IdentificationGroupWidget end"; } -void IdentificationGroupWidget::setIdentificationGroup(ProjectWindow * parent, IdentificationGroup* p_identification_group) { - _p_identification_group = p_identification_group; - - _p_project_window = parent; +void +IdentificationGroupWidget::setIdentificationGroup( + ProjectWindow *parent, IdentificationGroup *p_identification_group) +{ + _p_identification_group = p_identification_group; + + _p_project_window = parent; #if QT_VERSION >= 0x050000 - // Qt5 code - connect (_p_project_window, &ProjectWindow::identificationGroupGrouped, this,&IdentificationGroupWidget::doIdentificationGroupGrouped); + // Qt5 code + connect(_p_project_window, &ProjectWindow::identificationGroupGrouped, this, + &IdentificationGroupWidget::doIdentificationGroupGrouped); #else -// Qt4 code + // Qt4 code - connect (_p_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + connect(_p_project_window, + SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this, + SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); #endif } -void IdentificationGroupWidget::doViewPtmIslandList() { - qDebug() << "IdentificationGroupWidget::doViewPtmIslandList begin " << _p_identification_group; - _p_project_window->doViewPtmIslandList(_p_identification_group); - qDebug() << "IdentificationGroupWidget::doViewPtmIslandList end"; +void +IdentificationGroupWidget::doViewPtmIslandList() +{ + qDebug() << "IdentificationGroupWidget::doViewPtmIslandList begin " + << _p_identification_group; + _p_project_window->doViewPtmIslandList(_p_identification_group); + qDebug() << "IdentificationGroupWidget::doViewPtmIslandList end"; } -void IdentificationGroupWidget::doViewProteinList() { - qDebug() << "IdentificationGroupWidget::doViewProteinList begin " << _p_identification_group; - _p_project_window->doViewProteinList(_p_identification_group); - qDebug() << "IdentificationGroupWidget::doViewProteinList end"; +void +IdentificationGroupWidget::doViewProteinList() +{ + qDebug() << "IdentificationGroupWidget::doViewProteinList begin " + << _p_identification_group; + _p_project_window->doViewProteinList(_p_identification_group); + qDebug() << "IdentificationGroupWidget::doViewProteinList end"; } -void IdentificationGroupWidget::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { - qDebug() << "IdentificationGroupWidget::doIdentificationGroupGrouped begin " << _p_identification_group << " " << p_identification_group; - if (_p_identification_group == p_identification_group) { - vector< MsRunSp > ms_run_list = _p_identification_group->getMsRunSpList(); - ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); +void +IdentificationGroupWidget::doIdentificationGroupGrouped( + IdentificationGroup *p_identification_group) +{ + qDebug() << "IdentificationGroupWidget::doIdentificationGroupGrouped begin " + << _p_identification_group << " " << p_identification_group; + if(_p_identification_group == p_identification_group) + { + vector<MsRunSp> ms_run_list = _p_identification_group->getMsRunSpList(); + ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); - ui->group_number_display->setText(QString("%1").arg(_p_identification_group->countGroup())); - ui->subgroup_number_display->setText(QString("%1").arg(_p_identification_group->countSubGroup())); - ui->protein_number_display->setText(QString("%1").arg(_p_identification_group->countProteinMatch(ValidationState::grouped))); - ui->grouped_peptide_display->setText(QString("%1").arg(_p_identification_group->countPeptideMass(ValidationState::grouped))); - _p_identification_group->countPeptideMatch(ValidationState::grouped); + ui->group_number_display->setText( + QString("%1").arg(_p_identification_group->countGroup())); + ui->subgroup_number_display->setText( + QString("%1").arg(_p_identification_group->countSubGroup())); + ui->protein_number_display->setText(QString("%1").arg( + _p_identification_group->countProteinMatch(ValidationState::grouped))); + ui->grouped_peptide_display->setText(QString("%1").arg( + _p_identification_group->countPeptideMass(ValidationState::grouped))); + _p_identification_group->countPeptideMatch(ValidationState::grouped); } - qDebug() << "IdentificationGroupWidget::doIdentificationGroupGrouped end " << _p_identification_group; + qDebug() << "IdentificationGroupWidget::doIdentificationGroupGrouped end " + << _p_identification_group; } diff --git a/src/gui/project_view/identification_group_widget/identificationgroupwidget.h b/src/gui/project_view/identification_group_widget/identificationgroupwidget.h index 79ff9a1f8376494f5b1d2344b29fb8689a19c7f3..94d03b4be10e66674a09776ee399a786e35ef7af 100644 --- a/src/gui/project_view/identification_group_widget/identificationgroupwidget.h +++ b/src/gui/project_view/identification_group_widget/identificationgroupwidget.h @@ -1,58 +1,61 @@ /******************************************************************************* -* 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 IDENTIFICATIONGROUPWIDGET_H #define IDENTIFICATIONGROUPWIDGET_H #include "../projectwindow.h" -namespace Ui { -class IdentificationGroupWidget; +namespace Ui +{ + class IdentificationGroupWidget; } class IdentificationGroupWidget : public QWidget { - Q_OBJECT + Q_OBJECT -public: + public: + explicit IdentificationGroupWidget(QWidget *parent); + ~IdentificationGroupWidget(); - explicit IdentificationGroupWidget(QWidget * parent); - ~IdentificationGroupWidget(); - -public: - void setIdentificationGroup(ProjectWindow * parent, IdentificationGroup* p_identification_group); + public: + void setIdentificationGroup(ProjectWindow *parent, + IdentificationGroup *p_identification_group); -public slots: - void doViewProteinList(); - void doViewPtmIslandList(); - void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group); + public slots: + void doViewProteinList(); + void doViewPtmIslandList(); + void + doIdentificationGroupGrouped(IdentificationGroup *p_identification_group); -private: - Ui::IdentificationGroupWidget *ui; - ProjectWindow *_p_project_window; - IdentificationGroup* _p_identification_group; + private: + Ui::IdentificationGroupWidget *ui; + ProjectWindow *_p_project_window; + IdentificationGroup *_p_identification_group; }; Q_DECLARE_METATYPE(IdentificationGroupWidget *) diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 7af5685639bf5792d2b475eb65621eba69332d27..b270acd287e5f5d5259587a88694a1d075a99745 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.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 "projectwindow.h" #include "ui_project_view.h" @@ -39,772 +40,963 @@ #include <qcustomplot.h> - -ProjectWindow::ProjectWindow(MainWindow *parent): - QMainWindow(parent), - ui(new Ui::ProjectView) +ProjectWindow::ProjectWindow(MainWindow *parent) + : QMainWindow(parent), ui(new Ui::ProjectView) { - main_window = parent; + main_window = parent; - ui->setupUi(this); - WorkerThread * p_worker = new WorkerThread(this); - p_worker->moveToThread(&_worker_thread); - _worker_thread.start(); + ui->setupUi(this); + WorkerThread *p_worker = new WorkerThread(this); + p_worker->moveToThread(&_worker_thread); + _worker_thread.start(); - _p_fasta_str_li = new QStandardItemModel(); - ui->decoy_database_listview->setModel(_p_fasta_str_li); - ui->decoy_database_listview->setSelectionMode(QAbstractItemView::MultiSelection); + _p_fasta_str_li = new QStandardItemModel(); + ui->decoy_database_listview->setModel(_p_fasta_str_li); + ui->decoy_database_listview->setSelectionMode( + QAbstractItemView::MultiSelection); - _p_edit_modifications = new EditModifications(this); - _p_edit_label_methods = new EditLabelMethods(this); - _p_waiting_message_dialog = new WaitingMessageDialog(this); + _p_edit_modifications = new EditModifications(this); + _p_edit_label_methods = new EditLabelMethods(this); + _p_waiting_message_dialog = new WaitingMessageDialog(this); - ui->mass_histogram_widget->xAxis->setLabel("mass delta"); - ui->mass_histogram_widget->yAxis->setLabel("count"); - ui->mass_histogram_widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom ); - ui->mass_histogram_widget->axisRects().at(0)->setRangeDrag(Qt::Horizontal); - ui->mass_histogram_widget->axisRects().at(0)->setRangeZoom(Qt::Horizontal); - //legend->setVisible(false); - ui->mass_histogram_widget->legend->setFont(QFont("Helvetica",9)); -// set locale to english, so we get english decimal separator: -//setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom)); - setFocusPolicy(Qt::ClickFocus); + ui->mass_histogram_widget->xAxis->setLabel("mass delta"); + ui->mass_histogram_widget->yAxis->setLabel("count"); + ui->mass_histogram_widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); + ui->mass_histogram_widget->axisRects().at(0)->setRangeDrag(Qt::Horizontal); + ui->mass_histogram_widget->axisRects().at(0)->setRangeZoom(Qt::Horizontal); + // legend->setVisible(false); + ui->mass_histogram_widget->legend->setFont(QFont("Helvetica", 9)); + // set locale to english, so we get english decimal separator: + // setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom)); + setFocusPolicy(Qt::ClickFocus); - QCPGraph * p_graph = ui->mass_histogram_widget->addGraph(); - //p_graph->setName("raw xic"); - //QPen pen; - //pen.setColor(getNewColors()); - //graph()->setPen(pen); - //graph()->setName(lineNames.at(i-QCPGraph::lsNone)); - p_graph->setLineStyle(QCPGraph::LineStyle::lsStepCenter); - //p_graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2.0)); + QCPGraph *p_graph = ui->mass_histogram_widget->addGraph(); + // p_graph->setName("raw xic"); + // QPen pen; + // pen.setColor(getNewColors()); + // graph()->setPen(pen); + // graph()->setName(lineNames.at(i-QCPGraph::lsNone)); + p_graph->setLineStyle(QCPGraph::LineStyle::lsStepCenter); + // p_graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2.0)); - QVBoxLayout * p_layout = new QVBoxLayout(); - ui->identifications_widget->setLayout(p_layout); + QVBoxLayout *p_layout = new QVBoxLayout(); + ui->identifications_widget->setLayout(p_layout); - ui->apply_filter_button->setEnabled(false); + ui->apply_filter_button->setEnabled(false); #if QT_VERSION >= 0x050000 - // Qt5 code - connect (ui->filter_parameter_widget, &AutomaticFilterWidget::automaticFilterParametersChanged, this,&ProjectWindow::doAutomaticFilterParametersChanged); - connect (ui->contaminant_widget, &ContaminantWidget::changed, this,&ProjectWindow::doContaminantSelectionChanged); + // Qt5 code + connect(ui->filter_parameter_widget, + &AutomaticFilterWidget::automaticFilterParametersChanged, this, + &ProjectWindow::doAutomaticFilterParametersChanged); + connect(ui->contaminant_widget, &ContaminantWidget::changed, this, + &ProjectWindow::doContaminantSelectionChanged); - connect(_p_edit_label_methods, &EditLabelMethods::accepted, this,&ProjectWindow::doAcceptedLabelingMethod); + connect(_p_edit_label_methods, &EditLabelMethods::accepted, this, + &ProjectWindow::doAcceptedLabelingMethod); #else -// Qt4 code - //connect (_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this //,SLOT(doProteinMatchClicked(ProteinMatch *))); - connect (_p_automatic_filter_widget, SIGNAL(automaticFilterParametersChanged(AutomaticFilterParameters)), this,SLOT(doAutomaticFilterParametersChanged(AutomaticFilterParameters))); - - connect(_p_edit_label_methods, SIGNAL(accepted()), this,SLOT(doAcceptedLabelingMethod())); - - //connect(this, SIGNAL(operateGrouping(ProjectSp)), p_worker,SLOT(doGrouping(ProjectSp))); + // Qt4 code + // connect (_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), + // this //,SLOT(doProteinMatchClicked(ProteinMatch *))); + connect(_p_automatic_filter_widget, + SIGNAL(automaticFilterParametersChanged(AutomaticFilterParameters)), + this, + SLOT(doAutomaticFilterParametersChanged(AutomaticFilterParameters))); + + connect(_p_edit_label_methods, SIGNAL(accepted()), this, + SLOT(doAcceptedLabelingMethod())); + + // connect(this, SIGNAL(operateGrouping(ProjectSp)), + // p_worker,SLOT(doGrouping(ProjectSp))); #endif - /* - */ - - this->setDisabled(true); - + /* + */ + this->setDisabled(true); } ProjectWindow::~ProjectWindow() { - qDebug() << "ProjectWindow::~ProjectWindow"; - - //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; - _worker_thread.quit(); - _worker_thread.wait(); - qDebug() << "ProjectWindow::~ProjectWindow1"; - delete ui; - qDebug() << "ProjectWindow::~ProjectWindow2"; - delete _p_fasta_str_li ; - qDebug() << "ProjectWindow::~ProjectWindow3"; - delete _p_edit_modifications; - qDebug() << "ProjectWindow::~ProjectWindow5"; - delete _p_edit_label_methods ; - qDebug() << "ProjectWindow::~ProjectWindow6"; - delete _p_waiting_message_dialog; - qDebug() << "ProjectWindow::~ProjectWindow end"; - - -} - -Project * ProjectWindow::getProjectP() { - return _project_sp.get(); -} -void ProjectWindow::setDefaultProteinListWindow(ProteinListWindow* p_protein_list_window) { - qDebug() << "ProjectWindow::setDefaultProteinListWindow begin"; - _p_current_protein_list_window = p_protein_list_window; - qDebug() << "ProjectWindow::setDefaultProteinListWindow end"; + qDebug() << "ProjectWindow::~ProjectWindow"; + + // if (_p_ms_data_file != nullptr) delete _p_ms_data_file; + _worker_thread.quit(); + _worker_thread.wait(); + qDebug() << "ProjectWindow::~ProjectWindow1"; + delete ui; + qDebug() << "ProjectWindow::~ProjectWindow2"; + delete _p_fasta_str_li; + qDebug() << "ProjectWindow::~ProjectWindow3"; + delete _p_edit_modifications; + qDebug() << "ProjectWindow::~ProjectWindow5"; + delete _p_edit_label_methods; + qDebug() << "ProjectWindow::~ProjectWindow6"; + delete _p_waiting_message_dialog; + qDebug() << "ProjectWindow::~ProjectWindow end"; +} + +Project * +ProjectWindow::getProjectP() +{ + return _project_sp.get(); } - -void ProjectWindow::connectNewPtmIslandListWindow() { - qDebug() << "ProjectWindow::connectNewPtmIslandListWindow begin"; - _p_current_ptm_island_list_window = new PtmIslandListWindow(this); - _ptm_island_list_window_collection.push_back(_p_current_ptm_island_list_window); - qDebug() << "ProjectWindow::connectNewPtmIslandListWindow end"; +void +ProjectWindow::setDefaultProteinListWindow( + ProteinListWindow *p_protein_list_window) +{ + qDebug() << "ProjectWindow::setDefaultProteinListWindow begin"; + _p_current_protein_list_window = p_protein_list_window; + qDebug() << "ProjectWindow::setDefaultProteinListWindow end"; } -void ProjectWindow::connectNewProteinListWindow() { - qDebug() << "ProjectWindow::connectNewProteinListWindow begin"; - _p_current_protein_list_window = new ProteinListWindow(this); - _protein_list_window_collection.push_back(_p_current_protein_list_window); +void +ProjectWindow::connectNewPtmIslandListWindow() +{ + qDebug() << "ProjectWindow::connectNewPtmIslandListWindow begin"; + _p_current_ptm_island_list_window = new PtmIslandListWindow(this); + _ptm_island_list_window_collection.push_back( + _p_current_ptm_island_list_window); + qDebug() << "ProjectWindow::connectNewPtmIslandListWindow end"; +} +void +ProjectWindow::connectNewProteinListWindow() +{ + qDebug() << "ProjectWindow::connectNewProteinListWindow begin"; + _p_current_protein_list_window = new ProteinListWindow(this); - qDebug() << "ProjectWindow::connectNewProteinListWindow end"; + _protein_list_window_collection.push_back(_p_current_protein_list_window); + qDebug() << "ProjectWindow::connectNewProteinListWindow end"; } -void ProjectWindow::connectNewProteinDetailWindow() { - qDebug() << "ProjectWindow::connectNewProteinDetailWindow begin"; - _p_current_protein_detail_window = new ProteinWindow(this); - _protein_detail_window_collection.push_back(_p_current_protein_detail_window); - - qDebug() << "ProjectWindow::connectNewProteinDetailWindow end"; +void +ProjectWindow::connectNewProteinDetailWindow() +{ + qDebug() << "ProjectWindow::connectNewProteinDetailWindow begin"; + _p_current_protein_detail_window = new ProteinWindow(this); + _protein_detail_window_collection.push_back(_p_current_protein_detail_window); + qDebug() << "ProjectWindow::connectNewProteinDetailWindow end"; } -void ProjectWindow::connectNewPeptideDetailWindow() { - qDebug() << "ProjectWindow::connectNewPeptideDetailWindow begin"; - _p_current_peptide_detail_window = new PeptideWindow(this); - _peptide_detail_window_collection.push_back(_p_current_peptide_detail_window); - - qDebug() << "ProjectWindow::connectNewPeptideDetailWindow end"; +void +ProjectWindow::connectNewPeptideDetailWindow() +{ + qDebug() << "ProjectWindow::connectNewPeptideDetailWindow begin"; + _p_current_peptide_detail_window = new PeptideWindow(this); + _peptide_detail_window_collection.push_back(_p_current_peptide_detail_window); + qDebug() << "ProjectWindow::connectNewPeptideDetailWindow end"; } -void ProjectWindow::connectNewPeptideListWindow() { - qDebug() << "ProjectWindow::connectNewPeptideListWindow begin"; - _p_current_peptide_list_window = new PeptideListWindow(this); - _peptide_list_window_collection.push_back(_p_current_peptide_list_window); - - qDebug() << "ProjectWindow::connectNewPeptideListWindow end"; +void +ProjectWindow::connectNewPeptideListWindow() +{ + qDebug() << "ProjectWindow::connectNewPeptideListWindow begin"; + _p_current_peptide_list_window = new PeptideListWindow(this); + _peptide_list_window_collection.push_back(_p_current_peptide_list_window); + qDebug() << "ProjectWindow::connectNewPeptideListWindow end"; } -void ProjectWindow::refreshPtmGroup(IdentificationGroup * p_ident_group) { - qDebug() << "ProjectWindow::refreshPtmGroup begin"; - hideWaitingMessage(); - if (p_ident_group == nullptr) { - qDebug() << "ProjectWindow::refreshPtmGroup p_ident_group == nullptr"; - } - else { - try { - emit identificationPtmGroupGrouped(p_ident_group); +void +ProjectWindow::refreshPtmGroup(IdentificationGroup *p_ident_group) +{ + qDebug() << "ProjectWindow::refreshPtmGroup begin"; + hideWaitingMessage(); + if(p_ident_group == nullptr) + { + qDebug() << "ProjectWindow::refreshPtmGroup p_ident_group == nullptr"; + } + else + { + try + { + emit identificationPtmGroupGrouped(p_ident_group); } - catch (pappso::PappsoException exception_pappso) { - QMessageBox::warning(this, - tr("Unable to display project :"), exception_pappso.qwhat()); + catch(pappso::PappsoException exception_pappso) + { + QMessageBox::warning(this, tr("Unable to display project :"), + exception_pappso.qwhat()); } - catch (std::exception exception_std) { - QMessageBox::warning(this, - tr("Unable to display project :"), exception_std.what()); + catch(std::exception exception_std) + { + QMessageBox::warning(this, tr("Unable to display project :"), + exception_std.what()); } } - qDebug() << "ProjectWindow::refreshPtmGroup end"; + qDebug() << "ProjectWindow::refreshPtmGroup end"; } -void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) { - qDebug() << "ProjectWindow::refreshGroup begin"; - hideWaitingMessage(); - if (p_ident_group == nullptr) { - qDebug() << "ProjectWindow::refreshGroup p_ident_group == nullptr"; - } - else { - try { - emit identificationGroupGrouped(p_ident_group); +void +ProjectWindow::refreshGroup(IdentificationGroup *p_ident_group) +{ + qDebug() << "ProjectWindow::refreshGroup begin"; + hideWaitingMessage(); + if(p_ident_group == nullptr) + { + qDebug() << "ProjectWindow::refreshGroup p_ident_group == nullptr"; + } + else + { + try + { + emit identificationGroupGrouped(p_ident_group); } - catch (pappso::PappsoException exception_pappso) { - QMessageBox::warning(this, - tr("Unable to display project :"), exception_pappso.qwhat()); + catch(pappso::PappsoException exception_pappso) + { + QMessageBox::warning(this, tr("Unable to display project :"), + exception_pappso.qwhat()); } - catch (std::exception exception_std) { - QMessageBox::warning(this, - tr("Unable to display project :"), exception_std.what()); + catch(std::exception exception_std) + { + QMessageBox::warning(this, tr("Unable to display project :"), + exception_std.what()); } } - qDebug() << "ProjectWindow::refreshGroup end"; -} - -void ProjectWindow::computeFdr() { - qDebug() << "ProjectWindow::computeFdr begin "; - try { - ValidationState state = ValidationState::valid; - pappso::pappso_double total_prot=0; - pappso::pappso_double false_prot=0; - pappso::pappso_double total_peptide=0; - pappso::pappso_double false_peptide=0; - for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) { - total_prot += identification_group->countProteinMatch(state); - false_prot += identification_group->countDecoyProteinMatch(state); - total_peptide += identification_group->countPeptideEvidence(state); - false_peptide += identification_group->countDecoyPeptideEvidence(state); - } - ui->protein_fdr_label->setText(QString("%1 %").arg(QString::number((false_prot/total_prot)*100.0,'f',2))); - ui->peptide_fdr_label->setText(QString("%1 %").arg(QString::number((false_peptide/total_peptide)*100.0,'f',2))); + qDebug() << "ProjectWindow::refreshGroup end"; +} +void +ProjectWindow::computeFdr() +{ + qDebug() << "ProjectWindow::computeFdr begin "; + try + { + ValidationState state = ValidationState::valid; + pappso::pappso_double total_prot = 0; + pappso::pappso_double false_prot = 0; + pappso::pappso_double total_peptide = 0; + pappso::pappso_double false_peptide = 0; + for(IdentificationGroup *identification_group : + _project_sp.get()->getIdentificationGroupList()) + { + total_prot += identification_group->countProteinMatch(state); + false_prot += identification_group->countDecoyProteinMatch(state); + total_peptide += identification_group->countPeptideEvidence(state); + false_peptide += + identification_group->countDecoyPeptideEvidence(state); + } + ui->protein_fdr_label->setText(QString("%1 %").arg( + QString::number((false_prot / total_prot) * 100.0, 'f', 2))); + ui->peptide_fdr_label->setText(QString("%1 %").arg( + QString::number((false_peptide / total_peptide) * 100.0, 'f', 2))); } - catch (pappso::PappsoException exception_pappso) { - QMessageBox::warning(this, - tr("Unable to compute FDR :"), exception_pappso.qwhat()); + catch(pappso::PappsoException exception_pappso) + { + QMessageBox::warning(this, tr("Unable to compute FDR :"), + exception_pappso.qwhat()); } - catch (std::exception exception_std) { - QMessageBox::warning(this, - tr("Unable to compute FDR :"), exception_std.what()); + catch(std::exception exception_std) + { + QMessageBox::warning(this, tr("Unable to compute FDR :"), + exception_std.what()); } - qDebug() << "ProjectWindow::computeFdr end"; + qDebug() << "ProjectWindow::computeFdr end"; } -void ProjectWindow::computeMassPrecision() { - qDebug() << "ProjectWindow::computeMassPrecision begin"; - try { - ValidationState state = ValidationState::validAndChecked; - std::vector< pappso::pappso_double> delta_list; - pappso::PrecisionUnit unit = pappso::PrecisionUnit::dalton; - if (ui->precision_unit_combobox->currentText() == "ppm") { - unit = pappso::PrecisionUnit::ppm; +void +ProjectWindow::computeMassPrecision() +{ + qDebug() << "ProjectWindow::computeMassPrecision begin"; + try + { + ValidationState state = ValidationState::validAndChecked; + std::vector<pappso::pappso_double> delta_list; + pappso::PrecisionUnit unit = pappso::PrecisionUnit::dalton; + if(ui->precision_unit_combobox->currentText() == "ppm") + { + unit = pappso::PrecisionUnit::ppm; } - for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) { - identification_group->collectMhDelta(delta_list, unit, state); + for(IdentificationGroup *identification_group : + _project_sp.get()->getIdentificationGroupList()) + { + identification_group->collectMhDelta(delta_list, unit, state); } - qDebug() << "ProjectWindow::computeMassPrecision accumulate"; - pappso::pappso_double sum = std::accumulate(delta_list.begin(), delta_list.end(), 0); + qDebug() << "ProjectWindow::computeMassPrecision accumulate"; + pappso::pappso_double sum = + std::accumulate(delta_list.begin(), delta_list.end(), 0); - qDebug() << "ProjectWindow::computeMassPrecision delta_list.size()=" << delta_list.size(); - pappso::pappso_double mean = 0; - if (delta_list.size() > 0) { - mean = sum / ((pappso::pappso_double) delta_list.size()); + qDebug() << "ProjectWindow::computeMassPrecision delta_list.size()=" + << delta_list.size(); + pappso::pappso_double mean = 0; + if(delta_list.size() > 0) + { + mean = sum / ((pappso::pappso_double)delta_list.size()); } - else { - throw pappso::PappsoException(QObject::tr("division by zero : no valid peptide found. Please check your filter parameters (decoy regexp or database particularly)")); + else + { + throw pappso::PappsoException(QObject::tr( + "division by zero : no valid peptide found. Please check your " + "filter parameters (decoy regexp or database particularly)")); } - std::sort(delta_list.begin(), delta_list.end()); - pappso::pappso_double median = delta_list[(delta_list.size()/2)]; + std::sort(delta_list.begin(), delta_list.end()); + pappso::pappso_double median = delta_list[(delta_list.size() / 2)]; - qDebug() << "ProjectWindow::computeMassPrecision sd"; - pappso::pappso_double sd = 0; - for (pappso::pappso_double val : delta_list) { - //sd = sd + ((val - mean) * (val - mean)); - sd += std::pow((val - mean), 2); + qDebug() << "ProjectWindow::computeMassPrecision sd"; + pappso::pappso_double sd = 0; + for(pappso::pappso_double val : delta_list) + { + // sd = sd + ((val - mean) * (val - mean)); + sd += std::pow((val - mean), 2); } - sd = sd / delta_list.size(); - sd = std::sqrt(sd); + sd = sd / delta_list.size(); + sd = std::sqrt(sd); - ui->mass_precision_mean_label->setText(QString::number(mean,'f',10)); - ui->mass_precision_median_label->setText(QString::number(median,'f',10)); - ui->mass_precision_sd_label->setText(QString::number(sd,'f',10)); + ui->mass_precision_mean_label->setText(QString::number(mean, 'f', 10)); + ui->mass_precision_median_label->setText( + QString::number(median, 'f', 10)); + ui->mass_precision_sd_label->setText(QString::number(sd, 'f', 10)); - std::vector< std::pair<pappso::pappso_double, size_t >> histogram = Utils::getHistogram(delta_list, 100); - // generate some data: - QVector<double> x, y; - for (std::pair<pappso::pappso_double, size_t > & mass_pair: histogram) + std::vector<std::pair<pappso::pappso_double, size_t>> histogram = + Utils::getHistogram(delta_list, 100); + // generate some data: + QVector<double> x, y; + for(std::pair<pappso::pappso_double, size_t> &mass_pair : histogram) { - x.push_back(mass_pair.first); - y.push_back(mass_pair.second); + x.push_back(mass_pair.first); + y.push_back(mass_pair.second); } - QCPGraph * p_graph = ui->mass_histogram_widget->graph(); - p_graph->setData(x,y); - p_graph->rescaleAxes(true); - ui->mass_histogram_widget->rescaleAxes(); - ui->mass_histogram_widget->replot(); - } - catch (pappso::PappsoException exception_pappso) { - ui->mass_precision_mean_label->setText("0"); - ui->mass_precision_median_label->setText("0"); - ui->mass_precision_sd_label->setText("0"); - QMessageBox::warning(this, - tr("Unable to compute mass precision :"), exception_pappso.qwhat()); - } - catch (std::exception exception_std) { - ui->mass_precision_mean_label->setText("0"); - ui->mass_precision_median_label->setText("0"); - ui->mass_precision_sd_label->setText("0"); - QMessageBox::warning(this, - tr("Unable to compute mass precision :"), exception_std.what()); - } - qDebug() << "ProjectWindow::computeMassPrecision end"; -} - -void ProjectWindow::doFdrChanged() { - qDebug() << "ProjectWindow::doFdrChanged begin "; - try { - showWaitingMessage(tr("FDR modifications")); - doDisplayLoadingMessage(tr("tagging decoy proteins")); - if (ui->decoy_regexp_radiobutton->isChecked()) { - _project_sp.get()->getProteinStore().setRegexpDecoyPattern(ui->decoy_protein_regexp_line_edit->text()); + QCPGraph *p_graph = ui->mass_histogram_widget->graph(); + p_graph->setData(x, y); + p_graph->rescaleAxes(true); + ui->mass_histogram_widget->rescaleAxes(); + ui->mass_histogram_widget->replot(); + } + catch(pappso::PappsoException exception_pappso) + { + ui->mass_precision_mean_label->setText("0"); + ui->mass_precision_median_label->setText("0"); + ui->mass_precision_sd_label->setText("0"); + QMessageBox::warning(this, tr("Unable to compute mass precision :"), + exception_pappso.qwhat()); + } + catch(std::exception exception_std) + { + ui->mass_precision_mean_label->setText("0"); + ui->mass_precision_median_label->setText("0"); + ui->mass_precision_sd_label->setText("0"); + QMessageBox::warning(this, tr("Unable to compute mass precision :"), + exception_std.what()); + } + qDebug() << "ProjectWindow::computeMassPrecision end"; +} + +void +ProjectWindow::doFdrChanged() +{ + qDebug() << "ProjectWindow::doFdrChanged begin "; + try + { + showWaitingMessage(tr("FDR modifications")); + doDisplayLoadingMessage(tr("tagging decoy proteins")); + if(ui->decoy_regexp_radiobutton->isChecked()) + { + _project_sp.get()->getProteinStore().setRegexpDecoyPattern( + ui->decoy_protein_regexp_line_edit->text()); } - else { - _project_sp.get()->getProteinStore().clearDecoys(); - QModelIndexList index_list = ui->decoy_database_listview->selectionModel()->selectedIndexes(); - if (index_list.size() > 0) { - qDebug() << "ProjectWindow::doFdrChanged index_list.size()=" << index_list.size(); - for (QModelIndex index :index_list) { - if (index.data(Qt::UserRole).canConvert<FastaFile *>()) { - FastaFile * p_fasta_file = index.data(Qt::UserRole).value<FastaFile *>(); - p_fasta_file->setDecoys(_project_sp.get()->getProteinStore()); + else + { + _project_sp.get()->getProteinStore().clearDecoys(); + QModelIndexList index_list = + ui->decoy_database_listview->selectionModel()->selectedIndexes(); + if(index_list.size() > 0) + { + qDebug() << "ProjectWindow::doFdrChanged index_list.size()=" + << index_list.size(); + for(QModelIndex index : index_list) + { + if(index.data(Qt::UserRole).canConvert<FastaFile *>()) + { + FastaFile *p_fasta_file = + index.data(Qt::UserRole).value<FastaFile *>(); + p_fasta_file->setDecoys( + _project_sp.get()->getProteinStore()); } - else { - throw pappso::PappsoException(QObject::tr("can not convert to FastaFile index.data().canConvert<FastaFile *>()")); + else + { + throw pappso::PappsoException( + QObject::tr("can not convert to FastaFile " + "index.data().canConvert<FastaFile *>()")); } } } } - doDisplayLoadingMessage(tr("updating filters")); - _project_sp.get()->updateAutomaticFilters(_project_sp.get()->getAutomaticFilterParameters()); + doDisplayLoadingMessage(tr("updating filters")); + _project_sp.get()->updateAutomaticFilters( + _project_sp.get()->getAutomaticFilterParameters()); - //re group - emit operateGrouping(_project_sp); + // re group + emit operateGrouping(_project_sp); } - catch (pappso::PappsoException exception_pappso) { - hideWaitingMessage(); - QMessageBox::warning(this, - tr("Unable to compute FDR :"), exception_pappso.qwhat()); + catch(pappso::PappsoException exception_pappso) + { + hideWaitingMessage(); + QMessageBox::warning(this, tr("Unable to compute FDR :"), + exception_pappso.qwhat()); } - catch (std::exception exception_std) { - hideWaitingMessage(); - QMessageBox::warning(this, - tr("Unable to compute FDR :"), exception_std.what()); + catch(std::exception exception_std) + { + hideWaitingMessage(); + QMessageBox::warning(this, tr("Unable to compute FDR :"), + exception_std.what()); } - qDebug() << "ProjectWindow::doFdrChanged end "; + qDebug() << "ProjectWindow::doFdrChanged end "; } -void ProjectWindow::refresh() { - qDebug() << "ProjectWindow::refresh begin "; - computeFdr(); - computeMassPrecision(); - qDebug() << "ProjectWindow::refresh end "; - +void +ProjectWindow::refresh() +{ + qDebug() << "ProjectWindow::refresh begin "; + computeFdr(); + computeMassPrecision(); + qDebug() << "ProjectWindow::refresh end "; } -void ProjectWindow::doContaminantSelectionChanged() { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - ui->apply_filter_button->setEnabled(true); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; +void +ProjectWindow::doContaminantSelectionChanged() +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + ui->apply_filter_button->setEnabled(true); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProjectWindow::doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters) { - qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged begin "; - ui->apply_filter_button->setEnabled(true); - qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged end "; +void +ProjectWindow::doAutomaticFilterParametersChanged( + AutomaticFilterParameters parameters) +{ + qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged begin "; + ui->apply_filter_button->setEnabled(true); + qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged end "; } -void ProjectWindow::doOperationFailed(QString error) { - hideWaitingMessage(); - viewError(error); +void +ProjectWindow::doOperationFailed(QString error) +{ + hideWaitingMessage(); + viewError(error); } -void ProjectWindow::doOperationFinished() { - hideWaitingMessage(); +void +ProjectWindow::doOperationFinished() +{ + hideWaitingMessage(); } -void ProjectWindow::doDisplayLoadingMessage(QString message) { - qDebug() << "ProjectWindow::doDisplayLoadingMessage " << message; - _p_waiting_message_dialog->message(message); +void +ProjectWindow::doDisplayLoadingMessage(QString message) +{ + qDebug() << "ProjectWindow::doDisplayLoadingMessage " << message; + _p_waiting_message_dialog->message(message); } -void ProjectWindow::doDisplayLoadingMessagePercent(QString message, int value) { - qDebug() << "ProjectWindow::doDisplayLoadingMessagePercent " << message << " " << value; - _p_waiting_message_dialog->message(message, value); +void +ProjectWindow::doDisplayLoadingMessagePercent(QString message, int value) +{ + qDebug() << "ProjectWindow::doDisplayLoadingMessagePercent " << message << " " + << value; + _p_waiting_message_dialog->message(message, value); } -void ProjectWindow::doGroupingFinished() { - qDebug() << "ProjectWindow::doGroupingFinished begin " ; - hideWaitingMessage(); - - //re group - for (IdentificationGroup * p_ident_group : _project_sp.get()->getIdentificationGroupList()) { - refreshGroup(p_ident_group); +void +ProjectWindow::doGroupingFinished() +{ + qDebug() << "ProjectWindow::doGroupingFinished begin "; + hideWaitingMessage(); + // re group + for(IdentificationGroup *p_ident_group : + _project_sp.get()->getIdentificationGroupList()) + { + refreshGroup(p_ident_group); } - refresh(); + refresh(); - qDebug() << "ProjectWindow::doGroupingFinished end"; + qDebug() << "ProjectWindow::doGroupingFinished end"; } -void ProjectWindow::doMassPrecisionUnitChanged(QString combo_value) { - qDebug() << "ProjectWindow::doMassPrecisionUnitChanged begin "<< combo_value; +void +ProjectWindow::doMassPrecisionUnitChanged(QString combo_value) +{ + qDebug() << "ProjectWindow::doMassPrecisionUnitChanged begin " << combo_value; - refresh(); - qDebug() << "ProjectWindow::doMassPrecisionUnitChanged end "; + refresh(); + qDebug() << "ProjectWindow::doMassPrecisionUnitChanged end "; } -void ProjectWindow::doViewPeptideList(IdentificationGroup * p_ident_group, ProteinMatch * protein_match) { +void +ProjectWindow::doViewPeptideList(IdentificationGroup *p_ident_group, + ProteinMatch *protein_match) +{ - qDebug() << "ProjectWindow::doViewPeptideList begin"; - if (_peptide_list_window_collection.size() == 0) { - connectNewPeptideListWindow(); + qDebug() << "ProjectWindow::doViewPeptideList begin"; + if(_peptide_list_window_collection.size() == 0) + { + connectNewPeptideListWindow(); } - Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); - if (modifier == Qt::ControlModifier) { - connectNewPeptideListWindow(); + Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); + if(modifier == Qt::ControlModifier) + { + connectNewPeptideListWindow(); } - _p_current_peptide_list_window->setProteinMatch(p_ident_group, protein_match); - _p_current_peptide_list_window->show(); - //_p_current_peptide_list_window->raise(); - //_p_current_peptide_list_window->activateWindow(); - qDebug() << "ProjectWindow::doViewPeptideList end"; + _p_current_peptide_list_window->setProteinMatch(p_ident_group, protein_match); + _p_current_peptide_list_window->show(); + //_p_current_peptide_list_window->raise(); + //_p_current_peptide_list_window->activateWindow(); + qDebug() << "ProjectWindow::doViewPeptideList end"; } -void ProjectWindow::doViewPeptideDetail(PeptideEvidence * peptide_evidence) { +void +ProjectWindow::doViewPeptideDetail(PeptideEvidence *peptide_evidence) +{ - qDebug() << "ProjectWindow::doViewPeptideDetail begin " << peptide_evidence; - if (_peptide_detail_window_collection.size() == 0) { - connectNewPeptideDetailWindow(); + qDebug() << "ProjectWindow::doViewPeptideDetail begin " << peptide_evidence; + if(_peptide_detail_window_collection.size() == 0) + { + connectNewPeptideDetailWindow(); } - Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); - if (modifier == Qt::ControlModifier) { - connectNewPeptideDetailWindow(); + Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); + if(modifier == Qt::ControlModifier) + { + connectNewPeptideDetailWindow(); } - _p_current_peptide_detail_window->setPeptideEvidence(peptide_evidence); - _p_current_peptide_detail_window->show(); - //_p_current_peptide_detail_window->raise(); - //_p_current_peptide_detail_window->activateWindow(); + _p_current_peptide_detail_window->setPeptideEvidence(peptide_evidence); + _p_current_peptide_detail_window->show(); + //_p_current_peptide_detail_window->raise(); + //_p_current_peptide_detail_window->activateWindow(); - emit peptideEvidenceSelected(peptide_evidence); - qDebug() << "ProjectWindow::doViewPeptideDetail end"; + emit peptideEvidenceSelected(peptide_evidence); + qDebug() << "ProjectWindow::doViewPeptideDetail end"; } -void ProjectWindow::doViewProteinDetail(ProteinMatch * protein_match) { +void +ProjectWindow::doViewProteinDetail(ProteinMatch *protein_match) +{ - qDebug() << "ProjectWindow::doViewProteinDetail begin"; - if (_protein_detail_window_collection.size() == 0) { - connectNewProteinDetailWindow(); + qDebug() << "ProjectWindow::doViewProteinDetail begin"; + if(_protein_detail_window_collection.size() == 0) + { + connectNewProteinDetailWindow(); } - Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); - if (modifier == Qt::ControlModifier) { - connectNewProteinDetailWindow(); + Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); + if(modifier == Qt::ControlModifier) + { + connectNewProteinDetailWindow(); } - _p_current_protein_detail_window->setProteinMatch(protein_match); - _p_current_protein_detail_window->show(); - //_p_current_protein_detail_window->raise(); - //_p_current_protein_detail_window->activateWindow(); - qDebug() << "ProjectWindow::doViewProteinDetail end"; + _p_current_protein_detail_window->setProteinMatch(protein_match); + _p_current_protein_detail_window->show(); + //_p_current_protein_detail_window->raise(); + //_p_current_protein_detail_window->activateWindow(); + qDebug() << "ProjectWindow::doViewProteinDetail end"; } -void ProjectWindow::doPtmIslandGrouping(IdentificationGroup* p_identification_group) { +void +ProjectWindow::doPtmIslandGrouping(IdentificationGroup *p_identification_group) +{ - if (p_identification_group->getPtmGroupingExperiment() == nullptr) { - showWaitingMessage(tr("Computing PTM islands")); - emit operatePtmGroupingOnIdentification(p_identification_group); + if(p_identification_group->getPtmGroupingExperiment() == nullptr) + { + showWaitingMessage(tr("Computing PTM islands")); + emit operatePtmGroupingOnIdentification(p_identification_group); } - } -void ProjectWindow::doViewPtmIslandList(IdentificationGroup* p_identification_group) { - qDebug() << "ProjectWindow::doViewPtmIslandList begin " << p_identification_group; - //if (p_identification_group == nullptr) { - //} - if (_ptm_island_list_window_collection.size() == 0) { - connectNewPtmIslandListWindow(); +void +ProjectWindow::doViewPtmIslandList(IdentificationGroup *p_identification_group) +{ + qDebug() << "ProjectWindow::doViewPtmIslandList begin " + << p_identification_group; + // if (p_identification_group == nullptr) { + //} + if(_ptm_island_list_window_collection.size() == 0) + { + connectNewPtmIslandListWindow(); } - Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); - if (modifier == Qt::ControlModifier) { - connectNewPtmIslandListWindow(); + Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); + if(modifier == Qt::ControlModifier) + { + connectNewPtmIslandListWindow(); } - _p_current_ptm_island_list_window->show(); - //_p_current_protein_list_window->raise(); - //_p_current_protein_list_window->activateWindow(); + _p_current_ptm_island_list_window->show(); + //_p_current_protein_list_window->raise(); + //_p_current_protein_list_window->activateWindow(); - qDebug() << "ProjectWindow::doViewPtmIslandList end " << p_identification_group; - _p_current_ptm_island_list_window->setIdentificationGroup(p_identification_group); + qDebug() << "ProjectWindow::doViewPtmIslandList end " + << p_identification_group; + _p_current_ptm_island_list_window->setIdentificationGroup( + p_identification_group); - doPtmIslandGrouping(p_identification_group); - //emit identificationGroupGrouped(p_identification_group); - qDebug() << "ProjectWindow::doViewPtmIslandList end"; + doPtmIslandGrouping(p_identification_group); + // emit identificationGroupGrouped(p_identification_group); + qDebug() << "ProjectWindow::doViewPtmIslandList end"; } -void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_group) { - qDebug() << "ProjectWindow::doViewProteinList begin " << p_identification_group; - //if (p_identification_group == nullptr) { - //} - if (_protein_list_window_collection.size() == 0) { - connectNewProteinListWindow(); +void +ProjectWindow::doViewProteinList(IdentificationGroup *p_identification_group) +{ + qDebug() << "ProjectWindow::doViewProteinList begin " + << p_identification_group; + // if (p_identification_group == nullptr) { + //} + if(_protein_list_window_collection.size() == 0) + { + connectNewProteinListWindow(); } - Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); - if (modifier == Qt::ControlModifier) { - connectNewProteinListWindow(); + Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); + if(modifier == Qt::ControlModifier) + { + connectNewProteinListWindow(); } - _p_current_protein_list_window->show(); - _p_current_protein_list_window->raise(); - _p_current_protein_list_window->activateWindow(); + _p_current_protein_list_window->show(); + _p_current_protein_list_window->raise(); + _p_current_protein_list_window->activateWindow(); - qDebug() << "ProjectWindow::doViewProteinList end " << p_identification_group; - _p_current_protein_list_window->setIdentificationGroup(p_identification_group); + qDebug() << "ProjectWindow::doViewProteinList end " << p_identification_group; + _p_current_protein_list_window->setIdentificationGroup( + p_identification_group); - emit identificationGroupGrouped(p_identification_group); - qDebug() << "ProjectWindow::doViewProteinList end"; + emit identificationGroupGrouped(p_identification_group); + qDebug() << "ProjectWindow::doViewProteinList end"; } -void ProjectWindow::setProjectSp(ProjectSp project_sp) { - qDebug() << "ProjectWindow::setProjectSp begin" ; +void +ProjectWindow::setProjectSp(ProjectSp project_sp) +{ + qDebug() << "ProjectWindow::setProjectSp begin"; - _project_sp = project_sp; - ui->decoy_regexp_radiobutton->setChecked(true); - ui->decoy_regexp_groupbox->setVisible(true); - ui->decoy_database_groupbox->setVisible(false); - if (_project_sp.get()->getProteinStore().getDecoyFastaFileList().size() > 0) { - ui->decoy_database_files_radiobutton->setChecked(true); - ui->decoy_regexp_groupbox->setVisible(false); - ui->decoy_database_groupbox->setVisible(true); + _project_sp = project_sp; + ui->decoy_regexp_radiobutton->setChecked(true); + ui->decoy_regexp_groupbox->setVisible(true); + ui->decoy_database_groupbox->setVisible(false); + if(_project_sp.get()->getProteinStore().getDecoyFastaFileList().size() > 0) + { + ui->decoy_database_files_radiobutton->setChecked(true); + ui->decoy_regexp_groupbox->setVisible(false); + ui->decoy_database_groupbox->setVisible(true); } - ui->contaminant_widget->getProjectContaminants(_project_sp.get()); + ui->contaminant_widget->getProjectContaminants(_project_sp.get()); - qDebug() << "ProjectWindow::setProjectSp begin " << _project_sp.get()->getFastaFileStore().getFastaFileList().size() ; - _fastafile_list = _project_sp.get()->getFastaFileStore().getFastaFileList(); + qDebug() << "ProjectWindow::setProjectSp begin " + << _project_sp.get()->getFastaFileStore().getFastaFileList().size(); + _fastafile_list = _project_sp.get()->getFastaFileStore().getFastaFileList(); - _p_fasta_str_li->removeRows(0, _p_fasta_str_li->rowCount()); - for (FastaFileSp fasta_file : _fastafile_list ) { + _p_fasta_str_li->removeRows(0, _p_fasta_str_li->rowCount()); + for(FastaFileSp fasta_file : _fastafile_list) + { - QStandardItem *item; - item = new QStandardItem(QString("%1").arg(fasta_file.get()->getFilename())); - item->setEditable(false); - item->setData(QVariant::fromValue(fasta_file.get()), Qt::UserRole); - _p_fasta_str_li->appendRow(item); - //item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); + QStandardItem *item; + item = + new QStandardItem(QString("%1").arg(fasta_file.get()->getFilename())); + item->setEditable(false); + item->setData(QVariant::fromValue(fasta_file.get()), Qt::UserRole); + _p_fasta_str_li->appendRow(item); + // item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); } - for (auto && p_window :_ptm_island_list_window_collection) { - delete p_window; + for(auto &&p_window : _ptm_island_list_window_collection) + { + delete p_window; } - _ptm_island_list_window_collection.clear(); - _p_current_ptm_island_list_window = nullptr; + _ptm_island_list_window_collection.clear(); + _p_current_ptm_island_list_window = nullptr; - for (auto && p_window :_peptide_list_window_collection) { - delete p_window; + for(auto &&p_window : _peptide_list_window_collection) + { + delete p_window; } - _peptide_list_window_collection.clear(); - _p_current_peptide_list_window = nullptr; + _peptide_list_window_collection.clear(); + _p_current_peptide_list_window = nullptr; - for (auto && p_window :_protein_list_window_collection) { - delete p_window; + for(auto &&p_window : _protein_list_window_collection) + { + delete p_window; } - _protein_list_window_collection.clear(); - _p_current_protein_list_window = nullptr; + _protein_list_window_collection.clear(); + _p_current_protein_list_window = nullptr; - for (auto && p_window :_protein_detail_window_collection) { - delete p_window; + for(auto &&p_window : _protein_detail_window_collection) + { + delete p_window; } - _protein_detail_window_collection.clear(); - _p_current_protein_detail_window = nullptr; + _protein_detail_window_collection.clear(); + _p_current_protein_detail_window = nullptr; - for (auto && p_window :_peptide_detail_window_collection) { - delete p_window; + for(auto &&p_window : _peptide_detail_window_collection) + { + delete p_window; } - _peptide_detail_window_collection.clear(); - _p_current_peptide_detail_window = nullptr; + _peptide_detail_window_collection.clear(); + _p_current_peptide_detail_window = nullptr; - if (_p_identification_widget != nullptr) { - delete _p_identification_widget; + if(_p_identification_widget != nullptr) + { + delete _p_identification_widget; } - std::vector<IdentificationGroup *> identification_list = _project_sp.get()->getIdentificationGroupList(); + std::vector<IdentificationGroup *> identification_list = + _project_sp.get()->getIdentificationGroupList(); - doViewProteinList(identification_list[0]); + doViewProteinList(identification_list[0]); - //qDeleteAll(ui->identifications_widget->children()); - QLayoutItem *wItem; - while (wItem = ui->identifications_widget->layout()->takeAt(0)) { - wItem->widget()->setVisible(false); - delete wItem; + // qDeleteAll(ui->identifications_widget->children()); + QLayoutItem *wItem; + while(wItem = ui->identifications_widget->layout()->takeAt(0)) + { + wItem->widget()->setVisible(false); + delete wItem; } - if (_p_xic_window != nullptr) { - _p_xic_window->clear(); - _p_xic_window->hide(); - delete _p_xic_window; - _p_xic_window = nullptr; + if(_p_xic_window != nullptr) + { + _p_xic_window->clear(); + _p_xic_window->hide(); + delete _p_xic_window; + _p_xic_window = nullptr; } - qDebug() << " ProjectWindow::setProjectSp size=" << identification_list.size(); - if (identification_list.size() == 1) { - ui->identifications_combobox->setVisible(false); + qDebug() << " ProjectWindow::setProjectSp size=" + << identification_list.size(); + if(identification_list.size() == 1) + { + ui->identifications_combobox->setVisible(false); - IdentificationGroupWidget * p_identification_widget = new IdentificationGroupWidget(this); - p_identification_widget->setIdentificationGroup(this, identification_list[0]); + IdentificationGroupWidget *p_identification_widget = + new IdentificationGroupWidget(this); + p_identification_widget->setIdentificationGroup(this, + identification_list[0]); - ui->identifications_widget->layout()->addWidget(p_identification_widget); + ui->identifications_widget->layout()->addWidget(p_identification_widget); - refreshGroup(identification_list[0]); + refreshGroup(identification_list[0]); } - else { - ui->identifications_combobox->clear(); - ui->identifications_combobox->setVisible(true); + else + { + ui->identifications_combobox->clear(); + ui->identifications_combobox->setVisible(true); - for (IdentificationGroup * identification_group : identification_list) { - IdentificationGroupWidget * p_identification_widget = new IdentificationGroupWidget(this); - p_identification_widget->setVisible(false); + for(IdentificationGroup *identification_group : identification_list) + { + IdentificationGroupWidget *p_identification_widget = + new IdentificationGroupWidget(this); + p_identification_widget->setVisible(false); - ui->identifications_combobox->addItem(identification_group->getTabName(), QVariant::fromValue(p_identification_widget)); + ui->identifications_combobox->addItem( + identification_group->getTabName(), + QVariant::fromValue(p_identification_widget)); - p_identification_widget->setIdentificationGroup(this, identification_group); + p_identification_widget->setIdentificationGroup(this, + identification_group); - ui->identifications_widget->layout()->addWidget(p_identification_widget); + ui->identifications_widget->layout()->addWidget( + p_identification_widget); - refreshGroup(identification_group); + refreshGroup(identification_group); } - ui->identifications_combobox->setCurrentIndex(0); - qobject_cast<IdentificationGroupWidget*>(qvariant_cast<QObject*>(ui->identifications_combobox->itemData( ui->identifications_combobox->currentIndex())))->setVisible(true); + ui->identifications_combobox->setCurrentIndex(0); + qobject_cast<IdentificationGroupWidget *>( + qvariant_cast<QObject *>(ui->identifications_combobox->itemData( + ui->identifications_combobox->currentIndex()))) + ->setVisible(true); } - AutomaticFilterParameters params = _project_sp.get()->getAutomaticFilterParameters(); - - ui->filter_parameter_widget->setAutomaticFilterParameters(params); - //_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP()); - //_protein_list_window->show(); + AutomaticFilterParameters params = + _project_sp.get()->getAutomaticFilterParameters(); - ui->decoy_protein_regexp_line_edit->setText(_project_sp.get()->getProteinStore().getRegexpDecoy().pattern()); + ui->filter_parameter_widget->setAutomaticFilterParameters(params); + //_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP()); + //_protein_list_window->show(); - refresh(); - this->setEnabled(true); + ui->decoy_protein_regexp_line_edit->setText( + _project_sp.get()->getProteinStore().getRegexpDecoy().pattern()); - //doAutomaticFilterParametersChanged(params); - //doFdrChanged(); + refresh(); + this->setEnabled(true); + // doAutomaticFilterParametersChanged(params); + // doFdrChanged(); } -void ProjectWindow::doIdentificationsComboboxChanged(int index_in) { - qDebug() << "ProjectWindow::doIdentificationsComboboxChanged begin "; - for (int index = 0; index < ui->identifications_combobox->count(); index++) { - qobject_cast<IdentificationGroupWidget*>(qvariant_cast<QObject*>(ui->identifications_combobox->itemData(index)))->setVisible(false); +void +ProjectWindow::doIdentificationsComboboxChanged(int index_in) +{ + qDebug() << "ProjectWindow::doIdentificationsComboboxChanged begin "; + for(int index = 0; index < ui->identifications_combobox->count(); index++) + { + qobject_cast<IdentificationGroupWidget *>( + qvariant_cast<QObject *>(ui->identifications_combobox->itemData(index))) + ->setVisible(false); } - qobject_cast<IdentificationGroupWidget*>(qvariant_cast<QObject*>(ui->identifications_combobox->itemData(index_in)))->setVisible(true); - qDebug() << "ProjectWindow::doIdentificationsComboboxChanged end "; + qobject_cast<IdentificationGroupWidget *>( + qvariant_cast<QObject *>(ui->identifications_combobox->itemData(index_in))) + ->setVisible(true); + qDebug() << "ProjectWindow::doIdentificationsComboboxChanged end "; } -void ProjectWindow::editModifications() { - _p_edit_modifications->setProjectSp(_project_sp); - _p_edit_modifications->show(); - _p_edit_modifications->raise(); - _p_edit_modifications->activateWindow(); - +void +ProjectWindow::editModifications() +{ + _p_edit_modifications->setProjectSp(_project_sp); + _p_edit_modifications->show(); + _p_edit_modifications->raise(); + _p_edit_modifications->activateWindow(); } -void ProjectWindow::editLabelingMethods() { - _p_edit_label_methods->setProjectSp(_project_sp); - _p_edit_label_methods->show(); - _p_edit_label_methods->raise(); - _p_edit_label_methods->activateWindow(); - +void +ProjectWindow::editLabelingMethods() +{ + _p_edit_label_methods->setProjectSp(_project_sp); + _p_edit_label_methods->show(); + _p_edit_label_methods->raise(); + _p_edit_label_methods->activateWindow(); } -void ProjectWindow::hideWaitingMessage() { +void +ProjectWindow::hideWaitingMessage() +{ - _p_waiting_message_dialog->hide(); + _p_waiting_message_dialog->hide(); } -void ProjectWindow::showWaitingMessage(const QString title) { - _p_waiting_message_dialog->setWindowTitle(title); - _p_waiting_message_dialog->show(); - _p_waiting_message_dialog->raise(); - _p_waiting_message_dialog->activateWindow(); - +void +ProjectWindow::showWaitingMessage(const QString title) +{ + _p_waiting_message_dialog->setWindowTitle(title); + _p_waiting_message_dialog->show(); + _p_waiting_message_dialog->raise(); + _p_waiting_message_dialog->activateWindow(); } -void ProjectWindow::doIdentificationGroupEdited(IdentificationGroup* p_identification_group) { - showWaitingMessage(tr("Updating identification group")); +void +ProjectWindow::doIdentificationGroupEdited( + IdentificationGroup *p_identification_group) +{ + showWaitingMessage(tr("Updating identification group")); - qDebug() << "ProjectWindow::doIdentificationGroupEdited emit operateGroupingOnIdentification(_project_sp) "; - emit operateGroupingOnIdentification(p_identification_group, _project_sp.get()->getGroupingType()); + qDebug() << "ProjectWindow::doIdentificationGroupEdited emit " + "operateGroupingOnIdentification(_project_sp) "; + emit operateGroupingOnIdentification(p_identification_group, + _project_sp.get()->getGroupingType()); } -void ProjectWindow::viewError(QString error) { - QMessageBox::warning(this, - tr("Oops! an error occurred in XTPCPP. Dont Panic :"), error); +void +ProjectWindow::viewError(QString error) +{ + QMessageBox::warning( + this, tr("Oops! an error occurred in XTPCPP. Dont Panic :"), error); } -void ProjectWindow::doAcceptedLabelingMethod() { - qDebug() << "ProjectWindow::doAcceptedLabelingMethod"; - showWaitingMessage(tr("Apply labeling method")); - - LabelingMethodSp labeling_method_sp = _p_edit_label_methods->getLabelingMethodSp(); - _project_sp.get()->setLabelingMethodSp(labeling_method_sp); - //_p_edit_label_methods->applyLabelingMethodInProject(); +void +ProjectWindow::doAcceptedLabelingMethod() +{ + qDebug() << "ProjectWindow::doAcceptedLabelingMethod"; + showWaitingMessage(tr("Apply labeling method")); - doDisplayLoadingMessage(tr("labeling peptides")); + LabelingMethodSp labeling_method_sp = + _p_edit_label_methods->getLabelingMethodSp(); + _project_sp.get()->setLabelingMethodSp(labeling_method_sp); + //_p_edit_label_methods->applyLabelingMethodInProject(); - qDebug() << "ProjectWindow::doAcceptedLabelingMethod emit operateGrouping(_project_sp) "; - emit operateGrouping(_project_sp); + doDisplayLoadingMessage(tr("labeling peptides")); + qDebug() << "ProjectWindow::doAcceptedLabelingMethod emit " + "operateGrouping(_project_sp) "; + emit operateGrouping(_project_sp); } -void ProjectWindow::openInXicViewer(const PeptideEvidence * p_peptide_evidence) { - qDebug() << "ProjectWindow::openInXicViewer begin"; - if (_p_xic_window == nullptr) { - _p_xic_window = new XicWindow(this); +void +ProjectWindow::openInXicViewer(const PeptideEvidence *p_peptide_evidence) +{ + qDebug() << "ProjectWindow::openInXicViewer begin"; + if(_p_xic_window == nullptr) + { + _p_xic_window = new XicWindow(this); } - _p_xic_window->show(); + _p_xic_window->show(); - _p_xic_window->addXic(p_peptide_evidence); - qDebug() << "ProjectWindow::openInXicViewer end"; + _p_xic_window->addXic(p_peptide_evidence); + qDebug() << "ProjectWindow::openInXicViewer end"; } -void ProjectWindow::doSelectDecoySource() { - qDebug() << "ProjectWindow::doSelectDecoySource begin"; - ui->decoy_database_groupbox->setVisible(false); - ui->decoy_regexp_groupbox->setVisible(false); - if (ui->decoy_database_files_radiobutton->isChecked()) { - ui->decoy_database_groupbox->setVisible(true); +void +ProjectWindow::doSelectDecoySource() +{ + qDebug() << "ProjectWindow::doSelectDecoySource begin"; + ui->decoy_database_groupbox->setVisible(false); + ui->decoy_regexp_groupbox->setVisible(false); + if(ui->decoy_database_files_radiobutton->isChecked()) + { + ui->decoy_database_groupbox->setVisible(true); } - else { - ui->decoy_regexp_groupbox->setVisible(true); + else + { + ui->decoy_regexp_groupbox->setVisible(true); } - qDebug() << "ProjectWindow::doSelectDecoySource end"; + qDebug() << "ProjectWindow::doSelectDecoySource end"; } -void ProjectWindow::doFilterChanged() { - ui->apply_filter_button->setEnabled(true); +void +ProjectWindow::doFilterChanged() +{ + ui->apply_filter_button->setEnabled(true); } -void ProjectWindow::doApplyFilter() { - ui->apply_filter_button->setEnabled(false); - AutomaticFilterParameters automatic_filter = ui->filter_parameter_widget->getAutomaticFilterParameters(); - //doAutomaticFilterParametersChanged(automatic_filter); - try { - showWaitingMessage(tr("Updating filters")); - - doDisplayLoadingMessage(tr("tagging contaminant proteins")); - - ui->contaminant_widget->setProjectContaminants(_project_sp.get()); - doDisplayLoadingMessage(tr("updating filters")); - _project_sp.get()->updateAutomaticFilters(automatic_filter); - - qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged emit operateGrouping(_project_sp) "; - emit operateGrouping(_project_sp); - } - catch (pappso::PappsoException exception_pappso) { - hideWaitingMessage(); - QMessageBox::warning(this, - tr("Error filtering results :"), exception_pappso.qwhat()); - } - catch (std::exception exception_std) { - hideWaitingMessage(); - QMessageBox::warning(this, - tr("Error filtering results :"), exception_std.what()); +void +ProjectWindow::doApplyFilter() +{ + ui->apply_filter_button->setEnabled(false); + AutomaticFilterParameters automatic_filter = + ui->filter_parameter_widget->getAutomaticFilterParameters(); + // doAutomaticFilterParametersChanged(automatic_filter); + try + { + showWaitingMessage(tr("Updating filters")); + + doDisplayLoadingMessage(tr("tagging contaminant proteins")); + + ui->contaminant_widget->setProjectContaminants(_project_sp.get()); + doDisplayLoadingMessage(tr("updating filters")); + _project_sp.get()->updateAutomaticFilters(automatic_filter); + + qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged emit " + "operateGrouping(_project_sp) "; + emit operateGrouping(_project_sp); + } + catch(pappso::PappsoException exception_pappso) + { + hideWaitingMessage(); + QMessageBox::warning(this, tr("Error filtering results :"), + exception_pappso.qwhat()); + } + catch(std::exception exception_std) + { + hideWaitingMessage(); + QMessageBox::warning(this, tr("Error filtering results :"), + exception_std.what()); } - } diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h index f1f8f2f399adc9eb2162304d88add404e93c718c..7855d705dcbc082d3ec45ee288c78d145617979c 100644 --- a/src/gui/project_view/projectwindow.h +++ b/src/gui/project_view/projectwindow.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 PROJECTWINDOW_H #define PROJECTWINDOW_H @@ -42,106 +43,111 @@ class MainWindow; -//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html -namespace Ui { -class ProjectView; +// http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html +namespace Ui +{ + class ProjectView; } -class ProjectWindow: public QMainWindow { - Q_OBJECT - - friend class ProteinListWindow; - friend class PeptideListWindow; -public: - - explicit ProjectWindow(MainWindow * parent = 0); - Project * getProjectP(); - void setProjectSp(ProjectSp project_sp); - void editModifications(); - void editLabelingMethods(); - void openInXicViewer(const PeptideEvidence * p_peptide_evidence); - ~ProjectWindow(); - -public slots: - void doViewPtmIslandList(IdentificationGroup* p_identification_group); - void doPtmIslandGrouping(IdentificationGroup* p_identification_group); - void doViewProteinList(IdentificationGroup* p_identification_group =nullptr); - void setDefaultProteinListWindow(ProteinListWindow* p_protein_list_window); - void doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters); - void doFdrChanged(); - void doSelectDecoySource(); - void doMassPrecisionUnitChanged(QString combo_value); - void doOperationFailed(QString); - void doOperationFinished(); - void doGroupingFinished(); - void doIdentificationsComboboxChanged(int index); - void doDisplayLoadingMessage(QString message); - void doDisplayLoadingMessagePercent(QString message, int value); - void refreshGroup(IdentificationGroup * p_ident_group); - void refreshPtmGroup(IdentificationGroup * p_ident_group); - void doAcceptedLabelingMethod(); - void doViewPeptideDetail(PeptideEvidence * peptide_evidence); - void doFilterChanged(); - void doApplyFilter(); - // void setColor(const QColor &color); - // void setShape(Shape shape); -signals: - void identificationGroupGrouped(IdentificationGroup * p_identification_group); - void identificationPtmGroupGrouped(IdentificationGroup * p_identification_group); - void peptideEvidenceSelected(PeptideEvidence * peptide_evidence); - void operateGrouping(ProjectSp project_sp); - void operatePtmGroupingOnIdentification(IdentificationGroup * p_identification_group); - void operateGroupingOnIdentification(IdentificationGroup * p_identification_group, GroupingType grouping_type); - //void peptideChanged(pappso::PeptideSp peptide); - -protected : - void doViewPeptideList(IdentificationGroup * p_ident_group, ProteinMatch * protein_match); - void doViewProteinDetail(ProteinMatch * protein_match); - void doIdentificationGroupEdited(IdentificationGroup* p_identification_group); - void doContaminantSelectionChanged(); - void computeFdr(); - void computeMassPrecision(); - -private : - void connectNewPtmIslandListWindow(); - void connectNewProteinListWindow(); - void connectNewPeptideListWindow(); - void connectNewProteinDetailWindow(); - void connectNewPeptideDetailWindow(); - void refresh(); - void showWaitingMessage(const QString title); - void hideWaitingMessage(); - void viewError(QString error); - - -private: - QThread _worker_thread; - Ui::ProjectView *ui; - QWidget * _p_identification_widget = nullptr; - MainWindow * main_window; - std::list <ProteinListWindow *> _protein_list_window_collection; - ProteinListWindow * _p_current_protein_list_window = nullptr; - std::list <PeptideListWindow *> _peptide_list_window_collection; - PeptideListWindow * _p_current_peptide_list_window = nullptr; - std::list <ProteinWindow *> _protein_detail_window_collection; - ProteinWindow * _p_current_protein_detail_window = nullptr; - std::list <PeptideWindow *> _peptide_detail_window_collection; - PeptideWindow * _p_current_peptide_detail_window = nullptr; - std::list <PtmIslandListWindow *> _ptm_island_list_window_collection; - PtmIslandListWindow * _p_current_ptm_island_list_window = nullptr; - - EditModifications * _p_edit_modifications = nullptr; - EditLabelMethods * _p_edit_label_methods = nullptr; - XicWindow * _p_xic_window = nullptr; - - ProjectSp _project_sp; - - QStandardItemModel * _p_fasta_str_li; - std::vector<FastaFileSp> _fastafile_list; - WaitingMessageDialog * _p_waiting_message_dialog; - //QCPBars *_p_bars; +class ProjectWindow : public QMainWindow +{ + Q_OBJECT + friend class ProteinListWindow; + friend class PeptideListWindow; + public: + explicit ProjectWindow(MainWindow *parent = 0); + Project *getProjectP(); + void setProjectSp(ProjectSp project_sp); + void editModifications(); + void editLabelingMethods(); + void openInXicViewer(const PeptideEvidence *p_peptide_evidence); + ~ProjectWindow(); + + public slots: + void doViewPtmIslandList(IdentificationGroup *p_identification_group); + void doPtmIslandGrouping(IdentificationGroup *p_identification_group); + void doViewProteinList(IdentificationGroup *p_identification_group = nullptr); + void setDefaultProteinListWindow(ProteinListWindow *p_protein_list_window); + void doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters); + void doFdrChanged(); + void doSelectDecoySource(); + void doMassPrecisionUnitChanged(QString combo_value); + void doOperationFailed(QString); + void doOperationFinished(); + void doGroupingFinished(); + void doIdentificationsComboboxChanged(int index); + void doDisplayLoadingMessage(QString message); + void doDisplayLoadingMessagePercent(QString message, int value); + void refreshGroup(IdentificationGroup *p_ident_group); + void refreshPtmGroup(IdentificationGroup *p_ident_group); + void doAcceptedLabelingMethod(); + void doViewPeptideDetail(PeptideEvidence *peptide_evidence); + void doFilterChanged(); + void doApplyFilter(); + // void setColor(const QColor &color); + // void setShape(Shape shape); + signals: + void identificationGroupGrouped(IdentificationGroup *p_identification_group); + void + identificationPtmGroupGrouped(IdentificationGroup *p_identification_group); + void peptideEvidenceSelected(PeptideEvidence *peptide_evidence); + void operateGrouping(ProjectSp project_sp); + void operatePtmGroupingOnIdentification( + IdentificationGroup *p_identification_group); + void + operateGroupingOnIdentification(IdentificationGroup *p_identification_group, + GroupingType grouping_type); + // void peptideChanged(pappso::PeptideSp peptide); + + protected: + void doViewPeptideList(IdentificationGroup *p_ident_group, + ProteinMatch *protein_match); + void doViewProteinDetail(ProteinMatch *protein_match); + void doIdentificationGroupEdited(IdentificationGroup *p_identification_group); + void doContaminantSelectionChanged(); + void computeFdr(); + void computeMassPrecision(); + + private: + void connectNewPtmIslandListWindow(); + void connectNewProteinListWindow(); + void connectNewPeptideListWindow(); + void connectNewProteinDetailWindow(); + void connectNewPeptideDetailWindow(); + void refresh(); + void showWaitingMessage(const QString title); + void hideWaitingMessage(); + void viewError(QString error); + + + private: + QThread _worker_thread; + Ui::ProjectView *ui; + QWidget *_p_identification_widget = nullptr; + MainWindow *main_window; + std::list<ProteinListWindow *> _protein_list_window_collection; + ProteinListWindow *_p_current_protein_list_window = nullptr; + std::list<PeptideListWindow *> _peptide_list_window_collection; + PeptideListWindow *_p_current_peptide_list_window = nullptr; + std::list<ProteinWindow *> _protein_detail_window_collection; + ProteinWindow *_p_current_protein_detail_window = nullptr; + std::list<PeptideWindow *> _peptide_detail_window_collection; + PeptideWindow *_p_current_peptide_detail_window = nullptr; + std::list<PtmIslandListWindow *> _ptm_island_list_window_collection; + PtmIslandListWindow *_p_current_ptm_island_list_window = nullptr; + + EditModifications *_p_edit_modifications = nullptr; + EditLabelMethods *_p_edit_label_methods = nullptr; + XicWindow *_p_xic_window = nullptr; + + ProjectSp _project_sp; + + QStandardItemModel *_p_fasta_str_li; + std::vector<FastaFileSp> _fastafile_list; + WaitingMessageDialog *_p_waiting_message_dialog; + // QCPBars *_p_bars; }; diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index e043d0cdd75bb3b54f1c62ab3894e2fec4f0a85f..73648355426d11880bc79d9f6c6fcf09d939c753 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #include "proteinlistwindow.h" @@ -27,324 +28,423 @@ #include "../mainwindow.h" #include <QSettings> -ProteinListQactionColumn::ProteinListQactionColumn(ProteinListWindow * parent, ProteinListColumn column):QAction(parent) { +ProteinListQactionColumn::ProteinListQactionColumn(ProteinListWindow *parent, + ProteinListColumn column) + : QAction(parent) +{ - this->setText(ProteinTableModel::getTitle(column)); + this->setText(ProteinTableModel::getTitle(column)); - this->setCheckable(true); - this->setChecked(parent->getProteinListColumnDisplay(column)); + this->setCheckable(true); + this->setChecked(parent->getProteinListColumnDisplay(column)); - //evalue_action.setChecked(_display_evalue); - //connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool))); - _column = column; - _p_protein_list_window = parent; + // evalue_action.setChecked(_display_evalue); + // connect(p_action, SIGNAL(toggled(bool)), this, + // SLOT(showEvalueColumn(bool))); + _column = column; + _p_protein_list_window = parent; #if QT_VERSION >= 0x050000 - // Qt5 code - connect (this, &ProteinListQactionColumn::toggled, this,&ProteinListQactionColumn::doToggled); + // Qt5 code + connect(this, &ProteinListQactionColumn::toggled, this, + &ProteinListQactionColumn::doToggled); #else -// Qt4 code - connect (this, SIGNAL(toggled(bool)), this,SLOT(doToggled(bool))); + // Qt4 code + connect(this, SIGNAL(toggled(bool)), this, SLOT(doToggled(bool))); #endif } ProteinListQactionColumn::~ProteinListQactionColumn() { - //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; - qDebug() << "ProteinListQactionColumn::~ProteinListQactionColumn begin "; - + // if (_p_ms_data_file != nullptr) delete _p_ms_data_file; + qDebug() << "ProteinListQactionColumn::~ProteinListQactionColumn begin "; } -void ProteinListQactionColumn::doToggled(bool toggled) { - qDebug() << "ProteinListQactionColumn::doToggled begin " << toggled; - setChecked(toggled); - _p_protein_list_window->setProteinListColumnDisplay(_column, toggled); +void +ProteinListQactionColumn::doToggled(bool toggled) +{ + qDebug() << "ProteinListQactionColumn::doToggled begin " << toggled; + setChecked(toggled); + _p_protein_list_window->setProteinListColumnDisplay(_column, toggled); - qDebug() << "ProteinListQactionColumn::doToggled end"; + qDebug() << "ProteinListQactionColumn::doToggled end"; } -ProteinListWindow::ProteinListWindow(ProjectWindow *parent): - QMainWindow(parent), - ui(new Ui::ProteinView) +ProteinListWindow::ProteinListWindow(ProjectWindow *parent) + : QMainWindow(parent), ui(new Ui::ProteinView) { - _project_window = parent; - ui->setupUi(this); - setWindowIcon(QIcon(":/xtpcpp_icon/resources/xtandempipeline_icon.svg")); - /* - */ - _protein_table_model_p = new ProteinTableModel(this); - - - _p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p); - _p_proxy_model->setSourceModel(_protein_table_model_p); - _p_proxy_model->setDynamicSortFilter(true); - ui->tableView->setModel( _p_proxy_model ); - ui->tableView->setSortingEnabled(true); - ui->tableView->setAlternatingRowColors(true); - - QSettings settings; - bool hide = settings.value("proteinview/hidenotvalid", "true").toBool(); - if (hide) { - ui->hideNotValidCheckBox->setCheckState(Qt::Checked); + _project_window = parent; + ui->setupUi(this); + setWindowIcon(QIcon(":/xtpcpp_icon/resources/xtandempipeline_icon.svg")); + /* + */ + _protein_table_model_p = new ProteinTableModel(this); + + + _p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p); + _p_proxy_model->setSourceModel(_protein_table_model_p); + _p_proxy_model->setDynamicSortFilter(true); + ui->tableView->setModel(_p_proxy_model); + ui->tableView->setSortingEnabled(true); + ui->tableView->setAlternatingRowColors(true); + + QSettings settings; + bool hide = settings.value("proteinview/hidenotvalid", "true").toBool(); + if(hide) + { + ui->hideNotValidCheckBox->setCheckState(Qt::Checked); } - _p_proxy_model->hideNotValid(hide); - hide = settings.value("proteinview/hidenotchecked", "false").toBool(); - if (hide) { - ui->hideNotCheckedCheckBox->setCheckState(Qt::Checked); + _p_proxy_model->hideNotValid(hide); + hide = settings.value("proteinview/hidenotchecked", "false").toBool(); + if(hide) + { + ui->hideNotCheckedCheckBox->setCheckState(Qt::Checked); } - _p_proxy_model->hideNotChecked(hide); - hide = settings.value("proteinview/hidenotgrouped", "false").toBool(); - if (hide) { - ui->hideNotGroupedCheckBox->setCheckState(Qt::Checked); + _p_proxy_model->hideNotChecked(hide); + hide = settings.value("proteinview/hidenotgrouped", "false").toBool(); + if(hide) + { + ui->hideNotGroupedCheckBox->setCheckState(Qt::Checked); } - _p_proxy_model->hideNotGrouped(hide); - - + _p_proxy_model->hideNotGrouped(hide); - ui->scan_number_edit->setVisible(false); - ui->msrun_auto_completion->setVisible(false); - ui->mod_auto_completion->setVisible(false); - ui->protein_search_edit->setVisible(true); + ui->scan_number_edit->setVisible(false); + ui->msrun_auto_completion->setVisible(false); + ui->mod_auto_completion->setVisible(false); + ui->protein_search_edit->setVisible(true); #if QT_VERSION >= 0x050000 - // Qt5 code - connect (_project_window, &ProjectWindow::identificationGroupGrouped, this,&ProteinListWindow::doIdentificationGroupGrouped); - - connect (this, &ProteinListWindow::proteinDataChanged, _protein_table_model_p, &ProteinTableModel::onProteinDataChanged); - connect(ui->tableView, &QTableView::clicked, _p_proxy_model, &ProteinTableProxyModel::onTableClicked); - connect(ui->centralwidget, &QWidget::customContextMenuRequested, - this, &ProteinListWindow::showContextMenu); - connect(_protein_table_model_p, &ProteinTableModel::layoutChanged, this, &ProteinListWindow::updateStatusBar); + // Qt5 code + connect(_project_window, &ProjectWindow::identificationGroupGrouped, this, + &ProteinListWindow::doIdentificationGroupGrouped); + + connect(this, &ProteinListWindow::proteinDataChanged, _protein_table_model_p, + &ProteinTableModel::onProteinDataChanged); + connect(ui->tableView, &QTableView::clicked, _p_proxy_model, + &ProteinTableProxyModel::onTableClicked); + connect(ui->centralwidget, &QWidget::customContextMenuRequested, this, + &ProteinListWindow::showContextMenu); + connect(_protein_table_model_p, &ProteinTableModel::layoutChanged, this, + &ProteinListWindow::updateStatusBar); #else -// Qt4 code - connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - - connect (this, SIGNAL(proteinDataChanged()), _protein_table_model_p, SLOT(onProteinDataChanged())); - connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); - //connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &))); - //connect(ui->protein_search_edit, SIGNAL(textChanged(QString)), this, SLOT(onProteinSearchEdit(QString))); - - - //connect( this, SIGNAL( focusReceived(bool) ),this, SLOT(doFocusReceived(bool)) ); - connect(ui->centralwidget, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(showContextMenu(const QPoint &))); - //connect(_p_proxy_model, SIGNAL(layoutChanged()), - // this, SLOT(doProxyLayoutChanged())); - connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); + // Qt4 code + connect(_project_window, + SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this, + SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + + connect(this, SIGNAL(proteinDataChanged()), _protein_table_model_p, + SLOT(onProteinDataChanged())); + connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, + SLOT(onTableClicked(const QModelIndex &))); + // connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), + // _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &))); + // connect(ui->protein_search_edit, SIGNAL(textChanged(QString)), this, + // SLOT(onProteinSearchEdit(QString))); + + + // connect( this, SIGNAL( focusReceived(bool) ),this, + // SLOT(doFocusReceived(bool)) ); + connect(ui->centralwidget, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(showContextMenu(const QPoint &))); + // connect(_p_proxy_model, SIGNAL(layoutChanged()), + // this, SLOT(doProxyLayoutChanged())); + connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, + SLOT(updateStatusBar())); #endif } -void ProteinListWindow::doProxyLayoutChanged() { - qDebug() << "ProteinListWindow::doProxyLayoutChanged begin"; - //updateStatusBar(); - qDebug() << "ProteinListWindow::doProxyLayoutChanged end"; +void +ProteinListWindow::doProxyLayoutChanged() +{ + qDebug() << "ProteinListWindow::doProxyLayoutChanged begin"; + // updateStatusBar(); + qDebug() << "ProteinListWindow::doProxyLayoutChanged end"; } -void ProteinListWindow::askPeptideListView(ProteinMatch * p_protein_match) { - qDebug() << "ProteinListWindow::askPeptideListView begin"; - _project_window->doViewPeptideList(_p_identification_group, p_protein_match); - qDebug() << "ProteinListWindow::askPeptideListView end"; - //updateStatusBar(); +void +ProteinListWindow::askPeptideListView(ProteinMatch *p_protein_match) +{ + qDebug() << "ProteinListWindow::askPeptideListView begin"; + _project_window->doViewPeptideList(_p_identification_group, p_protein_match); + qDebug() << "ProteinListWindow::askPeptideListView end"; + // updateStatusBar(); } -void ProteinListWindow::askProteinDetailView(ProteinMatch * p_protein_match) { - qDebug() << "ProteinListWindow::askProteinDetailView begin"; - _project_window->doViewProteinDetail(p_protein_match); - qDebug() << "ProteinListWindow::askProteinDetailView end"; - //updateStatusBar(); +void +ProteinListWindow::askProteinDetailView(ProteinMatch *p_protein_match) +{ + qDebug() << "ProteinListWindow::askProteinDetailView begin"; + _project_window->doViewProteinDetail(p_protein_match); + qDebug() << "ProteinListWindow::askProteinDetailView end"; + // updateStatusBar(); } -void ProteinListWindow::doFocusReceived(bool has_focus) { - if (has_focus ) { - qDebug() << "ProteinListWindow::doFocusReceived begin"; - _project_window->setDefaultProteinListWindow(this); - qDebug() << "ProteinListWindow::doFocusReceived end"; +void +ProteinListWindow::doFocusReceived(bool has_focus) +{ + if(has_focus) + { + qDebug() << "ProteinListWindow::doFocusReceived begin"; + _project_window->setDefaultProteinListWindow(this); + qDebug() << "ProteinListWindow::doFocusReceived end"; } } -void ProteinListWindow::showContextMenu(const QPoint & pos) { - if (_p_context_menu == nullptr) { - _p_context_menu = new QMenu(tr("Context menu"), this); +void +ProteinListWindow::showContextMenu(const QPoint &pos) +{ + if(_p_context_menu == nullptr) + { + _p_context_menu = new QMenu(tr("Context menu"), this); - ProteinListQactionColumn * p_action; - for (unsigned int i=0; i < _protein_table_model_p->columnCount(); i++) { - p_action = new ProteinListQactionColumn(this,ProteinTableModel::getProteinListColumn(i)); - _p_context_menu->addAction(p_action); + ProteinListQactionColumn *p_action; + for(unsigned int i = 0; i < _protein_table_model_p->columnCount(); i++) + { + p_action = new ProteinListQactionColumn( + this, ProteinTableModel::getProteinListColumn(i)); + _p_context_menu->addAction(p_action); } - _p_context_menu->exec(mapToGlobal(pos)); + _p_context_menu->exec(mapToGlobal(pos)); } - _p_context_menu->move(mapToGlobal(pos)); - _p_context_menu->show(); + _p_context_menu->move(mapToGlobal(pos)); + _p_context_menu->show(); } ProteinListWindow::~ProteinListWindow() { - //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; - delete ui; - if (_p_context_menu != nullptr) { - delete _p_context_menu; + // if (_p_ms_data_file != nullptr) delete _p_ms_data_file; + delete ui; + if(_p_context_menu != nullptr) + { + delete _p_context_menu; } - } -void ProteinListWindow::edited() { - qDebug() << "ProteinListWindow::edited begin"; - //emit dataChanged(index, index); - _project_window->doIdentificationGroupEdited(_p_identification_group); - //updateStatusBar(); +void +ProteinListWindow::edited() +{ + qDebug() << "ProteinListWindow::edited begin"; + // emit dataChanged(index, index); + _project_window->doIdentificationGroupEdited(_p_identification_group); + // updateStatusBar(); - qDebug() << "ProteinListWindow::edited end"; + qDebug() << "ProteinListWindow::edited end"; } -void ProteinListWindow::doNotValidHide(bool hide) { - qDebug() << "ProteinListWindow::doNotValidHide begin"; - _p_proxy_model->hideNotValid(hide); - QSettings settings; - settings.setValue("proteinview/hidenotvalid", QString("%1").arg(hide)); - emit proteinDataChanged(); - qDebug() << "ProteinListWindow::doNotValidHide end"; +void +ProteinListWindow::doNotValidHide(bool hide) +{ + qDebug() << "ProteinListWindow::doNotValidHide begin"; + _p_proxy_model->hideNotValid(hide); + QSettings settings; + settings.setValue("proteinview/hidenotvalid", QString("%1").arg(hide)); + emit proteinDataChanged(); + qDebug() << "ProteinListWindow::doNotValidHide end"; } -void ProteinListWindow::doNotCheckedHide(bool hide) { - qDebug() << "ProteinListWindow::doNotCheckedHide begin"; - _p_proxy_model->hideNotChecked(hide); - QSettings settings; - settings.setValue("proteinview/hidenotchecked", QString("%1").arg(hide)); - emit proteinDataChanged(); - qDebug() << "ProteinListWindow::doNotCheckedHide end"; +void +ProteinListWindow::doNotCheckedHide(bool hide) +{ + qDebug() << "ProteinListWindow::doNotCheckedHide begin"; + _p_proxy_model->hideNotChecked(hide); + QSettings settings; + settings.setValue("proteinview/hidenotchecked", QString("%1").arg(hide)); + emit proteinDataChanged(); + qDebug() << "ProteinListWindow::doNotCheckedHide end"; } -void ProteinListWindow::doNotGroupedHide(bool hide) { - qDebug() << "ProteinListWindow::doNotGroupedHide begin"; - _p_proxy_model->hideNotGrouped(hide); - QSettings settings; - settings.setValue("proteinview/hidenotgrouped", QString("%1").arg(hide)); - emit proteinDataChanged(); - qDebug() << "ProteinListWindow::doNotGroupedHide end"; +void +ProteinListWindow::doNotGroupedHide(bool hide) +{ + qDebug() << "ProteinListWindow::doNotGroupedHide begin"; + _p_proxy_model->hideNotGrouped(hide); + QSettings settings; + settings.setValue("proteinview/hidenotgrouped", QString("%1").arg(hide)); + emit proteinDataChanged(); + qDebug() << "ProteinListWindow::doNotGroupedHide end"; } -void ProteinListWindow::doSearchOn(QString search_on) { - qDebug() << "ProteinTableProxyModel::doSearchOn begin " << search_on; - _p_proxy_model->setSearchOn( search_on); - ui->mod_auto_completion->setVisible(false); - ui->scan_number_edit->setVisible(false); - ui->msrun_auto_completion->setVisible(false); - ui->protein_search_edit->setVisible(false); - if (search_on == "msrun/scan" ) { - - qDebug() << "ProteinTableProxyModel::doSearchOn visible " << search_on; - ui->scan_number_edit->setVisible(true); - ui->msrun_auto_completion->setVisible(true); - } else if (search_on == "modifications" ) { - - qDebug() << "ProteinTableProxyModel::doSearchOn visible " << search_on; - ui->mod_auto_completion->setVisible(true); +void +ProteinListWindow::doSearchOn(QString search_on) +{ + qDebug() << "ProteinTableProxyModel::doSearchOn begin " << search_on; + _p_proxy_model->setSearchOn(search_on); + ui->mod_auto_completion->setVisible(false); + ui->scan_number_edit->setVisible(false); + ui->msrun_auto_completion->setVisible(false); + ui->protein_search_edit->setVisible(false); + if(search_on == "msrun/scan") + { + + qDebug() << "ProteinTableProxyModel::doSearchOn visible " << search_on; + ui->scan_number_edit->setVisible(true); + ui->msrun_auto_completion->setVisible(true); + } + else if(search_on == "modifications") + { + + qDebug() << "ProteinTableProxyModel::doSearchOn visible " << search_on; + ui->mod_auto_completion->setVisible(true); } - else { - qDebug() << "ProteinTableProxyModel::doSearchOn hidden " << search_on; - ui->protein_search_edit->setVisible(true); + else + { + qDebug() << "ProteinTableProxyModel::doSearchOn hidden " << search_on; + ui->protein_search_edit->setVisible(true); } - emit proteinDataChanged(); + emit proteinDataChanged(); } -void ProteinListWindow::doMsrunFileSearch(QString msr_run_file_search) { - //_p_proxy_model->setMsrunFileSearch(msr_run_file_search); - emit proteinDataChanged(); +void +ProteinListWindow::doMsrunFileSearch(QString msr_run_file_search) +{ + //_p_proxy_model->setMsrunFileSearch(msr_run_file_search); + emit proteinDataChanged(); } -void ProteinListWindow::doModificationSearch(QString mod_search) { - emit proteinDataChanged(); +void +ProteinListWindow::doModificationSearch(QString mod_search) +{ + emit proteinDataChanged(); } -void ProteinListWindow::doScanNumberSearch(int scan_num) { - emit proteinDataChanged(); +void +ProteinListWindow::doScanNumberSearch(int scan_num) +{ + emit proteinDataChanged(); } -void ProteinListWindow::onProteinSearchEdit(QString protein_search_string) { - qDebug() << "ProteinTableProxyModel::onProteinSearchEdit begin " << protein_search_string; - _p_proxy_model->setProteinSearchString(protein_search_string); - emit proteinDataChanged(); +void +ProteinListWindow::onProteinSearchEdit(QString protein_search_string) +{ + qDebug() << "ProteinTableProxyModel::onProteinSearchEdit begin " + << protein_search_string; + _p_proxy_model->setProteinSearchString(protein_search_string); + emit proteinDataChanged(); } -void ProteinListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { - qDebug() << "ProteinListWindow::doIdentificationGroupGrouped begin"; - if (_p_identification_group == p_identification_group) { - //_protein_table_model_p->setIdentificationGroup(p_identification_group); - //_p_proxy_model->setSourceModel(_protein_table_model_p); - emit proteinDataChanged(); +void +ProteinListWindow::doIdentificationGroupGrouped( + IdentificationGroup *p_identification_group) +{ + qDebug() << "ProteinListWindow::doIdentificationGroupGrouped begin"; + if(_p_identification_group == p_identification_group) + { + //_protein_table_model_p->setIdentificationGroup(p_identification_group); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + emit proteinDataChanged(); } - qDebug() << "ProteinListWindow::doIdentificationGroupGrouped end"; + qDebug() << "ProteinListWindow::doIdentificationGroupGrouped end"; } -void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { - qDebug() << "ProteinListWindow::setIdentificationGroup begin " ; - if (p_identification_group != nullptr) { - qDebug() << "ProteinListWindow::setIdentificationGroup not null"; - _p_identification_group = p_identification_group; - _protein_table_model_p->setIdentificationGroup(p_identification_group); - //_p_proxy_model->setSourceModel(_protein_table_model_p); - - if (_project_window->getProjectP()->getProjectMode() == ProjectMode::individual ) { - this->setWindowTitle(QString("%1 protein list").arg(_p_identification_group->getTabName())); +void +ProteinListWindow::setIdentificationGroup( + IdentificationGroup *p_identification_group) +{ + qDebug() << "ProteinListWindow::setIdentificationGroup begin "; + if(p_identification_group != nullptr) + { + qDebug() << "ProteinListWindow::setIdentificationGroup not null"; + _p_identification_group = p_identification_group; + _protein_table_model_p->setIdentificationGroup(p_identification_group); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + + if(_project_window->getProjectP()->getProjectMode() == + ProjectMode::individual) + { + this->setWindowTitle(QString("%1 protein list") + .arg(_p_identification_group->getTabName())); } - QStringList msrun_list; - for (MsRunSp msrun_sp : _p_identification_group->getMsRunSpList()) { - msrun_list << msrun_sp.get()->getFilename(); - qDebug() << "ProteinListWindow::setIdentificationGroup " << msrun_sp.get()->getFilename(); + QStringList msrun_list; + for(MsRunSp msrun_sp : _p_identification_group->getMsRunSpList()) + { + msrun_list << msrun_sp.get()->getFilename(); + qDebug() << "ProteinListWindow::setIdentificationGroup " + << msrun_sp.get()->getFilename(); } - QCompleter *completer = new QCompleter(msrun_list, this); - completer->setCaseSensitivity(Qt::CaseInsensitive); - - completer->setCompletionMode(QCompleter::PopupCompletion); - completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); - completer->setFilterMode(Qt::MatchContains); - ui->msrun_auto_completion->setCompleter(completer); - - - QStringList mod_list; - for (pappso::AaModificationP mod :_project_window->getProjectP()->getPeptideStore().getModificationCollection()) { - mod_list << QString("[%1] %2 %3").arg(mod->getAccession()).arg(mod->getName()).arg(mod->getMass()); - //qDebug() << "ProteinListWindow::setIdentificationGroup " << msrun_sp.get()->getFilename(); + QCompleter *completer = new QCompleter(msrun_list, this); + completer->setCaseSensitivity(Qt::CaseInsensitive); + + completer->setCompletionMode(QCompleter::PopupCompletion); + completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); + completer->setFilterMode(Qt::MatchContains); + ui->msrun_auto_completion->setCompleter(completer); + + + QStringList mod_list; + for(pappso::AaModificationP mod : _project_window->getProjectP() + ->getPeptideStore() + .getModificationCollection()) + { + mod_list << QString("[%1] %2 %3") + .arg(mod->getAccession()) + .arg(mod->getName()) + .arg(mod->getMass()); + // qDebug() << "ProteinListWindow::setIdentificationGroup " << + // msrun_sp.get()->getFilename(); } - completer = new QCompleter(mod_list, this); - completer->setCaseSensitivity(Qt::CaseInsensitive); + completer = new QCompleter(mod_list, this); + completer->setCaseSensitivity(Qt::CaseInsensitive); - completer->setCompletionMode(QCompleter::PopupCompletion); - completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); - completer->setFilterMode(Qt::MatchContains); - ui->mod_auto_completion->setCompleter(completer); + completer->setCompletionMode(QCompleter::PopupCompletion); + completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); + completer->setFilterMode(Qt::MatchContains); + ui->mod_auto_completion->setCompleter(completer); - _p_proxy_model->resteItemDelegates(); + _p_proxy_model->resteItemDelegates(); } - else { - qDebug() << "ProteinListWindow::setIdentificationGroup null"; + else + { + qDebug() << "ProteinListWindow::setIdentificationGroup null"; } - qDebug() << "ProteinListWindow::setIdentificationGroup end"; + qDebug() << "ProteinListWindow::setIdentificationGroup end"; } -void ProteinListWindow::updateStatusBar() { - if (_p_identification_group == nullptr) { +void +ProteinListWindow::updateStatusBar() +{ + if(_p_identification_group == nullptr) + { } - else { - ui->statusbar->showMessage(tr("proteins all:%1 valid:%2 valid&checked:%3 grouped:%4 displayed:%5").arg(_p_identification_group->countProteinMatch(ValidationState::notValid)).arg(_p_identification_group->countProteinMatch(ValidationState::valid)).arg(_p_identification_group->countProteinMatch(ValidationState::validAndChecked)).arg(_p_identification_group->countProteinMatch(ValidationState::grouped)).arg(_p_proxy_model->rowCount())); + else + { + ui->statusbar->showMessage( + tr("proteins all:%1 valid:%2 valid&checked:%3 grouped:%4 displayed:%5") + .arg(_p_identification_group->countProteinMatch( + ValidationState::notValid)) + .arg( + _p_identification_group->countProteinMatch(ValidationState::valid)) + .arg(_p_identification_group->countProteinMatch( + ValidationState::validAndChecked)) + .arg(_p_identification_group->countProteinMatch( + ValidationState::grouped)) + .arg(_p_proxy_model->rowCount())); } } -void ProteinListWindow::setProteinListColumnDisplay(ProteinListColumn column, bool toggled) { - _p_proxy_model->setProteinListColumnDisplay(column, toggled); +void +ProteinListWindow::setProteinListColumnDisplay(ProteinListColumn column, + bool toggled) +{ + _p_proxy_model->setProteinListColumnDisplay(column, toggled); } -bool ProteinListWindow::getProteinListColumnDisplay(ProteinListColumn column) const { - return _p_proxy_model->getProteinListColumnDisplay(column); +bool +ProteinListWindow::getProteinListColumnDisplay(ProteinListColumn column) const +{ + return _p_proxy_model->getProteinListColumnDisplay(column); } -void ProteinListWindow::resizeColumnsToContents() { - ui->tableView->resizeColumnsToContents(); +void +ProteinListWindow::resizeColumnsToContents() +{ + ui->tableView->resizeColumnsToContents(); } -ProjectWindow * ProteinListWindow::getProjectWindow() { - return _project_window; +ProjectWindow * +ProteinListWindow::getProjectWindow() +{ + return _project_window; } diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index e5d1d9d7163ebf27993b51e103bf703bf67bb721..a1015a9a3cb4dae50f4d6ba401aacd6fc6ad002b 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -1,25 +1,26 @@ /******************************************************************************* -* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef PROTEINLISTWINDOW_H #define PROTEINLISTWINDOW_H @@ -33,84 +34,86 @@ class ProjectWindow; -//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html -namespace Ui { -class ProteinView; +// http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html +namespace Ui +{ + class ProteinView; } class ProteinListWindow; -class ProteinListQactionColumn: public QAction { - Q_OBJECT -public: - - explicit ProteinListQactionColumn(ProteinListWindow * parent, ProteinListColumn column); - ~ProteinListQactionColumn(); - -public slots: - void doToggled(bool toggled); - -private: - ProteinListWindow * _p_protein_list_window; - ProteinListColumn _column; +class ProteinListQactionColumn : public QAction +{ + Q_OBJECT + public: + explicit ProteinListQactionColumn(ProteinListWindow *parent, + ProteinListColumn column); + ~ProteinListQactionColumn(); + + public slots: + void doToggled(bool toggled); + + private: + ProteinListWindow *_p_protein_list_window; + ProteinListColumn _column; }; -class ProteinListWindow: public QMainWindow { - Q_OBJECT - - friend class ProteinTableModel; - friend class ProteinTableProxyModel; -public: - - explicit ProteinListWindow(ProjectWindow * parent = 0); - ~ProteinListWindow(); - void setIdentificationGroup(IdentificationGroup * p_identification_group); - void setProteinListColumnDisplay(ProteinListColumn column, bool toggled); - bool getProteinListColumnDisplay(ProteinListColumn column) const; - void resizeColumnsToContents(); - - void edited(); - -public slots: - void doFocusReceived(bool has_focus); - void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group); - //void peptideEdited(QString peptideStr); - // void setColor(const QColor &color); - // void setShape(Shape shape); -signals: - void identificationGroupEdited(IdentificationGroup * p_identification_group); - void proteinDataChanged(); - - -protected slots: - void doNotValidHide(bool hide); - void doNotCheckedHide(bool hide); - void doNotGroupedHide(bool hide); - void doMsrunFileSearch(QString msr_run_file_search); - void doModificationSearch(QString mod_search); - void doScanNumberSearch(int scan_num); - void doProxyLayoutChanged(); - void showContextMenu(const QPoint &); - void updateStatusBar(); - void onProteinSearchEdit(QString protein_search_string); - void doSearchOn(QString search_on); - -protected : - void askProteinDetailView(ProteinMatch * p_protein_match); - void askPeptideListView(ProteinMatch * p_protein_match); - ProjectWindow * getProjectWindow(); - - - -private: - IdentificationGroup * _p_identification_group=nullptr; - Ui::ProteinView *ui; - ProteinTableModel * _protein_table_model_p = nullptr; - ProteinTableProxyModel * _p_proxy_model = nullptr; - ProjectWindow * _project_window; - QMenu * _p_context_menu = nullptr; - bool _display_evalue = true; - bool _display_accession = true; - +class ProteinListWindow : public QMainWindow +{ + Q_OBJECT + + friend class ProteinTableModel; + friend class ProteinTableProxyModel; + + public: + explicit ProteinListWindow(ProjectWindow *parent = 0); + ~ProteinListWindow(); + void setIdentificationGroup(IdentificationGroup *p_identification_group); + void setProteinListColumnDisplay(ProteinListColumn column, bool toggled); + bool getProteinListColumnDisplay(ProteinListColumn column) const; + void resizeColumnsToContents(); + + void edited(); + + public slots: + void doFocusReceived(bool has_focus); + void + doIdentificationGroupGrouped(IdentificationGroup *p_identification_group); + // void peptideEdited(QString peptideStr); + // void setColor(const QColor &color); + // void setShape(Shape shape); + signals: + void identificationGroupEdited(IdentificationGroup *p_identification_group); + void proteinDataChanged(); + + + protected slots: + void doNotValidHide(bool hide); + void doNotCheckedHide(bool hide); + void doNotGroupedHide(bool hide); + void doMsrunFileSearch(QString msr_run_file_search); + void doModificationSearch(QString mod_search); + void doScanNumberSearch(int scan_num); + void doProxyLayoutChanged(); + void showContextMenu(const QPoint &); + void updateStatusBar(); + void onProteinSearchEdit(QString protein_search_string); + void doSearchOn(QString search_on); + + protected: + void askProteinDetailView(ProteinMatch *p_protein_match); + void askPeptideListView(ProteinMatch *p_protein_match); + ProjectWindow *getProjectWindow(); + + + private: + IdentificationGroup *_p_identification_group = nullptr; + Ui::ProteinView *ui; + ProteinTableModel *_protein_table_model_p = nullptr; + ProteinTableProxyModel *_p_proxy_model = nullptr; + ProjectWindow *_project_window; + QMenu *_p_context_menu = nullptr; + bool _display_evalue = true; + bool _display_accession = true; }; #endif // PROTEINLISTWINDOW_H diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index efd5d1f62a417553f2f1f6e6e3505a5a3ef272af..490f40bb9af62e4406a2325e0be34d837bfa13f1 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.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 "proteintablemodel.h" #include <pappsomspp/grouping/grpprotein.h> @@ -30,314 +31,434 @@ #include "proteinlistwindow.h" #include "../../utils/types.h" -IdentificationGroup * ProteinTableModel::getIdentificationGroup() { - return _p_identification_group; +IdentificationGroup * +ProteinTableModel::getIdentificationGroup() +{ + return _p_identification_group; } -ProteinTableModel::ProteinTableModel(ProteinListWindow * p_protein_list_window) - :QAbstractTableModel(p_protein_list_window) +ProteinTableModel::ProteinTableModel(ProteinListWindow *p_protein_list_window) + : QAbstractTableModel(p_protein_list_window) { - _p_protein_list_window = p_protein_list_window; - _p_identification_group = nullptr; + _p_protein_list_window = p_protein_list_window; + _p_identification_group = nullptr; } -void ProteinTableModel::setIdentificationGroup(IdentificationGroup * p_identification_group) { - qDebug() << "ProteinTableModel::setIdentificationGroup begin " << p_identification_group->getProteinMatchList().size(); - beginResetModel(); - _p_identification_group = p_identification_group; - - //emit headerDataChanged(Qt::Horizontal, 0,11); - //refresh(); - qDebug() << "ProteinTableModel::setIdentificationGroup end "; - endResetModel(); - - _p_protein_list_window->resizeColumnsToContents(); +void +ProteinTableModel::setIdentificationGroup( + IdentificationGroup *p_identification_group) +{ + qDebug() << "ProteinTableModel::setIdentificationGroup begin " + << p_identification_group->getProteinMatchList().size(); + beginResetModel(); + _p_identification_group = p_identification_group; + + // emit headerDataChanged(Qt::Horizontal, 0,11); + // refresh(); + qDebug() << "ProteinTableModel::setIdentificationGroup end "; + endResetModel(); + + _p_protein_list_window->resizeColumnsToContents(); } -int ProteinTableModel::rowCount(const QModelIndex &parent ) const { - //qDebug() << "ProteinTableModel::rowCount begin "; - if (_p_identification_group != nullptr) { - //qDebug() << "ProteinTableModel::rowCount(const QModelIndex &parent ) " << _p_identification_group->getProteinMatchList().size(); - return (int) _p_identification_group->getProteinMatchList().size(); +int +ProteinTableModel::rowCount(const QModelIndex &parent) const +{ + // qDebug() << "ProteinTableModel::rowCount begin "; + if(_p_identification_group != nullptr) + { + // qDebug() << "ProteinTableModel::rowCount(const QModelIndex &parent ) " + // << _p_identification_group->getProteinMatchList().size(); + return (int)_p_identification_group->getProteinMatchList().size(); } - return 0; + return 0; } -int ProteinTableModel::columnCount(const QModelIndex &parent ) const { - //qDebug() << "ProteinTableModel::columnCount begin "; - if (_p_identification_group != nullptr) { - return 14; +int +ProteinTableModel::columnCount(const QModelIndex &parent) const +{ + // qDebug() << "ProteinTableModel::columnCount begin "; + if(_p_identification_group != nullptr) + { + return 14; } - return 0; + return 0; } -const QString ProteinTableModel::getTitle(ProteinListColumn column) { - qDebug() << "ProteinTableModel::getTitle begin "; - return ProteinTableModel::getTitle((std::int8_t) column); - //qDebug() << "ProteinTableModel::getTitle end "; +const QString +ProteinTableModel::getTitle(ProteinListColumn column) +{ + qDebug() << "ProteinTableModel::getTitle begin "; + return ProteinTableModel::getTitle((std::int8_t)column); + // qDebug() << "ProteinTableModel::getTitle end "; } -const QString ProteinTableModel::getDescription(ProteinListColumn column) { - qDebug() << "ProteinTableModel::columnCount begin "; - return ProteinTableModel::getDescription((std::int8_t) column); - //qDebug() << "ProteinTableModel::columnCount end "; +const QString +ProteinTableModel::getDescription(ProteinListColumn column) +{ + qDebug() << "ProteinTableModel::columnCount begin "; + return ProteinTableModel::getDescription((std::int8_t)column); + // qDebug() << "ProteinTableModel::columnCount end "; } -const QString ProteinTableModel::getTitle(std::int8_t column) { +const QString +ProteinTableModel::getTitle(std::int8_t column) +{ - qDebug() << "ProteinTableModel::getTitle begin " << column; - switch (column) { + qDebug() << "ProteinTableModel::getTitle begin " << column; + switch(column) + { - case (std::int8_t) ProteinListColumn::checked: + case(std::int8_t)ProteinListColumn::checked: return "checked"; break; - case (std::int8_t) ProteinListColumn::protein_grouping_id: + case(std::int8_t)ProteinListColumn::protein_grouping_id: return "group"; break; - case (std::int8_t) ProteinListColumn::accession: + case(std::int8_t)ProteinListColumn::accession: return "accession"; break; - case (std::int8_t) ProteinListColumn::description: + case(std::int8_t)ProteinListColumn::description: return "description"; break; - case (std::int8_t) ProteinListColumn::log_evalue: + case(std::int8_t)ProteinListColumn::log_evalue: return "log(Evalue)"; break; - case (std::int8_t) ProteinListColumn::evalue: + case(std::int8_t)ProteinListColumn::evalue: return "Evalue"; break; - case (std::int8_t) ProteinListColumn::spectrum: + case(std::int8_t)ProteinListColumn::spectrum: return "spectra"; break; - case (std::int8_t) ProteinListColumn::specific_spectrum: + case(std::int8_t)ProteinListColumn::specific_spectrum: return "specific spectra"; break; - case (std::int8_t) ProteinListColumn::sequence: + case(std::int8_t)ProteinListColumn::sequence: return "sequences"; break; - case (std::int8_t) ProteinListColumn::coverage: + case(std::int8_t)ProteinListColumn::coverage: return "coverage"; break; - case (std::int8_t) ProteinListColumn::pai: + case(std::int8_t)ProteinListColumn::pai: return "PAI"; break; - case (std::int8_t) ProteinListColumn::empai: + case(std::int8_t)ProteinListColumn::empai: return "emPAI"; break; - case (std::int8_t) ProteinListColumn::specific_sequence: + case(std::int8_t)ProteinListColumn::specific_sequence: return "specific sequences"; - case (std::int8_t) ProteinListColumn::molecular_weight: + case(std::int8_t)ProteinListColumn::molecular_weight: return "MW"; break; - - } - return ""; + return ""; } -const QString ProteinTableModel::getDescription(std::int8_t column) { +const QString +ProteinTableModel::getDescription(std::int8_t column) +{ - qDebug() << "ProteinTableModel::getDescription begin " << column; - switch (column) { + qDebug() << "ProteinTableModel::getDescription begin " << column; + switch(column) + { - case (std::int8_t) ProteinListColumn::checked: + case(std::int8_t)ProteinListColumn::checked: return "manual protein check"; break; - case (std::int8_t) ProteinListColumn::protein_grouping_id: + case(std::int8_t)ProteinListColumn::protein_grouping_id: return "unique protein identifier within this grouping experiment"; break; - case (std::int8_t) ProteinListColumn::accession: + case(std::int8_t)ProteinListColumn::accession: return "protein accession"; break; - case (std::int8_t) ProteinListColumn::description: + case(std::int8_t)ProteinListColumn::description: return "protein description"; break; - case (std::int8_t) ProteinListColumn::log_evalue: + case(std::int8_t)ProteinListColumn::log_evalue: return "log(Evalue)"; break; - case (std::int8_t) ProteinListColumn::evalue: + case(std::int8_t)ProteinListColumn::evalue: return "protein Evalue"; break; - case (std::int8_t) ProteinListColumn::spectrum: + case(std::int8_t)ProteinListColumn::spectrum: return "number of distinct MS spectrum assigned to this protein"; break; - case (std::int8_t) ProteinListColumn::specific_spectrum: - return "number of distinct MS spectrum only assigned to this protein within the group"; + case(std::int8_t)ProteinListColumn::specific_spectrum: + return "number of distinct MS spectrum only assigned to this protein " + "within the group"; break; - case (std::int8_t) ProteinListColumn::sequence: + case(std::int8_t)ProteinListColumn::sequence: return "number of unique distinct peptide sequences"; break; - case (std::int8_t) ProteinListColumn::coverage: + case(std::int8_t)ProteinListColumn::coverage: return "protein coverage (ratio)"; break; - case (std::int8_t) ProteinListColumn::pai: + case(std::int8_t)ProteinListColumn::pai: return "Protein Abundance Index (Rappsilber et al. 2002)"; break; - case (std::int8_t) ProteinListColumn::empai: - return "Exponentially Modified Protein Abundance Index (emPAI) as described by Ishihama 2005"; + case(std::int8_t)ProteinListColumn::empai: + return "Exponentially Modified Protein Abundance Index (emPAI) as " + "described by Ishihama 2005"; break; - case (std::int8_t) ProteinListColumn::specific_sequence: - return "number of unique distinct peptide sequences only assigned to this protein within the group"; + case(std::int8_t)ProteinListColumn::specific_sequence: + return "number of unique distinct peptide sequences only assigned to " + "this protein within the group"; - case (std::int8_t) ProteinListColumn::molecular_weight: + case(std::int8_t)ProteinListColumn::molecular_weight: return "protein molecular weight in Dalton"; } - return ""; + return ""; } -QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant +ProteinTableModel::headerData(int section, Qt::Orientation orientation, + int role) const { - if (_p_identification_group == nullptr) return QVariant(); - if (orientation == Qt::Horizontal) + if(_p_identification_group == nullptr) + return QVariant(); + if(orientation == Qt::Horizontal) { - switch (role) { - case Qt::DisplayRole : + switch(role) + { + case Qt::DisplayRole: return QVariant(getTitle(section)); break; - case Qt::ToolTipRole : + case Qt::ToolTipRole: return QVariant(getDescription(section)); break; - case Qt::SizeHintRole : - //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); - return QSize( ProteinTableModel::getColumnWidth(section), 40 ); + case Qt::SizeHintRole: + // qDebug() << "ProteinTableModel::headerData " << + // ProteinTableModel::getColumnWidth(section); + return QSize(ProteinTableModel::getColumnWidth(section), 40); break; } } - return QVariant(); + return QVariant(); } -int ProteinTableModel::getColumnWidth(int column) { - qDebug() << "ProteinTableModel::getColumnWidth " << column; - switch (column) { +int +ProteinTableModel::getColumnWidth(int column) +{ + qDebug() << "ProteinTableModel::getColumnWidth " << column; + switch(column) + { - case (int) ProteinListColumn::checked: + case(int)ProteinListColumn::checked: break; - case (int) ProteinListColumn::protein_grouping_id: + case(int)ProteinListColumn::protein_grouping_id: return 120; break; - case (int) ProteinListColumn::accession: + case(int)ProteinListColumn::accession: qDebug() << "ProteinTableModel::getColumnWidth accession " << column; return 250; break; - case (int) ProteinListColumn::description: + case(int)ProteinListColumn::description: return 400; break; } - return 100; + return 100; } -ProteinListColumn ProteinTableModel::getProteinListColumn(std::int8_t column) { - return static_cast<ProteinListColumn>(column); +ProteinListColumn +ProteinTableModel::getProteinListColumn(std::int8_t column) +{ + return static_cast<ProteinListColumn>(column); } -QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { - // generate a log message when this method gets called - if (_p_identification_group == nullptr) return QVariant(); - 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: +QVariant +ProteinTableModel::data(const QModelIndex &index, int role) const +{ + // generate a log message when this method gets called + if(_p_identification_group == nullptr) + return QVariant(); + int row = index.row(); + int col = index.column(); + // qDebug() << QString("row %1, col%2, role %3") + // .arg(row).arg(col).arg(role); - if (col == 0) //add a checkbox to cell(1,0) - { - if ( _p_identification_group->getProteinMatchList().at(row)->isChecked()) { + switch(role) + { + case Qt::CheckStateRole: + + if(col == 0) // add a checkbox to cell(1,0) + { + if(_p_identification_group->getProteinMatchList() + .at(row) + ->isChecked()) + { return Qt::Checked; - } - else { + } + else + { return Qt::Unchecked; - } - } - break; - case Qt::SizeHintRole : - //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); - return QSize( ProteinTableModel::getColumnWidth(col), 30 ); - break; - case Qt::BackgroundRole: - if (_p_identification_group->getProteinMatchList().at(row)->isValid() == false) - { + } + } + break; + case Qt::SizeHintRole: + // qDebug() << "ProteinTableModel::headerData " << + // ProteinTableModel::getColumnWidth(section); + return QSize(ProteinTableModel::getColumnWidth(col), 30); + break; + case Qt::BackgroundRole: + if(_p_identification_group->getProteinMatchList().at(row)->isValid() == + false) + { return QVariant(QColor("grey")); - } - if (_p_identification_group->getProteinMatchList().at(row)->getProteinXtpSp().get()->isDecoy() == true) - { + } + if(_p_identification_group->getProteinMatchList() + .at(row) + ->getProteinXtpSp() + .get() + ->isDecoy() == true) + { return QVariant(QColor("orange")); - } - if (_p_identification_group->getProteinMatchList().at(row)->getProteinXtpSp().get()->isContaminant() == true) - { + } + if(_p_identification_group->getProteinMatchList() + .at(row) + ->getProteinXtpSp() + .get() + ->isContaminant() == true) + { return QVariant(QColor("orange")); - } + } break; - case Qt::DisplayRole: - if (_p_identification_group == nullptr) { - return QVariant(); - } - switch (col) { - case (std::int8_t)ProteinListColumn::checked: - return QVariant(); - break; - - case (std::int8_t)ProteinListColumn::protein_grouping_id: - pappso::GrpProtein * p_grp_prot = _p_identification_group->getProteinMatchList().at(row)->getGrpProteinSp().get(); - if (p_grp_prot != nullptr) return p_grp_prot->getGroupingId(); + case Qt::DisplayRole: + if(_p_identification_group == nullptr) + { return QVariant(); - break; - } - if (col == (std::int8_t) ProteinListColumn::accession ) { - return QVariant(_p_identification_group->getProteinMatchList().at(row)->getProteinXtpSp().get()->getAccession()); - - } - - if (col == (std::int8_t) ProteinListColumn::description ) { - return _p_identification_group->getProteinMatchList().at(row)->getProteinXtpSp().get()->getDescription(); - } - if (col == (std::int8_t) ProteinListColumn::log_evalue ) { - return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getLogEvalue()); - } - - if (col == (std::int8_t) ProteinListColumn::evalue ) { - return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getEvalue()); - } - if (col == (std::int8_t) ProteinListColumn::spectrum ) { - return QVariant ((qreal) _p_identification_group->getProteinMatchList().at(row)->countSampleScan(ValidationState::validAndChecked)); - } - - if (col == (std::int8_t) ProteinListColumn::specific_spectrum ) { - GroupingGroup * p_groupin_group = _p_identification_group->getProteinMatchList().at(row)->getGroupingGroupSp().get(); - if (p_groupin_group != nullptr) { - return QVariant ((qreal) p_groupin_group->countSpecificSampleScan(_p_identification_group->getProteinMatchList().at(row),ValidationState::validAndChecked)); - } - } - - if (col == (std::int8_t) ProteinListColumn::sequence ) { - return QVariant ((qreal) _p_identification_group->getProteinMatchList().at(row)->countSequenceLi(ValidationState::validAndChecked)); - } - if (col == (std::int8_t) ProteinListColumn::specific_sequence ) { - GroupingGroup * p_groupin_group = _p_identification_group->getProteinMatchList().at(row)->getGroupingGroupSp().get(); - if (p_groupin_group != nullptr) { - return QVariant ((qreal) p_groupin_group->countSpecificSequenceLi(_p_identification_group->getProteinMatchList().at(row),ValidationState::validAndChecked)); - } - } - if (col == (std::int8_t) ProteinListColumn::coverage ) { - return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getCoverage()); - } - - if (col == (std::int8_t) ProteinListColumn::pai ) { - return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getPAI()); - } - if (col == (std::int8_t) ProteinListColumn::empai ) { - return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getEmPAI()); - } - if (col == (std::int8_t) ProteinListColumn::molecular_weight ) { - return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getProteinXtpSp().get()->getMass()); - } + } + switch(col) + { + case(std::int8_t)ProteinListColumn::checked: + return QVariant(); + break; + + case(std::int8_t)ProteinListColumn::protein_grouping_id: + pappso::GrpProtein *p_grp_prot = + _p_identification_group->getProteinMatchList() + .at(row) + ->getGrpProteinSp() + .get(); + if(p_grp_prot != nullptr) + return p_grp_prot->getGroupingId(); + return QVariant(); + break; + } + if(col == (std::int8_t)ProteinListColumn::accession) + { + return QVariant(_p_identification_group->getProteinMatchList() + .at(row) + ->getProteinXtpSp() + .get() + ->getAccession()); + } + + if(col == (std::int8_t)ProteinListColumn::description) + { + return _p_identification_group->getProteinMatchList() + .at(row) + ->getProteinXtpSp() + .get() + ->getDescription(); + } + if(col == (std::int8_t)ProteinListColumn::log_evalue) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->getLogEvalue()); + } + + if(col == (std::int8_t)ProteinListColumn::evalue) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->getEvalue()); + } + if(col == (std::int8_t)ProteinListColumn::spectrum) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->countSampleScan(ValidationState::validAndChecked)); + } + + if(col == (std::int8_t)ProteinListColumn::specific_spectrum) + { + GroupingGroup *p_groupin_group = + _p_identification_group->getProteinMatchList() + .at(row) + ->getGroupingGroupSp() + .get(); + if(p_groupin_group != nullptr) + { + return QVariant((qreal)p_groupin_group->countSpecificSampleScan( + _p_identification_group->getProteinMatchList().at(row), + ValidationState::validAndChecked)); + } + } + + if(col == (std::int8_t)ProteinListColumn::sequence) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->countSequenceLi(ValidationState::validAndChecked)); + } + if(col == (std::int8_t)ProteinListColumn::specific_sequence) + { + GroupingGroup *p_groupin_group = + _p_identification_group->getProteinMatchList() + .at(row) + ->getGroupingGroupSp() + .get(); + if(p_groupin_group != nullptr) + { + return QVariant((qreal)p_groupin_group->countSpecificSequenceLi( + _p_identification_group->getProteinMatchList().at(row), + ValidationState::validAndChecked)); + } + } + if(col == (std::int8_t)ProteinListColumn::coverage) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->getCoverage()); + } + + if(col == (std::int8_t)ProteinListColumn::pai) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->getPAI()); + } + if(col == (std::int8_t)ProteinListColumn::empai) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->getEmPAI()); + } + if(col == (std::int8_t)ProteinListColumn::molecular_weight) + { + return QVariant( + (qreal)_p_identification_group->getProteinMatchList() + .at(row) + ->getProteinXtpSp() + .get() + ->getMass()); + } return QVariant(); } - return QVariant(); + return QVariant(); } -void ProteinTableModel::onProteinDataChanged() { - qDebug() << "ProteinTableModel::onProteinDataChanged begin " << rowCount(); - emit layoutAboutToBeChanged(); - emit layoutChanged(); +void +ProteinTableModel::onProteinDataChanged() +{ + qDebug() << "ProteinTableModel::onProteinDataChanged begin " << rowCount(); + emit layoutAboutToBeChanged(); + emit layoutChanged(); } diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index a3f103260b31cb002f89ab043ae3e69519d17543..6cdaa1ce25844a2f4998f71d9d9dcc886edb3b90 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.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 PROTEINTABLEMODEL_H #define PROTEINTABLEMODEL_H @@ -32,53 +33,59 @@ * */ -enum class ProteinListColumn: std::int8_t { - checked=0, ///< manual checked - protein_grouping_id=1, ///< protein grouping id - accession=2, ///< accession - description=3, ///< protein description - log_evalue=4, ///< log(Evalue) - evalue=5, ///< Evalue - spectrum=6, ///< spectrum count - specific_spectrum=7, ///< specific spectrum count - sequence=8, ///< unique sequence count - specific_sequence=9, ///< specific unique sequence - coverage=10, ///< protein coverage - molecular_weight=11, ///< protein molecular weight in Dalton - pai=12, ///< PAI - empai=13, ///< emPAI +enum class ProteinListColumn : std::int8_t +{ + checked = 0, ///< manual checked + protein_grouping_id = 1, ///< protein grouping id + accession = 2, ///< accession + description = 3, ///< protein description + log_evalue = 4, ///< log(Evalue) + evalue = 5, ///< Evalue + spectrum = 6, ///< spectrum count + specific_spectrum = 7, ///< specific spectrum count + sequence = 8, ///< unique sequence count + specific_sequence = 9, ///< specific unique sequence + coverage = 10, ///< protein coverage + molecular_weight = 11, ///< protein molecular weight in Dalton + pai = 12, ///< PAI + empai = 13, ///< emPAI }; class ProteinListWindow; -class ProteinTableModel: public QAbstractTableModel +class ProteinTableModel : public QAbstractTableModel { - Q_OBJECT -public: - ProteinTableModel(ProteinListWindow * p_protein_list_window); - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Q_OBJECT + public: + ProteinTableModel(ProteinListWindow *p_protein_list_window); + virtual int + rowCount(const QModelIndex &parent = QModelIndex()) const override; + virtual int + columnCount(const QModelIndex &parent = QModelIndex()) const override; + virtual QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + virtual QVariant data(const QModelIndex &index, + int role = Qt::DisplayRole) const override; + + static const QString getTitle(ProteinListColumn column); + static const QString getDescription(ProteinListColumn column); + static const QString getTitle(std::int8_t column); + static const QString getDescription(std::int8_t column); + static ProteinListColumn getProteinListColumn(std::int8_t column); - static const QString getTitle(ProteinListColumn column); - static const QString getDescription(ProteinListColumn column); - static const QString getTitle(std::int8_t column); - static const QString getDescription(std::int8_t column); - static ProteinListColumn getProteinListColumn(std::int8_t column); + void setIdentificationGroup(IdentificationGroup *p_identification_group); + IdentificationGroup *getIdentificationGroup(); + public slots: + void onProteinDataChanged(); - void setIdentificationGroup(IdentificationGroup * p_identification_group); - IdentificationGroup * getIdentificationGroup(); -public slots: - void onProteinDataChanged(); -private : + private: + static int getColumnWidth(int column); + void refresh(); - static int getColumnWidth(int column); - void refresh(); -private : - IdentificationGroup * _p_identification_group = nullptr; - ProteinListWindow * _p_protein_list_window; + private: + IdentificationGroup *_p_identification_group = nullptr; + ProteinListWindow *_p_protein_list_window; }; #endif // PROTEINTABLEMODEL_H diff --git a/src/gui/protein_view/proteinwindow.cpp b/src/gui/protein_view/proteinwindow.cpp index 31c8e83ea8cb2e71035dc2c7ce30a0bd11103d82..0e69385626f0834edfb0da01fffb16ea19c61246 100644 --- a/src/gui/protein_view/proteinwindow.cpp +++ b/src/gui/protein_view/proteinwindow.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 "proteinwindow.h" #include "../project_view/projectwindow.h" @@ -33,223 +34,277 @@ //#include <QWebEnginePage> //#include <QtWebEngine> -DbXrefButton::DbXrefButton(QWidget * parent, DbXref dbxref): QPushButton(parent) { - _dbxref = dbxref; +DbXrefButton::DbXrefButton(QWidget *parent, DbXref dbxref) : QPushButton(parent) +{ + _dbxref = dbxref; #if QT_VERSION >= 0x050000 - // Qt5 code - QObject::connect(this, &DbXrefButton::clicked,this, &DbXrefButton::clickedSlot); + // Qt5 code + QObject::connect(this, &DbXrefButton::clicked, this, + &DbXrefButton::clickedSlot); #else -// Qt4 code - QObject::connect(this, SIGNAL(clicked()),this, SLOT(clickedSlot())); + // Qt4 code + QObject::connect(this, SIGNAL(clicked()), this, SLOT(clickedSlot())); #endif - setText(_dbxref.accession); + setText(_dbxref.accession); } -void DbXrefButton::clickedSlot() { - qDebug() << "DbXrefButton::clickedSlot " << _dbxref.getUrl(); - QDesktopServices::openUrl (_dbxref.getUrl()) ; +void +DbXrefButton::clickedSlot() +{ + qDebug() << "DbXrefButton::clickedSlot " << _dbxref.getUrl(); + QDesktopServices::openUrl(_dbxref.getUrl()); } -ProteinWindow::ProteinWindow(ProjectWindow *parent): - QMainWindow(parent), - ui(new Ui::ProteinDetailView) +ProteinWindow::ProteinWindow(ProjectWindow *parent) + : QMainWindow(parent), ui(new Ui::ProteinDetailView) { - _p_project_window = parent; - ui->setupUi(this); - /* - */ + _p_project_window = parent; + ui->setupUi(this); + /* + */ #if QT_VERSION >= 0x050000 - // Qt5 code - connect (_p_project_window, &ProjectWindow::identificationGroupGrouped, this,&ProteinWindow::doIdentificationGroupGrouped); - connect (_p_project_window, &ProjectWindow::peptideEvidenceSelected, this,&ProteinWindow::doPeptideEvidenceSelected); + // Qt5 code + connect(_p_project_window, &ProjectWindow::identificationGroupGrouped, this, + &ProteinWindow::doIdentificationGroupGrouped); + connect(_p_project_window, &ProjectWindow::peptideEvidenceSelected, this, + &ProteinWindow::doPeptideEvidenceSelected); #else -// Qt4 code - connect (_p_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - connect (_p_project_window, SIGNAL(peptideMatchSelected(PeptideMatch*)), this,SLOT(doPeptideMatchSelected(PeptideMatch*))); - - //connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); + // Qt4 code + connect(_p_project_window, + SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this, + SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + connect(_p_project_window, SIGNAL(peptideMatchSelected(PeptideMatch *)), this, + SLOT(doPeptideMatchSelected(PeptideMatch *))); + + // connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, + // SLOT(updateStatusBar())); #endif } ProteinWindow::~ProteinWindow() { - clearDbXrefLayout(); - delete ui; + clearDbXrefLayout(); + delete ui; } -void ProteinWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { - updateDisplay(); +void +ProteinWindow::doIdentificationGroupGrouped( + IdentificationGroup *p_identification_group) +{ + updateDisplay(); } -void ProteinWindow::doPeptideEvidenceSelected(PeptideEvidence * peptide_evidence) { - if (peptide_evidence != nullptr) { - ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence(peptide_evidence)); - +void +ProteinWindow::doPeptideEvidenceSelected(PeptideEvidence *peptide_evidence) +{ + if(peptide_evidence != nullptr) + { + ui->sequenceTextEdit->setText( + _p_protein_match->getHtmlSequence(peptide_evidence)); } } -void ProteinWindow::clearDbXrefLayout() { - for (int i = 0; i < ui->dbxref_list_layout->count(); ++i) +void +ProteinWindow::clearDbXrefLayout() +{ + for(int i = 0; i < ui->dbxref_list_layout->count(); ++i) { - delete ui->dbxref_list_layout->itemAt(i)->widget(); + delete ui->dbxref_list_layout->itemAt(i)->widget(); } } -void ProteinWindow::browseUrl(int i) { +void +ProteinWindow::browseUrl(int i) +{ } -void ProteinWindow::updateDisplay() { - try { - clearDbXrefLayout(); - ui->valid_checkbox->setCheckState(Qt::Unchecked); - if (_p_protein_match->isValid()) ui->valid_checkbox->setCheckState(Qt::Checked); - ui->decoy_checkbox->setCheckState(Qt::Unchecked); - if (_p_protein_match->getProteinXtpSp().get()->isDecoy()) ui->decoy_checkbox->setCheckState(Qt::Checked); - ui->accession_label->setText(_p_protein_match->getProteinXtpSp().get()->getAccession()); - for (const DbXref & dbxref:_p_protein_match->getProteinXtpSp().get()->getDbxrefList()) { - QString accession = ui->accession_label->text().replace(dbxref.accession, QString("<span style=\"color:%2;\">%1</span>").arg(dbxref.accession).arg("blue")); - ui->accession_label->setText(accession); - qDebug() << "ProteinWindow::updateDisplay " << accession; - - DbXrefButton * dbxref_button = new DbXrefButton(this,dbxref); - ui->dbxref_list_layout->addWidget(dbxref_button); +void +ProteinWindow::updateDisplay() +{ + try + { + clearDbXrefLayout(); + ui->valid_checkbox->setCheckState(Qt::Unchecked); + if(_p_protein_match->isValid()) + ui->valid_checkbox->setCheckState(Qt::Checked); + ui->decoy_checkbox->setCheckState(Qt::Unchecked); + if(_p_protein_match->getProteinXtpSp().get()->isDecoy()) + ui->decoy_checkbox->setCheckState(Qt::Checked); + ui->accession_label->setText( + _p_protein_match->getProteinXtpSp().get()->getAccession()); + for(const DbXref &dbxref : + _p_protein_match->getProteinXtpSp().get()->getDbxrefList()) + { + QString accession = ui->accession_label->text().replace( + dbxref.accession, QString("<span style=\"color:%2;\">%1</span>") + .arg(dbxref.accession) + .arg("blue")); + ui->accession_label->setText(accession); + qDebug() << "ProteinWindow::updateDisplay " << accession; + + DbXrefButton *dbxref_button = new DbXrefButton(this, dbxref); + ui->dbxref_list_layout->addWidget(dbxref_button); } - ui->button_layout->setVisible(true); - if (ui->dbxref_list_layout->count() == 0) { - ui->button_layout->setVisible(false); + ui->button_layout->setVisible(true); + if(ui->dbxref_list_layout->count() == 0) + { + ui->button_layout->setVisible(false); } - ui->description_label->setText(_p_protein_match->getProteinXtpSp().get()->getDescription()); - ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence()); - ui->coverage_label->setText(QString("%1 %").arg(_p_protein_match->getCoverage()*100)); - ui->mw_label->setText(QString("%1 kDa").arg(_p_protein_match->getProteinXtpSp().get()->getMass()/1000)); - ui->evalue_label->setText(QString("%1 (log10: %2)").arg(_p_protein_match->getEvalue()).arg(_p_protein_match->getLogEvalue())); + ui->description_label->setText( + _p_protein_match->getProteinXtpSp().get()->getDescription()); + ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence()); + ui->coverage_label->setText( + QString("%1 %").arg(_p_protein_match->getCoverage() * 100)); + ui->mw_label->setText(QString("%1 kDa").arg( + _p_protein_match->getProteinXtpSp().get()->getMass() / 1000)); + ui->evalue_label->setText(QString("%1 (log10: %2)") + .arg(_p_protein_match->getEvalue()) + .arg(_p_protein_match->getLogEvalue())); } - catch (pappso::PappsoException exception_pappso) { - QMessageBox::warning(this, - tr("Unable to display protein details :"), exception_pappso.qwhat()); + catch(pappso::PappsoException exception_pappso) + { + QMessageBox::warning(this, tr("Unable to display protein details :"), + exception_pappso.qwhat()); } - catch (std::exception exception_std) { - QMessageBox::warning(this, - tr("Unable to display protein details :"), exception_std.what()); + catch(std::exception exception_std) + { + QMessageBox::warning(this, tr("Unable to display protein details :"), + exception_std.what()); } - } -void ProteinWindow::setProteinMatch(ProteinMatch * p_protein_match) { - _p_protein_match = p_protein_match; - updateDisplay(); +void +ProteinWindow::setProteinMatch(ProteinMatch *p_protein_match) +{ + _p_protein_match = p_protein_match; + updateDisplay(); } -void ProteinWindow::doSaveSvg() { +void +ProteinWindow::doSaveSvg() +{ - try { - QSettings settings; - QString default_location = settings.value("path/export_svg", "").toString(); + try + { + QSettings settings; + QString default_location = + settings.value("path/export_svg", "").toString(); - QString proposed_filename = QString("%1/protein_%1.pdf").arg(_p_protein_match->getProteinXtpSp().get()->getAccession()); + QString proposed_filename = + QString("%1/protein_%1.pdf") + .arg(_p_protein_match->getProteinXtpSp().get()->getAccession()); - QString filename = QFileDialog::getSaveFileName(this, tr("Save PDF file"), - proposed_filename, - tr("pdf (*.pdf)")); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save PDF file"), proposed_filename, tr("pdf (*.pdf)")); - if (filename.isEmpty()) { - return; + if(filename.isEmpty()) + { + return; } - settings.setValue("path/export_svg", QFileInfo(filename).absolutePath()); - - //https://bugreports.qt.io/browse/QTBUG-52538 - QPrinter printer(QPrinter::PrinterResolution); - printer.setOutputFormat(QPrinter::PdfFormat); - printer.setPaperSize(QPrinter::A4); - printer.setOutputFileName(filename); - /* - QSvgGenerator generator; - //generator.setOutputDevice(&buffer); - QSize size(600, 1000); - generator.setFileName(filename); - generator.setSize(size); - generator.setViewBox(QRect(0, 0, size.width(), size.height())); - generator.setTitle(_p_protein_match->getProteinXtpSp().get()->getAccession()); - */ - - //generator.setDescription(description); - //QPainter painter; - //painter.begin(&generator); - //painter.setViewport(0,0, size.width(), size.height()); - - // ui->sequenceTextEdit->document()->drawContents(&painter); - // painter.end(); - //QFont::Monospace - QFont font("Monospace"); - font.setStyleHint(QFont::Monospace); - font.setLetterSpacing(QFont::AbsoluteSpacing,0); - font.setPointSize(10); //generator.setDefaultFont(font); - - QTextOption text_option; - text_option.setWrapMode(QTextOption::WrapAnywhere); - text_option.setFlags(QTextOption::IncludeTrailingSpaces|QTextOption::ShowTabsAndSpaces); - text_option.setUseDesignMetrics(0); - - //QTextDocument *doc = ui->sequenceTextEdit->document()->clone(); - QTextDocument *doc = new QTextDocument(); - doc->setHtml(QString("<p>%1</p><p>%2</p><p>%3</p>").arg(_p_protein_match->getProteinXtpSp().get()->getAccession()).arg(_p_protein_match->getProteinXtpSp().get()->getDescription()).arg(ui->sequenceTextEdit->toHtml())); - doc->setUndoRedoEnabled(false); - //doc->setHtml("<p><span style=\"color:#000000; font-weight:600\">"+text_x+"</span></p>"); - doc->setTextWidth(printer.pageRect().size().width()); - doc->setDefaultFont(font); - doc->setPageSize(printer.pageRect().size()); - //// height from doc QTextDocument - //// http://fop-miniscribus.googlecode.com/svn/trunk/fop_miniscribus.1.0.0/src/floating_box/floatdiagram.cpp - //////setMaximumHeight(DocumentHighgtActual()); - doc->setPageSize(printer.pageRect().size()); // This is necessary if you want to hide the page number - doc->print(&printer); - - /* - QPainter *painter = new QPainter(&generator); - painter->setRenderHint(QPainter::Antialiasing, true); - painter->setFont(font); - doc->drawContents(painter); - painter->end(); - */ - - - /* - QSvgGenerator svg; - svg.setFileName(filename); - QTextDocument *doc = ui->sequenceTextEdit->document()->clone(); - QRect rectSize(0, 0, (int) doc->size().width(), (int) doc->size().height()); - QPainter painter(&svg); - //painter.setViewport(rectSize); - //doc->documentLayout()->setPaintDevice(&svg); - doc->drawContents(&painter); - */ - - /* - QtWebEngine::initialize(); - QWebEnginePage page; - QEventLoop loop; - loop.connect(&page, &QWebEnginePage::loadFinished, [&page, &loop, &filename]() { - page.printToPdf([&loop, &filename] (QByteArray ba) { - QFile f(filename); - if (f.open(QIODevice::WriteOnly)) - { - f.write(ba); - f.close(); - } else { - qDebug() << "Error opening file for writing" << filename << f.errorString(); - } - loop.exit(); - }); - }); - qDebug() << ui->sequenceTextEdit->toHtml(); - page.setHtml(ui->sequenceTextEdit->toHtml()); - loop.exec(); - */ + settings.setValue("path/export_svg", QFileInfo(filename).absolutePath()); + + // https://bugreports.qt.io/browse/QTBUG-52538 + QPrinter printer(QPrinter::PrinterResolution); + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setPaperSize(QPrinter::A4); + printer.setOutputFileName(filename); + /* + QSvgGenerator generator; + //generator.setOutputDevice(&buffer); + QSize size(600, 1000); + generator.setFileName(filename); + generator.setSize(size); + generator.setViewBox(QRect(0, 0, size.width(), size.height())); + generator.setTitle(_p_protein_match->getProteinXtpSp().get()->getAccession()); + */ + + // generator.setDescription(description); + // QPainter painter; + // painter.begin(&generator); + // painter.setViewport(0,0, size.width(), size.height()); + + // ui->sequenceTextEdit->document()->drawContents(&painter); + // painter.end(); + // QFont::Monospace + QFont font("Monospace"); + font.setStyleHint(QFont::Monospace); + font.setLetterSpacing(QFont::AbsoluteSpacing, 0); + font.setPointSize(10); // generator.setDefaultFont(font); + + QTextOption text_option; + text_option.setWrapMode(QTextOption::WrapAnywhere); + text_option.setFlags(QTextOption::IncludeTrailingSpaces | + QTextOption::ShowTabsAndSpaces); + text_option.setUseDesignMetrics(0); + + // QTextDocument *doc = ui->sequenceTextEdit->document()->clone(); + QTextDocument *doc = new QTextDocument(); + doc->setHtml( + QString("<p>%1</p><p>%2</p><p>%3</p>") + .arg(_p_protein_match->getProteinXtpSp().get()->getAccession()) + .arg(_p_protein_match->getProteinXtpSp().get()->getDescription()) + .arg(ui->sequenceTextEdit->toHtml())); + doc->setUndoRedoEnabled(false); + // doc->setHtml("<p><span style=\"color:#000000; + // font-weight:600\">"+text_x+"</span></p>"); + doc->setTextWidth(printer.pageRect().size().width()); + doc->setDefaultFont(font); + doc->setPageSize(printer.pageRect().size()); + //// height from doc QTextDocument + //// + ///http://fop-miniscribus.googlecode.com/svn/trunk/fop_miniscribus.1.0.0/src/floating_box/floatdiagram.cpp + //////setMaximumHeight(DocumentHighgtActual()); + doc->setPageSize( + printer.pageRect() + .size()); // This is necessary if you want to hide the page number + doc->print(&printer); + + /* + QPainter *painter = new QPainter(&generator); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setFont(font); + doc->drawContents(painter); + painter->end(); + */ + + + /* + QSvgGenerator svg; + svg.setFileName(filename); + QTextDocument *doc = ui->sequenceTextEdit->document()->clone(); + QRect rectSize(0, 0, (int) doc->size().width(), (int) + doc->size().height()); QPainter painter(&svg); + //painter.setViewport(rectSize); + //doc->documentLayout()->setPaintDevice(&svg); + doc->drawContents(&painter); + */ + + /* + QtWebEngine::initialize(); + QWebEnginePage page; + QEventLoop loop; + loop.connect(&page, &QWebEnginePage::loadFinished, [&page, &loop, + &filename]() { page.printToPdf([&loop, &filename] (QByteArray ba) { QFile + f(filename); if (f.open(QIODevice::WriteOnly)) + { + f.write(ba); + f.close(); + } else { + qDebug() << "Error opening file for writing" << filename + << f.errorString(); + } + loop.exit(); + }); + }); + qDebug() << ui->sequenceTextEdit->toHtml(); + page.setHtml(ui->sequenceTextEdit->toHtml()); + loop.exec(); + */ } - catch (pappso::PappsoException & error) { - QMessageBox::warning(this, - tr("Error trying to save spectrum to SVG file :"), error.qwhat()); + catch(pappso::PappsoException &error) + { + QMessageBox::warning( + this, tr("Error trying to save spectrum to SVG file :"), error.qwhat()); } - } diff --git a/src/gui/protein_view/proteinwindow.h b/src/gui/protein_view/proteinwindow.h index c0862c185040388e53bbe6d71758751640e8966e..8bb6fcf33d8d49ce293db8ed755a560169e8409b 100644 --- a/src/gui/protein_view/proteinwindow.h +++ b/src/gui/protein_view/proteinwindow.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 PROTEINWINDOW_H #define PROTEINWINDOW_H @@ -29,48 +30,51 @@ #include <QPushButton> #include "../../core/proteinmatch.h" -class DbXrefButton: public QPushButton { - Q_OBJECT -public : - DbXrefButton(QWidget * parent, DbXref dbxref); -protected slots: - void clickedSlot(); -private: - DbXref _dbxref; +class DbXrefButton : public QPushButton +{ + Q_OBJECT + public: + DbXrefButton(QWidget *parent, DbXref dbxref); + protected slots: + void clickedSlot(); + + private: + DbXref _dbxref; }; class ProjectWindow; -namespace Ui { -class ProteinDetailView; +namespace Ui +{ + class ProteinDetailView; } -class ProteinWindow: public QMainWindow { - Q_OBJECT - -public: - - explicit ProteinWindow(ProjectWindow * parent = 0); - ~ProteinWindow(); - void setProteinMatch(ProteinMatch * p_protein_match); +class ProteinWindow : public QMainWindow +{ + Q_OBJECT -public slots: - void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group); - void doPeptideEvidenceSelected(PeptideEvidence * peptide_evidence); -protected slots: - void browseUrl(int i); - void doSaveSvg(); + public: + explicit ProteinWindow(ProjectWindow *parent = 0); + ~ProteinWindow(); + void setProteinMatch(ProteinMatch *p_protein_match); -protected : - void updateDisplay(); - void clearDbXrefLayout(); + public slots: + void + doIdentificationGroupGrouped(IdentificationGroup *p_identification_group); + void doPeptideEvidenceSelected(PeptideEvidence *peptide_evidence); + protected slots: + void browseUrl(int i); + void doSaveSvg(); -private: - Ui::ProteinDetailView *ui; - QTextDocument sequence_text; - ProjectWindow * _p_project_window; - ProteinMatch * _p_protein_match = nullptr; + protected: + void updateDisplay(); + void clearDbXrefLayout(); + private: + Ui::ProteinDetailView *ui; + QTextDocument sequence_text; + ProjectWindow *_p_project_window; + ProteinMatch *_p_protein_match = nullptr; }; #endif // PROTEINWINDOW_H diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp index f3b0d219599b215608741c5d287634c47966b889..5114d8f0d6450f6ebcad0c3d370d3c34f0e6af36 100644 --- a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp +++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp @@ -6,26 +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 "ptmislandlistwindow.h" @@ -36,153 +37,198 @@ #include "../ptm_peptide_list_view/ptmpeptidelistwindow.h" -PtmIslandListWindow::PtmIslandListWindow(ProjectWindow *parent): - QMainWindow(parent), - ui(new Ui::PtmIslandListWindow) +PtmIslandListWindow::PtmIslandListWindow(ProjectWindow *parent) + : QMainWindow(parent), ui(new Ui::PtmIslandListWindow) { - _project_window = parent; - ui->setupUi(this); - /* - */ - _ptm_table_model_p = new PtmIslandTableModel(this); + _project_window = parent; + ui->setupUi(this); + /* + */ + _ptm_table_model_p = new PtmIslandTableModel(this); - _ptm_proxy_model_p = new PtmIslandProxyModel(this, _ptm_table_model_p); - _ptm_proxy_model_p->setSourceModel(_ptm_table_model_p); - _ptm_proxy_model_p->setDynamicSortFilter(true); - ui->ptm_island_tableview->setModel( _ptm_proxy_model_p ); - ui->ptm_island_tableview->setSortingEnabled(true); - ui->ptm_island_tableview->setAlternatingRowColors(true); + _ptm_proxy_model_p = new PtmIslandProxyModel(this, _ptm_table_model_p); + _ptm_proxy_model_p->setSourceModel(_ptm_table_model_p); + _ptm_proxy_model_p->setDynamicSortFilter(true); + ui->ptm_island_tableview->setModel(_ptm_proxy_model_p); + ui->ptm_island_tableview->setSortingEnabled(true); + ui->ptm_island_tableview->setAlternatingRowColors(true); + _statusbar_ptm_islands_label = new QLabel(""); + ui->statusbar->addWidget(_statusbar_ptm_islands_label); - _statusbar_ptm_islands_label = new QLabel(""); - ui->statusbar->addWidget(_statusbar_ptm_islands_label); - - _statusbar_displayed_label = new QLabel(""); - ui->statusbar->addWidget(_statusbar_displayed_label); + _statusbar_displayed_label = new QLabel(""); + ui->statusbar->addWidget(_statusbar_displayed_label); #if QT_VERSION >= 0x050000 - // Qt5 code - connect (this, &PtmIslandListWindow::ptmIslandDataChanged, _ptm_table_model_p, &PtmIslandTableModel::onPtmIslandDataChanged); - - connect (_project_window, &ProjectWindow::identificationPtmGroupGrouped, this,&PtmIslandListWindow::doIdentificationPtmGroupGrouped); - connect (_project_window, &ProjectWindow::identificationGroupGrouped, this,&PtmIslandListWindow::doIdentificationGroupGrouped); - connect(ui->ptm_island_tableview, &QTableView::clicked, _ptm_proxy_model_p, &PtmIslandProxyModel::onTableClicked); - connect(_ptm_table_model_p, &PtmIslandTableModel::layoutChanged, this, &PtmIslandListWindow::updateStatusBar); + // Qt5 code + connect(this, &PtmIslandListWindow::ptmIslandDataChanged, _ptm_table_model_p, + &PtmIslandTableModel::onPtmIslandDataChanged); + + connect(_project_window, &ProjectWindow::identificationPtmGroupGrouped, this, + &PtmIslandListWindow::doIdentificationPtmGroupGrouped); + connect(_project_window, &ProjectWindow::identificationGroupGrouped, this, + &PtmIslandListWindow::doIdentificationGroupGrouped); + connect(ui->ptm_island_tableview, &QTableView::clicked, _ptm_proxy_model_p, + &PtmIslandProxyModel::onTableClicked); + connect(_ptm_table_model_p, &PtmIslandTableModel::layoutChanged, this, + &PtmIslandListWindow::updateStatusBar); #else -// Qt4 code - connect (this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, SLOT(onPtmIslandDataChanged())); - - connect (_project_window, SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *))); - connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - connect(ui->ptm_island_tableview, SIGNAL(clicked(const QModelIndex &)), _ptm_proxy_model_p, SLOT(onTableClicked(const QModelIndex &))); + // Qt4 code + connect(this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, + SLOT(onPtmIslandDataChanged())); + + connect(_project_window, + SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), this, + SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *))); + connect(_project_window, + SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this, + SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + connect(ui->ptm_island_tableview, SIGNAL(clicked(const QModelIndex &)), + _ptm_proxy_model_p, SLOT(onTableClicked(const QModelIndex &))); #endif } PtmIslandListWindow::~PtmIslandListWindow() { - delete _ptm_table_model_p; - delete _ptm_proxy_model_p; - delete _statusbar_displayed_label; + delete _ptm_table_model_p; + delete _ptm_proxy_model_p; + delete _statusbar_displayed_label; } -ProjectWindow * PtmIslandListWindow::getProjectWindowP() { - return _project_window; +ProjectWindow * +PtmIslandListWindow::getProjectWindowP() +{ + return _project_window; } -void PtmIslandListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { - - qDebug() << "PtmIslandListWindow::setIdentificationGroup begin " ; - if (p_identification_group != nullptr) { - qDebug() << "PtmIslandListWindow::setIdentificationGroup not null"; - _p_identification_group = p_identification_group; - _ptm_table_model_p->setIdentificationGroup(p_identification_group); - //_p_proxy_model->setSourceModel(_protein_table_model_p); - +void +PtmIslandListWindow::setIdentificationGroup( + IdentificationGroup *p_identification_group) +{ + qDebug() << "PtmIslandListWindow::setIdentificationGroup begin "; + if(p_identification_group != nullptr) + { + qDebug() << "PtmIslandListWindow::setIdentificationGroup not null"; + _p_identification_group = p_identification_group; + _ptm_table_model_p->setIdentificationGroup(p_identification_group); + //_p_proxy_model->setSourceModel(_protein_table_model_p); } - else { - qDebug() << "PtmIslandListWindow::setIdentificationGroup null"; + else + { + qDebug() << "PtmIslandListWindow::setIdentificationGroup null"; } - qDebug() << "PtmIslandListWindow::setIdentificationGroup end"; + qDebug() << "PtmIslandListWindow::setIdentificationGroup end"; } -void PtmIslandListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { - qDebug() << "PtmIslandListWindow::doIdentificationGroupGrouped begin"; - if (_p_identification_group == p_identification_group) { - //ui->ptm_island_tableview->resizeRowToContents(_ptm_table_model_p->rowCount()); - _project_window->doPtmIslandGrouping(p_identification_group); - //emit ptmIslandDataChanged(); +void +PtmIslandListWindow::doIdentificationGroupGrouped( + IdentificationGroup *p_identification_group) +{ + qDebug() << "PtmIslandListWindow::doIdentificationGroupGrouped begin"; + if(_p_identification_group == p_identification_group) + { + // ui->ptm_island_tableview->resizeRowToContents(_ptm_table_model_p->rowCount()); + _project_window->doPtmIslandGrouping(p_identification_group); + // emit ptmIslandDataChanged(); } - qDebug() << "PtmIslandListWindow::doIdentificationGroupGrouped end"; + qDebug() << "PtmIslandListWindow::doIdentificationGroupGrouped end"; } -void PtmIslandListWindow::doIdentificationPtmGroupGrouped(IdentificationGroup * p_identification_group) { - qDebug() << "PtmIslandListWindow::doIdentificationPtmGroupGrouped begin"; - if (_p_identification_group == p_identification_group) { - //ui->ptm_island_tableview->resizeRowToContents(0); - //_protein_table_model_p->setIdentificationGroup(p_identification_group); - //_p_proxy_model->setSourceModel(_protein_table_model_p); - _ptm_table_model_p->setIdentificationGroup(p_identification_group); - emit ptmIslandDataChanged(); - - const PtmGroupingExperiment * p_ptm_grouping_experiment = p_identification_group->getPtmGroupingExperiment(); - _statusbar_ptm_islands_label->setText(tr("ptm island groups:%1 ptm island subgroups:%2 ptm islands:%3").arg(p_ptm_grouping_experiment->getPtmIslandGroupList().size()).arg(p_ptm_grouping_experiment->getPtmIslandSubgroupList().size()).arg(p_ptm_grouping_experiment->getPtmIslandList().size())); - //ui->ptm_island_tableview->resizeRowToContents(_ptm_table_model_p->rowCount()); +void +PtmIslandListWindow::doIdentificationPtmGroupGrouped( + IdentificationGroup *p_identification_group) +{ + qDebug() << "PtmIslandListWindow::doIdentificationPtmGroupGrouped begin"; + if(_p_identification_group == p_identification_group) + { + // ui->ptm_island_tableview->resizeRowToContents(0); + //_protein_table_model_p->setIdentificationGroup(p_identification_group); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + _ptm_table_model_p->setIdentificationGroup(p_identification_group); + emit ptmIslandDataChanged(); + + const PtmGroupingExperiment *p_ptm_grouping_experiment = + p_identification_group->getPtmGroupingExperiment(); + _statusbar_ptm_islands_label->setText( + tr("ptm island groups:%1 ptm island subgroups:%2 ptm islands:%3") + .arg(p_ptm_grouping_experiment->getPtmIslandGroupList().size()) + .arg(p_ptm_grouping_experiment->getPtmIslandSubgroupList().size()) + .arg(p_ptm_grouping_experiment->getPtmIslandList().size())); + // ui->ptm_island_tableview->resizeRowToContents(_ptm_table_model_p->rowCount()); } - qDebug() << "PtmIslandListWindow::doIdentificationPtmGroupGrouped end"; + qDebug() << "PtmIslandListWindow::doIdentificationPtmGroupGrouped end"; } -void PtmIslandListWindow::resizeColumnsToContents() { - ui->ptm_island_tableview->resizeColumnsToContents(); +void +PtmIslandListWindow::resizeColumnsToContents() +{ + ui->ptm_island_tableview->resizeColumnsToContents(); } -void PtmIslandListWindow::connectNewPtmPeptideListWindow() { - qDebug() << "PtmIslandListWindow::connectNewPtmPeptideListWindow begin"; - _p_current_ptm_peptide_list_window = new PtmPeptideListWindow(this); - _ptm_peptide_list_window_collection.push_back(_p_current_ptm_peptide_list_window); - - qDebug() << "PtmIslandListWindow::connectNewPtmPeptideListWindow end"; +void +PtmIslandListWindow::connectNewPtmPeptideListWindow() +{ + qDebug() << "PtmIslandListWindow::connectNewPtmPeptideListWindow begin"; + _p_current_ptm_peptide_list_window = new PtmPeptideListWindow(this); + _ptm_peptide_list_window_collection.push_back( + _p_current_ptm_peptide_list_window); + qDebug() << "PtmIslandListWindow::connectNewPtmPeptideListWindow end"; } -void PtmIslandListWindow::askViewPtmPeptideList(PtmIsland * ptm_island) { - if (_ptm_peptide_list_window_collection.size() == 0) { - connectNewPtmPeptideListWindow(); +void +PtmIslandListWindow::askViewPtmPeptideList(PtmIsland *ptm_island) +{ + if(_ptm_peptide_list_window_collection.size() == 0) + { + connectNewPtmPeptideListWindow(); } - Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); - if (modifier == Qt::ControlModifier) { - connectNewPtmPeptideListWindow(); + Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); + if(modifier == Qt::ControlModifier) + { + connectNewPtmPeptideListWindow(); } - _p_current_ptm_peptide_list_window->setPtmIsland(ptm_island); - _p_current_ptm_peptide_list_window->show(); - + _p_current_ptm_peptide_list_window->setPtmIsland(ptm_island); + _p_current_ptm_peptide_list_window->show(); } -const IdentificationGroup * PtmIslandListWindow::getIdentificationGroup() const { - return _p_identification_group; +const IdentificationGroup * +PtmIslandListWindow::getIdentificationGroup() const +{ + return _p_identification_group; } -void PtmIslandListWindow::updateStatusBar() { - if (_p_identification_group == nullptr) { +void +PtmIslandListWindow::updateStatusBar() +{ + if(_p_identification_group == nullptr) + { } - else { - _statusbar_displayed_label->setText(tr("displayed: %1").arg(_ptm_proxy_model_p->rowCount())); + else + { + _statusbar_displayed_label->setText( + tr("displayed: %1").arg(_ptm_proxy_model_p->rowCount())); } } -void PtmIslandListWindow::doPtmSearchEdit(QString ptm_search_string) { - _ptm_proxy_model_p->setPtmSearchString(ptm_search_string); - emit ptmIslandDataChanged(); +void +PtmIslandListWindow::doPtmSearchEdit(QString ptm_search_string) +{ + _ptm_proxy_model_p->setPtmSearchString(ptm_search_string); + emit ptmIslandDataChanged(); } -void PtmIslandListWindow::doSearchOn(QString search_on) { - _ptm_proxy_model_p->setSearchOn(search_on); - emit ptmIslandDataChanged(); +void +PtmIslandListWindow::doSearchOn(QString search_on) +{ + _ptm_proxy_model_p->setSearchOn(search_on); + emit ptmIslandDataChanged(); } diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.h b/src/gui/ptm_island_list_view/ptmislandlistwindow.h index cb460570dd9c82afe281c3120d422e257af767ed..70cb8e16864ed226b8bd6f18e014e76351cec23c 100644 --- a/src/gui/ptm_island_list_view/ptmislandlistwindow.h +++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMISLANDLISTWINDOW_H #define PTMISLANDLISTWINDOW_H @@ -38,53 +39,59 @@ class ProjectWindow; class PtmPeptideListWindow; -//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html -namespace Ui { -class PtmIslandListWindow; +// http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html +namespace Ui +{ + class PtmIslandListWindow; } -class PtmIslandListWindow: public QMainWindow { - Q_OBJECT - friend PtmIslandProxyModel; -public: - explicit PtmIslandListWindow(ProjectWindow * parent = 0); - ~PtmIslandListWindow(); - void setIdentificationGroup(IdentificationGroup * p_identification_group); - void resizeColumnsToContents(); - const IdentificationGroup * getIdentificationGroup() const; - ProjectWindow * getProjectWindowP(); +class PtmIslandListWindow : public QMainWindow +{ + Q_OBJECT + friend PtmIslandProxyModel; + public: + explicit PtmIslandListWindow(ProjectWindow *parent = 0); + ~PtmIslandListWindow(); + void setIdentificationGroup(IdentificationGroup *p_identification_group); + void resizeColumnsToContents(); + const IdentificationGroup *getIdentificationGroup() const; + ProjectWindow *getProjectWindowP(); -public slots: - void doIdentificationPtmGroupGrouped(IdentificationGroup * p_identification_group); - void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group); -protected slots: - void updateStatusBar(); - void doPtmSearchEdit(QString ptm_search_string); - void doSearchOn(QString search_on); + public slots: + void + doIdentificationPtmGroupGrouped(IdentificationGroup *p_identification_group); + void + doIdentificationGroupGrouped(IdentificationGroup *p_identification_group); + protected slots: + void updateStatusBar(); + void doPtmSearchEdit(QString ptm_search_string); + void doSearchOn(QString search_on); -signals: - void ptmIslandDataChanged(); -protected: - void askViewPtmPeptideList(PtmIsland * ptm_island); -private: - void connectNewPtmPeptideListWindow(); -private: - IdentificationGroup * _p_identification_group=nullptr; - Ui::PtmIslandListWindow *ui; - PtmIslandTableModel * _ptm_table_model_p = nullptr; - PtmIslandProxyModel * _ptm_proxy_model_p = nullptr; - ProjectWindow * _project_window; + signals: + void ptmIslandDataChanged(); - PtmPeptideListWindow * _p_current_ptm_peptide_list_window; - std::vector<PtmPeptideListWindow *> _ptm_peptide_list_window_collection; + protected: + void askViewPtmPeptideList(PtmIsland *ptm_island); - QLabel * _statusbar_displayed_label; - QLabel * _statusbar_ptm_islands_label; + private: + void connectNewPtmPeptideListWindow(); + private: + IdentificationGroup *_p_identification_group = nullptr; + Ui::PtmIslandListWindow *ui; + PtmIslandTableModel *_ptm_table_model_p = nullptr; + PtmIslandProxyModel *_ptm_proxy_model_p = nullptr; + ProjectWindow *_project_window; + + PtmPeptideListWindow *_p_current_ptm_peptide_list_window; + std::vector<PtmPeptideListWindow *> _ptm_peptide_list_window_collection; + + QLabel *_statusbar_displayed_label; + QLabel *_statusbar_ptm_islands_label; }; #endif // PTMISLANDLISTWINDOW_H diff --git a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp index be015191e27cfe8afba36fe9778c010186822a1e..d9634eeb5c654e8c6f98e386894e04a58393a24c 100644 --- a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp +++ b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp @@ -6,26 +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 "ptmislandproxymodel.h" #include "ptmislandtablemodel.h" @@ -34,111 +35,173 @@ #include "../../grouping/ptm/ptmisland.h" #include <pappsomspp/pappsoexception.h> -PtmIslandProxyModel::PtmIslandProxyModel(PtmIslandListWindow * p_ptm_island_list_window, PtmIslandTableModel* ptm_table_model_p) +PtmIslandProxyModel::PtmIslandProxyModel( + PtmIslandListWindow *p_ptm_island_list_window, + PtmIslandTableModel *ptm_table_model_p) { - _p_ptm_island_list_window = p_ptm_island_list_window; - _p_ptm_island_table_model = ptm_table_model_p; - _ptm_search_string = ""; - _search_on = "accession"; + _p_ptm_island_list_window = p_ptm_island_list_window; + _p_ptm_island_table_model = ptm_table_model_p; + _ptm_search_string = ""; + _search_on = "accession"; } PtmIslandProxyModel::~PtmIslandProxyModel() { - } -bool PtmIslandProxyModel::filterAcceptsRow(int source_row, - const QModelIndex &source_parent) const { - try { - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow begin " << source_row; - PtmIslandSp sp_ptm_island = _p_ptm_island_table_model->getPtmGroupingExperiment()->getPtmIslandList().at(source_row); - //qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match " << source_row; - - if (!_ptm_search_string.isEmpty()) { - if (_search_on == "accession") { - if (!sp_ptm_island.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession().contains(_ptm_search_string)) { - return false; +bool +PtmIslandProxyModel::filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const +{ + try + { + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow begin " << + // source_row; + PtmIslandSp sp_ptm_island = + _p_ptm_island_table_model->getPtmGroupingExperiment() + ->getPtmIslandList() + .at(source_row); + // qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match " + // << source_row; + + if(!_ptm_search_string.isEmpty()) + { + if(_search_on == "accession") + { + if(!sp_ptm_island.get() + ->getProteinMatch() + ->getProteinXtpSp() + .get() + ->getAccession() + .contains(_ptm_search_string)) + { + return false; } } - else if (_search_on == "group") { - if (!sp_ptm_island.get()->getGroupingId().startsWith(QString("ptm%1").arg(_ptm_search_string))) { - return false; + else if(_search_on == "group") + { + if(!sp_ptm_island.get()->getGroupingId().startsWith( + QString("ptm%1").arg(_ptm_search_string))) + { + return false; } - } - else if (_search_on == "sequence") { - if (!sp_ptm_island.get()->getProteinMatch()->getProteinXtpSp().get()->getSequence().contains(_ptm_search_string)) { - return false; + else if(_search_on == "sequence") + { + if(!sp_ptm_island.get() + ->getProteinMatch() + ->getProteinXtpSp() + .get() + ->getSequence() + .contains(_ptm_search_string)) + { + return false; } } - else if (_search_on == "peptide") { - QString peptide_search_string = QString(_ptm_search_string).replace("L","I"); - for (const PeptideMatch & p_peptide_match: sp_ptm_island.get()->getProteinMatch()->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(_ptm_search_string).replace("L", "I"); + for(const PeptideMatch &p_peptide_match : + sp_ptm_island.get()->getProteinMatch()->getPeptideMatchList()) + { + if(p_peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequenceLi() + .contains(peptide_search_string)) + { + return true; } } - return false; + return false; } - else if (_search_on == "description") { - //description - if (!sp_ptm_island.get()->getProteinMatch()->getProteinXtpSp().get()->getDescription().contains(_ptm_search_string)) { - return false; + else if(_search_on == "description") + { + // description + if(!sp_ptm_island.get() + ->getProteinMatch() + ->getProteinXtpSp() + .get() + ->getDescription() + .contains(_ptm_search_string)) + { + return false; } } } - if (sp_ptm_island != nullptr) { - return true; + if(sp_ptm_island != nullptr) + { + 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 PtmIslandProxyModel::acceptRow :" << exception_pappso.qwhat(); + catch(pappso::PappsoException exception_pappso) + { + // QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), + // exception_pappso.qwhat()); + qDebug() << "Error in PtmIslandProxyModel::acceptRow :" + << exception_pappso.qwhat(); } - catch (std::exception exception_std) { - //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); - qDebug() << "Error in PtmIslandProxyModel::acceptRow :" << exception_std.what(); + catch(std::exception exception_std) + { + // QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), + // exception_std.what()); + qDebug() << "Error in PtmIslandProxyModel::acceptRow :" + << exception_std.what(); } - return true; + return true; - //return true; + // return true; } -void PtmIslandProxyModel::onTableClicked(const QModelIndex &index) +void +PtmIslandProxyModel::onTableClicked(const QModelIndex &index) { - qDebug() << "PtmIslandProxyModel::onTableClicked begin " << index.row(); - qDebug() << "PtmIslandProxyModel::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(); - int col = source_index.column(); - - //ProteinMatch* p_protein_match = _p_ptm_island_table_model->getIdentificationGroup()->getProteinMatchList().at(row); - - if ((col == (std::int8_t) PtmIslandListColumn::accession)||(col == (std::int8_t) PtmIslandListColumn::description)) { - //_p_ptm_island_table_model->askPtmProteinDetailView(p_protein_match); + qDebug() << "PtmIslandProxyModel::onTableClicked begin " << index.row(); + qDebug() << "PtmIslandProxyModel::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(); + int col = source_index.column(); + + // ProteinMatch* p_protein_match = + // _p_ptm_island_table_model->getIdentificationGroup()->getProteinMatchList().at(row); + + if((col == (std::int8_t)PtmIslandListColumn::accession) || + (col == (std::int8_t)PtmIslandListColumn::description)) + { + //_p_ptm_island_table_model->askPtmProteinDetailView(p_protein_match); } - else { - _p_ptm_island_list_window->askViewPtmPeptideList(_p_ptm_island_table_model->getPtmGroupingExperiment()->getPtmIslandList().at(row).get()); + else + { + _p_ptm_island_list_window->askViewPtmPeptideList( + _p_ptm_island_table_model->getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get()); } - qDebug() << "PtmIslandProxyModel::onTableClicked end " << index.row(); - + qDebug() << "PtmIslandProxyModel::onTableClicked end " << index.row(); } -void PtmIslandProxyModel::setSearchOn(QString search_on) { - _search_on = search_on; +void +PtmIslandProxyModel::setSearchOn(QString search_on) +{ + _search_on = search_on; } -void PtmIslandProxyModel::setPtmSearchString(QString ptm_search_string) { - _ptm_search_string = ptm_search_string; +void +PtmIslandProxyModel::setPtmSearchString(QString ptm_search_string) +{ + _ptm_search_string = ptm_search_string; } diff --git a/src/gui/ptm_island_list_view/ptmislandproxymodel.h b/src/gui/ptm_island_list_view/ptmislandproxymodel.h index 71eaf6d34045197cad1f16a1803f3141e560b8a4..b65464b89f63b4e8c7c3eb660906511195df60d0 100644 --- a/src/gui/ptm_island_list_view/ptmislandproxymodel.h +++ b/src/gui/ptm_island_list_view/ptmislandproxymodel.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMISLANDPROXYMODEL_H #define PTMISLANDPROXYMODEL_H @@ -37,28 +38,28 @@ class PtmIslandListWindow; class PtmIslandTableModel; -class PtmIslandProxyModel: public QSortFilterProxyModel +class PtmIslandProxyModel : public QSortFilterProxyModel { - Q_OBJECT -public: - PtmIslandProxyModel(PtmIslandListWindow * p_ptm_island_list_window, PtmIslandTableModel* ptm_table_model_p); - ~PtmIslandProxyModel(); - bool filterAcceptsRow(int source_row, - const QModelIndex &source_parent) const override; + Q_OBJECT + public: + PtmIslandProxyModel(PtmIslandListWindow *p_ptm_island_list_window, + PtmIslandTableModel *ptm_table_model_p); + ~PtmIslandProxyModel(); + bool filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const override; - void setSearchOn(QString search_on); + void setSearchOn(QString search_on); - void setPtmSearchString(QString ptm_search_string) ; + void setPtmSearchString(QString ptm_search_string); -public slots: - void onTableClicked(const QModelIndex &index); - -private: - PtmIslandListWindow * _p_ptm_island_list_window; - PtmIslandTableModel * _p_ptm_island_table_model; - QString _search_on; - QString _ptm_search_string; + public slots: + void onTableClicked(const QModelIndex &index); + private: + PtmIslandListWindow *_p_ptm_island_list_window; + PtmIslandTableModel *_p_ptm_island_table_model; + QString _search_on; + QString _ptm_search_string; }; #endif // PTMISLANDPROXYMODEL_H diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp index a51a54093c63dddc17d0830052725820a87d4acb..d039db1fe402edff4d6d9ff8fcea4b678fba7991 100644 --- a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp +++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp @@ -6,243 +6,325 @@ */ /******************************************************************************* -* 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 "ptmislandtablemodel.h" #include "ptmislandlistwindow.h" - -PtmIslandTableModel::PtmIslandTableModel(PtmIslandListWindow * p_ptm_island_list_window) +PtmIslandTableModel::PtmIslandTableModel( + PtmIslandListWindow *p_ptm_island_list_window) { -_p_ptm_island_list_window = p_ptm_island_list_window; + _p_ptm_island_list_window = p_ptm_island_list_window; } PtmIslandTableModel::~PtmIslandTableModel() { - } -const QString PtmIslandTableModel::getTitle(PtmIslandListColumn column) { - qDebug() << "PtmIslandTableModel::getTitle begin "; - return PtmIslandTableModel::getTitle((std::int8_t) column); - //qDebug() << "ProteinTableModel::getTitle end "; +const QString +PtmIslandTableModel::getTitle(PtmIslandListColumn column) +{ + qDebug() << "PtmIslandTableModel::getTitle begin "; + return PtmIslandTableModel::getTitle((std::int8_t)column); + // qDebug() << "ProteinTableModel::getTitle end "; } -const QString PtmIslandTableModel::getDescription(PtmIslandListColumn column) { - qDebug() << "PtmIslandTableModel::columnCount begin "; - return PtmIslandTableModel::getDescription((std::int8_t) column); - //qDebug() << "ProteinTableModel::columnCount end "; +const QString +PtmIslandTableModel::getDescription(PtmIslandListColumn column) +{ + qDebug() << "PtmIslandTableModel::columnCount begin "; + return PtmIslandTableModel::getDescription((std::int8_t)column); + // qDebug() << "ProteinTableModel::columnCount end "; } -const QString PtmIslandTableModel::getTitle(std::int8_t column) { - switch (column) { +const QString +PtmIslandTableModel::getTitle(std::int8_t column) +{ + switch(column) + { - case (std::int8_t) PtmIslandListColumn::spectrum: + case(std::int8_t)PtmIslandListColumn::spectrum: return "spectrum"; break; - case (std::int8_t) PtmIslandListColumn::description: + case(std::int8_t)PtmIslandListColumn::description: return "description"; break; - case (std::int8_t) PtmIslandListColumn::multiptm: + case(std::int8_t)PtmIslandListColumn::multiptm: return "multi PTM"; break; - case (std::int8_t) PtmIslandListColumn::sequence: + case(std::int8_t)PtmIslandListColumn::sequence: return "sequence"; break; - case (std::int8_t) PtmIslandListColumn::ptm_island_id: + case(std::int8_t)PtmIslandListColumn::ptm_island_id: return "PTM island ID"; break; - case (std::int8_t) PtmIslandListColumn::accession: + case(std::int8_t)PtmIslandListColumn::accession: return "accession"; break; - case (std::int8_t) PtmIslandListColumn::ptm_position_list: + case(std::int8_t)PtmIslandListColumn::ptm_position_list: return "ptm positions"; break; - case (std::int8_t) PtmIslandListColumn::ptm_island_start: + case(std::int8_t)PtmIslandListColumn::ptm_island_start: return "start"; break; - case (std::int8_t) PtmIslandListColumn::ptm_island_length: + case(std::int8_t)PtmIslandListColumn::ptm_island_length: return "length"; - } - return ""; + return ""; } -const QString PtmIslandTableModel::getDescription(std::int8_t column) { - switch (column) { +const QString +PtmIslandTableModel::getDescription(std::int8_t column) +{ + switch(column) + { - case (std::int8_t) PtmIslandListColumn::spectrum: + case(std::int8_t)PtmIslandListColumn::spectrum: return "number of distinct spectrum assigned to this PTM island"; break; - case (std::int8_t) PtmIslandListColumn::description: + case(std::int8_t)PtmIslandListColumn::description: return "protein description"; break; - case (std::int8_t) PtmIslandListColumn::multiptm: + case(std::int8_t)PtmIslandListColumn::multiptm: return "number of distinct spectrum containing more than 1 ptm"; break; - case (std::int8_t) PtmIslandListColumn::sequence: + case(std::int8_t)PtmIslandListColumn::sequence: return "number of unique peptide sequence"; break; - case (std::int8_t) PtmIslandListColumn::ptm_island_id: + case(std::int8_t)PtmIslandListColumn::ptm_island_id: return "unique PTM island identifier"; break; - case (std::int8_t) PtmIslandListColumn::accession: + case(std::int8_t)PtmIslandListColumn::accession: return "protein accession"; break; - case (std::int8_t) PtmIslandListColumn::ptm_position_list: + case(std::int8_t)PtmIslandListColumn::ptm_position_list: return "PTM positions observed in this PTM island"; break; - case (std::int8_t) PtmIslandListColumn::ptm_island_start: + case(std::int8_t)PtmIslandListColumn::ptm_island_start: return "PTM island start on the protein"; break; - case (std::int8_t) PtmIslandListColumn::ptm_island_length: + case(std::int8_t)PtmIslandListColumn::ptm_island_length: return "PTM island length"; - } - return ""; + return ""; } -void PtmIslandTableModel::setIdentificationGroup(IdentificationGroup * p_identification_group) { - qDebug() << "PtmIslandTableModel::setIdentificationGroup begin "; - - beginResetModel(); - _p_identification_group = p_identification_group; - - //emit headerDataChanged(Qt::Horizontal, 0,11); - //refresh(); - qDebug() << "PtmIslandTableModel::setIdentificationGroup end "; - endResetModel(); - - this->_p_ptm_island_list_window->resizeColumnsToContents(); - +void +PtmIslandTableModel::setIdentificationGroup( + IdentificationGroup *p_identification_group) +{ + qDebug() << "PtmIslandTableModel::setIdentificationGroup begin "; + + beginResetModel(); + _p_identification_group = p_identification_group; + + // emit headerDataChanged(Qt::Horizontal, 0,11); + // refresh(); + qDebug() << "PtmIslandTableModel::setIdentificationGroup end "; + endResetModel(); + + this->_p_ptm_island_list_window->resizeColumnsToContents(); } -const PtmGroupingExperiment * PtmIslandTableModel::getPtmGroupingExperiment() const { - if (_p_identification_group == nullptr) { - return nullptr; +const PtmGroupingExperiment * +PtmIslandTableModel::getPtmGroupingExperiment() const +{ + if(_p_identification_group == nullptr) + { + return nullptr; } - return _p_identification_group->getPtmGroupingExperiment(); + return _p_identification_group->getPtmGroupingExperiment(); } -int PtmIslandTableModel::rowCount(const QModelIndex &parent ) const { - //qDebug() << "PtmIslandTableModel::rowCount begin "; - if (getPtmGroupingExperiment() != nullptr) { - //qDebug() << "PtmIslandTableModel::rowCount(const QModelIndex &parent ) " << getPtmGroupingExperiment()->getPtmIslandList().size(); - return (int) getPtmGroupingExperiment()->getPtmIslandList().size(); +int +PtmIslandTableModel::rowCount(const QModelIndex &parent) const +{ + // qDebug() << "PtmIslandTableModel::rowCount begin "; + if(getPtmGroupingExperiment() != nullptr) + { + // qDebug() << "PtmIslandTableModel::rowCount(const QModelIndex &parent ) + // " << getPtmGroupingExperiment()->getPtmIslandList().size(); + return (int)getPtmGroupingExperiment()->getPtmIslandList().size(); } - return 0; + return 0; } -int PtmIslandTableModel::columnCount(const QModelIndex &parent ) const { - //qDebug() << "ProteinTableModel::columnCount begin "; - if (getPtmGroupingExperiment() != nullptr) { - return 9; +int +PtmIslandTableModel::columnCount(const QModelIndex &parent) const +{ + // qDebug() << "ProteinTableModel::columnCount begin "; + if(getPtmGroupingExperiment() != nullptr) + { + return 9; } - return 0; + return 0; } -QVariant PtmIslandTableModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant +PtmIslandTableModel::headerData(int section, Qt::Orientation orientation, + int role) const { - if (getPtmGroupingExperiment() == nullptr) return QVariant(); - if (orientation == Qt::Horizontal) + if(getPtmGroupingExperiment() == nullptr) + return QVariant(); + if(orientation == Qt::Horizontal) { - switch (role) { - case Qt::DisplayRole : + switch(role) + { + case Qt::DisplayRole: return QVariant(getTitle(section)); break; - case Qt::ToolTipRole : - return QVariant(getDescription(section)); + case Qt::ToolTipRole: + return QVariant(getDescription(section)); break; - } } - return QVariant(); + return QVariant(); } -QVariant PtmIslandTableModel::data(const QModelIndex &index, int role ) const { - // generate a log message when this method gets called - if (getPtmGroupingExperiment() == nullptr) return QVariant(); - int row = index.row(); - int col = index.column(); - switch(role) { - case Qt::SizeHintRole : - //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); - return QSize( PtmIslandTableModel::getColumnWidth(col), 30 ); - break; - case Qt::DisplayRole: - if (_p_identification_group == nullptr) { +QVariant +PtmIslandTableModel::data(const QModelIndex &index, int role) const +{ + // generate a log message when this method gets called + if(getPtmGroupingExperiment() == nullptr) + return QVariant(); + int row = index.row(); + int col = index.column(); + switch(role) + { + case Qt::SizeHintRole: + // qDebug() << "ProteinTableModel::headerData " << + // ProteinTableModel::getColumnWidth(section); + return QSize(PtmIslandTableModel::getColumnWidth(col), 30); + break; + case Qt::DisplayRole: + if(_p_identification_group == nullptr) + { return QVariant(); - } - switch (col) { + } + switch(col) + { - case (std::int8_t) PtmIslandListColumn::spectrum: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getPtmIslandSubroup()->countSampleScan()); - break; + case(std::int8_t)PtmIslandListColumn::spectrum: + return QVariant(getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->getPtmIslandSubroup() + ->countSampleScan()); + break; - case (std::int8_t) PtmIslandListColumn::description: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getProteinMatch()->getProteinXtpSp().get()->getDescription()); - break; - case (std::int8_t) PtmIslandListColumn::multiptm: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->countSampleScanMultiPtm(getPtmGroupingExperiment())); - break; - case (std::int8_t) PtmIslandListColumn::sequence: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->countSequence()); - break; - case (std::int8_t) PtmIslandListColumn::ptm_island_id: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getGroupingId()); - break; - case (std::int8_t) PtmIslandListColumn::accession: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getProteinMatch()->getProteinXtpSp().get()->getAccession()); - break; - case (std::int8_t) PtmIslandListColumn::ptm_island_start: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getStart()+1); - break; - case (std::int8_t) PtmIslandListColumn::ptm_island_length: - return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->size()); - break; - case (std::int8_t) PtmIslandListColumn::ptm_position_list: - QStringList position_list; - for (unsigned int position :getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getPositionList()) { - position_list << QString("%1").arg(position+1); - } - return QVariant(position_list.join(" ")); - } + case(std::int8_t)PtmIslandListColumn::description: + return QVariant(getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->getProteinMatch() + ->getProteinXtpSp() + .get() + ->getDescription()); + break; + case(std::int8_t)PtmIslandListColumn::multiptm: + return QVariant( + getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->countSampleScanMultiPtm(getPtmGroupingExperiment())); + break; + case(std::int8_t)PtmIslandListColumn::sequence: + return QVariant(getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->countSequence()); + break; + case(std::int8_t)PtmIslandListColumn::ptm_island_id: + return QVariant(getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->getGroupingId()); + break; + case(std::int8_t)PtmIslandListColumn::accession: + return QVariant(getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->getProteinMatch() + ->getProteinXtpSp() + .get() + ->getAccession()); + break; + case(std::int8_t)PtmIslandListColumn::ptm_island_start: + return QVariant(getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->getStart() + + 1); + break; + case(std::int8_t)PtmIslandListColumn::ptm_island_length: + return QVariant(getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->size()); + break; + case(std::int8_t)PtmIslandListColumn::ptm_position_list: + QStringList position_list; + for(unsigned int position : getPtmGroupingExperiment() + ->getPtmIslandList() + .at(row) + .get() + ->getPositionList()) + { + position_list << QString("%1").arg(position + 1); + } + return QVariant(position_list.join(" ")); + } } - return QVariant(); + return QVariant(); } -void PtmIslandTableModel::onPtmIslandDataChanged() { - qDebug() << "PtmIslandTableModel::onPtmIslandDataChanged begin " << rowCount(); - emit layoutAboutToBeChanged(); - emit layoutChanged(); +void +PtmIslandTableModel::onPtmIslandDataChanged() +{ + qDebug() << "PtmIslandTableModel::onPtmIslandDataChanged begin " + << rowCount(); + emit layoutAboutToBeChanged(); + emit layoutChanged(); } -int PtmIslandTableModel::getColumnWidth(int column) { - qDebug() << "PtmIslandTableModel::getColumnWidth " << column; - switch (column) { - case (int) PtmIslandListColumn::accession: +int +PtmIslandTableModel::getColumnWidth(int column) +{ + qDebug() << "PtmIslandTableModel::getColumnWidth " << column; + switch(column) + { + case(int)PtmIslandListColumn::accession: qDebug() << "PtmIslandTableModel::getColumnWidth accession " << column; return 250; break; - case (int) PtmIslandListColumn::description: + case(int)PtmIslandListColumn::description: return 400; break; } - return 100; + return 100; } diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.h b/src/gui/ptm_island_list_view/ptmislandtablemodel.h index 948b1bddf466b6526f87521e8cd5868fcdf9524d..2cee9bc6260f1f14c7bd0a7ab96649de8104208e 100644 --- a/src/gui/ptm_island_list_view/ptmislandtablemodel.h +++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMISLANDTABLEMODEL_H #define PTMISLANDTABLEMODEL_H @@ -35,54 +36,61 @@ #include "../../grouping/ptm/ptmgroupingexperiment.h" - -/** \def PtmIslandListColumn list of available fields to display in ptm island list +/** \def PtmIslandListColumn list of available fields to display in ptm island + * list * */ -enum class PtmIslandListColumn: std::int8_t { - ptm_island_id=0, ///< ptm_island_id - accession=1, ///< protein accession - description=2, ///< protein description - ptm_position_list=3, ///< ptm position list - spectrum=4, ///< count sample scans - sequence=5, ///< unique sequence count - multiptm=6, ///< count multi ptm peptide match - ptm_island_start=7, ///< start position of the ptm island on the protein - ptm_island_length=8, ///< length of the ptm island +enum class PtmIslandListColumn : std::int8_t +{ + ptm_island_id = 0, ///< ptm_island_id + accession = 1, ///< protein accession + description = 2, ///< protein description + ptm_position_list = 3, ///< ptm position list + spectrum = 4, ///< count sample scans + sequence = 5, ///< unique sequence count + multiptm = 6, ///< count multi ptm peptide match + ptm_island_start = 7, ///< start position of the ptm island on the protein + ptm_island_length = 8, ///< length of the ptm island }; class PtmIslandListWindow; -class PtmIslandTableModel: public QAbstractTableModel +class PtmIslandTableModel : public QAbstractTableModel { - Q_OBJECT -public: - PtmIslandTableModel(PtmIslandListWindow * p_ptm_island_list_window); - - ~PtmIslandTableModel(); - - void setIdentificationGroup(IdentificationGroup * p_identification_group); - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - static const QString getTitle(PtmIslandListColumn column); - static const QString getDescription(PtmIslandListColumn column); - - const PtmGroupingExperiment * getPtmGroupingExperiment() const; - -public slots: - void onPtmIslandDataChanged(); -private : - static int getColumnWidth(int column); - static const QString getTitle(std::int8_t column); - static const QString getDescription(std::int8_t column); -private : - IdentificationGroup * _p_identification_group=nullptr; - PtmIslandListWindow * _p_ptm_island_list_window=nullptr; + Q_OBJECT + public: + PtmIslandTableModel(PtmIslandListWindow *p_ptm_island_list_window); + + ~PtmIslandTableModel(); + + void setIdentificationGroup(IdentificationGroup *p_identification_group); + virtual int + rowCount(const QModelIndex &parent = QModelIndex()) const override; + virtual int + columnCount(const QModelIndex &parent = QModelIndex()) const override; + virtual QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + virtual QVariant data(const QModelIndex &index, + int role = Qt::DisplayRole) const override; + + static const QString getTitle(PtmIslandListColumn column); + static const QString getDescription(PtmIslandListColumn column); + + const PtmGroupingExperiment *getPtmGroupingExperiment() const; + + public slots: + void onPtmIslandDataChanged(); + + private: + static int getColumnWidth(int column); + static const QString getTitle(std::int8_t column); + static const QString getDescription(std::int8_t column); + + private: + IdentificationGroup *_p_identification_group = nullptr; + PtmIslandListWindow *_p_ptm_island_list_window = nullptr; }; #endif // PTMISLANDTABLEMODEL_H diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp index 7babd9b4ba2106bde6d45b52309aa526310b1b22..f2b0b68b5139d7e68b911f18f9198a7e51e0b1b6 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp @@ -6,26 +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 "ptmpeptidelistwindow.h" #include "../ptm_island_list_view/ptmislandlistwindow.h" @@ -36,56 +37,76 @@ #include "ui_ptm_peptide_list_view.h" +PtmPeptideListWindow::PtmPeptideListWindow(PtmIslandListWindow *parent) + : QMainWindow(parent), ui(new Ui::PtmPeptideListWindow) +{ + _p_ptm_island_list_window = parent; + ui->setupUi(this); + /* + */ + _ptm_table_model_p = new PtmPeptideTableModel(this); -PtmPeptideListWindow::PtmPeptideListWindow(PtmIslandListWindow * parent):QMainWindow(parent), - ui(new Ui::PtmPeptideListWindow) { - _p_ptm_island_list_window = parent; - - ui->setupUi(this); - /* - */ - _ptm_table_model_p = new PtmPeptideTableModel(this); - - - _ptm_proxy_model_p = new PtmPeptideTableProxyModel(this, _ptm_table_model_p); - _ptm_proxy_model_p->setSourceModel(_ptm_table_model_p); - _ptm_proxy_model_p->setDynamicSortFilter(true); - ui->ptm_peptide_tableview->setModel( _ptm_proxy_model_p ); - ui->ptm_peptide_tableview->setSortingEnabled(true); - ui->ptm_peptide_tableview->setAlternatingRowColors(true); - PtmSequenceDelegate * p_sequence_delegate = new PtmSequenceDelegate(_p_ptm_island_list_window, this); - ui->ptm_peptide_tableview->setItemDelegateForColumn((std::int8_t) PtmPeptideListColumn::sequence, p_sequence_delegate); + _ptm_proxy_model_p = new PtmPeptideTableProxyModel(this, _ptm_table_model_p); + _ptm_proxy_model_p->setSourceModel(_ptm_table_model_p); + _ptm_proxy_model_p->setDynamicSortFilter(true); + ui->ptm_peptide_tableview->setModel(_ptm_proxy_model_p); + ui->ptm_peptide_tableview->setSortingEnabled(true); + ui->ptm_peptide_tableview->setAlternatingRowColors(true); + PtmSequenceDelegate *p_sequence_delegate = + new PtmSequenceDelegate(_p_ptm_island_list_window, this); + ui->ptm_peptide_tableview->setItemDelegateForColumn( + (std::int8_t)PtmPeptideListColumn::sequence, p_sequence_delegate); #if QT_VERSION >= 0x050000 - // Qt5 code - connect(ui->ptm_peptide_tableview, &QTableView::clicked, _ptm_proxy_model_p, &PtmPeptideTableProxyModel::onTableClicked); - connect (this, &PtmPeptideListWindow::requestPeptideDetailView, _p_ptm_island_list_window->getProjectWindowP(),&ProjectWindow::doViewPeptideDetail); + // Qt5 code + connect(ui->ptm_peptide_tableview, &QTableView::clicked, _ptm_proxy_model_p, + &PtmPeptideTableProxyModel::onTableClicked); + connect(this, &PtmPeptideListWindow::requestPeptideDetailView, + _p_ptm_island_list_window->getProjectWindowP(), + &ProjectWindow::doViewPeptideDetail); #else -// Qt4 code - //connect (this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, SLOT(onPtmIslandDataChanged())); + // Qt4 code + // connect (this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, + // SLOT(onPtmIslandDataChanged())); - //connect (_project_window, SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *))); - //connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - connect(ui->ptm_peptide_tableview, SIGNAL(clicked(const QModelIndex &)), _ptm_proxy_model_p, SLOT(onTableClicked(const QModelIndex &))); - connect (this, SIGNAL(requestPeptideDetailView(PeptideMatch *)), _p_ptm_island_list_window->getProjectWindowP(),SLOT(doViewPeptideDetail(PeptideMatch *))); + // connect (_project_window, + // SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), + // this,SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *))); connect + // (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), + // this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + connect(ui->ptm_peptide_tableview, SIGNAL(clicked(const QModelIndex &)), + _ptm_proxy_model_p, SLOT(onTableClicked(const QModelIndex &))); + connect(this, SIGNAL(requestPeptideDetailView(PeptideMatch *)), + _p_ptm_island_list_window->getProjectWindowP(), + SLOT(doViewPeptideDetail(PeptideMatch *))); #endif } -PtmPeptideListWindow::~PtmPeptideListWindow() { +PtmPeptideListWindow::~PtmPeptideListWindow() +{ } -void PtmPeptideListWindow::setPtmIsland(PtmIsland * p_ptm_island) { - _p_ptm_island = p_ptm_island; - _ptm_table_model_p->setPtmIsland(_p_ptm_island_list_window->getIdentificationGroup()->getPtmGroupingExperiment(), _p_ptm_island); +void +PtmPeptideListWindow::setPtmIsland(PtmIsland *p_ptm_island) +{ + _p_ptm_island = p_ptm_island; + _ptm_table_model_p->setPtmIsland( + _p_ptm_island_list_window->getIdentificationGroup() + ->getPtmGroupingExperiment(), + _p_ptm_island); } -void PtmPeptideListWindow::askPeptideDetailView(PeptideEvidence * p_peptide_evidence) { - qDebug() << "PtmPeptideListWindow::askPeptideDetailView begin " << p_peptide_evidence; - //PeptideMatch peptide_match(* p_peptide_match); - //qDebug() << "PtmPeptideListWindow::askPeptideDetailView begin " << peptide_match.getPeptideEvidence(); - emit requestPeptideDetailView(p_peptide_evidence); - qDebug() << "PtmPeptideListWindow::askPeptideDetailView end"; - //updateStatusBar(); +void +PtmPeptideListWindow::askPeptideDetailView(PeptideEvidence *p_peptide_evidence) +{ + qDebug() << "PtmPeptideListWindow::askPeptideDetailView begin " + << p_peptide_evidence; + // PeptideMatch peptide_match(* p_peptide_match); + // qDebug() << "PtmPeptideListWindow::askPeptideDetailView begin " << + // peptide_match.getPeptideEvidence(); + emit requestPeptideDetailView(p_peptide_evidence); + qDebug() << "PtmPeptideListWindow::askPeptideDetailView end"; + // updateStatusBar(); } diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h index b467c3aea7fa2198f5302d2b799daf62d72578e5..d49489ef74f2197e0e22c0dca384ecd5e8b6046c 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h +++ b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMPEPTIDELISTWINDOW_H #define PTMPEPTIDELISTWINDOW_H @@ -37,32 +38,32 @@ class PtmIslandListWindow; -namespace Ui { -class PtmPeptideListWindow; +namespace Ui +{ + class PtmPeptideListWindow; } -class PtmPeptideListWindow: public QMainWindow { - Q_OBJECT -public: +class PtmPeptideListWindow : public QMainWindow +{ + Q_OBJECT + public: + explicit PtmPeptideListWindow(PtmIslandListWindow *parent = 0); + ~PtmPeptideListWindow(); + void setPtmIsland(PtmIsland *p_ptm_island); + void askPeptideDetailView(PeptideEvidence *p_peptide_evidence); - explicit PtmPeptideListWindow(PtmIslandListWindow * parent = 0); - ~PtmPeptideListWindow(); - void setPtmIsland(PtmIsland * p_ptm_island); - void askPeptideDetailView(PeptideEvidence * p_peptide_evidence); - -signals: - void requestPeptideDetailView(PeptideEvidence * p_peptide_evidence); + signals: + void requestPeptideDetailView(PeptideEvidence *p_peptide_evidence); - -private: - PtmIsland * _p_ptm_island=nullptr; - Ui::PtmPeptideListWindow *ui; - PtmPeptideTableModel * _ptm_table_model_p = nullptr; - PtmPeptideTableProxyModel * _ptm_proxy_model_p = nullptr; - PtmIslandListWindow * _p_ptm_island_list_window; - QMenu * _p_context_menu = nullptr; + private: + PtmIsland *_p_ptm_island = nullptr; + Ui::PtmPeptideListWindow *ui; + PtmPeptideTableModel *_ptm_table_model_p = nullptr; + PtmPeptideTableProxyModel *_ptm_proxy_model_p = nullptr; + PtmIslandListWindow *_p_ptm_island_list_window; + QMenu *_p_context_menu = nullptr; }; #endif // PTMPEPTIDELISTWINDOW_H diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp index 20a4f59fa8703b267eee86443f97c975533322f7..ca333c6a2eb8909b7351cb914800d21ba344f689 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp @@ -5,262 +5,358 @@ */ /******************************************************************************* -* 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 "ptmpeptidetablemodel.h" #include "ptmpeptidelistwindow.h" #include <QDebug> #include <QStringList> -PtmPeptideTableModel::PtmPeptideTableModel(PtmPeptideListWindow * p_ptm_peptide_list_window) { +PtmPeptideTableModel::PtmPeptideTableModel( + PtmPeptideListWindow *p_ptm_peptide_list_window) +{ } -PtmPeptideTableModel::~PtmPeptideTableModel() { +PtmPeptideTableModel::~PtmPeptideTableModel() +{ } - const PtmGroupingExperiment * PtmPeptideTableModel::getPtmGroupingExperiment() const { - return _p_ptm_grouping_experiment; - } -const std::vector<PtmSampleScanSp> & PtmPeptideTableModel::getPtmSampleScanSpList() const { - return _ptm_sample_scan_list; +const PtmGroupingExperiment * +PtmPeptideTableModel::getPtmGroupingExperiment() const +{ + return _p_ptm_grouping_experiment; +} +const std::vector<PtmSampleScanSp> & +PtmPeptideTableModel::getPtmSampleScanSpList() const +{ + return _ptm_sample_scan_list; } -const QString PtmPeptideTableModel::getTitle(PtmPeptideListColumn column) { - qDebug() << "PtmPeptideTableModel::getTitle begin "; - return PtmPeptideTableModel::getTitle((std::int8_t) column); - //qDebug() << "ProteinTableModel::getTitle end "; +const QString +PtmPeptideTableModel::getTitle(PtmPeptideListColumn column) +{ + qDebug() << "PtmPeptideTableModel::getTitle begin "; + return PtmPeptideTableModel::getTitle((std::int8_t)column); + // qDebug() << "ProteinTableModel::getTitle end "; } -const QString PtmPeptideTableModel::getDescription(PtmPeptideListColumn column) { - qDebug() << "PtmPeptideTableModel::columnCount begin "; - return PtmPeptideTableModel::getDescription((std::int8_t) column); - //qDebug() << "ProteinTableModel::columnCount end "; +const QString +PtmPeptideTableModel::getDescription(PtmPeptideListColumn column) +{ + qDebug() << "PtmPeptideTableModel::columnCount begin "; + return PtmPeptideTableModel::getDescription((std::int8_t)column); + // qDebug() << "ProteinTableModel::columnCount end "; } -const QString PtmPeptideTableModel::getTitle(std::int8_t column) { - switch (column) { +const QString +PtmPeptideTableModel::getTitle(std::int8_t column) +{ + switch(column) + { - case (std::int8_t) PtmPeptideListColumn::peptide_ptm_grouping_id: + case(std::int8_t)PtmPeptideListColumn::peptide_ptm_grouping_id: return "peptide ID"; break; - case (std::int8_t) PtmPeptideListColumn::sample: + case(std::int8_t)PtmPeptideListColumn::sample: return "sample"; break; - case (std::int8_t) PtmPeptideListColumn::scan: + case(std::int8_t)PtmPeptideListColumn::scan: return "scan"; break; - case (std::int8_t) PtmPeptideListColumn::rt: + case(std::int8_t)PtmPeptideListColumn::rt: return "RT"; break; - case (std::int8_t) PtmPeptideListColumn::charge: + case(std::int8_t)PtmPeptideListColumn::charge: return "charge"; break; - case (std::int8_t) PtmPeptideListColumn::sequence: + case(std::int8_t)PtmPeptideListColumn::sequence: return "sequence"; break; - case (std::int8_t) PtmPeptideListColumn::modifs: + case(std::int8_t)PtmPeptideListColumn::modifs: return "modifs"; break; - case (std::int8_t) PtmPeptideListColumn::start: + case(std::int8_t)PtmPeptideListColumn::start: return "start"; break; - case (std::int8_t) PtmPeptideListColumn::length: + case(std::int8_t)PtmPeptideListColumn::length: return "length"; break; - case (std::int8_t) PtmPeptideListColumn::bestEvalue: + case(std::int8_t)PtmPeptideListColumn::bestEvalue: return "top Evalue"; break; - case (std::int8_t) PtmPeptideListColumn::theoretical_mhplus: + case(std::int8_t)PtmPeptideListColumn::theoretical_mhplus: return "theoretical MH+"; break; - case (std::int8_t) PtmPeptideListColumn::delta_mhplus: + case(std::int8_t)PtmPeptideListColumn::delta_mhplus: return "delta MH+"; break; - case (std::int8_t) PtmPeptideListColumn::besthyperscore: + case(std::int8_t)PtmPeptideListColumn::besthyperscore: return "top hyperscore"; - case (std::int8_t) PtmPeptideListColumn::bestposition: + case(std::int8_t)PtmPeptideListColumn::bestposition: return "top PTM positions"; - case (std::int8_t) PtmPeptideListColumn::allobservedposition: + case(std::int8_t)PtmPeptideListColumn::allobservedposition: return "observed PTM positions"; - } - return ""; + return ""; } -const QString PtmPeptideTableModel::getDescription(std::int8_t column) { - switch (column) { +const QString +PtmPeptideTableModel::getDescription(std::int8_t column) +{ + switch(column) + { - case (std::int8_t) PtmPeptideListColumn::peptide_ptm_grouping_id: - return "unique PTM peptide identifier within this PTM grouping experiment"; + case(std::int8_t)PtmPeptideListColumn::peptide_ptm_grouping_id: + return "unique PTM peptide identifier within this PTM grouping " + "experiment"; break; - case (std::int8_t) PtmPeptideListColumn::sample: + case(std::int8_t)PtmPeptideListColumn::sample: return "MS sample name"; break; - case (std::int8_t) PtmPeptideListColumn::scan: + case(std::int8_t)PtmPeptideListColumn::scan: return "scan number"; break; - case (std::int8_t) PtmPeptideListColumn::rt: + case(std::int8_t)PtmPeptideListColumn::rt: return "retention time in seconds"; break; - case (std::int8_t) PtmPeptideListColumn::charge: + case(std::int8_t)PtmPeptideListColumn::charge: return "peptide charge"; break; - case (std::int8_t) PtmPeptideListColumn::sequence: + case(std::int8_t)PtmPeptideListColumn::sequence: return "peptide sequence"; break; - case (std::int8_t) PtmPeptideListColumn::modifs: + case(std::int8_t)PtmPeptideListColumn::modifs: return "peptide modifications"; break; - case (std::int8_t) PtmPeptideListColumn::start: + case(std::int8_t)PtmPeptideListColumn::start: return "peptide start position on protein"; break; - case (std::int8_t) PtmPeptideListColumn::length: + case(std::int8_t)PtmPeptideListColumn::length: return "peptide length"; break; - case (std::int8_t) PtmPeptideListColumn::bestEvalue: + case(std::int8_t)PtmPeptideListColumn::bestEvalue: return "best peptide Evalue"; break; - case (std::int8_t) PtmPeptideListColumn::theoretical_mhplus: + case(std::int8_t)PtmPeptideListColumn::theoretical_mhplus: return "peptide theoretical MH+"; break; - case (std::int8_t) PtmPeptideListColumn::delta_mhplus: - return "peptide mass difference between observed mass and theoretical mass"; + case(std::int8_t)PtmPeptideListColumn::delta_mhplus: + return "peptide mass difference between observed mass and theoretical " + "mass"; break; - case (std::int8_t) PtmPeptideListColumn::besthyperscore: + case(std::int8_t)PtmPeptideListColumn::besthyperscore: return "best X!Tandem hyperscore"; - case (std::int8_t) PtmPeptideListColumn::bestposition: - return "PTM positions of the top identified peptide (best Evalue) for this scan"; - case (std::int8_t) PtmPeptideListColumn::allobservedposition: + case(std::int8_t)PtmPeptideListColumn::bestposition: + return "PTM positions of the top identified peptide (best Evalue) for " + "this scan"; + case(std::int8_t)PtmPeptideListColumn::allobservedposition: return "all observed PTM positions for the same scan"; - } - return ""; + return ""; } -int PtmPeptideTableModel::rowCount(const QModelIndex &parent ) const { - qDebug() << "PtmPeptideTableModel::rowCount begin "; - return _ptm_sample_scan_list.size(); +int +PtmPeptideTableModel::rowCount(const QModelIndex &parent) const +{ + qDebug() << "PtmPeptideTableModel::rowCount begin "; + return _ptm_sample_scan_list.size(); } -int PtmPeptideTableModel::columnCount(const QModelIndex &parent ) const { - //qDebug() << "ProteinTableModel::columnCount begin "; - return 15; +int +PtmPeptideTableModel::columnCount(const QModelIndex &parent) const +{ + // qDebug() << "ProteinTableModel::columnCount begin "; + return 15; } -QVariant PtmPeptideTableModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant +PtmPeptideTableModel::headerData(int section, Qt::Orientation orientation, + int role) const { - if (orientation == Qt::Horizontal) + if(orientation == Qt::Horizontal) { - switch (role) { - case Qt::DisplayRole : + switch(role) + { + case Qt::DisplayRole: return QVariant(getTitle(section)); break; - case Qt::ToolTipRole : - return QVariant(getDescription(section)); + case Qt::ToolTipRole: + return QVariant(getDescription(section)); break; - } } - return QVariant(); + return QVariant(); } -QVariant PtmPeptideTableModel::data(const QModelIndex &index, int role ) const { - // generate a log message when this method gets called - int row = index.row(); - int col = index.column(); - QStringList position_list; - - if (row >= _ptm_sample_scan_list.size()) return QVariant(); - switch(role) { - case Qt::DisplayRole: - switch (col) { +QVariant +PtmPeptideTableModel::data(const QModelIndex &index, int role) const +{ + // generate a log message when this method gets called + int row = index.row(); + int col = index.column(); + QStringList position_list; - case (std::int8_t)PtmPeptideListColumn::peptide_ptm_grouping_id: - return QVariant (_ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getGrpPeptideSp().get()->getGroupingId()); - break; - case (std::int8_t)PtmPeptideListColumn::sample: - return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getIdentificationDataSource()->getSampleName(); - break; - case (std::int8_t)PtmPeptideListColumn::scan: - return QVariant ((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getScan()); - break; - case (std::int8_t)PtmPeptideListColumn::rt: - return QVariant ((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getRetentionTime()); - break; - case (std::int8_t)PtmPeptideListColumn::charge: - return QVariant ((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getCharge()); - break; - case (std::int8_t)PtmPeptideListColumn::sequence: - return QVariant::fromValue( _ptm_sample_scan_list.at(row).get()); - break; - case (std::int8_t)PtmPeptideListColumn::modifs: - return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getModifString(); - break; - case (std::int8_t)PtmPeptideListColumn::start: - return QVariant((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getStart()+1); - break; - case (std::int8_t)PtmPeptideListColumn::length: - return QVariant((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->size()); - break; - case (std::int8_t)PtmPeptideListColumn::bestEvalue: - return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getEvalue()); - break; - case (std::int8_t)PtmPeptideListColumn::theoretical_mhplus: - return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getMz(1)); - break; - case (std::int8_t)PtmPeptideListColumn::delta_mhplus: - return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getDeltaMass()); - break; - case (std::int8_t)PtmPeptideListColumn::besthyperscore: - return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getParam(PeptideEvidenceParam::tandem_hyperscore); - break; - case (std::int8_t)PtmPeptideListColumn::bestposition: - for (unsigned int position :_ptm_sample_scan_list.at(row).get()->getBestPtmPositionList(_p_ptm_grouping_experiment)) { - position_list << QString("%1").arg(position+1); + if(row >= _ptm_sample_scan_list.size()) + return QVariant(); + switch(role) + { + case Qt::DisplayRole: + switch(col) + { + + case(std::int8_t)PtmPeptideListColumn::peptide_ptm_grouping_id: + return QVariant(_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getGrpPeptideSp() + .get() + ->getGroupingId()); + break; + case(std::int8_t)PtmPeptideListColumn::sample: + return _ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getIdentificationDataSource() + ->getSampleName(); + break; + case(std::int8_t)PtmPeptideListColumn::scan: + return QVariant((quint32)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getScan()); + break; + case(std::int8_t)PtmPeptideListColumn::rt: + return QVariant((qreal)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getRetentionTime()); + break; + case(std::int8_t)PtmPeptideListColumn::charge: + return QVariant((quint32)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getCharge()); + break; + case(std::int8_t)PtmPeptideListColumn::sequence: + return QVariant::fromValue(_ptm_sample_scan_list.at(row).get()); + break; + case(std::int8_t)PtmPeptideListColumn::modifs: + return _ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getModifString(); + break; + case(std::int8_t)PtmPeptideListColumn::start: + return QVariant((quint32)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getStart() + + 1); + break; + case(std::int8_t)PtmPeptideListColumn::length: + return QVariant((quint32)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->size()); + break; + case(std::int8_t)PtmPeptideListColumn::bestEvalue: + return QVariant((qreal)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getEvalue()); + break; + case(std::int8_t)PtmPeptideListColumn::theoretical_mhplus: + return QVariant((qreal)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getMz(1)); + break; + case(std::int8_t)PtmPeptideListColumn::delta_mhplus: + return QVariant((qreal)_ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getDeltaMass()); + break; + case(std::int8_t)PtmPeptideListColumn::besthyperscore: + return _ptm_sample_scan_list.at(row) + .get() + ->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getParam(PeptideEvidenceParam::tandem_hyperscore); + break; + case(std::int8_t)PtmPeptideListColumn::bestposition: + for(unsigned int position : + _ptm_sample_scan_list.at(row).get()->getBestPtmPositionList( + _p_ptm_grouping_experiment)) + { + position_list << QString("%1").arg(position + 1); } - return QVariant(position_list.join(" ")); - break; - case (std::int8_t)PtmPeptideListColumn::allobservedposition: - //return _ptm_sample_scan_list.at(row).get()->getObservedPtmPositionList(); - for (unsigned int position :_ptm_sample_scan_list.at(row).get()->getObservedPtmPositionList(_p_ptm_grouping_experiment)) { - position_list << QString("%1").arg(position+1); + return QVariant(position_list.join(" ")); + break; + case(std::int8_t)PtmPeptideListColumn::allobservedposition: + // return + // _ptm_sample_scan_list.at(row).get()->getObservedPtmPositionList(); + for(unsigned int position : + _ptm_sample_scan_list.at(row) + .get() + ->getObservedPtmPositionList(_p_ptm_grouping_experiment)) + { + position_list << QString("%1").arg(position + 1); } - return QVariant(position_list.join(" ")); - break; - - } + return QVariant(position_list.join(" ")); + break; + } } - return QVariant(); + return QVariant(); } -void PtmPeptideTableModel::setPtmIsland(const PtmGroupingExperiment * p_ptm_grouping_experiment, PtmIsland * ptm_island) { - qDebug() << "tmPeptideTableModel::setPtmIsland begin "; - - beginResetModel(); - _p_ptm_grouping_experiment = p_ptm_grouping_experiment; - _p_ptm_island = ptm_island; -_ptm_sample_scan_list = ptm_island->getPtmSampleScanSpList(); - //emit headerDataChanged(Qt::Horizontal, 0,11); - //refresh(); - qDebug() << "tmPeptideTableModel::setPtmIsland end "; - endResetModel(); - - //this->_p_ptm_island_list_window->resizeColumnsToContents(); +void +PtmPeptideTableModel::setPtmIsland( + const PtmGroupingExperiment *p_ptm_grouping_experiment, PtmIsland *ptm_island) +{ + qDebug() << "tmPeptideTableModel::setPtmIsland begin "; + + beginResetModel(); + _p_ptm_grouping_experiment = p_ptm_grouping_experiment; + _p_ptm_island = ptm_island; + _ptm_sample_scan_list = ptm_island->getPtmSampleScanSpList(); + // emit headerDataChanged(Qt::Horizontal, 0,11); + // refresh(); + qDebug() << "tmPeptideTableModel::setPtmIsland end "; + endResetModel(); + // this->_p_ptm_island_list_window->resizeColumnsToContents(); } diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h index cbd8344d0d42732629282b2c032e6b371a86ab93..76c02ce65b2f5ac008d2fe0dbb74427e876171c1 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h @@ -5,26 +5,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 + ******************************************************************************/ #ifndef PTMPEPTIDETABLEMODEL_H #define PTMPEPTIDETABLEMODEL_H @@ -34,58 +35,64 @@ #include "../../grouping/ptm/ptmisland.h" - -/** \def PtmPeptideListColumn list of available fields to display in ptm peptide list +/** \def PtmPeptideListColumn list of available fields to display in ptm peptide + * list * */ -enum class PtmPeptideListColumn: std::int8_t { - peptide_ptm_grouping_id=0, ///< peptide PTM grouping id - sample=1, - scan=2, - rt=3, - charge=4, - sequence=5, - modifs=6, - start=7, - length=8, - bestEvalue=9, - theoretical_mhplus=10, - delta_mhplus=11, - besthyperscore=12, - bestposition=13, - allobservedposition=14 +enum class PtmPeptideListColumn : std::int8_t +{ + peptide_ptm_grouping_id = 0, ///< peptide PTM grouping id + sample = 1, + scan = 2, + rt = 3, + charge = 4, + sequence = 5, + modifs = 6, + start = 7, + length = 8, + bestEvalue = 9, + theoretical_mhplus = 10, + delta_mhplus = 11, + besthyperscore = 12, + bestposition = 13, + allobservedposition = 14 }; class PtmPeptideListWindow; -class PtmPeptideTableModel: public QAbstractTableModel +class PtmPeptideTableModel : public QAbstractTableModel { - Q_OBJECT -public: - PtmPeptideTableModel(PtmPeptideListWindow * p_ptm_peptide_list_window); - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - static const QString getTitle(PtmPeptideListColumn column); - static const QString getDescription(PtmPeptideListColumn column); + Q_OBJECT + public: + PtmPeptideTableModel(PtmPeptideListWindow *p_ptm_peptide_list_window); + virtual int + rowCount(const QModelIndex &parent = QModelIndex()) const override; + virtual int + columnCount(const QModelIndex &parent = QModelIndex()) const override; + virtual QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + virtual QVariant data(const QModelIndex &index, + int role = Qt::DisplayRole) const override; + static const QString getTitle(PtmPeptideListColumn column); + static const QString getDescription(PtmPeptideListColumn column); + + ~PtmPeptideTableModel(); + void setPtmIsland(const PtmGroupingExperiment *p_ptm_grouping_experiment, + PtmIsland *ptm_island); + + const std::vector<PtmSampleScanSp> &getPtmSampleScanSpList() const; + const PtmGroupingExperiment *getPtmGroupingExperiment() const; + + private: + static const QString getTitle(std::int8_t column); + static const QString getDescription(std::int8_t column); - ~PtmPeptideTableModel(); - void setPtmIsland(const PtmGroupingExperiment * p_ptm_grouping_experiment, PtmIsland * ptm_island); - - const std::vector<PtmSampleScanSp> & getPtmSampleScanSpList() const; - const PtmGroupingExperiment * getPtmGroupingExperiment() const; - -private : - static const QString getTitle(std::int8_t column); - static const QString getDescription(std::int8_t column); - -private: - std::vector<PtmSampleScanSp> _ptm_sample_scan_list; - const PtmIsland * _p_ptm_island; - const PtmGroupingExperiment * _p_ptm_grouping_experiment; + private: + std::vector<PtmSampleScanSp> _ptm_sample_scan_list; + const PtmIsland *_p_ptm_island; + const PtmGroupingExperiment *_p_ptm_grouping_experiment; }; #endif // PTMPEPTIDETABLEMODEL_H diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp index 2110b928879c2f6f99e252d80c126ac5283defd0..2d4e4368cc6dbb01a64520034d3ba5fc21c0356a 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp @@ -5,26 +5,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 "ptmpeptidetableproxymodel.h" #include "ptmpeptidetablemodel.h" @@ -32,135 +33,197 @@ #include "../../grouping/ptm/ptmgroupingexperiment.h" #include <QTextDocument> -PtmPeptideMenuQicon::PtmPeptideMenuQicon(const PtmGroupingExperiment * p_ptm_grouping_experiment, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match):QIcon(), _peptide_match(*p_peptide_match) { - _p_ptm_sample_scan = p_ptm_sample; - _p_ptm_grouping_experiment = p_ptm_grouping_experiment; +PtmPeptideMenuQicon::PtmPeptideMenuQicon( + const PtmGroupingExperiment *p_ptm_grouping_experiment, + const PtmSampleScan *p_ptm_sample, const PeptideMatch *p_peptide_match) + : QIcon(), _peptide_match(*p_peptide_match) +{ + _p_ptm_sample_scan = p_ptm_sample; + _p_ptm_grouping_experiment = p_ptm_grouping_experiment; } -PtmPeptideMenuQicon::~PtmPeptideMenuQicon( ) { +PtmPeptideMenuQicon::~PtmPeptideMenuQicon() +{ } -void PtmPeptideMenuQicon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const +void +PtmPeptideMenuQicon::paint(QPainter *painter, const QRect &rect, + Qt::Alignment alignment, Mode mode, + State state) const { - // if (option.state & QStyle::State_Selected) - // painter->fillRect(option.rect, option.palette.highlight()); - QTextDocument document; - document.setDocumentMargin(2); - document.setHtml(_p_ptm_sample_scan->getHtmlSequence(_p_ptm_grouping_experiment)); - //painter->translate(option.rect.topLeft()); - document.drawContents(painter); - //painter->translate(-option.rect.topLeft()); - - //edit_seq.render(painter); - //edit..paint(painter, option.rect, option.palette, - // StarRating::ReadOnly); + // if (option.state & QStyle::State_Selected) + // painter->fillRect(option.rect, option.palette.highlight()); + QTextDocument document; + document.setDocumentMargin(2); + document.setHtml( + _p_ptm_sample_scan->getHtmlSequence(_p_ptm_grouping_experiment)); + // painter->translate(option.rect.topLeft()); + document.drawContents(painter); + // painter->translate(-option.rect.topLeft()); + + // edit_seq.render(painter); + // edit..paint(painter, option.rect, option.palette, + // StarRating::ReadOnly); } -PtmPeptideMenuQaction::PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmGroupingExperiment * p_ptm_grouping_experiment, const PtmSampleScan * p_ptm_sample, PeptideMatch * p_peptide_match):QAction(parent) { - - _p_ptm_peptide_table_proxy_model = parent; - _peptide_match = *p_peptide_match; - this->setIcon(PtmPeptideMenuQicon(p_ptm_grouping_experiment, p_ptm_sample, p_peptide_match)); - //this->setText(p_peptide_match->getPeptideXtpSp().get()->getSequence()); +PtmPeptideMenuQaction::PtmPeptideMenuQaction( + PtmPeptideTableProxyModel *parent, + const PtmGroupingExperiment *p_ptm_grouping_experiment, + const PtmSampleScan *p_ptm_sample, PeptideMatch *p_peptide_match) + : QAction(parent) +{ - QStringList position_list; - for (unsigned int position : p_ptm_grouping_experiment->getPtmPositions(*p_peptide_match)) { - position_list << QString("%1").arg(position+1); + _p_ptm_peptide_table_proxy_model = parent; + _peptide_match = *p_peptide_match; + this->setIcon(PtmPeptideMenuQicon(p_ptm_grouping_experiment, p_ptm_sample, + p_peptide_match)); + // this->setText(p_peptide_match->getPeptideXtpSp().get()->getSequence()); + + QStringList position_list; + for(unsigned int position : + p_ptm_grouping_experiment->getPtmPositions(*p_peptide_match)) + { + position_list << QString("%1").arg(position + 1); } - this->setText(QString("%1 (%2)").arg(p_peptide_match->getPeptideEvidence()->getPeptideXtpSp().get()->toString()).arg(position_list.join(" "))); - //evalue_action.setChecked(_display_evalue); - //connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool))); + this->setText(QString("%1 (%2)") + .arg(p_peptide_match->getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->toString()) + .arg(position_list.join(" "))); + // evalue_action.setChecked(_display_evalue); + // connect(p_action, SIGNAL(toggled(bool)), this, + // SLOT(showEvalueColumn(bool))); #if QT_VERSION >= 0x050000 - // Qt5 code - connect (this, &PtmPeptideMenuQaction::triggered, this,&PtmPeptideMenuQaction::doTriggered); + // Qt5 code + connect(this, &PtmPeptideMenuQaction::triggered, this, + &PtmPeptideMenuQaction::doTriggered); #else -// Qt4 code - connect (this, SIGNAL(triggered(bool)), this,SLOT(doTriggered(bool))); + // Qt4 code + connect(this, SIGNAL(triggered(bool)), this, SLOT(doTriggered(bool))); #endif } -void PtmPeptideMenuQaction::doTriggered(bool triggered) { - PeptideEvidence * p_peptide_evidence = _peptide_match.getPeptideEvidence(); - qDebug() << "PtmPeptideMenuQaction::doTriggered begin" << _peptide_match.getPeptideEvidence(); - qDebug() << "PtmPeptideMenuQaction::doTriggered begin 2 " << p_peptide_evidence; - qDebug() << "PtmPeptideMenuQaction::doTriggered begin 3 " << p_peptide_evidence->getPeptideXtpSp().get()->toString(); - _p_ptm_peptide_table_proxy_model->getPtmPeptideListWindowP()->askPeptideDetailView(p_peptide_evidence); +void +PtmPeptideMenuQaction::doTriggered(bool triggered) +{ + PeptideEvidence *p_peptide_evidence = _peptide_match.getPeptideEvidence(); + qDebug() << "PtmPeptideMenuQaction::doTriggered begin" + << _peptide_match.getPeptideEvidence(); + qDebug() << "PtmPeptideMenuQaction::doTriggered begin 2 " + << p_peptide_evidence; + qDebug() << "PtmPeptideMenuQaction::doTriggered begin 3 " + << p_peptide_evidence->getPeptideXtpSp().get()->toString(); + _p_ptm_peptide_table_proxy_model->getPtmPeptideListWindowP() + ->askPeptideDetailView(p_peptide_evidence); } PtmPeptideMenuQaction::~PtmPeptideMenuQaction() { - //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; - qDebug() << "PtmPeptideMenuQaction::~PtmPeptideMenuQaction begin "; - + // if (_p_ms_data_file != nullptr) delete _p_ms_data_file; + qDebug() << "PtmPeptideMenuQaction::~PtmPeptideMenuQaction begin "; } -PtmPeptideTableProxyModel::PtmPeptideTableProxyModel(PtmPeptideListWindow * p_ptm_peptide_list_window, PtmPeptideTableModel* ptm_table_model_p) +PtmPeptideTableProxyModel::PtmPeptideTableProxyModel( + PtmPeptideListWindow *p_ptm_peptide_list_window, + PtmPeptideTableModel *ptm_table_model_p) { - _p_ptm_peptide_list_window = p_ptm_peptide_list_window; - _p_ptm_table_model = ptm_table_model_p; + _p_ptm_peptide_list_window = p_ptm_peptide_list_window; + _p_ptm_table_model = ptm_table_model_p; } PtmPeptideTableProxyModel::~PtmPeptideTableProxyModel() { - } -PtmPeptideListWindow * PtmPeptideTableProxyModel::getPtmPeptideListWindowP() { - return _p_ptm_peptide_list_window; +PtmPeptideListWindow * +PtmPeptideTableProxyModel::getPtmPeptideListWindowP() +{ + return _p_ptm_peptide_list_window; } -bool PtmPeptideTableProxyModel::lessThan(const QModelIndex &left, - const QModelIndex &right) const +bool +PtmPeptideTableProxyModel::lessThan(const QModelIndex &left, + const QModelIndex &right) const { - QVariant leftData = sourceModel()->data(left); - QVariant rightData = sourceModel()->data(right); - - if (leftData.canConvert<PtmSampleScan *>()) { - PtmSampleScan * p_ptm_sample_scan_left = qvariant_cast<PtmSampleScan *>(leftData); - PtmSampleScan * p_ptm_sample_scan_right = qvariant_cast<PtmSampleScan *>(rightData); - return p_ptm_sample_scan_left->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->toAbsoluteString() < p_ptm_sample_scan_right->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->toAbsoluteString(); - } else { - return QSortFilterProxyModel::lessThan(left, right); + QVariant leftData = sourceModel()->data(left); + QVariant rightData = sourceModel()->data(right); + + if(leftData.canConvert<PtmSampleScan *>()) + { + PtmSampleScan *p_ptm_sample_scan_left = + qvariant_cast<PtmSampleScan *>(leftData); + PtmSampleScan *p_ptm_sample_scan_right = + qvariant_cast<PtmSampleScan *>(rightData); + return p_ptm_sample_scan_left->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->toAbsoluteString() < + p_ptm_sample_scan_right->getRepresentativePeptideMatch() + .getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->toAbsoluteString(); + } + else + { + return QSortFilterProxyModel::lessThan(left, right); } } -void PtmPeptideTableProxyModel::showContextMenu(const QModelIndex &index) { - if (_p_context_menu == nullptr) { - _p_context_menu = new QMenu(tr("Context menu")); +void +PtmPeptideTableProxyModel::showContextMenu(const QModelIndex &index) +{ + if(_p_context_menu == nullptr) + { + _p_context_menu = new QMenu(tr("Context menu")); } - _p_context_menu->clear(); - QModelIndex source_index(this->mapToSource(index)); - int row = source_index.row(); - PtmSampleScanSp sp_ptm_sample_scan = _p_ptm_table_model->getPtmSampleScanSpList().at(row); - - PtmPeptideMenuQaction * p_action; - for (auto p_peptide_match : sp_ptm_sample_scan.get()->getPeptideMatchList()) { - p_action = new PtmPeptideMenuQaction(this, _p_ptm_table_model->getPtmGroupingExperiment(), sp_ptm_sample_scan.get(), &p_peptide_match); - _p_context_menu->addAction(p_action); + _p_context_menu->clear(); + QModelIndex source_index(this->mapToSource(index)); + int row = source_index.row(); + PtmSampleScanSp sp_ptm_sample_scan = + _p_ptm_table_model->getPtmSampleScanSpList().at(row); + + PtmPeptideMenuQaction *p_action; + for(auto p_peptide_match : sp_ptm_sample_scan.get()->getPeptideMatchList()) + { + p_action = new PtmPeptideMenuQaction( + this, _p_ptm_table_model->getPtmGroupingExperiment(), + sp_ptm_sample_scan.get(), &p_peptide_match); + _p_context_menu->addAction(p_action); } - _p_context_menu->exec(QCursor::pos()); + _p_context_menu->exec(QCursor::pos()); - //_p_context_menu->exec(_p_ptm_peptide_list_window-> mapToGlobal(QCursor::pos())); + //_p_context_menu->exec(_p_ptm_peptide_list_window-> + //mapToGlobal(QCursor::pos())); - _p_context_menu->show(); + _p_context_menu->show(); } -void PtmPeptideTableProxyModel::onTableClicked(const QModelIndex &index) +void +PtmPeptideTableProxyModel::onTableClicked(const QModelIndex &index) { - qDebug() << "PtmPeptideTableProxyModel::onTableClicked begin " << index.row(); - qDebug() << "PtmPeptideTableProxyModel::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(); - int col = source_index.column(); - PtmSampleScanSp sp_ptm_sample_scan = _p_ptm_table_model->getPtmSampleScanSpList().at(row); - - if (sp_ptm_sample_scan.get()->getPeptideMatchList().size() == 1) { - _p_ptm_peptide_list_window->askPeptideDetailView(sp_ptm_sample_scan.get()->getPeptideMatchList().at(0).getPeptideEvidence()); + qDebug() << "PtmPeptideTableProxyModel::onTableClicked begin " << index.row(); + qDebug() << "PtmPeptideTableProxyModel::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(); + int col = source_index.column(); + PtmSampleScanSp sp_ptm_sample_scan = + _p_ptm_table_model->getPtmSampleScanSpList().at(row); + + if(sp_ptm_sample_scan.get()->getPeptideMatchList().size() == 1) + { + _p_ptm_peptide_list_window->askPeptideDetailView(sp_ptm_sample_scan.get() + ->getPeptideMatchList() + .at(0) + .getPeptideEvidence()); } - else { - this->showContextMenu(index); + else + { + this->showContextMenu(index); } - qDebug() << "PtmPeptideTableProxyModel::onTableClicked end " << index.row(); - + qDebug() << "PtmPeptideTableProxyModel::onTableClicked end " << index.row(); } diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h index 373ca4d30f17a0f3c7b89b85f1b6903a4b765305..3b458883bfd391828b05e20202daed9b4270f104 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h @@ -5,26 +5,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 + ******************************************************************************/ #ifndef PTMPEPTIDETABLEPROXYMODEL_H #define PTMPEPTIDETABLEPROXYMODEL_H @@ -40,56 +41,65 @@ class PtmPeptideListWindow; class PtmPeptideTableModel; class PtmPeptideTableProxyModel; -class PtmPeptideMenuQicon: public QIcon { -public: - - explicit PtmPeptideMenuQicon(const PtmGroupingExperiment * p_ptm_grouping_experiment, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match); - ~PtmPeptideMenuQicon(); - - void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const; - -private: - const PtmSampleScan * _p_ptm_sample_scan; - const PeptideMatch _peptide_match; - const PtmGroupingExperiment * _p_ptm_grouping_experiment; +class PtmPeptideMenuQicon : public QIcon +{ + public: + explicit PtmPeptideMenuQicon( + const PtmGroupingExperiment *p_ptm_grouping_experiment, + const PtmSampleScan *p_ptm_sample, const PeptideMatch *p_peptide_match); + ~PtmPeptideMenuQicon(); + + void paint(QPainter *painter, const QRect &rect, + Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, + State state = Off) const; + + private: + const PtmSampleScan *_p_ptm_sample_scan; + const PeptideMatch _peptide_match; + const PtmGroupingExperiment *_p_ptm_grouping_experiment; }; -class PtmPeptideMenuQaction: public QAction { - Q_OBJECT -public: - - explicit PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmGroupingExperiment * p_ptm_grouping_experiment, const PtmSampleScan * p_ptm_sample, PeptideMatch * p_peptide_match); - ~PtmPeptideMenuQaction(); - -public slots: - void doTriggered(bool triggered); - -private: - PeptideMatch _peptide_match; - PtmPeptideTableProxyModel * _p_ptm_peptide_table_proxy_model; +class PtmPeptideMenuQaction : public QAction +{ + Q_OBJECT + public: + explicit PtmPeptideMenuQaction( + PtmPeptideTableProxyModel *parent, + const PtmGroupingExperiment *p_ptm_grouping_experiment, + const PtmSampleScan *p_ptm_sample, PeptideMatch *p_peptide_match); + ~PtmPeptideMenuQaction(); + + public slots: + void doTriggered(bool triggered); + + private: + PeptideMatch _peptide_match; + PtmPeptideTableProxyModel *_p_ptm_peptide_table_proxy_model; }; -class PtmPeptideTableProxyModel: public QSortFilterProxyModel +class PtmPeptideTableProxyModel : public QSortFilterProxyModel { - Q_OBJECT -public: - PtmPeptideTableProxyModel(PtmPeptideListWindow * p_ptm_peptide_list_window, PtmPeptideTableModel* ptm_table_model_p); - ~PtmPeptideTableProxyModel(); - - PtmPeptideListWindow * getPtmPeptideListWindowP(); - -public slots: - void onTableClicked(const QModelIndex &index); - -protected: - bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; - void showContextMenu(const QModelIndex &index); - -private: - PtmPeptideListWindow * _p_ptm_peptide_list_window; - PtmPeptideTableModel* _p_ptm_table_model; - QMenu * _p_context_menu = nullptr; + Q_OBJECT + public: + PtmPeptideTableProxyModel(PtmPeptideListWindow *p_ptm_peptide_list_window, + PtmPeptideTableModel *ptm_table_model_p); + ~PtmPeptideTableProxyModel(); + + PtmPeptideListWindow *getPtmPeptideListWindowP(); + + public slots: + void onTableClicked(const QModelIndex &index); + + protected: + bool lessThan(const QModelIndex &left, + const QModelIndex &right) const override; + void showContextMenu(const QModelIndex &index); + + private: + PtmPeptideListWindow *_p_ptm_peptide_list_window; + PtmPeptideTableModel *_p_ptm_table_model; + QMenu *_p_context_menu = nullptr; }; #endif // PTMPEPTIDETABLEPROXYMODEL_H diff --git a/src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp index 57a2c504e492c1bf6cb4623c5fbb16928630f0ac..a477e0a95c5be3238ea11efa83f7cfbd9cfa7c45 100644 --- a/src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp +++ b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp @@ -5,26 +5,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 "ptmsequencedelegate.h" #include "../../grouping/ptm/ptmsamplescan.h" @@ -32,29 +33,39 @@ #include <QTextDocument> #include <QPainter> -PtmSequenceDelegate::PtmSequenceDelegate(PtmIslandListWindow * p_ptm_island_list_window, QWidget *parent) : QStyledItemDelegate(parent) { - _p_ptm_island_list_window = p_ptm_island_list_window; +PtmSequenceDelegate::PtmSequenceDelegate( + PtmIslandListWindow *p_ptm_island_list_window, QWidget *parent) + : QStyledItemDelegate(parent) +{ + _p_ptm_island_list_window = p_ptm_island_list_window; } -void PtmSequenceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const +void +PtmSequenceDelegate::paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const { - if (index.data().canConvert<PtmSampleScan *>()) { - PtmSampleScan * p_ptm_sample_scan = index.data().value<PtmSampleScan *>(); + if(index.data().canConvert<PtmSampleScan *>()) + { + PtmSampleScan *p_ptm_sample_scan = index.data().value<PtmSampleScan *>(); + + // if (option.state & QStyle::State_Selected) + // painter->fillRect(option.rect, option.palette.highlight()); + QTextDocument document; + document.setDocumentMargin(2); + document.setHtml(p_ptm_sample_scan->getHtmlSequence( + _p_ptm_island_list_window->getIdentificationGroup() + ->getPtmGroupingExperiment())); + painter->translate(option.rect.topLeft()); + document.drawContents(painter); + painter->translate(-option.rect.topLeft()); - // if (option.state & QStyle::State_Selected) - // painter->fillRect(option.rect, option.palette.highlight()); - QTextDocument document; - document.setDocumentMargin(2); - document.setHtml(p_ptm_sample_scan->getHtmlSequence(_p_ptm_island_list_window->getIdentificationGroup()->getPtmGroupingExperiment())); - painter->translate(option.rect.topLeft()); - document.drawContents(painter); - painter->translate(-option.rect.topLeft()); - - //edit_seq.render(painter); - //edit..paint(painter, option.rect, option.palette, - // StarRating::ReadOnly); - } else { - QStyledItemDelegate::paint(painter, option, index); + // edit_seq.render(painter); + // edit..paint(painter, option.rect, option.palette, + // StarRating::ReadOnly); + } + else + { + QStyledItemDelegate::paint(painter, option, index); } } diff --git a/src/gui/ptm_peptide_list_view/ptmsequencedelegate.h b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.h index ab98fc180ea9d18f2438533759cc766175a7eb60..e9b786bcc63c4700a6db961e0def62f88408155d 100644 --- a/src/gui/ptm_peptide_list_view/ptmsequencedelegate.h +++ b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.h @@ -5,26 +5,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 + ******************************************************************************/ #ifndef PTMSEQUENCEDELEGATE_H #define PTMSEQUENCEDELEGATE_H @@ -34,21 +35,22 @@ class PtmIslandListWindow; class PtmSequenceDelegate : public QStyledItemDelegate { - Q_OBJECT + Q_OBJECT -public: - PtmSequenceDelegate(PtmIslandListWindow * p_ptm_island_list_window, QWidget *parent = 0); + public: + PtmSequenceDelegate(PtmIslandListWindow *p_ptm_island_list_window, + QWidget *parent = 0); - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const override; - //QSize sizeHint(const QStyleOptionViewItem &option, - // const QModelIndex &index) const override; - //QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - // const QModelIndex &index) const override; - //void setEditorData(QWidget *editor, const QModelIndex &index) const override; - //void setModelData(QWidget *editor, QAbstractItemModel *model, - // const QModelIndex &index) const override; -private: - PtmIslandListWindow * _p_ptm_island_list_window; + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + // QSize sizeHint(const QStyleOptionViewItem &option, + // const QModelIndex &index) const override; + // QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + // const QModelIndex &index) const override; + // void setEditorData(QWidget *editor, const QModelIndex &index) const + // override; void setModelData(QWidget *editor, QAbstractItemModel *model, + // const QModelIndex &index) const override; + private: + PtmIslandListWindow *_p_ptm_island_list_window; }; #endif // PTMSEQUENCEDELEGATE_H diff --git a/src/gui/tandem_run_dialog/tandemrundialog.cpp b/src/gui/tandem_run_dialog/tandemrundialog.cpp index 0d4cb8ad9ba0c3887e43f8326da39c1e9cd0e215..3337ec9fba3d0f8428261331212a12f1ee3da4b0 100644 --- a/src/gui/tandem_run_dialog/tandemrundialog.cpp +++ b/src/gui/tandem_run_dialog/tandemrundialog.cpp @@ -6,26 +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 "tandemrundialog.h" #include "ui_tandem_run_dialog.h" @@ -36,325 +37,422 @@ #include <pappsomspp/pappsoexception.h> #include "../../files/tandemparametersfile.h" -//Q_DECLARE_METATYPE(QFileInfo) +// Q_DECLARE_METATYPE(QFileInfo) -TandemRunDialog::TandemRunDialog(QWidget * parent): - QDialog(parent), - ui(new Ui::TandemRunDialog) +TandemRunDialog::TandemRunDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::TandemRunDialog) { - qDebug() << "TandemRunDialog::TandemRunDialog begin"; - ui->setupUi(this); - this->setModal(true); - _p_fasta_file_list = new QStringListModel(); - _p_mz_file_list = new QStringListModel(); - ui->fasta_file_listview->setModel(_p_fasta_file_list); - ui->mz_file_listview->setModel(_p_mz_file_list); - ui->exe_group_widget->setVisible(false); - - QSettings settings; - /* - QString condor_tmp_dir = QString("%1/xtpcpp").arg(settings.value("condor/tmp_dir", "/tmp").toString()); - _p_tmp_dir = new QTemporaryDir(condor_tmp_dir); - _p_tmp_dir->setAutoRemove(settings.value("condor/tmp_dir_autoremove", true).toBool()); - _condor_submit_command = settings.value("condor/submit", "/usr/bin/condor_submit").toString(); - _condor_q_command = settings.value("condor/condor_q", "/usr/bin/condor_q").toString(); - _condor_rm_command = settings.value("condor/condor_rm", "/usr/bin/condor_rm").toString(); - _condor_request_memory = settings.value("condor/request_memory", "10000").toUInt(); - - QString default_preset_name = ; - */ - - ui->use_htcondor_groupbox->setChecked(settings.value("tandem/use_HTCondor", "false").toBool()); - ui->request_memory_edit->setText(settings.value("tandem/condor_request_memory", "5000").toString()); - - settings.value("condor/tmp_dir", "/gorgone/pappso/tmp"); + qDebug() << "TandemRunDialog::TandemRunDialog begin"; + ui->setupUi(this); + this->setModal(true); + _p_fasta_file_list = new QStringListModel(); + _p_mz_file_list = new QStringListModel(); + ui->fasta_file_listview->setModel(_p_fasta_file_list); + ui->mz_file_listview->setModel(_p_mz_file_list); + ui->exe_group_widget->setVisible(false); + + QSettings settings; + /* + QString condor_tmp_dir = + QString("%1/xtpcpp").arg(settings.value("condor/tmp_dir", "/tmp").toString()); + _p_tmp_dir = new QTemporaryDir(condor_tmp_dir); + _p_tmp_dir->setAutoRemove(settings.value("condor/tmp_dir_autoremove", + true).toBool()); _condor_submit_command = settings.value("condor/submit", + "/usr/bin/condor_submit").toString(); _condor_q_command = + settings.value("condor/condor_q", "/usr/bin/condor_q").toString(); + _condor_rm_command = settings.value("condor/condor_rm", + "/usr/bin/condor_rm").toString(); _condor_request_memory = + settings.value("condor/request_memory", "10000").toUInt(); + + QString default_preset_name = ; + */ + + ui->use_htcondor_groupbox->setChecked( + settings.value("tandem/use_HTCondor", "false").toBool()); + ui->request_memory_edit->setText( + settings.value("tandem/condor_request_memory", "5000").toString()); + + settings.value("condor/tmp_dir", "/gorgone/pappso/tmp"); #if QT_VERSION >= 0x050000 - // Qt5 code + // Qt5 code #else -// Qt4 code + // Qt4 code #endif - reset(); - fillPresetComboBox(); - qDebug() << "TandemRunDialog::TandemRunDialog end"; + reset(); + fillPresetComboBox(); + qDebug() << "TandemRunDialog::TandemRunDialog end"; } TandemRunDialog::~TandemRunDialog() { - delete ui; - delete _p_fasta_file_list; - delete _p_mz_file_list; + delete ui; + delete _p_fasta_file_list; + delete _p_mz_file_list; } -void TandemRunDialog::exeGroupBoxClicked(bool clicked) { - qDebug() << "TandemRunDialog::exeGroupBoxClicked begin"; - ui->exe_group_widget->setVisible(false); - if (clicked) { - ui->exe_group_widget->setVisible(true); +void +TandemRunDialog::exeGroupBoxClicked(bool clicked) +{ + qDebug() << "TandemRunDialog::exeGroupBoxClicked begin"; + ui->exe_group_widget->setVisible(false); + if(clicked) + { + ui->exe_group_widget->setVisible(true); } - qDebug() << "TandemRunDialog::exeGroupBoxClicked end"; + qDebug() << "TandemRunDialog::exeGroupBoxClicked end"; } -void TandemRunDialog::setPresetName(QString preset_name) { - qDebug() << "TandemRunDialog::setPresetName begin"; - if (!preset_name.isEmpty() && !preset_name.isNull()) { - - qDebug() << "TandemRunDialog::setPresetName not null"; - //test if this is an X!Tandem preset file: - //get presets : - TandemParametersFile param_file(ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()).value<QString>()); - - if (param_file.isTandemPresetFile()) { - QSettings settings; - settings.setValue("tandem/preset_name", preset_name); - +void +TandemRunDialog::setPresetName(QString preset_name) +{ + qDebug() << "TandemRunDialog::setPresetName begin"; + if(!preset_name.isEmpty() && !preset_name.isNull()) + { - if (_previous_preset_file != param_file.getAbsoluteFilePath()) { - _previous_preset_file = param_file.getAbsoluteFilePath(); - ui->thread_spin_box->setValue(param_file.getTandemParameters().getValue("spectrum, threads").toInt()); + qDebug() << "TandemRunDialog::setPresetName not null"; + // test if this is an X!Tandem preset file: + // get presets : + TandemParametersFile param_file( + ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()) + .value<QString>()); + + if(param_file.isTandemPresetFile()) + { + QSettings settings; + settings.setValue("tandem/preset_name", preset_name); + + + if(_previous_preset_file != param_file.getAbsoluteFilePath()) + { + _previous_preset_file = param_file.getAbsoluteFilePath(); + ui->thread_spin_box->setValue(param_file.getTandemParameters() + .getValue("spectrum, threads") + .toInt()); } } } - qDebug() << "TandemRunDialog::setPresetName end"; + qDebug() << "TandemRunDialog::setPresetName end"; } -void TandemRunDialog::fillPresetComboBox() { - qDebug() << "TandemRunDialog::fillPresetComboBox begin"; - ui->preset_combobox->clear(); - QSettings settings; - QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString(); - QString default_preset_name = settings.value("tandem/preset_name", "").toString(); - - qDebug() << "TandemRunDialog::fillPresetComboBox default_preset_location=" << default_preset_location; - qDebug() << "TandemRunDialog::fillPresetComboBox default_preset_name=" << default_preset_name; - QDir preset_dir(default_preset_location); - QStringList filters; - filters << "*.xml"; - preset_dir.setNameFilters(filters); - for (QFileInfo file_info: preset_dir.entryInfoList() ) { - TandemParametersFile param_file(file_info.absoluteFilePath()); - if (param_file.isTandemPresetFile()) { - ui->preset_combobox->addItem(file_info.baseName(), QVariant(file_info.absoluteFilePath())); +void +TandemRunDialog::fillPresetComboBox() +{ + qDebug() << "TandemRunDialog::fillPresetComboBox begin"; + ui->preset_combobox->clear(); + QSettings settings; + QString default_preset_location = + settings.value("path/tandemrun_preset_directory", "").toString(); + QString default_preset_name = + settings.value("tandem/preset_name", "").toString(); + + qDebug() << "TandemRunDialog::fillPresetComboBox default_preset_location=" + << default_preset_location; + qDebug() << "TandemRunDialog::fillPresetComboBox default_preset_name=" + << default_preset_name; + QDir preset_dir(default_preset_location); + QStringList filters; + filters << "*.xml"; + preset_dir.setNameFilters(filters); + for(QFileInfo file_info : preset_dir.entryInfoList()) + { + TandemParametersFile param_file(file_info.absoluteFilePath()); + if(param_file.isTandemPresetFile()) + { + ui->preset_combobox->addItem(file_info.baseName(), + QVariant(file_info.absoluteFilePath())); } } - int index = ui->preset_combobox->findText(default_preset_name); - if ( index != -1 ) { // -1 for not found - ui->preset_combobox->setCurrentIndex(index); + int index = ui->preset_combobox->findText(default_preset_name); + if(index != -1) + { // -1 for not found + ui->preset_combobox->setCurrentIndex(index); } - } -void TandemRunDialog::reset() { - QSettings settings; - QString default_output_location = settings.value("path/identificationfiles", "").toString(); - QString tandem_bin_path = settings.value("path/tandem_bin", "/usr/bin/tandem").toString(); - - ui->output_directory_label->setText(default_output_location); - ui->tandem_bin_label->setText(tandem_bin_path); - - _p_fasta_file_list->stringList().clear(); - _p_mz_file_list->stringList().clear(); - /* - if (filenames.size() > 0) { - settings.setValue("path/identificationfiles", QFileInfo(filenames[0]).absolutePath()); - }*/ +void +TandemRunDialog::reset() +{ + QSettings settings; + QString default_output_location = + settings.value("path/identificationfiles", "").toString(); + QString tandem_bin_path = + settings.value("path/tandem_bin", "/usr/bin/tandem").toString(); + + ui->output_directory_label->setText(default_output_location); + ui->tandem_bin_label->setText(tandem_bin_path); + + _p_fasta_file_list->stringList().clear(); + _p_mz_file_list->stringList().clear(); + /* + if (filenames.size() > 0) { + settings.setValue("path/identificationfiles", + QFileInfo(filenames[0]).absolutePath()); + }*/ } -void TandemRunDialog::selectPresetDirectory() { - try { - QSettings settings; - QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString(); +void +TandemRunDialog::selectPresetDirectory() +{ + try + { + QSettings settings; + QString default_preset_location = + settings.value("path/tandemrun_preset_directory", "").toString(); - QString directory = QFileDialog::getExistingDirectory(this,tr("Choose preset directory"),default_preset_location ); + QString directory = QFileDialog::getExistingDirectory( + this, tr("Choose preset directory"), default_preset_location); - if (!directory.isEmpty() && ! directory.isNull()) { - settings.setValue("path/tandemrun_preset_directory", directory); - fillPresetComboBox(); + if(!directory.isEmpty() && !directory.isNull()) + { + settings.setValue("path/tandemrun_preset_directory", directory); + fillPresetComboBox(); } - } - catch (pappso::PappsoException & error) { - //QMessageBox::warning(this, - // tr("Error choosing identification result files : %1").arg(error.qwhat()), error); + catch(pappso::PappsoException &error) + { + // QMessageBox::warning(this, + // tr("Error choosing identification result files : + // %1").arg(error.qwhat()), error); } } -void TandemRunDialog::editPresets() { - QSettings settings; - QString default_preset_location = settings.value("path/tandemrun_preset_directory", "").toString(); +void +TandemRunDialog::editPresets() +{ + QSettings settings; + QString default_preset_location = + settings.value("path/tandemrun_preset_directory", "").toString(); - if (_p_preset_dialog == nullptr) { - _p_preset_dialog = new EditTandemPresetDialog(this); + if(_p_preset_dialog == nullptr) + { + _p_preset_dialog = new EditTandemPresetDialog(this); } - _p_preset_dialog->setTandemParametersFile(TandemParametersFile(ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()).value<QString>())); - _p_preset_dialog->show(); + _p_preset_dialog->setTandemParametersFile(TandemParametersFile( + ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()) + .value<QString>())); + _p_preset_dialog->show(); #if QT_VERSION >= 0x050000 - // Qt5 code - connect(_p_preset_dialog, &EditTandemPresetDialog::accepted, this, &TandemRunDialog::acceptPresetEdit); - connect(_p_preset_dialog, &EditTandemPresetDialog::rejected, this, &TandemRunDialog::rejectPresetEdit); + // Qt5 code + connect(_p_preset_dialog, &EditTandemPresetDialog::accepted, this, + &TandemRunDialog::acceptPresetEdit); + connect(_p_preset_dialog, &EditTandemPresetDialog::rejected, this, + &TandemRunDialog::rejectPresetEdit); #else -// Qt4 code + // Qt4 code #endif } -void TandemRunDialog::rejectPresetEdit() { - fillPresetComboBox(); +void +TandemRunDialog::rejectPresetEdit() +{ + fillPresetComboBox(); } -void TandemRunDialog::acceptPresetEdit() { - TandemParametersFile param_file = _p_preset_dialog->getTandemParametersFile(); - QSettings settings; - settings.setValue("path/tandemrun_preset_directory", param_file.getAbsoluteDir().absolutePath()); - settings.setValue("tandem/preset_name", param_file.getMethodName()); - +void +TandemRunDialog::acceptPresetEdit() +{ + TandemParametersFile param_file = _p_preset_dialog->getTandemParametersFile(); + QSettings settings; + settings.setValue("path/tandemrun_preset_directory", + param_file.getAbsoluteDir().absolutePath()); + settings.setValue("tandem/preset_name", param_file.getMethodName()); - fillPresetComboBox(); + fillPresetComboBox(); } -void TandemRunDialog::selectOutputDirectory() { - try { - QSettings settings; - QString default_output_location = settings.value("path/identificationfiles", "").toString(); +void +TandemRunDialog::selectOutputDirectory() +{ + try + { + QSettings settings; + QString default_output_location = + settings.value("path/identificationfiles", "").toString(); - QString directory = QFileDialog::getExistingDirectory(this,tr("Choose output directory"),default_output_location ); + QString directory = QFileDialog::getExistingDirectory( + this, tr("Choose output directory"), default_output_location); - if (!directory.isEmpty()) { - settings.setValue("path/identificationfiles", directory); - ui->output_directory_label->setText(directory); + if(!directory.isEmpty()) + { + settings.setValue("path/identificationfiles", directory); + ui->output_directory_label->setText(directory); } - - } - catch (pappso::PappsoException & error) { - //QMessageBox::warning(this, - // tr("Error choosing identification result files : %1").arg(error.qwhat()), error); + catch(pappso::PappsoException &error) + { + // QMessageBox::warning(this, + // tr("Error choosing identification result files : + // %1").arg(error.qwhat()), error); } } -void TandemRunDialog::clearFastaFiles() { - _p_fasta_file_list->removeRows( 0, _p_fasta_file_list->rowCount() ); +void +TandemRunDialog::clearFastaFiles() +{ + _p_fasta_file_list->removeRows(0, _p_fasta_file_list->rowCount()); } -void TandemRunDialog::selectFastaFiles() { - try { - QSettings settings; - QString default_fasta_location = settings.value("path/tandemrun_fastafiles_directory", "").toString(); - - QStringList filenames = QFileDialog::getOpenFileNames(this,tr("FASTA files"),default_fasta_location, - tr("FASTA files (*.fasta);;all files (*)") ); - - if (filenames.size() > 0) { - settings.setValue("path/tandemrun_fastafiles_directory", QFileInfo(filenames[0]).absolutePath()); +void +TandemRunDialog::selectFastaFiles() +{ + try + { + QSettings settings; + QString default_fasta_location = + settings.value("path/tandemrun_fastafiles_directory", "").toString(); + + QStringList filenames = QFileDialog::getOpenFileNames( + this, tr("FASTA files"), default_fasta_location, + tr("FASTA files (*.fasta);;all files (*)")); + + if(filenames.size() > 0) + { + settings.setValue("path/tandemrun_fastafiles_directory", + QFileInfo(filenames[0]).absolutePath()); } - QStringList file_list = _p_fasta_file_list->stringList(); - file_list.append(filenames); - _p_fasta_file_list->setStringList(file_list); - + QStringList file_list = _p_fasta_file_list->stringList(); + file_list.append(filenames); + _p_fasta_file_list->setStringList(file_list); } - catch (pappso::PappsoException & error) { - //QMessageBox::warning(this, - // tr("Error choosing identification result files : %1").arg(error.qwhat()), error); + catch(pappso::PappsoException &error) + { + // QMessageBox::warning(this, + // tr("Error choosing identification result files : + // %1").arg(error.qwhat()), error); } } -void TandemRunDialog::selectXtandemExe() { - try { - QSettings settings; - QString tandem_bin_path = settings.value("path/tandem_bin", "/usr/bin/tandem").toString(); - - - QString filename = QFileDialog::getOpenFileName(this,tr("select X!Tandem executable"),QDir(tandem_bin_path).absolutePath(), - tr("all files (*);;exe files (*.exe)") ); - - if (!filename.isEmpty()) { - QFileInfo tandem_bin(filename); - filename = tandem_bin.absoluteFilePath(); - if (tandem_bin.isExecutable()) { - ui->tandem_bin_label->setText(filename); - settings.setValue("path/tandem_bin", filename); +void +TandemRunDialog::selectXtandemExe() +{ + try + { + QSettings settings; + QString tandem_bin_path = + settings.value("path/tandem_bin", "/usr/bin/tandem").toString(); + + + QString filename = + QFileDialog::getOpenFileName(this, tr("select X!Tandem executable"), + QDir(tandem_bin_path).absolutePath(), + tr("all files (*);;exe files (*.exe)")); + + if(!filename.isEmpty()) + { + QFileInfo tandem_bin(filename); + filename = tandem_bin.absoluteFilePath(); + if(tandem_bin.isExecutable()) + { + ui->tandem_bin_label->setText(filename); + settings.setValue("path/tandem_bin", filename); } - else { - QMessageBox::warning(this, - tr("Wrong X!Tandem exe file"), tr("%1 is not executable.").arg(filename)); + else + { + QMessageBox::warning(this, tr("Wrong X!Tandem exe file"), + tr("%1 is not executable.").arg(filename)); } } } - catch (pappso::PappsoException & error) { - //QMessageBox::warning(this, - // tr("Error choosing identification result files : %1").arg(error.qwhat()), error); + catch(pappso::PappsoException &error) + { + // QMessageBox::warning(this, + // tr("Error choosing identification result files : + // %1").arg(error.qwhat()), error); } } -void TandemRunDialog::selectMzFiles() { - try { - QSettings settings; - QString default_mz_location = settings.value("path/tandemrun_mzfiles_directory", "").toString(); - - QStringList filenames = QFileDialog::getOpenFileNames(this,tr("select peak list files"),default_mz_location, - tr("any mz files (*.mzXML *.mzxml *.mzML *.mzml *.mgf);;mzXML (*.mzXML *.mzxml);;mzML (*.mzML *.mzml);;MGF (*.mgf);;all files (*)") ); - - if (filenames.size() > 0) { - settings.setValue("path/tandemrun_mzfiles_directory", QFileInfo(filenames[0]).absolutePath()); +void +TandemRunDialog::selectMzFiles() +{ + try + { + QSettings settings; + QString default_mz_location = + settings.value("path/tandemrun_mzfiles_directory", "").toString(); + + QStringList filenames = QFileDialog::getOpenFileNames( + this, tr("select peak list files"), default_mz_location, + tr("any mz files (*.mzXML *.mzxml *.mzML *.mzml *.mgf);;mzXML (*.mzXML " + "*.mzxml);;mzML (*.mzML *.mzml);;MGF (*.mgf);;all files (*)")); + + if(filenames.size() > 0) + { + settings.setValue("path/tandemrun_mzfiles_directory", + QFileInfo(filenames[0]).absolutePath()); } - QStringList file_list = _p_mz_file_list->stringList(); - file_list.append(filenames); - _p_mz_file_list->setStringList(file_list); - + QStringList file_list = _p_mz_file_list->stringList(); + file_list.append(filenames); + _p_mz_file_list->setStringList(file_list); } - catch (pappso::PappsoException & error) { - //QMessageBox::warning(this, - // tr("Error choosing identification result files : %1").arg(error.qwhat()), error); + catch(pappso::PappsoException &error) + { + // QMessageBox::warning(this, + // tr("Error choosing identification result files : + // %1").arg(error.qwhat()), error); } } -void TandemRunDialog::clearMzFiles() { - _p_mz_file_list->removeRows( 0, _p_mz_file_list->rowCount() ); +void +TandemRunDialog::clearMzFiles() +{ + _p_mz_file_list->removeRows(0, _p_mz_file_list->rowCount()); } -TandemRunBatch TandemRunDialog::getTandemRunBatch() const { - TandemRunBatch tandem_run_batch; - tandem_run_batch._tandem_bin_path = ui->tandem_bin_label->text(); - tandem_run_batch._mz_file_list = _p_mz_file_list->stringList(); - tandem_run_batch._fasta_file_list = _p_fasta_file_list->stringList(); - //tandem_run_batch._preset_file = ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()).value<QFileInfo>().absoluteFilePath(); - tandem_run_batch._preset_file = ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()).value<QString>(); - tandem_run_batch._output_directory = ui->output_directory_label->text(); - tandem_run_batch._number_of_threads = ui->thread_spin_box->value(); - return tandem_run_batch; +TandemRunBatch +TandemRunDialog::getTandemRunBatch() const +{ + TandemRunBatch tandem_run_batch; + tandem_run_batch._tandem_bin_path = ui->tandem_bin_label->text(); + tandem_run_batch._mz_file_list = _p_mz_file_list->stringList(); + tandem_run_batch._fasta_file_list = _p_fasta_file_list->stringList(); + // tandem_run_batch._preset_file = + // ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()).value<QFileInfo>().absoluteFilePath(); + tandem_run_batch._preset_file = + ui->preset_combobox->itemData(ui->preset_combobox->currentIndex()) + .value<QString>(); + tandem_run_batch._output_directory = ui->output_directory_label->text(); + tandem_run_batch._number_of_threads = ui->thread_spin_box->value(); + return tandem_run_batch; } -void TandemRunDialog::done(int r) +void +TandemRunDialog::done(int r) { - if(QDialog::Accepted == r) // ok was pressed + if(QDialog::Accepted == r) // ok was pressed { - QSettings settings; - settings.setValue("tandem/use_HTCondor", "false"); - if ( ui->use_htcondor_groupbox->isChecked()) { - settings.setValue("tandem/use_HTCondor", "true"); + QSettings settings; + settings.setValue("tandem/use_HTCondor", "false"); + if(ui->use_htcondor_groupbox->isChecked()) + { + settings.setValue("tandem/use_HTCondor", "true"); } - //QString condor_tmp_dir = QString("%1/xtpcpp").arg(settings.value("condor/tmp_dir", "/tmp").toString()); - //_p_tmp_dir = new QTemporaryDir(condor_tmp_dir); - //_p_tmp_dir->setAutoRemove(settings.value("condor/tmp_dir_autoremove", true).toBool()); - //_condor_submit_command = settings.value("condor/submit", "/usr/bin/condor_submit").toString(); - //_condor_q_command = settings.value("condor/condor_q", "/usr/bin/condor_q").toString(); - //_condor_rm_command = settings.value("condor/condor_rm", "/usr/bin/condor_rm").toString(); - settings.setValue("tandem/condor_request_memory", ui->request_memory_edit->text()); - - QDialog::done(r); - return; + // QString condor_tmp_dir = + // QString("%1/xtpcpp").arg(settings.value("condor/tmp_dir", + // "/tmp").toString()); _p_tmp_dir = new QTemporaryDir(condor_tmp_dir); + //_p_tmp_dir->setAutoRemove(settings.value("condor/tmp_dir_autoremove", + //true).toBool()); _condor_submit_command = + //settings.value("condor/submit", "/usr/bin/condor_submit").toString(); + //_condor_q_command = settings.value("condor/condor_q", + //"/usr/bin/condor_q").toString(); _condor_rm_command = + //settings.value("condor/condor_rm", "/usr/bin/condor_rm").toString(); + settings.setValue("tandem/condor_request_memory", + ui->request_memory_edit->text()); + + QDialog::done(r); + return; } - else // cancel, close or exc was pressed + else // cancel, close or exc was pressed { - QDialog::done(r); - return; + QDialog::done(r); + return; } } - diff --git a/src/gui/tandem_run_dialog/tandemrundialog.h b/src/gui/tandem_run_dialog/tandemrundialog.h index c7dcdee799c717f04d5fc77b22630ae2c142da43..edd690fdcf43c724733aecb5d7b0784bfaf4607d 100644 --- a/src/gui/tandem_run_dialog/tandemrundialog.h +++ b/src/gui/tandem_run_dialog/tandemrundialog.h @@ -6,26 +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 + ******************************************************************************/ #ifndef TANDEMRUNDIALOG_H #define TANDEMRUNDIALOG_H @@ -35,49 +36,50 @@ #include "../../core/tandem_run/tandemrunbatch.h" #include "../edit_tandem_preset_dialog/edittandempresetdialog.h" -namespace Ui { -class TandemRunDialog; +namespace Ui +{ + class TandemRunDialog; } class TandemRunDialog : public QDialog { - Q_OBJECT + Q_OBJECT + + public: + explicit TandemRunDialog(QWidget *parent); + ~TandemRunDialog(); -public: - explicit TandemRunDialog(QWidget * parent); - ~TandemRunDialog(); + TandemRunBatch getTandemRunBatch() const; + void reset(); + public slots: + void exeGroupBoxClicked(bool clicked); + void selectFastaFiles(); + void clearFastaFiles(); + void selectXtandemExe(); + void selectMzFiles(); + void clearMzFiles(); + void selectOutputDirectory(); + void selectPresetDirectory(); + void editPresets(); + void setPresetName(QString preset_name); + void acceptPresetEdit(); + void rejectPresetEdit(); + signals: - TandemRunBatch getTandemRunBatch() const; - void reset(); -public slots: - void exeGroupBoxClicked(bool clicked); - void selectFastaFiles(); - void clearFastaFiles(); - void selectXtandemExe(); - void selectMzFiles(); - void clearMzFiles(); - void selectOutputDirectory(); - void selectPresetDirectory(); - void editPresets(); - void setPresetName(QString preset_name); - void acceptPresetEdit(); - void rejectPresetEdit(); -signals: - -protected: - void done(int r) override; + protected: + void done(int r) override; -private: - void fillPresetComboBox(); -private: - Ui::TandemRunDialog *ui; - EditTandemPresetDialog * _p_preset_dialog=nullptr; - QStringListModel * _p_fasta_file_list; - QStringListModel * _p_mz_file_list; - QString _previous_preset_file; + private: + void fillPresetComboBox(); + private: + Ui::TandemRunDialog *ui; + EditTandemPresetDialog *_p_preset_dialog = nullptr; + QStringListModel *_p_fasta_file_list; + QStringListModel *_p_mz_file_list; + QString _previous_preset_file; }; #endif // TANDEMRUNDIALOG_H diff --git a/src/gui/waiting_message_dialog/waitingmessagedialog.cpp b/src/gui/waiting_message_dialog/waitingmessagedialog.cpp index 9b37ca64c71fc91642ec0aa51fa554b20d3759ca..ff1f67e724891117c70b13c4a362cc686f7e6107 100644 --- a/src/gui/waiting_message_dialog/waitingmessagedialog.cpp +++ b/src/gui/waiting_message_dialog/waitingmessagedialog.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 "ui_waiting_message_dialog.h" #include "waitingmessagedialog.h" @@ -27,95 +28,113 @@ #include <QLabel> #include <QMutexLocker> -WaitingMessageDialog::WaitingMessageDialog(QWidget * parent): - QDialog(parent), - ui(new Ui::WaitingMessageDialog) +WaitingMessageDialog::WaitingMessageDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::WaitingMessageDialog) { - qDebug() << "WaitingMessageDialog::WaitingMessageDialog begin"; - ui->setupUi(this); - this->setModal(true); - this->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); - //this->setWindowFlags(Qt::FramelessWindowHint); - //this->setWindowFlags(Qt::WindowTitleHint); - - _p_movie = new QMovie(":/xtpcpp_icon/resources/xtandempipeline_animated_gif.gif"); - if (!_p_movie->isValid()) + qDebug() << "WaitingMessageDialog::WaitingMessageDialog begin"; + ui->setupUi(this); + this->setModal(true); + this->setWindowFlags(Qt::Window | Qt::WindowTitleHint | + Qt::CustomizeWindowHint); + // this->setWindowFlags(Qt::FramelessWindowHint); + // this->setWindowFlags(Qt::WindowTitleHint); + + _p_movie = + new QMovie(":/xtpcpp_icon/resources/xtandempipeline_animated_gif.gif"); + if(!_p_movie->isValid()) { - qDebug() << "WaitingMessageDialog::WaitingMessageDialog animation not found"; + qDebug() + << "WaitingMessageDialog::WaitingMessageDialog animation not found"; } - ui->movie_label->setMovie(_p_movie); - ui->progress_bar->setVisible(false); - - ui->progress_bar->setMaximum(100); - ui->progress_bar->setMinimum(0); - ui->console_plaintextedit->setHidden(true); - ui->stop_push_button->setVisible(false); - _asked_to_stop = false; - //movie->start(); - qDebug() << "WaitingMessageDialog::WaitingMessageDialog end"; + ui->movie_label->setMovie(_p_movie); + ui->progress_bar->setVisible(false); + + ui->progress_bar->setMaximum(100); + ui->progress_bar->setMinimum(0); + ui->console_plaintextedit->setHidden(true); + ui->stop_push_button->setVisible(false); + _asked_to_stop = false; + // movie->start(); + qDebug() << "WaitingMessageDialog::WaitingMessageDialog end"; } WaitingMessageDialog::~WaitingMessageDialog() { - qDebug() << "WaitingMessageDialog::~WaitingMessageDialog"; - delete ui; - qDebug() << "WaitingMessageDialog::~WaitingMessageDialog end"; + qDebug() << "WaitingMessageDialog::~WaitingMessageDialog"; + delete ui; + qDebug() << "WaitingMessageDialog::~WaitingMessageDialog end"; } -void WaitingMessageDialog::toggledStopButton(bool pushed) { - QMutexLocker mutex_locker(&_mutex); - _asked_to_stop = true; +void +WaitingMessageDialog::toggledStopButton(bool pushed) +{ + QMutexLocker mutex_locker(&_mutex); + _asked_to_stop = true; } -bool WaitingMessageDialog::stopWorkerThread() { - QMutexLocker mutex_locker(&_mutex); - if (!ui->stop_push_button->isVisible()) { - ui->stop_push_button->setChecked(false); - ui->stop_push_button->setVisible(true); - _asked_to_stop = false; - return false; +bool +WaitingMessageDialog::stopWorkerThread() +{ + QMutexLocker mutex_locker(&_mutex); + if(!ui->stop_push_button->isVisible()) + { + ui->stop_push_button->setChecked(false); + ui->stop_push_button->setVisible(true); + _asked_to_stop = false; + return false; } - return _asked_to_stop; - + return _asked_to_stop; } -void WaitingMessageDialog::message(const QString & message) { +void +WaitingMessageDialog::message(const QString &message) +{ - ui->progress_bar->setVisible(false); - ui->message_label->setText(message); + ui->progress_bar->setVisible(false); + ui->message_label->setText(message); } -void WaitingMessageDialog::message(const QString & message, int progress_value) { - qDebug() << "WaitingMessageDialog::message " << progress_value; - ui->progress_bar->setVisible(true); - ui->progress_bar->setValue(progress_value); - ui->message_label->setText(message); +void +WaitingMessageDialog::message(const QString &message, int progress_value) +{ + qDebug() << "WaitingMessageDialog::message " << progress_value; + ui->progress_bar->setVisible(true); + ui->progress_bar->setValue(progress_value); + ui->message_label->setText(message); } -void WaitingMessageDialog::appendText(char * text) { - ui->console_plaintextedit->setHidden(false); - //ui->console_plaintextedit->appendText(text); +void +WaitingMessageDialog::appendText(char *text) +{ + ui->console_plaintextedit->setHidden(false); + // ui->console_plaintextedit->appendText(text); - ui->console_plaintextedit->moveCursor (QTextCursor::End); - ui->console_plaintextedit->insertPlainText (text); + ui->console_plaintextedit->moveCursor(QTextCursor::End); + ui->console_plaintextedit->insertPlainText(text); } -void WaitingMessageDialog::setText(const QString text) { - ui->console_plaintextedit->setHidden(false); - //ui->console_plaintextedit->appendText(text); - ui->console_plaintextedit->setPlainText(text); +void +WaitingMessageDialog::setText(const QString text) +{ + ui->console_plaintextedit->setHidden(false); + // ui->console_plaintextedit->appendText(text); + ui->console_plaintextedit->setPlainText(text); } -void WaitingMessageDialog::hideEvent( QHideEvent* event ) { - QWidget::hideEvent( event ); - qDebug() << "WaitingMessageDialog::hideEvent"; - _p_movie->stop(); - ui->console_plaintextedit->setHidden(true); +void +WaitingMessageDialog::hideEvent(QHideEvent *event) +{ + QWidget::hideEvent(event); + qDebug() << "WaitingMessageDialog::hideEvent"; + _p_movie->stop(); + ui->console_plaintextedit->setHidden(true); } -void WaitingMessageDialog::showEvent( QShowEvent* event ) { - QWidget::showEvent( event ); - _p_movie->start(); - ui->stop_push_button->setChecked(false); - ui->stop_push_button->setVisible(false); - _asked_to_stop = false; +void +WaitingMessageDialog::showEvent(QShowEvent *event) +{ + QWidget::showEvent(event); + _p_movie->start(); + ui->stop_push_button->setChecked(false); + ui->stop_push_button->setVisible(false); + _asked_to_stop = false; } diff --git a/src/gui/waiting_message_dialog/waitingmessagedialog.h b/src/gui/waiting_message_dialog/waitingmessagedialog.h index ab9a471f6a3994b34413a4cf8ec499dd23582168..50a73da76796de26bf466165342ef5658bdad11c 100644 --- a/src/gui/waiting_message_dialog/waitingmessagedialog.h +++ b/src/gui/waiting_message_dialog/waitingmessagedialog.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 WAITINGMESSAGEDIALOG_H #define WAITINGMESSAGEDIALOG_H @@ -31,40 +32,40 @@ #include "../widgets/automatic_filter_widget/automaticfilterwidget.h" -namespace Ui { -class WaitingMessageDialog; +namespace Ui +{ + class WaitingMessageDialog; } class WaitingMessageDialog : public QDialog { - Q_OBJECT - -public: - explicit WaitingMessageDialog(QWidget * parent); - ~WaitingMessageDialog(); - - void message(const QString & message); - void message(const QString & message, int progress_value); - void appendText(char * text); - void setText(const QString text); - void showEvent( QShowEvent* event ); - void hideEvent( QHideEvent* event ); - - bool stopWorkerThread(); - -private slots: - void toggledStopButton(bool pushed); - -private: - Ui::WaitingMessageDialog *ui; - QMovie * _p_movie; - - bool _asked_to_stop = false; - - - QMutex _mutex; + Q_OBJECT + + public: + explicit WaitingMessageDialog(QWidget *parent); + ~WaitingMessageDialog(); + + void message(const QString &message); + void message(const QString &message, int progress_value); + void appendText(char *text); + void setText(const QString text); + void showEvent(QShowEvent *event); + void hideEvent(QHideEvent *event); + + bool stopWorkerThread(); + + private slots: + void toggledStopButton(bool pushed); + + private: + Ui::WaitingMessageDialog *ui; + QMovie *_p_movie; + + bool _asked_to_stop = false; + + QMutex _mutex; }; #endif // WAITINGMESSAGEDIALOG_H diff --git a/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.cpp b/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.cpp index 3b8b1be26fb8b4fc189f2c4209886b2102ba62a6..e0202de5db129818c8ed968f0c2a627c6a533034 100644 --- a/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.cpp +++ b/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.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 "automaticfilterwidget.h" @@ -29,77 +30,104 @@ #include <cmath> -AutomaticFilterWidget::AutomaticFilterWidget(QWidget * parent): - QWidget(parent), - ui(new Ui::AutomaticFilterWidget) +AutomaticFilterWidget::AutomaticFilterWidget(QWidget *parent) + : QWidget(parent), ui(new Ui::AutomaticFilterWidget) { - qDebug() << "AutomaticFilterWidget::AutomaticFilterWidget begin"; - ui->setupUi(this); + qDebug() << "AutomaticFilterWidget::AutomaticFilterWidget begin"; + ui->setupUi(this); - qDebug() << "AutomaticFilterWidget::AutomaticFilterWidget end"; + qDebug() << "AutomaticFilterWidget::AutomaticFilterWidget end"; } AutomaticFilterWidget::~AutomaticFilterWidget() { - qDebug() << "AutomaticFilterWidget::~AutomaticFilterWidget"; - delete ui; - qDebug() << "AutomaticFilterWidget::~AutomaticFilterWidget end"; + qDebug() << "AutomaticFilterWidget::~AutomaticFilterWidget"; + delete ui; + qDebug() << "AutomaticFilterWidget::~AutomaticFilterWidget end"; } -AutomaticFilterParameters AutomaticFilterWidget::getAutomaticFilterParameters() const { - return _parameters; +AutomaticFilterParameters +AutomaticFilterWidget::getAutomaticFilterParameters() const +{ + return _parameters; } -void AutomaticFilterWidget::setAutomaticFilterParameters(const AutomaticFilterParameters & params) { - qDebug() << "AutomaticFilterWidget::setAutomaticFilterParameters begin "; - _parameters = params; - _emit_changed = false; - ui->peptide_evalue_spinbox->setValue(_parameters.getFilterPeptideEvalue()); - ui->protein_evalue_spinbox->setValue(_parameters.getFilterProteinEvalue()); - ui->peptide_number_spinbox->setValue(_parameters.getFilterMinimumPeptidePerMatch()); - //ui->protein_evalue_log_spinbox->setValue(std::log(_parameters.getFilterProteinEvalue())); - ui->cross_sample_checkbox->setCheckState(Qt::Unchecked); - if (_parameters.getFilterCrossSamplePeptideNumber()) ui->cross_sample_checkbox->setCheckState(Qt::Checked); - _emit_changed = true; - qDebug() << "AutomaticFilterWidget::setAutomaticFilterParameters end "; +void +AutomaticFilterWidget::setAutomaticFilterParameters( + const AutomaticFilterParameters ¶ms) +{ + qDebug() << "AutomaticFilterWidget::setAutomaticFilterParameters begin "; + _parameters = params; + _emit_changed = false; + ui->peptide_evalue_spinbox->setValue(_parameters.getFilterPeptideEvalue()); + ui->protein_evalue_spinbox->setValue(_parameters.getFilterProteinEvalue()); + ui->peptide_number_spinbox->setValue( + _parameters.getFilterMinimumPeptidePerMatch()); + // ui->protein_evalue_log_spinbox->setValue(std::log(_parameters.getFilterProteinEvalue())); + ui->cross_sample_checkbox->setCheckState(Qt::Unchecked); + if(_parameters.getFilterCrossSamplePeptideNumber()) + ui->cross_sample_checkbox->setCheckState(Qt::Checked); + _emit_changed = true; + qDebug() << "AutomaticFilterWidget::setAutomaticFilterParameters end "; } -void AutomaticFilterWidget::doCrossSample(bool is_cross_sample) { - _parameters.setFilterCrossSamplePeptideNumber(is_cross_sample); +void +AutomaticFilterWidget::doCrossSample(bool is_cross_sample) +{ + _parameters.setFilterCrossSamplePeptideNumber(is_cross_sample); - if (_emit_changed) emit automaticFilterParametersChanged(_parameters); + if(_emit_changed) + emit automaticFilterParametersChanged(_parameters); } -void AutomaticFilterWidget::doPeptideEvalue(double evalue) { - _parameters.setFilterPeptideEvalue(evalue); +void +AutomaticFilterWidget::doPeptideEvalue(double evalue) +{ + _parameters.setFilterPeptideEvalue(evalue); - if (_emit_changed) emit automaticFilterParametersChanged(_parameters); + if(_emit_changed) + emit automaticFilterParametersChanged(_parameters); } -void AutomaticFilterWidget::doProteinEvalue(double evalue) { - if (_signal) { - _parameters.setFilterProteinEvalue(evalue); - _signal = false; - ui->protein_evalue_log_spinbox->setValue(std::log10(_parameters.getFilterProteinEvalue())); +void +AutomaticFilterWidget::doProteinEvalue(double evalue) +{ + if(_signal) + { + _parameters.setFilterProteinEvalue(evalue); + _signal = false; + ui->protein_evalue_log_spinbox->setValue( + std::log10(_parameters.getFilterProteinEvalue())); - if (_emit_changed) emit automaticFilterParametersChanged(_parameters); + if(_emit_changed) + emit automaticFilterParametersChanged(_parameters); } - else { - _signal = true; + else + { + _signal = true; } } -void AutomaticFilterWidget::doProteinLogEvalue(double evalue) { - if (_signal) { - _parameters.setFilterProteinEvalue(std::pow(10, evalue)); - _signal = false; - ui->protein_evalue_spinbox->setValue(_parameters.getFilterProteinEvalue()); +void +AutomaticFilterWidget::doProteinLogEvalue(double evalue) +{ + if(_signal) + { + _parameters.setFilterProteinEvalue(std::pow(10, evalue)); + _signal = false; + ui->protein_evalue_spinbox->setValue( + _parameters.getFilterProteinEvalue()); - if (_emit_changed) emit automaticFilterParametersChanged(_parameters); + if(_emit_changed) + emit automaticFilterParametersChanged(_parameters); } - else { - _signal = true; + else + { + _signal = true; } } -void AutomaticFilterWidget::doPeptideNumber(int number) { - _parameters.setFilterMinimumPeptidePerMatch((unsigned int) number); - if (_emit_changed) emit automaticFilterParametersChanged(_parameters); +void +AutomaticFilterWidget::doPeptideNumber(int number) +{ + _parameters.setFilterMinimumPeptidePerMatch((unsigned int)number); + if(_emit_changed) + emit automaticFilterParametersChanged(_parameters); } diff --git a/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.h b/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.h index 4b6e118d462a3551e09544ef029f4293297df0ca..a01b80525f1ec1fe1c66eb6068af61c41b67c56e 100644 --- a/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.h +++ b/src/gui/widgets/automatic_filter_widget/automaticfilterwidget.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 AUTOMATICFILTERWIDGET_H #define AUTOMATICFILTERWIDGET_H @@ -28,40 +29,40 @@ #include <QWidget> -namespace Ui { -class AutomaticFilterWidget; +namespace Ui +{ + class AutomaticFilterWidget; } class AutomaticFilterWidget : public QWidget { - Q_OBJECT + Q_OBJECT -public: - explicit AutomaticFilterWidget(QWidget * parent); - ~AutomaticFilterWidget(); + public: + explicit AutomaticFilterWidget(QWidget *parent); + ~AutomaticFilterWidget(); - void setAutomaticFilterParameters(const AutomaticFilterParameters & params); - AutomaticFilterParameters getAutomaticFilterParameters() const; + void setAutomaticFilterParameters(const AutomaticFilterParameters ¶ms); + AutomaticFilterParameters getAutomaticFilterParameters() const; -public slots: + public slots: -signals: - void automaticFilterParametersChanged(AutomaticFilterParameters parameters); - -private slots: - void doPeptideEvalue(double evalue); - void doProteinEvalue(double evalue); - void doProteinLogEvalue(double evalue); - void doPeptideNumber(int number); - void doCrossSample(bool is_cross_sample); + signals: + void automaticFilterParametersChanged(AutomaticFilterParameters parameters); -private: - Ui::AutomaticFilterWidget *ui; - bool _signal = true; - bool _emit_changed=true; + private slots: + void doPeptideEvalue(double evalue); + void doProteinEvalue(double evalue); + void doProteinLogEvalue(double evalue); + void doPeptideNumber(int number); + void doCrossSample(bool is_cross_sample); - AutomaticFilterParameters _parameters; + private: + Ui::AutomaticFilterWidget *ui; + bool _signal = true; + bool _emit_changed = true; + AutomaticFilterParameters _parameters; }; #endif // AUTOMATICFILTERWIDGET_H diff --git a/src/gui/widgets/contaminant_widget/contaminantwidget.cpp b/src/gui/widgets/contaminant_widget/contaminantwidget.cpp index 97b05057f938402594c443dc0c3158605a6713f6..2ab9d7847a202aa5bf775a582369784139795f95 100644 --- a/src/gui/widgets/contaminant_widget/contaminantwidget.cpp +++ b/src/gui/widgets/contaminant_widget/contaminantwidget.cpp @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "contaminantwidget.h" @@ -36,160 +37,206 @@ #include <QSettings> #include <QFileDialog> -ContaminantWidget::ContaminantWidget(QWidget * parent): - QWidget(parent), - ui(new Ui::ContaminantWidget) +ContaminantWidget::ContaminantWidget(QWidget *parent) + : QWidget(parent), ui(new Ui::ContaminantWidget) { - qDebug() << "ContaminantWidget::ContaminantWidget begin"; - ui->setupUi(this); - _emit_changed = false; - _p_fasta_str_li = new QStandardItemModel(); - ui->contaminant_database_listview->setModel(_p_fasta_str_li); - QItemSelectionModel * selection_model = ui->contaminant_database_listview->selectionModel(); - ui->contaminant_database_listview->setSelectionMode(QAbstractItemView::MultiSelection); - - doSelectContaminantSource(); - _emit_changed = true; - qDebug() << "ContaminantWidget::ContaminantWidget end"; + qDebug() << "ContaminantWidget::ContaminantWidget begin"; + ui->setupUi(this); + _emit_changed = false; + _p_fasta_str_li = new QStandardItemModel(); + ui->contaminant_database_listview->setModel(_p_fasta_str_li); + QItemSelectionModel *selection_model = + ui->contaminant_database_listview->selectionModel(); + ui->contaminant_database_listview->setSelectionMode( + QAbstractItemView::MultiSelection); + + doSelectContaminantSource(); + _emit_changed = true; + qDebug() << "ContaminantWidget::ContaminantWidget end"; } ContaminantWidget::~ContaminantWidget() { - qDebug() << "ContaminantWidget::~ContaminantWidget"; - delete ui; - delete _p_fasta_str_li; - qDebug() << "ContaminantWidget::~ContaminantWidget end"; + qDebug() << "ContaminantWidget::~ContaminantWidget"; + delete ui; + delete _p_fasta_str_li; + qDebug() << "ContaminantWidget::~ContaminantWidget end"; } -void ContaminantWidget::setRegexpContaminantPattern(const QString & pattern) { - _emit_changed = false; - ui->contaminant_protein_regexp_line_edit->setText(pattern); - _emit_changed = true; +void +ContaminantWidget::setRegexpContaminantPattern(const QString &pattern) +{ + _emit_changed = false; + ui->contaminant_protein_regexp_line_edit->setText(pattern); + _emit_changed = true; } -void ContaminantWidget::setFastaFileList(std::vector<FastaFileSp> fasta_file_list) { - - _p_fasta_str_li->removeRows(0, _p_fasta_str_li->rowCount()); - for (FastaFileSp fasta_file : fasta_file_list ) { +void +ContaminantWidget::setFastaFileList(std::vector<FastaFileSp> fasta_file_list) +{ - QStandardItem *item; - item = new QStandardItem(QString("%1").arg(fasta_file.get()->getFilename())); - item->setEditable(false); - item->setData(QVariant::fromValue(fasta_file), Qt::UserRole); - _p_fasta_str_li->appendRow(item); - //item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); + _p_fasta_str_li->removeRows(0, _p_fasta_str_li->rowCount()); + for(FastaFileSp fasta_file : fasta_file_list) + { + + QStandardItem *item; + item = + new QStandardItem(QString("%1").arg(fasta_file.get()->getFilename())); + item->setEditable(false); + item->setData(QVariant::fromValue(fasta_file), Qt::UserRole); + _p_fasta_str_li->appendRow(item); + // item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); } - } -void ContaminantWidget::getProjectContaminants(const Project * p_project) { - _emit_changed = false; - ui->contaminant_regexp_radiobutton->setChecked(true); - ui->contaminant_protein_regexp_line_edit->setVisible(true); - ui->contaminant_database_listview->setVisible(false); - if (p_project->getProteinStore().getContaminantFastaFileList().size() > 0) { - ui->contaminant_file_radiobutton->setChecked(true); - ui->contaminant_protein_regexp_line_edit->setVisible(false); - ui->contaminant_database_listview->setVisible(true); +void +ContaminantWidget::getProjectContaminants(const Project *p_project) +{ + _emit_changed = false; + ui->contaminant_regexp_radiobutton->setChecked(true); + ui->contaminant_protein_regexp_line_edit->setVisible(true); + ui->contaminant_database_listview->setVisible(false); + if(p_project->getProteinStore().getContaminantFastaFileList().size() > 0) + { + ui->contaminant_file_radiobutton->setChecked(true); + ui->contaminant_protein_regexp_line_edit->setVisible(false); + ui->contaminant_database_listview->setVisible(true); } - ui->contaminant_protein_regexp_line_edit->setText(p_project->getProteinStore().getRegexpContaminant().pattern()); + ui->contaminant_protein_regexp_line_edit->setText( + p_project->getProteinStore().getRegexpContaminant().pattern()); - this->setFastaFileList( p_project->getFastaFileStore().getFastaFileList()); + this->setFastaFileList(p_project->getFastaFileStore().getFastaFileList()); - ui->control_list_widget->setVisible(false); - _no_project = false; - _emit_changed = true; + ui->control_list_widget->setVisible(false); + _no_project = false; + _emit_changed = true; } -void ContaminantWidget::setProjectContaminants(Project * p_project) { - qDebug() << "ContaminantWidget::setProjectContaminants begin"; - _emit_changed = false; - if (ui->contaminant_file_radiobutton->isChecked()) { - QModelIndexList index_list = ui->contaminant_database_listview->selectionModel()->selectedIndexes(); - p_project->getProteinStore().clearContaminants(); - if (index_list.size() > 0) { - for (QModelIndex index :index_list) { - if (index.data(Qt::UserRole).canConvert<FastaFileSp>()) { - FastaFileSp p_fasta_file = index.data(Qt::UserRole).value<FastaFileSp>(); - p_fasta_file.get()->setContaminants(p_project->getProteinStore()); +void +ContaminantWidget::setProjectContaminants(Project *p_project) +{ + qDebug() << "ContaminantWidget::setProjectContaminants begin"; + _emit_changed = false; + if(ui->contaminant_file_radiobutton->isChecked()) + { + QModelIndexList index_list = + ui->contaminant_database_listview->selectionModel()->selectedIndexes(); + p_project->getProteinStore().clearContaminants(); + if(index_list.size() > 0) + { + for(QModelIndex index : index_list) + { + if(index.data(Qt::UserRole).canConvert<FastaFileSp>()) + { + FastaFileSp p_fasta_file = + index.data(Qt::UserRole).value<FastaFileSp>(); + p_fasta_file.get()->setContaminants( + p_project->getProteinStore()); } - else { - throw pappso::PappsoException(QObject::tr("can not convert to FastaFile index.data().canConvert<FastaFile *>()")); + else + { + throw pappso::PappsoException( + QObject::tr("can not convert to FastaFile " + "index.data().canConvert<FastaFile *>()")); } } } - if (_no_project) { - ui->control_list_widget->setVisible(true); + if(_no_project) + { + ui->control_list_widget->setVisible(true); } } - else { - p_project->getProteinStore().setRegexpContaminantPattern(ui->contaminant_protein_regexp_line_edit->text()); - ui->control_list_widget->setVisible(false); + else + { + p_project->getProteinStore().setRegexpContaminantPattern( + ui->contaminant_protein_regexp_line_edit->text()); + ui->control_list_widget->setVisible(false); } - _emit_changed = true; - qDebug() << "ContaminantWidget::setProjectContaminants end"; + _emit_changed = true; + qDebug() << "ContaminantWidget::setProjectContaminants end"; } -void ContaminantWidget::doChanged() { - qDebug() << "ContaminantWidget::doChanged begin"; - if (_emit_changed) emit changed(); - qDebug() << "ContaminantWidget::doChanged end"; +void +ContaminantWidget::doChanged() +{ + qDebug() << "ContaminantWidget::doChanged begin"; + if(_emit_changed) + emit changed(); + qDebug() << "ContaminantWidget::doChanged end"; } -void ContaminantWidget::doSelectContaminantSource() { - qDebug() << "ContaminantWidget::doSelectContaminantSource begin"; - ui->contaminant_database_listview->setVisible(false); - ui->contaminant_protein_regexp_line_edit->setVisible(false); - if (ui->contaminant_file_radiobutton->isChecked()) { - ui->contaminant_database_listview->setVisible(true); +void +ContaminantWidget::doSelectContaminantSource() +{ + qDebug() << "ContaminantWidget::doSelectContaminantSource begin"; + ui->contaminant_database_listview->setVisible(false); + ui->contaminant_protein_regexp_line_edit->setVisible(false); + if(ui->contaminant_file_radiobutton->isChecked()) + { + ui->contaminant_database_listview->setVisible(true); } - else { - ui->contaminant_protein_regexp_line_edit->setVisible(true); + else + { + ui->contaminant_protein_regexp_line_edit->setVisible(true); } - if (_emit_changed) emit changed(); - qDebug() << "ContaminantWidget::doSelectContaminantSource end"; + if(_emit_changed) + emit changed(); + qDebug() << "ContaminantWidget::doSelectContaminantSource end"; } -void ContaminantWidget::doSelectFastaFile() { - try { - QSettings settings; - QString default_fasta_location = settings.value("path/fastafiles_directory", "").toString(); - - QStringList filenames = QFileDialog::getOpenFileNames(this,tr("FASTA files"),default_fasta_location, - tr("FASTA files (*.fasta);;all files (*)") ); - - if (filenames.size() > 0) { - settings.setValue("path/fastafiles_directory", QFileInfo(filenames[0]).absolutePath()); +void +ContaminantWidget::doSelectFastaFile() +{ + try + { + QSettings settings; + QString default_fasta_location = + settings.value("path/fastafiles_directory", "").toString(); + + QStringList filenames = QFileDialog::getOpenFileNames( + this, tr("FASTA files"), default_fasta_location, + tr("FASTA files (*.fasta);;all files (*)")); + + if(filenames.size() > 0) + { + settings.setValue("path/fastafiles_directory", + QFileInfo(filenames[0]).absolutePath()); } - std::vector<FastaFileSp> fasta_file_list; - for (QString filename :filenames) { - fasta_file_list.push_back(std::make_shared<FastaFile>(filename)); + std::vector<FastaFileSp> fasta_file_list; + for(QString filename : filenames) + { + fasta_file_list.push_back(std::make_shared<FastaFile>(filename)); } - for (FastaFileSp fasta_file : fasta_file_list ) { + for(FastaFileSp fasta_file : fasta_file_list) + { - QStandardItem *item; - item = new QStandardItem(QString("%1").arg(fasta_file.get()->getFilename())); - item->setEditable(false); - item->setData(QVariant::fromValue(fasta_file), Qt::UserRole); - _p_fasta_str_li->appendRow(item); - //item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); + QStandardItem *item; + item = new QStandardItem( + QString("%1").arg(fasta_file.get()->getFilename())); + item->setEditable(false); + item->setData(QVariant::fromValue(fasta_file), Qt::UserRole); + _p_fasta_str_li->appendRow(item); + // item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); } - } - catch (pappso::PappsoException & error) { - //QMessageBox::warning(this, - // tr("Error choosing identification result files : %1").arg(error.qwhat()), error); + catch(pappso::PappsoException &error) + { + // QMessageBox::warning(this, + // tr("Error choosing identification result files : + // %1").arg(error.qwhat()), error); } } -void ContaminantWidget::doClearList() { - _p_fasta_str_li->removeRows( 0, _p_fasta_str_li->rowCount() ); +void +ContaminantWidget::doClearList() +{ + _p_fasta_str_li->removeRows(0, _p_fasta_str_li->rowCount()); } diff --git a/src/gui/widgets/contaminant_widget/contaminantwidget.h b/src/gui/widgets/contaminant_widget/contaminantwidget.h index ef6c84a84497e451d44fab32c3175050f497b757..ffea09bd5da7ae97c8c5da086fb3b29eea72cae3 100644 --- a/src/gui/widgets/contaminant_widget/contaminantwidget.h +++ b/src/gui/widgets/contaminant_widget/contaminantwidget.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 CONTAMINANTWIDGET_H @@ -37,47 +38,47 @@ #include "../../../core/project.h" -namespace Ui { -class ContaminantWidget; +namespace Ui +{ + class ContaminantWidget; } class ContaminantWidget : public QWidget { - Q_OBJECT - -public: - explicit ContaminantWidget(QWidget * parent); - ~ContaminantWidget(); - - - void setRegexpContaminantPattern(const QString & pattern); - - void setFastaFileList(std::vector<FastaFileSp> fasta_file_list); - - void setProjectContaminants(Project * p_project); - void getProjectContaminants(const Project * p_project); - -public slots: - -signals: - void changed(); - -private slots: - void doSelectContaminantSource(); - void doSelectFastaFile(); - void doClearList(); - void doChanged(); - - -private: - Ui::ContaminantWidget *ui; - - bool _no_project = true; - - QStandardItemModel * _p_fasta_str_li; - - bool _emit_changed=true; + Q_OBJECT + + public: + explicit ContaminantWidget(QWidget *parent); + ~ContaminantWidget(); + + + void setRegexpContaminantPattern(const QString &pattern); + + void setFastaFileList(std::vector<FastaFileSp> fasta_file_list); + + void setProjectContaminants(Project *p_project); + void getProjectContaminants(const Project *p_project); + + public slots: + + signals: + void changed(); + + private slots: + void doSelectContaminantSource(); + void doSelectFastaFile(); + void doClearList(); + void doChanged(); + + + private: + Ui::ContaminantWidget *ui; + + bool _no_project = true; + + QStandardItemModel *_p_fasta_str_li; + bool _emit_changed = true; }; #endif // CONTAMINANTWIDGET_H diff --git a/src/gui/widgets/massitemdelegate.cpp b/src/gui/widgets/massitemdelegate.cpp index fd11881ea6156bf59d99eb0b0153c9f3822bdd0b..c31acf57dff3f350d33c6b3d856744751b90cab7 100644 --- a/src/gui/widgets/massitemdelegate.cpp +++ b/src/gui/widgets/massitemdelegate.cpp @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "massitemdelegate.h" diff --git a/src/gui/widgets/massitemdelegate.h b/src/gui/widgets/massitemdelegate.h index 80a20656baac5511e7246b74516b9649ad2e3655..1ee233834be08215c7381f9a172aaa5c279a13af 100644 --- a/src/gui/widgets/massitemdelegate.h +++ b/src/gui/widgets/massitemdelegate.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 MASSITEMDELEGATE_H #define MASSITEMDELEGATE_H @@ -34,65 +35,75 @@ class MinuteItemDelegate : public QStyledItemDelegate { - Q_OBJECT + Q_OBJECT -public: + public: + MinuteItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) + { + } - MinuteItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {} - - QString displayText(const QVariant & value, const QLocale & locale) const override - { - QString str = QString("%1'").arg(QString::number(value.toDouble(), 'f', 2)); - return str; - } + QString + displayText(const QVariant &value, const QLocale &locale) const override + { + QString str = QString("%1'").arg(QString::number(value.toDouble(), 'f', 2)); + return str; + } }; class SecondItemDelegate : public QStyledItemDelegate { - Q_OBJECT - -public: + Q_OBJECT - SecondItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {} + public: + SecondItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) + { + } - QString displayText(const QVariant & value, const QLocale & locale) const override - { - QString str = QString("%1\"").arg(QString::number(value.toDouble(), 'f', 2)); - return str; - } + QString + displayText(const QVariant &value, const QLocale &locale) const override + { + QString str = + QString("%1\"").arg(QString::number(value.toDouble(), 'f', 2)); + return str; + } }; class PercentItemDelegate : public QStyledItemDelegate { - Q_OBJECT + Q_OBJECT -public: + public: + PercentItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) + { + } - PercentItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {} - - QString displayText(const QVariant & value, const QLocale & locale) const override - { - QString str = QString("%1 %").arg(QString::number(value.toDouble()*100.0, 'f', 2)); - return str; - } + QString + displayText(const QVariant &value, const QLocale &locale) const override + { + QString str = + QString("%1 %").arg(QString::number(value.toDouble() * 100.0, 'f', 2)); + return str; + } }; class MassItemDelegate : public QStyledItemDelegate { - Q_OBJECT - -public: + Q_OBJECT - MassItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {} + public: + MassItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) + { + } - QString displayText(const QVariant & value, const QLocale & locale) const override - { - QString str = QString::number(value.toDouble(), 'f', 5); - return str; - } + QString + displayText(const QVariant &value, const QLocale &locale) const override + { + QString str = QString::number(value.toDouble(), 'f', 5); + return str; + } }; #endif // MASSITEMDELEGATE_H diff --git a/src/gui/workerthread.cpp b/src/gui/workerthread.cpp index c09396e119b988b2a043002f8e9ce7c851263c55..904e2c5e65a80714f39b69448362611df61a1321 100644 --- a/src/gui/workerthread.cpp +++ b/src/gui/workerthread.cpp @@ -6,26 +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 "workerthread.h" #include <odsstream/odsdocwriter.h> @@ -46,392 +47,555 @@ #include "../core/tandem_run/tandemcondorprocess.h" #include <QSettings> -WorkerThread::WorkerThread(MainWindow * p_main_window) +WorkerThread::WorkerThread(MainWindow *p_main_window) { - _p_main_window = p_main_window; - qDebug() << "WorkerThread::WorkerThread begin MainWindow"; + _p_main_window = p_main_window; + qDebug() << "WorkerThread::WorkerThread begin MainWindow"; - _p_work_monitor = new WorkMonitor(); + _p_work_monitor = new WorkMonitor(); #if QT_VERSION >= 0x050000 - // Qt5 code - //worker message - connect(_p_work_monitor, &WorkMonitor::workerMessage, p_main_window,&MainWindow::doDisplayLoadingMessage); - connect(_p_work_monitor, &WorkMonitor::workerMessagePercent, p_main_window,&MainWindow::doDisplayLoadingMessagePercent); - connect(_p_work_monitor, &WorkMonitor::workerAppendText, p_main_window,&MainWindow::doWorkerAppendText); - connect(_p_work_monitor, &WorkMonitor::workerSetText, p_main_window,&MainWindow::doWorkerSetText); - connect(_p_work_monitor, &WorkMonitor::workerJobFinished, p_main_window,&MainWindow::doDisplayJobFinished); - - connect(p_main_window, &MainWindow::operateXpipFile, this,&WorkerThread::doXpipFileLoad); - connect(p_main_window, &MainWindow::operateWritingXpipFile, this,&WorkerThread::doWritingXpipFile); - connect(this, &WorkerThread::projectReady, p_main_window,&MainWindow::doProjectReady); - connect(this, &WorkerThread::loadingResultsFinished, p_main_window,&MainWindow::doLoadingResultsReady); - - connect(p_main_window, &MainWindow::operateLoadingResults, this,&WorkerThread::doLoadingResults); - - connect(p_main_window, &MainWindow::operateRunningXtandem, this,&WorkerThread::doRunningXtandem); - connect(this, &WorkerThread::loadingMessage, p_main_window,&MainWindow::doDisplayLoadingMessage); - connect(this, &WorkerThread::projectNotReady, p_main_window,&MainWindow::doProjectNotReady); - - //grouping - connect(p_main_window, &MainWindow::operateGrouping, this,&WorkerThread::doGrouping); - connect(this, &WorkerThread::groupingFinished, p_main_window,&MainWindow::doGroupingFinished); - //masschroq write - connect(p_main_window, &MainWindow::operateWritingMassChroqFile, this,&WorkerThread::doWritingMassChroqFile); - connect(p_main_window, &MainWindow::operateWritingMassChroqPrmFile, this,&WorkerThread::doWritingMassChroqPrmFile); - connect(p_main_window, &MainWindow::operateWritingMcqrSpectralCountFile, this,&WorkerThread::doWritingMcqrSpectralCountFile); - //protic write - connect(p_main_window, &MainWindow::operateWritingProticFile, this,&WorkerThread::doWritingProticFile); - //writing ODS file : - connect(p_main_window, &MainWindow::operateWritingOdsFile, this,&WorkerThread::doWritingOdsFile); - connect(this, &WorkerThread::operationFailed, p_main_window,&MainWindow::doOperationFailed); - connect(this, &WorkerThread::operationFinished, p_main_window,&MainWindow::doOperationFinished); + // Qt5 code + // worker message + connect(_p_work_monitor, &WorkMonitor::workerMessage, p_main_window, + &MainWindow::doDisplayLoadingMessage); + connect(_p_work_monitor, &WorkMonitor::workerMessagePercent, p_main_window, + &MainWindow::doDisplayLoadingMessagePercent); + connect(_p_work_monitor, &WorkMonitor::workerAppendText, p_main_window, + &MainWindow::doWorkerAppendText); + connect(_p_work_monitor, &WorkMonitor::workerSetText, p_main_window, + &MainWindow::doWorkerSetText); + connect(_p_work_monitor, &WorkMonitor::workerJobFinished, p_main_window, + &MainWindow::doDisplayJobFinished); + + connect(p_main_window, &MainWindow::operateXpipFile, this, + &WorkerThread::doXpipFileLoad); + connect(p_main_window, &MainWindow::operateWritingXpipFile, this, + &WorkerThread::doWritingXpipFile); + connect(this, &WorkerThread::projectReady, p_main_window, + &MainWindow::doProjectReady); + connect(this, &WorkerThread::loadingResultsFinished, p_main_window, + &MainWindow::doLoadingResultsReady); + + connect(p_main_window, &MainWindow::operateLoadingResults, this, + &WorkerThread::doLoadingResults); + + connect(p_main_window, &MainWindow::operateRunningXtandem, this, + &WorkerThread::doRunningXtandem); + connect(this, &WorkerThread::loadingMessage, p_main_window, + &MainWindow::doDisplayLoadingMessage); + connect(this, &WorkerThread::projectNotReady, p_main_window, + &MainWindow::doProjectNotReady); + + // grouping + connect(p_main_window, &MainWindow::operateGrouping, this, + &WorkerThread::doGrouping); + connect(this, &WorkerThread::groupingFinished, p_main_window, + &MainWindow::doGroupingFinished); + // masschroq write + connect(p_main_window, &MainWindow::operateWritingMassChroqFile, this, + &WorkerThread::doWritingMassChroqFile); + connect(p_main_window, &MainWindow::operateWritingMassChroqPrmFile, this, + &WorkerThread::doWritingMassChroqPrmFile); + connect(p_main_window, &MainWindow::operateWritingMcqrSpectralCountFile, this, + &WorkerThread::doWritingMcqrSpectralCountFile); + // protic write + connect(p_main_window, &MainWindow::operateWritingProticFile, this, + &WorkerThread::doWritingProticFile); + // writing ODS file : + connect(p_main_window, &MainWindow::operateWritingOdsFile, this, + &WorkerThread::doWritingOdsFile); + connect(this, &WorkerThread::operationFailed, p_main_window, + &MainWindow::doOperationFailed); + connect(this, &WorkerThread::operationFinished, p_main_window, + &MainWindow::doOperationFinished); #else -// Qt4 code - //worker message - connect(_p_work_monitor, SIGNAL(workerMessage(QString)), p_main_window,SLOT(doDisplayLoadingMessage(QString))); - connect(_p_work_monitor, SIGNAL(workerMessage(QString, int)), p_main_window,SLOT(doDisplayLoadingMessage(QString, int))); - connect(_p_work_monitor, SIGNAL(workerAppendText(char *)), p_main_window,SLOT(doWorkerAppendText(char *))); - - connect(p_main_window, SIGNAL(operateXpipFile(QString)), this,SLOT(doXpipFileLoad(QString))); - connect(this, SIGNAL(projectReady(ProjectSp)), p_main_window,SLOT(doProjectReady(ProjectSp))); - connect(p_main_window, SIGNAL(operateLoadingResults(bool,AutomaticFilterParameters,QStringList)), this,SLOT(doLoadingResults(bool,AutomaticFilterParameters,QStringList))); - - connect(p_main_window, SIGNAL(operateRunningXtandem(TandemRunBatch)), this,SLOT(doRunningXtandem(TandemRunBatch))); - connect(this, SIGNAL(loadingMessage(QString)), p_main_window,SLOT(doDisplayLoadingMessage(QString))); - connect(this, SIGNAL(projectNotReady(QString)), p_main_window,SLOT(doProjectNotReady(QString))); - - //grouping - connect(p_main_window, SIGNAL(operateGrouping(ProjectSp)), this,SLOT(doGrouping(ProjectSp))); - connect(this, SIGNAL(groupingFinished()), p_main_window,SLOT(doGroupingFinished())); - //masschroq write - connect(p_main_window, SIGNAL(operateWritingMassChroqFile(QString, ProjectSp)), this,SLOT(doWritingMassChroqFile(QString, ProjectSp))); - //protic write - connect(p_main_window, SIGNAL(operateWritingProticFile(QString,ProjectSp)), this,SLOT(doWritingProticFile(QString,ProjectSp))); - //writing ODS file : - connect(p_main_window, SIGNAL(operateWritingOdsFile(QString, ProjectSp)), this,SLOT(doWritingOdsFile(QString, ProjectSp))); - connect(this, SIGNAL(operationFailed(QString)), p_main_window,SLOT(doOperationFailed(QString))); - connect(this, SIGNAL(operationFinished()), p_main_window,SLOT(doOperationFinished())); + // Qt4 code + // worker message + connect(_p_work_monitor, SIGNAL(workerMessage(QString)), p_main_window, + SLOT(doDisplayLoadingMessage(QString))); + connect(_p_work_monitor, SIGNAL(workerMessage(QString, int)), p_main_window, + SLOT(doDisplayLoadingMessage(QString, int))); + connect(_p_work_monitor, SIGNAL(workerAppendText(char *)), p_main_window, + SLOT(doWorkerAppendText(char *))); + + connect(p_main_window, SIGNAL(operateXpipFile(QString)), this, + SLOT(doXpipFileLoad(QString))); + connect(this, SIGNAL(projectReady(ProjectSp)), p_main_window, + SLOT(doProjectReady(ProjectSp))); + connect( + p_main_window, + SIGNAL(operateLoadingResults(bool, AutomaticFilterParameters, QStringList)), + this, SLOT(doLoadingResults(bool, AutomaticFilterParameters, QStringList))); + + connect(p_main_window, SIGNAL(operateRunningXtandem(TandemRunBatch)), this, + SLOT(doRunningXtandem(TandemRunBatch))); + connect(this, SIGNAL(loadingMessage(QString)), p_main_window, + SLOT(doDisplayLoadingMessage(QString))); + connect(this, SIGNAL(projectNotReady(QString)), p_main_window, + SLOT(doProjectNotReady(QString))); + + // grouping + connect(p_main_window, SIGNAL(operateGrouping(ProjectSp)), this, + SLOT(doGrouping(ProjectSp))); + connect(this, SIGNAL(groupingFinished()), p_main_window, + SLOT(doGroupingFinished())); + // masschroq write + connect(p_main_window, + SIGNAL(operateWritingMassChroqFile(QString, ProjectSp)), this, + SLOT(doWritingMassChroqFile(QString, ProjectSp))); + // protic write + connect(p_main_window, SIGNAL(operateWritingProticFile(QString, ProjectSp)), + this, SLOT(doWritingProticFile(QString, ProjectSp))); + // writing ODS file : + connect(p_main_window, SIGNAL(operateWritingOdsFile(QString, ProjectSp)), + this, SLOT(doWritingOdsFile(QString, ProjectSp))); + connect(this, SIGNAL(operationFailed(QString)), p_main_window, + SLOT(doOperationFailed(QString))); + connect(this, SIGNAL(operationFinished()), p_main_window, + SLOT(doOperationFinished())); #endif - qDebug() << "WorkerThread::WorkerThread end MainWindow"; + qDebug() << "WorkerThread::WorkerThread end MainWindow"; } -WorkerThread::WorkerThread(ProjectWindow * p_project_window) +WorkerThread::WorkerThread(ProjectWindow *p_project_window) { - qDebug() << "WorkerThread::WorkerThread begin ProjectWindow"; + qDebug() << "WorkerThread::WorkerThread begin ProjectWindow"; - _p_work_monitor = new WorkMonitor(); + _p_work_monitor = new WorkMonitor(); #if QT_VERSION >= 0x050000 - // Qt5 code - - //worker message - connect(_p_work_monitor, &WorkMonitor::workerMessage, p_project_window,&ProjectWindow::doDisplayLoadingMessage); - connect(_p_work_monitor, &WorkMonitor::workerMessagePercent, p_project_window,&ProjectWindow::doDisplayLoadingMessagePercent); - connect(this, &WorkerThread::loadingMessage, p_project_window,&ProjectWindow::doDisplayLoadingMessage); - //grouping - connect(p_project_window, &ProjectWindow::operateGrouping, this,&WorkerThread::doGrouping); - connect(this, &WorkerThread::groupingFinished, p_project_window,&ProjectWindow::doGroupingFinished); - - - //PTM grouping on IdentificationGroup - connect(p_project_window, &ProjectWindow::operatePtmGroupingOnIdentification, this,&WorkerThread::doPtmGroupingOnIdentification); - connect(this, &WorkerThread::ptmGroupingOnIdentificationFinished, p_project_window,&ProjectWindow::refreshPtmGroup); - - //grouping on IdentificationGroup - connect(p_project_window, &ProjectWindow::operateGroupingOnIdentification, this,&WorkerThread::doGroupingOnIdentification); - connect(this, &WorkerThread::groupingOnIdentificationFinished, p_project_window,&ProjectWindow::refreshGroup); - - connect(this, &WorkerThread::operationFailed, p_project_window,&ProjectWindow::doOperationFailed); - connect(this, &WorkerThread::operationFinished, p_project_window,&ProjectWindow::doOperationFinished); + // Qt5 code + + // worker message + connect(_p_work_monitor, &WorkMonitor::workerMessage, p_project_window, + &ProjectWindow::doDisplayLoadingMessage); + connect(_p_work_monitor, &WorkMonitor::workerMessagePercent, p_project_window, + &ProjectWindow::doDisplayLoadingMessagePercent); + connect(this, &WorkerThread::loadingMessage, p_project_window, + &ProjectWindow::doDisplayLoadingMessage); + // grouping + connect(p_project_window, &ProjectWindow::operateGrouping, this, + &WorkerThread::doGrouping); + connect(this, &WorkerThread::groupingFinished, p_project_window, + &ProjectWindow::doGroupingFinished); + + + // PTM grouping on IdentificationGroup + connect(p_project_window, &ProjectWindow::operatePtmGroupingOnIdentification, + this, &WorkerThread::doPtmGroupingOnIdentification); + connect(this, &WorkerThread::ptmGroupingOnIdentificationFinished, + p_project_window, &ProjectWindow::refreshPtmGroup); + + // grouping on IdentificationGroup + connect(p_project_window, &ProjectWindow::operateGroupingOnIdentification, + this, &WorkerThread::doGroupingOnIdentification); + connect(this, &WorkerThread::groupingOnIdentificationFinished, + p_project_window, &ProjectWindow::refreshGroup); + + connect(this, &WorkerThread::operationFailed, p_project_window, + &ProjectWindow::doOperationFailed); + connect(this, &WorkerThread::operationFinished, p_project_window, + &ProjectWindow::doOperationFinished); #else -// Qt4 code - qDebug() << "WorkerThread::WorkerThread Qt4 code"; - - //worker message - connect(_p_work_monitor, SIGNAL(workerMessage(QString)), p_project_window,SLOT(doDisplayLoadingMessage(QString))); - connect(_p_work_monitor, SIGNAL(workerMessage(QString, int)), p_project_window,SLOT(doDisplayLoadingMessage(QString, int))); - - connect(this, SIGNAL(loadingMessage(QString)), p_project_window,SLOT(doDisplayLoadingMessage(QString))); - //grouping - connect(p_project_window, SIGNAL(operateGrouping(ProjectSp)), this,SLOT(doGrouping(ProjectSp))); - connect(this, SIGNAL(groupingFinished()), p_project_window,SLOT(doGroupingFinished())); - - - //PTM grouping on IdentificationGroup - connect(p_project_window, SIGNAL(operatePtmGroupingOnIdentification(IdentificationGroup *)), this,SLOT(doPtmGroupingOnIdentification(IdentificationGroup *))); - connect(this, SIGNAL(ptmGroupingOnIdentificationFinished(IdentificationGroup *)), p_project_window,SLOT(refreshPtmGroup(IdentificationGroup *))); - - //grouping on IdentificationGroup - connect(p_project_window, SIGNAL(operateGroupingOnIdentification(IdentificationGroup *, GroupingType)), this,SLOT(doGroupingOnIdentification(IdentificationGroup *, GroupingType))); - connect(this, SIGNAL(groupingOnIdentificationFinished(IdentificationGroup *)), p_project_window,SLOT(refreshGroup(IdentificationGroup *))); - - connect(this, SIGNAL(operationFailed(QString)), p_project_window,SLOT(doOperationFailed(QString))); - connect(this, SIGNAL(operationFinished()), p_project_window,SLOT(doOperationFinished())); + // Qt4 code + qDebug() << "WorkerThread::WorkerThread Qt4 code"; + + // worker message + connect(_p_work_monitor, SIGNAL(workerMessage(QString)), p_project_window, + SLOT(doDisplayLoadingMessage(QString))); + connect(_p_work_monitor, SIGNAL(workerMessage(QString, int)), + p_project_window, SLOT(doDisplayLoadingMessage(QString, int))); + + connect(this, SIGNAL(loadingMessage(QString)), p_project_window, + SLOT(doDisplayLoadingMessage(QString))); + // grouping + connect(p_project_window, SIGNAL(operateGrouping(ProjectSp)), this, + SLOT(doGrouping(ProjectSp))); + connect(this, SIGNAL(groupingFinished()), p_project_window, + SLOT(doGroupingFinished())); + + + // PTM grouping on IdentificationGroup + connect(p_project_window, + SIGNAL(operatePtmGroupingOnIdentification(IdentificationGroup *)), + this, SLOT(doPtmGroupingOnIdentification(IdentificationGroup *))); + connect(this, + SIGNAL(ptmGroupingOnIdentificationFinished(IdentificationGroup *)), + p_project_window, SLOT(refreshPtmGroup(IdentificationGroup *))); + + // grouping on IdentificationGroup + connect( + p_project_window, + SIGNAL( + operateGroupingOnIdentification(IdentificationGroup *, GroupingType)), + this, + SLOT(doGroupingOnIdentification(IdentificationGroup *, GroupingType))); + connect(this, SIGNAL(groupingOnIdentificationFinished(IdentificationGroup *)), + p_project_window, SLOT(refreshGroup(IdentificationGroup *))); + + connect(this, SIGNAL(operationFailed(QString)), p_project_window, + SLOT(doOperationFailed(QString))); + connect(this, SIGNAL(operationFinished()), p_project_window, + SLOT(doOperationFinished())); #endif - qDebug() << "WorkerThread::WorkerThread end ProjectWindow"; + qDebug() << "WorkerThread::WorkerThread end ProjectWindow"; } WorkerThread::~WorkerThread() { - qDebug() << "WorkerThread::WorkerThread destructor"; + qDebug() << "WorkerThread::WorkerThread destructor"; } -void WorkerThread::doXpipFileLoad(QString filename) { - qDebug() << "WorkerThread::doXpipFileLoad begin "<< filename; - try { - QFileInfo new_xpip_file(filename); - emit loadingMessage(tr("loading XPIP file")); - qDebug() << "WorkerThread::doXpipFileLoad new_xpip_file "<< new_xpip_file.absoluteFilePath(); - XpipFile xpip_file(new_xpip_file); - ProjectSp project_sp = xpip_file.getProjectSp(_p_work_monitor); - - emit projectReady(project_sp); - +void +WorkerThread::doXpipFileLoad(QString filename) +{ + qDebug() << "WorkerThread::doXpipFileLoad begin " << filename; + try + { + QFileInfo new_xpip_file(filename); + emit loadingMessage(tr("loading XPIP file")); + qDebug() << "WorkerThread::doXpipFileLoad new_xpip_file " + << new_xpip_file.absoluteFilePath(); + XpipFile xpip_file(new_xpip_file); + ProjectSp project_sp = xpip_file.getProjectSp(_p_work_monitor); + + emit projectReady(project_sp); } - catch (pappso::PappsoException & error) { - emit projectNotReady(tr("Error while reading XPIP file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit projectNotReady( + tr("Error while reading XPIP file :\n%1").arg(error.qwhat())); } - qDebug() << "WorkerThread::doXpipFileLoad end"; + qDebug() << "WorkerThread::doXpipFileLoad end"; } -void WorkerThread::doPtmGroupingOnIdentification(IdentificationGroup * p_identification_group) { - qDebug() << "WorkerThread::doPtmGroupingOnIdentification begin "; - try { - emit loadingMessage(tr("computing PTM islands")); - try { - p_identification_group->startPtmGrouping(); - +void +WorkerThread::doPtmGroupingOnIdentification( + IdentificationGroup *p_identification_group) +{ + qDebug() << "WorkerThread::doPtmGroupingOnIdentification begin "; + try + { + emit loadingMessage(tr("computing PTM islands")); + try + { + p_identification_group->startPtmGrouping(); } - catch (pappso::PappsoException exception_pappso) { - emit operationFailed(tr("Error computing PTM islands : %1").arg(exception_pappso.qwhat())); + catch(pappso::PappsoException exception_pappso) + { + emit operationFailed(tr("Error computing PTM islands : %1") + .arg(exception_pappso.qwhat())); } - catch (std::exception exception_std) { - emit operationFailed(tr("Error computing PTM islands : %1").arg(exception_std.what())); + catch(std::exception exception_std) + { + emit operationFailed( + tr("Error computing PTM islands : %1").arg(exception_std.what())); } - emit loadingMessage(tr("computing PTM islands finished")); - emit ptmGroupingOnIdentificationFinished(p_identification_group); + emit loadingMessage(tr("computing PTM islands finished")); + emit ptmGroupingOnIdentificationFinished(p_identification_group); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while computing PTM islands :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed( + tr("Error while computing PTM islands :\n%1").arg(error.qwhat())); } - qDebug() << "WorkerThread::doPtmGroupingOnIdentification end "; + qDebug() << "WorkerThread::doPtmGroupingOnIdentification end "; } -void WorkerThread::doGroupingOnIdentification(IdentificationGroup * p_identification_group, GroupingType grouping_type) { - qDebug() << "WorkerThread::doGroupingOnIdentification begin "; - try { - emit loadingMessage(tr("grouping proteins")); - try { - p_identification_group->startGrouping(grouping_type, _p_work_monitor); - +void +WorkerThread::doGroupingOnIdentification( + IdentificationGroup *p_identification_group, GroupingType grouping_type) +{ + qDebug() << "WorkerThread::doGroupingOnIdentification begin "; + try + { + emit loadingMessage(tr("grouping proteins")); + try + { + p_identification_group->startGrouping(grouping_type, _p_work_monitor); } - catch (pappso::PappsoException exception_pappso) { - emit operationFailed(tr("Error grouping identification : %1").arg(exception_pappso.qwhat())); + catch(pappso::PappsoException exception_pappso) + { + emit operationFailed(tr("Error grouping identification : %1") + .arg(exception_pappso.qwhat())); } - catch (std::exception exception_std) { - emit operationFailed(tr("Error grouping identification : %1").arg(exception_std.what())); + catch(std::exception exception_std) + { + emit operationFailed( + tr("Error grouping identification : %1").arg(exception_std.what())); } - emit loadingMessage(tr("grouping proteins finished")); - emit groupingOnIdentificationFinished(p_identification_group); + emit loadingMessage(tr("grouping proteins finished")); + emit groupingOnIdentificationFinished(p_identification_group); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while grouping :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed(tr("Error while grouping :\n%1").arg(error.qwhat())); } - qDebug() << "WorkerThread::doGroupingOnIdentification end "; + qDebug() << "WorkerThread::doGroupingOnIdentification end "; } -void WorkerThread::doGrouping(ProjectSp project_sp) { - qDebug() << "WorkerThread::doGrouping begin "; - try { - emit loadingMessage(tr("grouping proteins")); - try { - project_sp.get()->startGrouping(_p_work_monitor); - +void +WorkerThread::doGrouping(ProjectSp project_sp) +{ + qDebug() << "WorkerThread::doGrouping begin "; + try + { + emit loadingMessage(tr("grouping proteins")); + try + { + project_sp.get()->startGrouping(_p_work_monitor); } - catch (pappso::PappsoException exception_pappso) { - emit operationFailed(tr("Error grouping project : %1").arg(exception_pappso.qwhat())); + catch(pappso::PappsoException exception_pappso) + { + emit operationFailed( + tr("Error grouping project : %1").arg(exception_pappso.qwhat())); } - catch (std::exception exception_std) { - emit operationFailed(tr("Error grouping project : %1").arg(exception_std.what())); + catch(std::exception exception_std) + { + emit operationFailed( + tr("Error grouping project : %1").arg(exception_std.what())); } - emit loadingMessage(tr("grouping proteins finished")); - emit groupingFinished(); + emit loadingMessage(tr("grouping proteins finished")); + emit groupingFinished(); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while grouping :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed(tr("Error while grouping :\n%1").arg(error.qwhat())); } - qDebug() << "WorkerThread::doGrouping end "; + qDebug() << "WorkerThread::doGrouping end "; } -void WorkerThread::doWritingXpipFile(QString filename, ProjectSp project_sp) { +void +WorkerThread::doWritingXpipFile(QString filename, ProjectSp project_sp) +{ - try { - emit loadingMessage(tr("writing XPIP file, please wait")); - project_sp.get()->checkPsimodCompliance(); - Xpip xpip_file(filename); - xpip_file.write(project_sp); - xpip_file.close(); + try + { + emit loadingMessage(tr("writing XPIP file, please wait")); + project_sp.get()->checkPsimodCompliance(); + Xpip xpip_file(filename); + xpip_file.write(project_sp); + xpip_file.close(); - emit operationFinished(); + emit operationFinished(); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while writing XPIP file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed( + tr("Error while writing XPIP file :\n%1").arg(error.qwhat())); } } -void WorkerThread::doWritingOdsFile(QString filename, ProjectSp project_sp) { - - try { - emit loadingMessage(tr("writing ODS file, please wait")); - OdsDocWriter writer(filename); - OdsExport export_ods(project_sp.get()); - export_ods.write(&writer, _p_work_monitor); - writer.close(); - emit operationFinished(); +void +WorkerThread::doWritingOdsFile(QString filename, ProjectSp project_sp) +{ + + try + { + emit loadingMessage(tr("writing ODS file, please wait")); + OdsDocWriter writer(filename); + OdsExport export_ods(project_sp.get()); + export_ods.write(&writer, _p_work_monitor); + writer.close(); + emit operationFinished(); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while writing ODS file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed( + tr("Error while writing ODS file :\n%1").arg(error.qwhat())); } } -void WorkerThread::doWritingMassChroqFile(QString filename, ProjectSp project_sp) { +void +WorkerThread::doWritingMassChroqFile(QString filename, ProjectSp project_sp) +{ + + try + { + emit loadingMessage(tr("writing MassChroqML file, please wait")); - try { - emit loadingMessage(tr("writing MassChroqML file, please wait")); - - project_sp.get()->checkPsimodCompliance(); - MassChroQml output(filename); - output.write(project_sp); - output.close(); - emit operationFinished(); + project_sp.get()->checkPsimodCompliance(); + MassChroQml output(filename); + output.write(project_sp); + output.close(); + emit operationFinished(); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed( + tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat())); } } -void WorkerThread::doWritingMassChroqPrmFile(QString filename, ProjectSp project_sp) { +void +WorkerThread::doWritingMassChroqPrmFile(QString filename, ProjectSp project_sp) +{ + + try + { + emit loadingMessage(tr("writing MassChroqPRM file, please wait")); - try { - emit loadingMessage(tr("writing MassChroqPRM file, please wait")); - - project_sp.get()->checkPsimodCompliance(); - MassChroqPrm output(filename); - output.write(project_sp); - output.close(); - emit operationFinished(); + project_sp.get()->checkPsimodCompliance(); + MassChroqPrm output(filename); + output.write(project_sp); + output.close(); + emit operationFinished(); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while writing MassChroqPRM file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed( + tr("Error while writing MassChroqPRM file :\n%1").arg(error.qwhat())); } } -void WorkerThread::doWritingProticFile(QString filename, ProjectSp project_sp) { +void +WorkerThread::doWritingProticFile(QString filename, ProjectSp project_sp) +{ + + try + { + emit loadingMessage(tr("writing PROTICdbML file, please wait")); - try { - emit loadingMessage(tr("writing PROTICdbML file, please wait")); - - project_sp.get()->checkPsimodCompliance(); - ProticdbMl output(filename); - output.write(project_sp); - output.close(); - emit operationFinished(); + project_sp.get()->checkPsimodCompliance(); + ProticdbMl output(filename); + output.write(project_sp); + output.close(); + emit operationFinished(); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while writing PROTICdbML file :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed( + tr("Error while writing PROTICdbML file :\n%1").arg(error.qwhat())); } } -void WorkerThread::doWritingMcqrSpectralCountFile(QString filename, ProjectSp project_sp) { - try { - emit loadingMessage(tr("Writing %1 spectral count file for MassChroqR").arg(filename)); - QFile outFile; - outFile.setFileName(filename); - outFile.open(QIODevice::WriteOnly); - QTextStream * p_outputStream = new QTextStream(&outFile); - TsvOutputStream * p_writer = new TsvOutputStream(*p_outputStream); - p_writer->setNoSheetName(true); - McqrSpectralCount spectra_sheet(p_writer, project_sp.get()); - spectra_sheet.writeSheet(); - - p_writer->close(); - delete p_writer; - delete p_outputStream; - outFile.close(); - emit operationFinished(); +void +WorkerThread::doWritingMcqrSpectralCountFile(QString filename, + ProjectSp project_sp) +{ + try + { + emit loadingMessage( + tr("Writing %1 spectral count file for MassChroqR").arg(filename)); + QFile outFile; + outFile.setFileName(filename); + outFile.open(QIODevice::WriteOnly); + QTextStream *p_outputStream = new QTextStream(&outFile); + TsvOutputStream *p_writer = new TsvOutputStream(*p_outputStream); + p_writer->setNoSheetName(true); + McqrSpectralCount spectra_sheet(p_writer, project_sp.get()); + spectra_sheet.writeSheet(); + + p_writer->close(); + delete p_writer; + delete p_outputStream; + outFile.close(); + emit operationFinished(); } - catch (OdsException & error) { - emit operationFailed(tr("Error while writing spectral count file for MassChroqR :\n%1").arg(error.qwhat())); + catch(OdsException &error) + { + emit operationFailed( + tr("Error while writing spectral count file for MassChroqR :\n%1") + .arg(error.qwhat())); } - catch (pappso::PappsoException & errorb) { - emit operationFailed(tr("Error while writing spectral count file for MassChroqR :\n%1").arg(errorb.qwhat())); + catch(pappso::PappsoException &errorb) + { + emit operationFailed( + tr("Error while writing spectral count file for MassChroqR :\n%1") + .arg(errorb.qwhat())); } } -void WorkerThread::doLoadingResults(bool is_individual, AutomaticFilterParameters param, QStringList file_list) { +void +WorkerThread::doLoadingResults(bool is_individual, + AutomaticFilterParameters param, + QStringList file_list) +{ - qDebug() << "WorkerThread::doLoadingResults begin "; - try { - if (file_list.size() == 0) { - throw pappso::PappsoException(QObject::tr("file list is empty")); + qDebug() << "WorkerThread::doLoadingResults begin "; + try + { + if(file_list.size() == 0) + { + throw pappso::PappsoException(QObject::tr("file list is empty")); } - ProjectSp project_sp = Project().makeProjectSp(); - if (is_individual) { - project_sp.get()->setProjectMode(ProjectMode::individual); + ProjectSp project_sp = Project().makeProjectSp(); + if(is_individual) + { + project_sp.get()->setProjectMode(ProjectMode::individual); } - else { - project_sp.get()->setProjectMode(ProjectMode::combined); + else + { + project_sp.get()->setProjectMode(ProjectMode::combined); } - _p_work_monitor->setProgressMaximumValue(file_list.size()); - int i=0; - for (QString filename : file_list) { - _p_work_monitor->message(tr("loading result file %1 (%2 on %3)").arg(filename).arg(i).arg(file_list.size()), i); - project_sp.get()->readResultFile(filename); - i++; + _p_work_monitor->setProgressMaximumValue(file_list.size()); + int i = 0; + for(QString filename : file_list) + { + _p_work_monitor->message(tr("loading result file %1 (%2 on %3)") + .arg(filename) + .arg(i) + .arg(file_list.size()), + i); + project_sp.get()->readResultFile(filename); + i++; } - emit loadingMessage(tr("filtering proteins")); - project_sp.get()->updateAutomaticFilters(param); - qDebug() << "WorkerThread::doLoadingResults emit loadingResultsFinished(project_sp) "; - emit loadingResultsFinished(project_sp); - + emit loadingMessage(tr("filtering proteins")); + project_sp.get()->updateAutomaticFilters(param); + qDebug() << "WorkerThread::doLoadingResults emit " + "loadingResultsFinished(project_sp) "; + emit loadingResultsFinished(project_sp); } - catch (pappso::PappsoException & error) { - qDebug() << "WorkerThread::doLoadingResults error "; - emit projectNotReady(tr("Error while reading result files :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + qDebug() << "WorkerThread::doLoadingResults error "; + emit projectNotReady( + tr("Error while reading result files :\n%1").arg(error.qwhat())); } - qDebug() << "WorkerThread::doLoadingResults end "; + qDebug() << "WorkerThread::doLoadingResults end "; } -void WorkerThread::doRunningXtandem(TandemRunBatch tandem_run_batch) { - qDebug() << "WorkerThread::doRunningXtandem begin "; - try { - emit loadingMessage(tr("Running X!Tandem, please wait")); - qDebug() << "WorkerThread::doRunningXtandem tandem_run_batch " << tandem_run_batch._tandem_bin_path; - - QSettings settings; - bool use_htcondor = settings.value("tandem/use_HTCondor", "false").toBool(); - - if (use_htcondor) { - TandemCondorProcess xt_process (_p_main_window ,_p_work_monitor, tandem_run_batch); - xt_process.run(); +void +WorkerThread::doRunningXtandem(TandemRunBatch tandem_run_batch) +{ + qDebug() << "WorkerThread::doRunningXtandem begin "; + try + { + emit loadingMessage(tr("Running X!Tandem, please wait")); + qDebug() << "WorkerThread::doRunningXtandem tandem_run_batch " + << tandem_run_batch._tandem_bin_path; + + QSettings settings; + bool use_htcondor = + settings.value("tandem/use_HTCondor", "false").toBool(); + + if(use_htcondor) + { + TandemCondorProcess xt_process(_p_main_window, _p_work_monitor, + tandem_run_batch); + xt_process.run(); } - else { - TandemBatchProcess xt_process (_p_main_window ,_p_work_monitor, tandem_run_batch); - xt_process.run(); + else + { + TandemBatchProcess xt_process(_p_main_window, _p_work_monitor, + tandem_run_batch); + xt_process.run(); } - emit operationFinished(); + emit operationFinished(); } - catch (pappso::PappsoException & error) { - emit operationFailed(tr("Error while running X!Tandem job :\n%1").arg(error.qwhat())); + catch(pappso::PappsoException &error) + { + emit operationFailed( + tr("Error while running X!Tandem job :\n%1").arg(error.qwhat())); } - qDebug() << "WorkerThread::doRunningXtandem end "; + qDebug() << "WorkerThread::doRunningXtandem end "; } diff --git a/src/gui/workerthread.h b/src/gui/workerthread.h index c778e9572f57e7db6214ef5d993e9b85e6f111a2..ba40f8664aae6e0ea92176c53b765148abe33def 100644 --- a/src/gui/workerthread.h +++ b/src/gui/workerthread.h @@ -6,26 +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 + ******************************************************************************/ #ifndef WORKERTHREAD_H #define WORKERTHREAD_H @@ -42,48 +43,51 @@ class ProjectWindow; class WorkerThread : public QObject { - Q_OBJECT + Q_OBJECT -public: + public: + WorkerThread(MainWindow *parent); + WorkerThread(ProjectWindow *parent); + ~WorkerThread(); - WorkerThread(MainWindow * parent); - WorkerThread(ProjectWindow * parent); - ~WorkerThread(); + protected: + void closeEvent(QCloseEvent *event); -protected: + public slots: + void doXpipFileLoad(QString filename); + void doLoadingResults(bool is_individual, AutomaticFilterParameters param, + QStringList file_list); + void doWritingXpipFile(QString filename, ProjectSp project_sp); + void doWritingOdsFile(QString filename, ProjectSp project_sp); + void doWritingMassChroqFile(QString filename, ProjectSp project_sp); + void doWritingMassChroqPrmFile(QString filename, ProjectSp project_sp); + void doWritingProticFile(QString filename, ProjectSp project_sp); + void doWritingMcqrSpectralCountFile(QString filename, ProjectSp project_sp); + void doGrouping(ProjectSp project_sp); + void doGroupingOnIdentification(IdentificationGroup *p_identification_group, + GroupingType grouping_type); + void + doPtmGroupingOnIdentification(IdentificationGroup *p_identification_group); + void doRunningXtandem(TandemRunBatch tandem_run_batch); - void closeEvent(QCloseEvent *event); -public slots: - void doXpipFileLoad(QString filename); - void doLoadingResults(bool is_individual, AutomaticFilterParameters param, QStringList file_list); - void doWritingXpipFile(QString filename, ProjectSp project_sp); - void doWritingOdsFile(QString filename, ProjectSp project_sp); - void doWritingMassChroqFile(QString filename, ProjectSp project_sp); - void doWritingMassChroqPrmFile(QString filename, ProjectSp project_sp); - void doWritingProticFile(QString filename, ProjectSp project_sp); - void doWritingMcqrSpectralCountFile(QString filename, ProjectSp project_sp); - void doGrouping(ProjectSp project_sp); - void doGroupingOnIdentification(IdentificationGroup * p_identification_group, GroupingType grouping_type); - void doPtmGroupingOnIdentification(IdentificationGroup * p_identification_group); - void doRunningXtandem(TandemRunBatch tandem_run_batch); + signals: + void loadingMessage(QString message); + void projectReady(ProjectSp project_sp); + void loadingResultsFinished(ProjectSp project_sp); + void projectNotReady(QString error); + void groupingFinished(); + void + groupingOnIdentificationFinished(IdentificationGroup *p_identification_group); + void ptmGroupingOnIdentificationFinished( + IdentificationGroup *p_identification_group); + void operationFinished(); + void operationFailed(QString error); - -signals: - void loadingMessage(QString message); - void projectReady(ProjectSp project_sp); - void loadingResultsFinished(ProjectSp project_sp); - void projectNotReady(QString error); - void groupingFinished(); - void groupingOnIdentificationFinished(IdentificationGroup * p_identification_group); - void ptmGroupingOnIdentificationFinished(IdentificationGroup * p_identification_group); - void operationFinished(); - void operationFailed(QString error); - -private: - WorkMonitor * _p_work_monitor; - MainWindow * _p_main_window; + private: + WorkMonitor *_p_work_monitor; + MainWindow *_p_main_window; }; #endif // WORKERTHREAD_H diff --git a/src/gui/xic_view/xic_box/xicbox.cpp b/src/gui/xic_view/xic_box/xicbox.cpp index d50674a6a5f38cbe262f71b4f41889255242c667..3fba0015823d580f69f774d0e4ae6a33058f0c6c 100644 --- a/src/gui/xic_view/xic_box/xicbox.cpp +++ b/src/gui/xic_view/xic_box/xicbox.cpp @@ -5,26 +5,27 @@ * \brief XIC box widget */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "xicbox.h" #include "ui_xic_box.h" @@ -36,436 +37,595 @@ #include <pappsomspp/exception/exceptionnotpossible.h> -bool XicBoxNaturalIsotope::contains(const pappso::XicPeakSp & peak) const { - for (const pappso::XicPeakSp & peak_i:detected_peak_list) { - if (peak_i.get() == peak.get()) { - return true; +bool +XicBoxNaturalIsotope::contains(const pappso::XicPeakSp &peak) const +{ + for(const pappso::XicPeakSp &peak_i : detected_peak_list) + { + if(peak_i.get() == peak.get()) + { + return true; } } - return false; + return false; } -class XicDetectionList: public pappso::XicDetectionSinkInterface { -public: - XicDetectionList () { - _max_peak= nullptr; - } - void setPeptideEvidenceList(const std::vector<const PeptideEvidence *> & peptide_evidence_list) { - for (const PeptideEvidence * p_evidence: peptide_evidence_list) { - _rt_list.push_back(p_evidence->getRetentionTime()); - } - } - void setXicPeak (pappso::XicPeak & xic_peak) override { - pappso::XicPeakSp peak_sp = xic_peak.makeXicPeakSp(); - _peak_list.push_back(peak_sp); - - for (pappso::pappso_double rt: _rt_list) { - if (xic_peak.containsRt(rt)) { - if ((_max_peak == nullptr) || (xic_peak.getArea() > _max_peak.get()->getArea())) { - _max_peak = peak_sp; - } - } - } - }; - const pappso::XicPeakSp & getMatchedPeak() const { - return _max_peak; - } - const std::vector<pappso::XicPeakSp> & getXicPeakList() const { - return _peak_list; - }; - void clear() { - _peak_list.clear(); - _max_peak = nullptr; - }; -private : - unsigned int _count=0; - std::vector<pappso::XicPeakSp> _peak_list; - std::vector<pappso::pappso_double> _rt_list; - pappso::XicPeakSp _max_peak; +class XicDetectionList : public pappso::XicDetectionSinkInterface +{ + public: + XicDetectionList() + { + _max_peak = nullptr; + } + void + setPeptideEvidenceList( + const std::vector<const PeptideEvidence *> &peptide_evidence_list) + { + for(const PeptideEvidence *p_evidence : peptide_evidence_list) + { + _rt_list.push_back(p_evidence->getRetentionTime()); + } + } + void + setXicPeak(pappso::XicPeak &xic_peak) override + { + pappso::XicPeakSp peak_sp = xic_peak.makeXicPeakSp(); + _peak_list.push_back(peak_sp); + + for(pappso::pappso_double rt : _rt_list) + { + if(xic_peak.containsRt(rt)) + { + if((_max_peak == nullptr) || + (xic_peak.getArea() > _max_peak.get()->getArea())) + { + _max_peak = peak_sp; + } + } + } + }; + const pappso::XicPeakSp & + getMatchedPeak() const + { + return _max_peak; + } + const std::vector<pappso::XicPeakSp> & + getXicPeakList() const + { + return _peak_list; + }; + void + clear() + { + _peak_list.clear(); + _max_peak = nullptr; + }; + + private: + unsigned int _count = 0; + std::vector<pappso::XicPeakSp> _peak_list; + std::vector<pappso::pappso_double> _rt_list; + pappso::XicPeakSp _max_peak; }; - -XicBox::XicBox(XicWindow *parent): - QWidget(parent), - ui(new Ui::XicBox) +XicBox::XicBox(XicWindow *parent) : QWidget(parent), ui(new Ui::XicBox) { - _p_xic_window = parent; - ui->setupUi(this); + _p_xic_window = parent; + ui->setupUi(this); - XicWorkerThread * p_worker = new XicWorkerThread(); - p_worker->moveToThread(&_xic_thread); - _xic_thread.start(); + XicWorkerThread *p_worker = new XicWorkerThread(); + p_worker->moveToThread(&_xic_thread); + _xic_thread.start(); - //ui->histo_widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom ); - //ui->xic_list_widget->setLayout(new QVBoxLayout(ui->xic_list_widget)); - ui->histo_widget->legend->setVisible(true); + // ui->histo_widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom ); + // ui->xic_list_widget->setLayout(new QVBoxLayout(ui->xic_list_widget)); + ui->histo_widget->legend->setVisible(true); - if (_p_xic_window->isRetentionTimeSeconds()) { - ui->xic_widget->setRetentionTimeInSeconds(); + if(_p_xic_window->isRetentionTimeSeconds()) + { + ui->xic_widget->setRetentionTimeInSeconds(); } - else { - ui->xic_widget->setRetentionTimeInMinutes(); + else + { + ui->xic_widget->setRetentionTimeInMinutes(); } #if QT_VERSION >= 0x050000 - // Qt5 code - connect(this, &XicBox::loadXic, p_worker, &XicWorkerThread::doXicLoad); - connect(p_worker, &XicWorkerThread::xicLoaded,this, &XicBox::setXic); - connect(p_worker, &XicWorkerThread::operationFailed, this, &XicBox::error); - - - connect(this, &XicBox::computeIsotopeMassList, p_worker, &XicWorkerThread::doComputeIsotopeMassList); - connect(p_worker, &XicWorkerThread::isotopeMassListComputed,this, &XicBox::setIsotopeMassList); - - connect(_p_xic_window, &XicWindow::reExtractXicNeeded,this, &XicBox::reExtractXic); - connect(ui->xic_widget, &pappso::XicWidget::xicPeakListChanged,this, &XicBox::setXicPeakList); - connect(ui->xic_widget, &pappso::XicWidget::clicked,this, &XicBox::onXicWidgetClick); - - connect(_p_xic_window, &XicWindow::rtUnitChangeNeeded,this, &XicBox::onRtUnitChanged); + // Qt5 code + connect(this, &XicBox::loadXic, p_worker, &XicWorkerThread::doXicLoad); + connect(p_worker, &XicWorkerThread::xicLoaded, this, &XicBox::setXic); + connect(p_worker, &XicWorkerThread::operationFailed, this, &XicBox::error); + + + connect(this, &XicBox::computeIsotopeMassList, p_worker, + &XicWorkerThread::doComputeIsotopeMassList); + connect(p_worker, &XicWorkerThread::isotopeMassListComputed, this, + &XicBox::setIsotopeMassList); + + connect(_p_xic_window, &XicWindow::reExtractXicNeeded, this, + &XicBox::reExtractXic); + connect(ui->xic_widget, &pappso::XicWidget::xicPeakListChanged, this, + &XicBox::setXicPeakList); + connect(ui->xic_widget, &pappso::XicWidget::clicked, this, + &XicBox::onXicWidgetClick); + + connect(_p_xic_window, &XicWindow::rtUnitChangeNeeded, this, + &XicBox::onRtUnitChanged); #else // Qt4 code #endif - QStringList msrun_list; - for (MsRunSp msrun_sp : _p_xic_window->getProjectWindow()->getProjectP()->getMsRunStore().getMsRunList()) { - msrun_list << msrun_sp.get()->getFilename(); - qDebug() << "ProteinListWindow::setIdentificationGroup " << msrun_sp.get()->getFilename(); + QStringList msrun_list; + for(MsRunSp msrun_sp : _p_xic_window->getProjectWindow() + ->getProjectP() + ->getMsRunStore() + .getMsRunList()) + { + msrun_list << msrun_sp.get()->getFilename(); + qDebug() << "ProteinListWindow::setIdentificationGroup " + << msrun_sp.get()->getFilename(); } - QCompleter *completer = new QCompleter(msrun_list, this); - completer->setCaseSensitivity(Qt::CaseInsensitive); - - completer->setCompletionMode(QCompleter::PopupCompletion); - completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); - completer->setFilterMode(Qt::MatchContains); - ui->msrun_autocompletion->setCompleter(completer); + QCompleter *completer = new QCompleter(msrun_list, this); + completer->setCaseSensitivity(Qt::CaseInsensitive); + completer->setCompletionMode(QCompleter::PopupCompletion); + completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); + completer->setFilterMode(Qt::MatchContains); + ui->msrun_autocompletion->setCompleter(completer); } XicBox::~XicBox() { - qDebug() << "XicBox::~XicBox"; - _xic_thread.quit(); - _xic_thread.wait(); + qDebug() << "XicBox::~XicBox"; + _xic_thread.quit(); + _xic_thread.wait(); } -void XicBox::onXicWidgetClick(double rt, double intensity) { - qDebug() << __FILE__ << " " <<__FUNCTION__ << " " << __LINE__; - ui->xic_widget->clearXicPeakBorders(); - std::vector <pappso::XicPeakSp> draw_peak_borders; - for (XicBoxNaturalIsotope peak:_natural_isotope_list) { - qDebug() << __FILE__ << " " <<__FUNCTION__ << " " << __LINE__; - draw_peak_borders.push_back(peak.one_peak_sp); - if (peak.one_peak_sp.get() != nullptr) { - ui->xic_widget->drawXicPeakBorders(peak.one_peak_sp); +void +XicBox::onXicWidgetClick(double rt, double intensity) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + ui->xic_widget->clearXicPeakBorders(); + std::vector<pappso::XicPeakSp> draw_peak_borders; + for(XicBoxNaturalIsotope peak : _natural_isotope_list) + { + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + draw_peak_borders.push_back(peak.one_peak_sp); + if(peak.one_peak_sp.get() != nullptr) + { + ui->xic_widget->drawXicPeakBorders(peak.one_peak_sp); } } - if (_peptide_evidence_list.size() == 0) { - drawObservedAreaBars(draw_peak_borders); + if(_peptide_evidence_list.size() == 0) + { + drawObservedAreaBars(draw_peak_borders); } - } -void XicBox::remove() { - _p_xic_window->removeXicBox(this); +void +XicBox::remove() +{ + _p_xic_window->removeXicBox(this); } -void XicBox::error(QString error_message) { - QMessageBox::warning(this, - tr("Error extracting XIC :"), error_message); - +void +XicBox::error(QString error_message) +{ + QMessageBox::warning(this, tr("Error extracting XIC :"), error_message); } -void XicBox::extractXicInOtherMsRun() { - qDebug() << "XicBox::extractXicInOtherMsRun begin"; - try { - MsRunSp msrun_sp = _p_xic_window->getProjectWindow()->getProjectP()->getMsRunStore().getInstance(ui->msrun_autocompletion->text()); - _p_xic_window->addXicInMsRun(_p_peptide_evidence, msrun_sp); +void +XicBox::extractXicInOtherMsRun() +{ + qDebug() << "XicBox::extractXicInOtherMsRun begin"; + try + { + MsRunSp msrun_sp = _p_xic_window->getProjectWindow() + ->getProjectP() + ->getMsRunStore() + .getInstance(ui->msrun_autocompletion->text()); + _p_xic_window->addXicInMsRun(_p_peptide_evidence, msrun_sp); } - catch (pappso::ExceptionNotFound & error) { - qDebug() << "XicBox::extractXicInOtherMsRun not found " << ui->msrun_autocompletion->text(); + catch(pappso::ExceptionNotFound &error) + { + qDebug() << "XicBox::extractXicInOtherMsRun not found " + << ui->msrun_autocompletion->text(); } } -void XicBox::setPeptideEvidence(const PeptideEvidence * p_peptide_evidence) { - - - _p_peptide_evidence = p_peptide_evidence; - _msrun_sp = p_peptide_evidence->getIdentificationDataSource()->getMsRunSp(); - - ui->peptide_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->toString()); - ui->msrun_label->setText(_p_peptide_evidence->getMsRunP()->getFilename()); - ui->charge_label->setText(QString("%1").arg(_p_peptide_evidence->getCharge())); - ui->mz_label->setText(QString::number(_p_peptide_evidence->getTheoreticalMz(), 'f', 4)); - - //get same xic peptide evidence (msrun, peptide, charge) - //p_projet - _peptide_evidence_list.clear(); - _p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(_peptide_evidence_list, _msrun_sp.get(),_p_peptide_evidence->getPeptideXtpSp().get(),_p_peptide_evidence->getCharge()); +void +XicBox::setPeptideEvidence(const PeptideEvidence *p_peptide_evidence) +{ - emit computeIsotopeMassList(_p_peptide_evidence->getPeptideXtpSp(), _p_peptide_evidence->getCharge(), _p_xic_window->getXicExtractPrecision(), 0.8); + _p_peptide_evidence = p_peptide_evidence; + _msrun_sp = p_peptide_evidence->getIdentificationDataSource()->getMsRunSp(); + + ui->peptide_label->setText( + _p_peptide_evidence->getPeptideXtpSp().get()->toString()); + ui->msrun_label->setText(_p_peptide_evidence->getMsRunP()->getFilename()); + ui->charge_label->setText( + QString("%1").arg(_p_peptide_evidence->getCharge())); + ui->mz_label->setText( + QString::number(_p_peptide_evidence->getTheoreticalMz(), 'f', 4)); + + // get same xic peptide evidence (msrun, peptide, charge) + // p_projet + _peptide_evidence_list.clear(); + _p_xic_window->getProjectWindow() + ->getProjectP() + ->getSameXicPeptideEvidenceList( + _peptide_evidence_list, _msrun_sp.get(), + _p_peptide_evidence->getPeptideXtpSp().get(), + _p_peptide_evidence->getCharge()); + + emit computeIsotopeMassList(_p_peptide_evidence->getPeptideXtpSp(), + _p_peptide_evidence->getCharge(), + _p_xic_window->getXicExtractPrecision(), 0.8); } -void XicBox::setPeptideEvidenceInMsRun(const PeptideEvidence * p_peptide_evidence, MsRunSp msrun_sp) { - _p_peptide_evidence = p_peptide_evidence; - _msrun_sp = msrun_sp; - - ui->peptide_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->toString()); - ui->msrun_label->setText(msrun_sp->getFilename()); - ui->charge_label->setText(QString("%1").arg(_p_peptide_evidence->getCharge())); - ui->mz_label->setText(QString::number(_p_peptide_evidence->getTheoreticalMz(), 'f', 4)); - - //get same xic peptide evidence (msrun, peptide, charge) - //p_projet - _peptide_evidence_list.clear(); - - _p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(_peptide_evidence_list, _msrun_sp.get(),_p_peptide_evidence->getPeptideXtpSp().get(),_p_peptide_evidence->getCharge()); - //_p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(p_peptide_evidence, _peptide_evidence_list); - - emit computeIsotopeMassList(_p_peptide_evidence->getPeptideXtpSp(), _p_peptide_evidence->getCharge(), _p_xic_window->getXicExtractPrecision(), 0.8); - +void +XicBox::setPeptideEvidenceInMsRun(const PeptideEvidence *p_peptide_evidence, + MsRunSp msrun_sp) +{ + _p_peptide_evidence = p_peptide_evidence; + _msrun_sp = msrun_sp; + + ui->peptide_label->setText( + _p_peptide_evidence->getPeptideXtpSp().get()->toString()); + ui->msrun_label->setText(msrun_sp->getFilename()); + ui->charge_label->setText( + QString("%1").arg(_p_peptide_evidence->getCharge())); + ui->mz_label->setText( + QString::number(_p_peptide_evidence->getTheoreticalMz(), 'f', 4)); + + // get same xic peptide evidence (msrun, peptide, charge) + // p_projet + _peptide_evidence_list.clear(); + + _p_xic_window->getProjectWindow() + ->getProjectP() + ->getSameXicPeptideEvidenceList( + _peptide_evidence_list, _msrun_sp.get(), + _p_peptide_evidence->getPeptideXtpSp().get(), + _p_peptide_evidence->getCharge()); + //_p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(p_peptide_evidence, + //_peptide_evidence_list); + + emit computeIsotopeMassList(_p_peptide_evidence->getPeptideXtpSp(), + _p_peptide_evidence->getCharge(), + _p_xic_window->getXicExtractPrecision(), 0.8); } -void XicBox::setXic(std::vector< pappso::XicSp> xic_sp_list) { - qDebug() << "XicBox::setXic begin " << xic_sp_list.size(); - ui->xic_widget->clear(); - for (int i=0; i < xic_sp_list.size(); i++) { - _natural_isotope_list[i].xic_sp = xic_sp_list[i]; +void +XicBox::setXic(std::vector<pappso::XicSp> xic_sp_list) +{ + qDebug() << "XicBox::setXic begin " << xic_sp_list.size(); + ui->xic_widget->clear(); + for(int i = 0; i < xic_sp_list.size(); i++) + { + _natural_isotope_list[i].xic_sp = xic_sp_list[i]; } - //pappso::XicWidget * xic_widget = new pappso::XicWidget(this); - //ui->xic_list_widget->layout()->addWidget(xic_widget); - for (XicBoxNaturalIsotope & xic_isotope :_natural_isotope_list) { - //qDebug() << "XicBox::setXic xic " << xic_isotope.xic_sp.get(); - if (xic_isotope.xic_sp.get() == nullptr) { - throw new pappso::PappsoException("Error in XicBox::setXic:\n xic_isotope.xic_sp.get() == nullptr"); + // pappso::XicWidget * xic_widget = new pappso::XicWidget(this); + // ui->xic_list_widget->layout()->addWidget(xic_widget); + for(XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) + { + // qDebug() << "XicBox::setXic xic " << xic_isotope.xic_sp.get(); + if(xic_isotope.xic_sp.get() == nullptr) + { + throw new pappso::PappsoException( + "Error in XicBox::setXic:\n xic_isotope.xic_sp.get() == nullptr"); } - qDebug() << "XicBox::setXic xic_isotope.xic_sp.size() " << xic_isotope.xic_sp.get()->size(); - ui->xic_widget->addXicSp(xic_isotope.xic_sp); - QString isotope_name = QString("+%1").arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()); - if (xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank() > 1) { - isotope_name = QString("+%1 [%2]").arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()).arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank()); + qDebug() << "XicBox::setXic xic_isotope.xic_sp.size() " + << xic_isotope.xic_sp.get()->size(); + ui->xic_widget->addXicSp(xic_isotope.xic_sp); + QString isotope_name = QString("+%1").arg( + xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()); + if(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank() > 1) + { + isotope_name = + QString("+%1 [%2]") + .arg(xic_isotope.peptide_natural_isotope_sp.get() + ->getIsotopeNumber()) + .arg( + xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank()); } - isotope_name.append(QString(" (%1%)").arg((int) (xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio()*100))); - ui->xic_widget->setName(xic_isotope.xic_sp.get(), isotope_name); - - if (xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber() == 0) { - for (const PeptideEvidence * peptide_evidence:_peptide_evidence_list) { - qDebug() << "XicBox::setXic peptide_evidence " << peptide_evidence->getRetentionTime(); - ui->xic_widget->addMsMsEvent(xic_isotope.xic_sp.get(), peptide_evidence->getRetentionTime()); + isotope_name.append(QString(" (%1%)").arg(( + int)(xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio() * + 100))); + ui->xic_widget->setName(xic_isotope.xic_sp.get(), isotope_name); + + if(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber() == 0) + { + for(const PeptideEvidence *peptide_evidence : _peptide_evidence_list) + { + qDebug() << "XicBox::setXic peptide_evidence " + << peptide_evidence->getRetentionTime(); + ui->xic_widget->addMsMsEvent( + xic_isotope.xic_sp.get(), peptide_evidence->getRetentionTime()); } } } - qDebug() << "XicBox::setXic rescale" ; + qDebug() << "XicBox::setXic rescale"; - if (!_scaled) { - ui->xic_widget->rescale(); - _scaled = true; + if(!_scaled) + { + ui->xic_widget->rescale(); + _scaled = true; } - /* - if (_isotope_mass_list.size() > _xic_widget_list.size()) { - emit loadXic(_p_peptide_evidence->getMsRunP(), _isotope_mass_list[_xic_widget_list.size()].get()->getMz(), _p_xic_window->getXicExtractPrecision(), XicExtractMethod::max); - } - */ - XicDetectionList xic_list; - xic_list.setPeptideEvidenceList(_peptide_evidence_list); - - std::vector <pappso::XicPeakSp> draw_peak_borders; - - for (XicBoxNaturalIsotope & xic_isotope :_natural_isotope_list) { - try { - xic_list.clear(); - _p_xic_window->xicDetect(*(xic_isotope.xic_sp.get()), &xic_list); - xic_isotope.matched_peak_sp = xic_list.getMatchedPeak(); - xic_isotope.detected_peak_list = xic_list.getXicPeakList(); - ui->xic_widget->addXicPeakList(xic_isotope.xic_sp.get(), xic_list.getXicPeakList()); - draw_peak_borders.push_back(xic_isotope.matched_peak_sp); + /* + if (_isotope_mass_list.size() > _xic_widget_list.size()) { + emit loadXic(_p_peptide_evidence->getMsRunP(), + _isotope_mass_list[_xic_widget_list.size()].get()->getMz(), + _p_xic_window->getXicExtractPrecision(), XicExtractMethod::max); + } + */ + XicDetectionList xic_list; + xic_list.setPeptideEvidenceList(_peptide_evidence_list); + + std::vector<pappso::XicPeakSp> draw_peak_borders; + + for(XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) + { + try + { + xic_list.clear(); + _p_xic_window->xicDetect(*(xic_isotope.xic_sp.get()), &xic_list); + xic_isotope.matched_peak_sp = xic_list.getMatchedPeak(); + xic_isotope.detected_peak_list = xic_list.getXicPeakList(); + ui->xic_widget->addXicPeakList(xic_isotope.xic_sp.get(), + xic_list.getXicPeakList()); + draw_peak_borders.push_back(xic_isotope.matched_peak_sp); } - catch (const pappso::ExceptionNotPossible & e) { - qDebug() << e.qwhat(); + catch(const pappso::ExceptionNotPossible &e) + { + qDebug() << e.qwhat(); } } - qDebug() << "XicBox::setXic plot" ; - ui->xic_widget->plot(); - drawObservedAreaBars(draw_peak_borders); + qDebug() << "XicBox::setXic plot"; + ui->xic_widget->plot(); + drawObservedAreaBars(draw_peak_borders); } -void XicBox::drawObservedAreaBars(const std::vector<pappso::XicPeakSp> & observed_peak_to_draw_list) { - if (_isotope_ratio_graph_observed_intensity == nullptr) { - qDebug() << "XicBox::setXic plot new QCPBars" ; - _isotope_ratio_graph_observed_intensity = new QCPBars(ui->histo_widget->xAxis, ui->histo_widget->yAxis2); +void +XicBox::drawObservedAreaBars( + const std::vector<pappso::XicPeakSp> &observed_peak_to_draw_list) +{ + if(_isotope_ratio_graph_observed_intensity == nullptr) + { + qDebug() << "XicBox::setXic plot new QCPBars"; + _isotope_ratio_graph_observed_intensity = + new QCPBars(ui->histo_widget->xAxis, ui->histo_widget->yAxis2); } - else { - qDebug() << "XicBox::setXic plot clearData" ; - _isotope_ratio_graph_observed_intensity->clearData(); + else + { + qDebug() << "XicBox::setXic plot clearData"; + _isotope_ratio_graph_observed_intensity->clearData(); } - _isotope_ratio_graph_observed_intensity->setName("XIC area"); - //ui->histo_widget->yAxis2->setLabel("intensity"); - - - QVector<double> observed_intensity_data; - QVector<QString> labels; - - QVector<double> ticks; - double sum = 0; - int i = 0; - - qDebug() << "XicBox::setXic plot _isotope_mass_list" ; - for (const XicBoxNaturalIsotope & xic_isotope : _natural_isotope_list) { - pappso::XicPeakSp peak_to_draw; - for (pappso::XicPeakSp observed_peak : observed_peak_to_draw_list) { - if (xic_isotope.contains(observed_peak)) { - peak_to_draw = observed_peak; + _isotope_ratio_graph_observed_intensity->setName("XIC area"); + // ui->histo_widget->yAxis2->setLabel("intensity"); + + + QVector<double> observed_intensity_data; + QVector<QString> labels; + + QVector<double> ticks; + double sum = 0; + int i = 0; + + qDebug() << "XicBox::setXic plot _isotope_mass_list"; + for(const XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) + { + pappso::XicPeakSp peak_to_draw; + for(pappso::XicPeakSp observed_peak : observed_peak_to_draw_list) + { + if(xic_isotope.contains(observed_peak)) + { + peak_to_draw = observed_peak; } } - if (peak_to_draw.get() == nullptr) { + if(peak_to_draw.get() == nullptr) + { } - else { - sum += peak_to_draw.get()->getArea(); - observed_intensity_data << peak_to_draw.get()->getArea(); - QString isotope_name = QString("+%1").arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()); - if (xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank() > 1) { - isotope_name = QString("+%1 [%2]").arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()).arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank()); + else + { + sum += peak_to_draw.get()->getArea(); + observed_intensity_data << peak_to_draw.get()->getArea(); + QString isotope_name = QString("+%1").arg( + xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()); + if(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank() > 1) + { + isotope_name = + QString("+%1 [%2]") + .arg(xic_isotope.peptide_natural_isotope_sp.get() + ->getIsotopeNumber()) + .arg(xic_isotope.peptide_natural_isotope_sp.get() + ->getIsotopeRank()); } - isotope_name.append(QString(" (%1%)").arg((int) (xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio()*100))); - labels << isotope_name; - ticks << i; + isotope_name.append(QString(" (%1%)").arg( + (int)(xic_isotope.peptide_natural_isotope_sp.get() + ->getIntensityRatio() * + 100))); + labels << isotope_name; + ticks << i; } - i++; + i++; } - _isotope_ratio_graph_observed_intensity->setPen(QPen(QColor("red"))); - //_graph_peak_surface_list.back()->setScatterStyle(QCPScatterStyle::ssDot); - // observed_intensity->setBrush(QBrush(QColor(170, 255, 0, 0))); + _isotope_ratio_graph_observed_intensity->setPen(QPen(QColor("red"))); + //_graph_peak_surface_list.back()->setScatterStyle(QCPScatterStyle::ssDot); + // observed_intensity->setBrush(QBrush(QColor(170, 255, 0, 0))); - if (ticks.size() > 0) { - _isotope_ratio_graph_observed_intensity->setData(ticks, observed_intensity_data); + if(ticks.size() > 0) + { + _isotope_ratio_graph_observed_intensity->setData(ticks, + observed_intensity_data); - ui->histo_widget->yAxis2->setVisible(true); - ui->histo_widget->yAxis2->setRange(0, sum); - ui->histo_widget->replot(); + ui->histo_widget->yAxis2->setVisible(true); + ui->histo_widget->yAxis2->setRange(0, sum); + ui->histo_widget->replot(); } - qDebug() << "XicBox::setXic end"; - + qDebug() << "XicBox::setXic end"; } -void XicBox::setIsotopeMassList(std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list) { +void +XicBox::setIsotopeMassList( + std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list) +{ - _natural_isotope_list.clear(); - std::vector<pappso::mz> mass_list; - for (pappso::PeptideNaturalIsotopeAverageSp & natural_isotope_average: isotope_mass_list) { - mass_list.push_back(natural_isotope_average.get()->getMz()); - _natural_isotope_list.push_back({nullptr, natural_isotope_average, nullptr, nullptr}); + _natural_isotope_list.clear(); + std::vector<pappso::mz> mass_list; + for(pappso::PeptideNaturalIsotopeAverageSp &natural_isotope_average : + isotope_mass_list) + { + mass_list.push_back(natural_isotope_average.get()->getMz()); + _natural_isotope_list.push_back( + {nullptr, natural_isotope_average, nullptr, nullptr}); } - emit loadXic(_msrun_sp, mass_list, _p_xic_window->getXicExtractPrecision(), pappso::XicExtractMethod::max); - - //histogram - QCPBars * theoretical_ratio = new QCPBars(ui->histo_widget->xAxis, ui->histo_widget->yAxis); - theoretical_ratio->setName("theoretical ratio"); - ui->histo_widget->xAxis->setLabel("isotopes"); - //ui->histo_widget->yAxis->setLabel("th. ratio"); - - QVector<double> theoretical_ratio_data; - - QVector<double> ticks; - QVector<QString> labels; - int i = 0; - double sum = 0; - for (const XicBoxNaturalIsotope & xic_isotope: _natural_isotope_list) { - sum += xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio(); - theoretical_ratio_data << xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio(); - QString isotope_name = QString("+%1").arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()); - if (xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank() > 1) { - isotope_name = QString("+%1 [%2]").arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()).arg(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank()); + emit loadXic(_msrun_sp, mass_list, _p_xic_window->getXicExtractPrecision(), + pappso::XicExtractMethod::max); + + // histogram + QCPBars *theoretical_ratio = + new QCPBars(ui->histo_widget->xAxis, ui->histo_widget->yAxis); + theoretical_ratio->setName("theoretical ratio"); + ui->histo_widget->xAxis->setLabel("isotopes"); + // ui->histo_widget->yAxis->setLabel("th. ratio"); + + QVector<double> theoretical_ratio_data; + + QVector<double> ticks; + QVector<QString> labels; + int i = 0; + double sum = 0; + for(const XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) + { + sum += xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio(); + theoretical_ratio_data + << xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio(); + QString isotope_name = QString("+%1").arg( + xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeNumber()); + if(xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank() > 1) + { + isotope_name = + QString("+%1 [%2]") + .arg(xic_isotope.peptide_natural_isotope_sp.get() + ->getIsotopeNumber()) + .arg( + xic_isotope.peptide_natural_isotope_sp.get()->getIsotopeRank()); } - isotope_name.append(QString(" (%1%)").arg((int) (xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio()*100))); - labels << isotope_name; - ticks << i; - i++; + isotope_name.append(QString(" (%1%)").arg(( + int)(xic_isotope.peptide_natural_isotope_sp.get()->getIntensityRatio() * + 100))); + labels << isotope_name; + ticks << i; + i++; } - //QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText); - //textTicker->addTicks(ticks, labels); - //ui->histo_widget->xAxis->setTicker(textTicker); - ui->histo_widget->xAxis->setTickLabelRotation(60); - //ui->histo_widget->xAxis->setSubTicks(false); - //ui->histo_widget->xAxis->setTickLength(0, 4); - //ui->histo_widget->xAxis->setRange(0, 8); + // QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText); + // textTicker->addTicks(ticks, labels); + // ui->histo_widget->xAxis->setTicker(textTicker); + ui->histo_widget->xAxis->setTickLabelRotation(60); + // ui->histo_widget->xAxis->setSubTicks(false); + // ui->histo_widget->xAxis->setTickLength(0, 4); + // ui->histo_widget->xAxis->setRange(0, 8); - ui->histo_widget->xAxis->setAutoTickStep(false); // <-- disable to use your own value + ui->histo_widget->xAxis->setAutoTickStep( + false); // <-- disable to use your own value - ui->histo_widget->xAxis->setTickStep(1); + ui->histo_widget->xAxis->setTickStep(1); - theoretical_ratio->setData(ticks, theoretical_ratio_data); + theoretical_ratio->setData(ticks, theoretical_ratio_data); - ui->histo_widget->yAxis->setRange(0, sum); - ui->histo_widget->xAxis->setRange(-0.8, _natural_isotope_list.size()); - ui->histo_widget->replot(); + ui->histo_widget->yAxis->setRange(0, sum); + ui->histo_widget->xAxis->setRange(-0.8, _natural_isotope_list.size()); + ui->histo_widget->replot(); } -void XicBox::reExtractXic() { - qDebug() << "XicBox::reExtractXic begin"; - ui->xic_widget->clear(); - - std::vector<pappso::mz> mass_list; - for (const XicBoxNaturalIsotope & xic_isotope: _natural_isotope_list) { - mass_list.push_back(xic_isotope.peptide_natural_isotope_sp.get()->getMz()); +void +XicBox::reExtractXic() +{ + qDebug() << "XicBox::reExtractXic begin"; + ui->xic_widget->clear(); + + std::vector<pappso::mz> mass_list; + for(const XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) + { + mass_list.push_back( + xic_isotope.peptide_natural_isotope_sp.get()->getMz()); } - emit loadXic(_msrun_sp, mass_list, _p_xic_window->getXicExtractPrecision(), pappso::XicExtractMethod::max); - qDebug() << "XicBox::reExtractXic end"; + emit loadXic(_msrun_sp, mass_list, _p_xic_window->getXicExtractPrecision(), + pappso::XicExtractMethod::max); + qDebug() << "XicBox::reExtractXic end"; } -void XicBox::setRetentionTime(double rt) { - qDebug() << "XicBox::setRetentionTime begin"; - ui->rt_label->setText(tr("rt=%1 (sec) rt=%2 (min)").arg(rt).arg(rt/60)); +void +XicBox::setRetentionTime(double rt) +{ + qDebug() << "XicBox::setRetentionTime begin"; + ui->rt_label->setText(tr("rt=%1 (sec) rt=%2 (min)").arg(rt).arg(rt / 60)); } -void XicBox::setXicPeakList(std::vector<std::pair<pappso::XicSp, pappso::XicPeakSp>> xic_peak_list) { - qDebug() << "XicBox::setXicPeakList begin"; - QString html ; - for (XicBoxNaturalIsotope & xic_isotope: _natural_isotope_list) { - xic_isotope.one_peak_sp = nullptr; +void +XicBox::setXicPeakList( + std::vector<std::pair<pappso::XicSp, pappso::XicPeakSp>> xic_peak_list) +{ + qDebug() << "XicBox::setXicPeakList begin"; + QString html; + for(XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) + { + xic_isotope.one_peak_sp = nullptr; } - for (std::pair<pappso::XicSp, pappso::XicPeakSp> & pair_xic_peak: xic_peak_list) { - for (XicBoxNaturalIsotope & xic_isotope: _natural_isotope_list) { - if (xic_isotope.xic_sp.get() == pair_xic_peak.first.get()) { - xic_isotope.one_peak_sp = pair_xic_peak.second; + for(std::pair<pappso::XicSp, pappso::XicPeakSp> &pair_xic_peak : + xic_peak_list) + { + for(XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) + { + if(xic_isotope.xic_sp.get() == pair_xic_peak.first.get()) + { + xic_isotope.one_peak_sp = pair_xic_peak.second; } } - html.append(tr("<p>%1<br/>area: %2<br/>rt begin: %3<br/>rt max: %4<br/>rt end: %5<br/></p>").arg(ui->xic_widget->getName(pair_xic_peak.first.get())).arg(pair_xic_peak.second.get()->getArea()).arg(pair_xic_peak.second.get()->getLeftBoundary().rt) + html.append(tr("<p>%1<br/>area: %2<br/>rt begin: %3<br/>rt max: " + "%4<br/>rt end: %5<br/></p>") + .arg(ui->xic_widget->getName(pair_xic_peak.first.get())) + .arg(pair_xic_peak.second.get()->getArea()) + .arg(pair_xic_peak.second.get()->getLeftBoundary().rt) .arg(pair_xic_peak.second.get()->getMaxXicElement().rt) - .arg(pair_xic_peak.second.get()->getRightBoundary().rt) - ); + .arg(pair_xic_peak.second.get()->getRightBoundary().rt)); } - ui->xic_widget->setToolTip(html); - /* - if (_popup_peak_info == nullptr) delete _popup_peak_info; - _popup_peak_info = new QFrame( this ,Qt::Popup); - //_popup_peak_info->setFrameStyle(Qt::WinPanel|Qt::Raised ); - _popup_peak_info->resize(150,100); - _popup_peak_info->show(); - */ - - + ui->xic_widget->setToolTip(html); + /* + if (_popup_peak_info == nullptr) delete _popup_peak_info; + _popup_peak_info = new QFrame( this ,Qt::Popup); + //_popup_peak_info->setFrameStyle(Qt::WinPanel|Qt::Raised ); + _popup_peak_info->resize(150,100); + _popup_peak_info->show(); + */ } -void XicBox::onRtUnitChanged() { - if (_p_xic_window->isRetentionTimeSeconds()) { - ui->xic_widget->setRetentionTimeInSeconds(); +void +XicBox::onRtUnitChanged() +{ + if(_p_xic_window->isRetentionTimeSeconds()) + { + ui->xic_widget->setRetentionTimeInSeconds(); } - else { - ui->xic_widget->setRetentionTimeInMinutes(); + else + { + ui->xic_widget->setRetentionTimeInMinutes(); } } diff --git a/src/gui/xic_view/xic_box/xicbox.h b/src/gui/xic_view/xic_box/xicbox.h index 32bb2093333b4e052936521fa8de9c5e4ffa70b1..9225a6367cd2780e86c3c94fbb6585c520665b29 100644 --- a/src/gui/xic_view/xic_box/xicbox.h +++ b/src/gui/xic_view/xic_box/xicbox.h @@ -5,26 +5,27 @@ * \brief XIC box widget */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 XICBOX_H #define XICBOX_H @@ -38,65 +39,73 @@ #include <pappsomspp/peptide/peptidenaturalisotopelist.h> #include <qcustomplot.h> -namespace Ui { -class XicBox; +namespace Ui +{ + class XicBox; } -struct XicBoxNaturalIsotope { - - bool contains(const pappso::XicPeakSp & peak) const; - - pappso::XicSp xic_sp; - pappso::PeptideNaturalIsotopeAverageSp peptide_natural_isotope_sp; - pappso::XicPeakSp matched_peak_sp; - pappso::XicPeakSp one_peak_sp; - std::vector <pappso::XicPeakSp> detected_peak_list; +struct XicBoxNaturalIsotope +{ + + bool contains(const pappso::XicPeakSp &peak) const; + + pappso::XicSp xic_sp; + pappso::PeptideNaturalIsotopeAverageSp peptide_natural_isotope_sp; + pappso::XicPeakSp matched_peak_sp; + pappso::XicPeakSp one_peak_sp; + std::vector<pappso::XicPeakSp> detected_peak_list; }; -class XicBox: public QWidget +class XicBox : public QWidget { - Q_OBJECT -public: - - explicit XicBox(XicWindow * parent = 0); - virtual ~XicBox(); - void setPeptideEvidence(const PeptideEvidence * p_peptide_evidence) ; - void setPeptideEvidenceInMsRun(const PeptideEvidence * p_peptide_evidence, MsRunSp msrun_sp); - -signals : - void loadXic(MsRunSp p_msrun, std::vector<pappso::mz> mz_list, pappso::PrecisionP precision, pappso::XicExtractMethod method); - void computeIsotopeMassList(pappso::PeptideSp peptide_sp, unsigned int charge, pappso::PrecisionP precision, double minimum_isotope_pattern_ratio); -private slots: - void remove(); - void reExtractXic(); - void setXic(std::vector< pappso::XicSp> xic_sp_list); - void setIsotopeMassList(std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list); - void error(QString error_message); - void extractXicInOtherMsRun(); - void setRetentionTime(double rt); - void setXicPeakList(std::vector<std::pair<pappso::XicSp, pappso::XicPeakSp>> xic_peak_list); - void onRtUnitChanged(); - void onXicWidgetClick(double rt, double intensity); - -private: - void drawObservedAreaBars(const std::vector<pappso::XicPeakSp> & observed_peak_to_draw); - -private: - Ui::XicBox *ui; - QThread _xic_thread; - XicWindow * _p_xic_window; - const PeptideEvidence * _p_peptide_evidence; - MsRunSp _msrun_sp; - std::vector<const PeptideEvidence *> _peptide_evidence_list; - std::vector<XicBoxNaturalIsotope> _natural_isotope_list; - std::vector<pappso::XicWidget *> _xic_widget_list; - - QCPBars * _isotope_ratio_graph_observed_intensity= nullptr; - - bool _scaled = false; - - //QFrame * _popup_peak_info = nullptr; + Q_OBJECT + public: + explicit XicBox(XicWindow *parent = 0); + virtual ~XicBox(); + void setPeptideEvidence(const PeptideEvidence *p_peptide_evidence); + void setPeptideEvidenceInMsRun(const PeptideEvidence *p_peptide_evidence, + MsRunSp msrun_sp); + + signals: + void loadXic(MsRunSp p_msrun, std::vector<pappso::mz> mz_list, + pappso::PrecisionP precision, pappso::XicExtractMethod method); + void computeIsotopeMassList(pappso::PeptideSp peptide_sp, unsigned int charge, + pappso::PrecisionP precision, + double minimum_isotope_pattern_ratio); + private slots: + void remove(); + void reExtractXic(); + void setXic(std::vector<pappso::XicSp> xic_sp_list); + void setIsotopeMassList( + std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list); + void error(QString error_message); + void extractXicInOtherMsRun(); + void setRetentionTime(double rt); + void setXicPeakList( + std::vector<std::pair<pappso::XicSp, pappso::XicPeakSp>> xic_peak_list); + void onRtUnitChanged(); + void onXicWidgetClick(double rt, double intensity); + + private: + void drawObservedAreaBars( + const std::vector<pappso::XicPeakSp> &observed_peak_to_draw); + + private: + Ui::XicBox *ui; + QThread _xic_thread; + XicWindow *_p_xic_window; + const PeptideEvidence *_p_peptide_evidence; + MsRunSp _msrun_sp; + std::vector<const PeptideEvidence *> _peptide_evidence_list; + std::vector<XicBoxNaturalIsotope> _natural_isotope_list; + std::vector<pappso::XicWidget *> _xic_widget_list; + + QCPBars *_isotope_ratio_graph_observed_intensity = nullptr; + + bool _scaled = false; + + // QFrame * _popup_peak_info = nullptr; }; diff --git a/src/gui/xic_view/xic_widgets/zivydialog.cpp b/src/gui/xic_view/xic_widgets/zivydialog.cpp index 5f4244c55cbb2bf2de6c34487af4ca8edc6ef788..5671bb6b37666f41517e09b3da647502c8700cc1 100644 --- a/src/gui/xic_view/xic_widgets/zivydialog.cpp +++ b/src/gui/xic_view/xic_widgets/zivydialog.cpp @@ -5,57 +5,63 @@ * \brief dialog window to edit Zivy quantification method */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "zivydialog.h" #include <QVBoxLayout> #include <QDebug> -ZivyDialog::ZivyDialog(QWidget *parent) { - _p_zivy_widget = new ZivyWidget(this); - _p_button_box = new QDialogButtonBox(QDialogButtonBox::Ok - | QDialogButtonBox::Cancel); +ZivyDialog::ZivyDialog(QWidget *parent) +{ + _p_zivy_widget = new ZivyWidget(this); + _p_button_box = + new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - connect(_p_button_box, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(_p_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(_p_button_box, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(_p_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(_p_zivy_widget); - mainLayout->addWidget(_p_button_box); - setLayout(mainLayout); + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(_p_zivy_widget); + mainLayout->addWidget(_p_button_box); + setLayout(mainLayout); - setWindowTitle(tr("Edit parameters")); + setWindowTitle(tr("Edit parameters")); } ZivyDialog::~ZivyDialog() { - qDebug() << "ZivyDialog::~ZivyDialog"; + qDebug() << "ZivyDialog::~ZivyDialog"; } -void ZivyDialog::setZivyParams(const ZivyParams & params) { - _p_zivy_widget->setZivyParams(params); +void +ZivyDialog::setZivyParams(const ZivyParams ¶ms) +{ + _p_zivy_widget->setZivyParams(params); } -const ZivyParams ZivyDialog::getZivyParams() const { - return _p_zivy_widget->getZivyParams(); +const ZivyParams +ZivyDialog::getZivyParams() const +{ + return _p_zivy_widget->getZivyParams(); } diff --git a/src/gui/xic_view/xic_widgets/zivydialog.h b/src/gui/xic_view/xic_widgets/zivydialog.h index 25c1625b46d9d1bd77d8a707e0133113ce4f5ac6..940a792c3e821d08de5572380d6434b31361ead0 100644 --- a/src/gui/xic_view/xic_widgets/zivydialog.h +++ b/src/gui/xic_view/xic_widgets/zivydialog.h @@ -5,26 +5,27 @@ * \brief dialog window to edit Zivy quantification method */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 ZIVYDIALOG_H #define ZIVYDIALOG_H @@ -35,19 +36,19 @@ class ZivyDialog : public QDialog { - Q_OBJECT - -public: - explicit ZivyDialog(QWidget *parent = 0); - virtual ~ZivyDialog(); - - - void setZivyParams(const ZivyParams & params); - const ZivyParams getZivyParams() const; - -private: - ZivyWidget * _p_zivy_widget; - QDialogButtonBox * _p_button_box; + Q_OBJECT + + public: + explicit ZivyDialog(QWidget *parent = 0); + virtual ~ZivyDialog(); + + + void setZivyParams(const ZivyParams ¶ms); + const ZivyParams getZivyParams() const; + + private: + ZivyWidget *_p_zivy_widget; + QDialogButtonBox *_p_button_box; }; #endif // ZIVYDIALOG_H diff --git a/src/gui/xic_view/xic_widgets/zivywidget.cpp b/src/gui/xic_view/xic_widgets/zivywidget.cpp index e49e207e9af296e84ee8535e5904040d3174b21e..99e9d4c9c9994a43941b83e8a8f8fba876530359 100644 --- a/src/gui/xic_view/xic_widgets/zivywidget.cpp +++ b/src/gui/xic_view/xic_widgets/zivywidget.cpp @@ -5,97 +5,126 @@ * \brief Widget to edit Zivy quantification method */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "zivywidget.h" #include "ui_zivy_widget.h" #include <QDebug> #include <QSettings> -void ZivyParams::setDetectionParameters(pappso::XicDetectionZivy * detect_zivy) const { - detect_zivy->setSmoothingHalfEdgeWindows(_smoothing_half_window); - detect_zivy->setMinMaxHalfEdgeWindows(_minmax_half_window); - detect_zivy->setMaxMinHalfEdgeWindows(_maxmin_half_window); - detect_zivy->setDetectionThresholdOnMinmax(_minmax_threshold); - detect_zivy->setDetectionThresholdOnMaxmin(_maxmin_threshold); +void +ZivyParams::setDetectionParameters(pappso::XicDetectionZivy *detect_zivy) const +{ + detect_zivy->setSmoothingHalfEdgeWindows(_smoothing_half_window); + detect_zivy->setMinMaxHalfEdgeWindows(_minmax_half_window); + detect_zivy->setMaxMinHalfEdgeWindows(_maxmin_half_window); + detect_zivy->setDetectionThresholdOnMinmax(_minmax_threshold); + detect_zivy->setDetectionThresholdOnMaxmin(_maxmin_threshold); } -void ZivyParams::saveSettings() const { - QSettings settings; - settings.setValue("xic/zivy_maxmin_threshold", QString("%1").arg(_maxmin_threshold)); - settings.setValue("xic/zivy_minmax_threshold", QString("%1").arg(_minmax_threshold)); - settings.setValue("xic/zivy_maxmin_half_window", QString("%1").arg(_maxmin_half_window)); - settings.setValue("xic/zivy_minmax_half_window", QString("%1").arg(_minmax_half_window)); - settings.setValue("xic/zivy_smoothing", QString("%1").arg(_smoothing_half_window)); +void +ZivyParams::saveSettings() const +{ + QSettings settings; + settings.setValue("xic/zivy_maxmin_threshold", + QString("%1").arg(_maxmin_threshold)); + settings.setValue("xic/zivy_minmax_threshold", + QString("%1").arg(_minmax_threshold)); + settings.setValue("xic/zivy_maxmin_half_window", + QString("%1").arg(_maxmin_half_window)); + settings.setValue("xic/zivy_minmax_half_window", + QString("%1").arg(_minmax_half_window)); + settings.setValue("xic/zivy_smoothing", + QString("%1").arg(_smoothing_half_window)); } -void ZivyParams::loadSettings() { - QSettings settings; - _maxmin_threshold = settings.value("xic/zivy_maxmin_threshold", QString("%1").arg(_maxmin_threshold)).toDouble(); - _minmax_threshold = settings.value("xic/zivy_minmax_threshold", QString("%1").arg(_minmax_threshold)).toDouble(); - _maxmin_half_window = settings.value("xic/zivy_maxmin_half_window", QString("%1").arg(_maxmin_half_window)).toInt(); - _minmax_half_window = settings.value("xic/zivy_minmax_half_window", QString("%1").arg(_minmax_half_window)).toInt(); - _smoothing_half_window = settings.value("xic/zivy_smoothing", QString("%1").arg(_smoothing_half_window)).toInt(); +void +ZivyParams::loadSettings() +{ + QSettings settings; + _maxmin_threshold = + settings + .value("xic/zivy_maxmin_threshold", QString("%1").arg(_maxmin_threshold)) + .toDouble(); + _minmax_threshold = + settings + .value("xic/zivy_minmax_threshold", QString("%1").arg(_minmax_threshold)) + .toDouble(); + _maxmin_half_window = settings + .value("xic/zivy_maxmin_half_window", + QString("%1").arg(_maxmin_half_window)) + .toInt(); + _minmax_half_window = settings + .value("xic/zivy_minmax_half_window", + QString("%1").arg(_minmax_half_window)) + .toInt(); + _smoothing_half_window = + settings + .value("xic/zivy_smoothing", QString("%1").arg(_smoothing_half_window)) + .toInt(); } -ZivyWidget::ZivyWidget(QWidget *parent): - QWidget(parent), - ui(new Ui::ZivyWidget) +ZivyWidget::ZivyWidget(QWidget *parent) + : QWidget(parent), ui(new Ui::ZivyWidget) { - ui->setupUi(this); + ui->setupUi(this); #if QT_VERSION >= 0x050000 - // Qt5 code + // Qt5 code #else // Qt4 code #endif - - } ZivyWidget::~ZivyWidget() { - qDebug() << "ZivyWidget::~ZivyWidget"; + qDebug() << "ZivyWidget::~ZivyWidget"; } -void ZivyWidget::setZivyParams(const ZivyParams & params) { - ui->maxmin_spinbox->setValue(params._maxmin_half_window); - ui->minmax_spinbox->setValue(params._minmax_half_window); - ui->maxmin_threshold_spinbox->setValue(params._maxmin_threshold); - ui->minmax_threshold_spinbox->setValue(params._minmax_threshold); - ui->smoothing_spinbox->setValue(params._smoothing_half_window); +void +ZivyWidget::setZivyParams(const ZivyParams ¶ms) +{ + ui->maxmin_spinbox->setValue(params._maxmin_half_window); + ui->minmax_spinbox->setValue(params._minmax_half_window); + ui->maxmin_threshold_spinbox->setValue(params._maxmin_threshold); + ui->minmax_threshold_spinbox->setValue(params._minmax_threshold); + ui->smoothing_spinbox->setValue(params._smoothing_half_window); } -const ZivyParams ZivyWidget::getZivyParams() const { - ZivyParams params; +const ZivyParams +ZivyWidget::getZivyParams() const +{ + ZivyParams params; - params._maxmin_half_window = ui->maxmin_spinbox->value(); - params._minmax_half_window = ui->minmax_spinbox->value(); - params._maxmin_threshold = ui->maxmin_threshold_spinbox->value(); - params._minmax_threshold = ui->minmax_threshold_spinbox->value(); - params._smoothing_half_window = ui->smoothing_spinbox->value(); - return params; + params._maxmin_half_window = ui->maxmin_spinbox->value(); + params._minmax_half_window = ui->minmax_spinbox->value(); + params._maxmin_threshold = ui->maxmin_threshold_spinbox->value(); + params._minmax_threshold = ui->minmax_threshold_spinbox->value(); + params._smoothing_half_window = ui->smoothing_spinbox->value(); + return params; } -void ZivyWidget::doSpinboxChanged (int value) { - emit zivyChanged(getZivyParams()); - +void +ZivyWidget::doSpinboxChanged(int value) +{ + emit zivyChanged(getZivyParams()); } diff --git a/src/gui/xic_view/xic_widgets/zivywidget.h b/src/gui/xic_view/xic_widgets/zivywidget.h index a6f3bbf29013a993ae2b02cc0a2c6dd8e859fd61..a8e36d0a8b4feaa29394c3252b63e910f444107b 100644 --- a/src/gui/xic_view/xic_widgets/zivywidget.h +++ b/src/gui/xic_view/xic_widgets/zivywidget.h @@ -5,26 +5,27 @@ * \brief Widget to edit Zivy quantification method */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 ZIVYWIDGET_H #define ZIVYWIDGET_H @@ -32,43 +33,44 @@ #include <QWidget> #include <pappsomspp/xic/detection/xicdetectionzivy.h> -namespace Ui { -class ZivyWidget; +namespace Ui +{ + class ZivyWidget; } -struct ZivyParams { - void setDetectionParameters(pappso::XicDetectionZivy * detect_zivy) const; - void saveSettings() const; - void loadSettings(); - - unsigned int _maxmin_half_window = 3; - unsigned int _minmax_half_window = 2; - double _maxmin_threshold = 3000; - double _minmax_threshold = 5000; - unsigned int _smoothing_half_window = 1; +struct ZivyParams +{ + void setDetectionParameters(pappso::XicDetectionZivy *detect_zivy) const; + void saveSettings() const; + void loadSettings(); + + unsigned int _maxmin_half_window = 3; + unsigned int _minmax_half_window = 2; + double _maxmin_threshold = 3000; + double _minmax_threshold = 5000; + unsigned int _smoothing_half_window = 1; }; -class ZivyWidget: public QWidget +class ZivyWidget : public QWidget { - Q_OBJECT -public: + Q_OBJECT + public: + explicit ZivyWidget(QWidget *parent = 0); + virtual ~ZivyWidget(); + + void setZivyParams(const ZivyParams ¶ms); + + const ZivyParams getZivyParams() const; - explicit ZivyWidget(QWidget * parent = 0); - virtual ~ZivyWidget(); - - void setZivyParams(const ZivyParams & params); - - const ZivyParams getZivyParams() const; + signals: + void zivyChanged(ZivyParams zivy_params); -signals : - void zivyChanged(ZivyParams zivy_params); + protected slots: + void doSpinboxChanged(int value); - protected -slots : - void doSpinboxChanged (int value); -private: - Ui::ZivyWidget *ui; + private: + Ui::ZivyWidget *ui; }; #endif // ZIVYWIDGET_H diff --git a/src/gui/xic_view/xicwindow.cpp b/src/gui/xic_view/xicwindow.cpp index 2fea617297b6908631e0531a2cdbf01b03da4546..039383fa588d077b78c1d19b9965e533fea5d4cf 100644 --- a/src/gui/xic_view/xicwindow.cpp +++ b/src/gui/xic_view/xicwindow.cpp @@ -6,140 +6,165 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "xicwindow.h" #include "ui_xic_window.h" #include "../project_view/projectwindow.h" #include "xic_box/xicbox.h" -XicWindow::XicWindow(ProjectWindow *parent): - QMainWindow(parent), - ui(new Ui::XicWindow) +XicWindow::XicWindow(ProjectWindow *parent) + : QMainWindow(parent), ui(new Ui::XicWindow) { - _project_window = parent; + _project_window = parent; - ui->setupUi(this); + ui->setupUi(this); - QSettings settings; - QString precision_str = settings.value("xic/precision", "10 ppm").toString(); + QSettings settings; + QString precision_str = settings.value("xic/precision", "10 ppm").toString(); - ui->xic_precision->setPrecision(pappso::Precision::fromString(precision_str)); + ui->xic_precision->setPrecision(pappso::Precision::fromString(precision_str)); - ZivyParams zivy_params; - zivy_params.loadSettings(); + ZivyParams zivy_params; + zivy_params.loadSettings(); - zivy_params.setDetectionParameters(&_detect_zivy); + zivy_params.setDetectionParameters(&_detect_zivy); - _p_zivy_dialog = new ZivyDialog(this); - _p_zivy_dialog->setZivyParams(zivy_params); + _p_zivy_dialog = new ZivyDialog(this); + _p_zivy_dialog->setZivyParams(zivy_params); - - connect(_p_zivy_dialog, &ZivyDialog::accepted, this, &XicWindow::doAcceptedZivyDialog); + connect(_p_zivy_dialog, &ZivyDialog::accepted, this, + &XicWindow::doAcceptedZivyDialog); #if QT_VERSION >= 0x050000 - // Qt5 code + // Qt5 code #else // Qt4 code #endif - - } XicWindow::~XicWindow() { - qDebug() << "XicWindow::~XicWindow"; - delete _p_zivy_dialog; + qDebug() << "XicWindow::~XicWindow"; + delete _p_zivy_dialog; } -void XicWindow::doEditZivyParams() { - _p_zivy_dialog->show(); +void +XicWindow::doEditZivyParams() +{ + _p_zivy_dialog->show(); } -void XicWindow::clear() { - QLayoutItem *wItem; - while (wItem = ui->xic_vertical_layout->layout()->takeAt(0)) { - wItem->widget()->setVisible(false); - ui->xic_vertical_layout->layout()->removeWidget(wItem->widget()); - delete wItem->widget(); +void +XicWindow::clear() +{ + QLayoutItem *wItem; + while(wItem = ui->xic_vertical_layout->layout()->takeAt(0)) + { + wItem->widget()->setVisible(false); + ui->xic_vertical_layout->layout()->removeWidget(wItem->widget()); + delete wItem->widget(); } } -ProjectWindow * XicWindow::getProjectWindow() { - return _project_window; +ProjectWindow * +XicWindow::getProjectWindow() +{ + return _project_window; } -void XicWindow::addXic(const PeptideEvidence * p_peptide_evidence) { - XicBox * p_box = new XicBox(this); - p_box->setPeptideEvidence(p_peptide_evidence); - ui->xic_vertical_layout->layout()->addWidget(p_box); +void +XicWindow::addXic(const PeptideEvidence *p_peptide_evidence) +{ + XicBox *p_box = new XicBox(this); + p_box->setPeptideEvidence(p_peptide_evidence); + ui->xic_vertical_layout->layout()->addWidget(p_box); } -void XicWindow::addXicInMsRun(const PeptideEvidence * p_peptide_evidence, MsRunSp msrun_sp) { - XicBox * p_box = new XicBox(this); - p_box->setPeptideEvidenceInMsRun(p_peptide_evidence, msrun_sp); - ui->xic_vertical_layout->layout()->addWidget(p_box); +void +XicWindow::addXicInMsRun(const PeptideEvidence *p_peptide_evidence, + MsRunSp msrun_sp) +{ + XicBox *p_box = new XicBox(this); + p_box->setPeptideEvidenceInMsRun(p_peptide_evidence, msrun_sp); + ui->xic_vertical_layout->layout()->addWidget(p_box); } -void XicWindow::removeXicBox(XicBox * xic_box) { - xic_box->setVisible(false); - ui->xic_vertical_layout->layout()->removeWidget(xic_box); - delete xic_box; +void +XicWindow::removeXicBox(XicBox *xic_box) +{ + xic_box->setVisible(false); + ui->xic_vertical_layout->layout()->removeWidget(xic_box); + delete xic_box; } -pappso::PrecisionP XicWindow::getXicExtractPrecision() const { - return (ui->xic_precision->getPrecision()); +pappso::PrecisionP +XicWindow::getXicExtractPrecision() const +{ + return (ui->xic_precision->getPrecision()); } -void XicWindow::xicPrecisionChanged(pappso::PrecisionP precision) { - qDebug() << "XicWindow::xicPrecisionChanged begin"; - qDebug() << "XicWindow::xicPrecisionChanged emit"; - emit reExtractXicNeeded(); - qDebug() << "XicWindow::xicPrecisionChanged end"; +void +XicWindow::xicPrecisionChanged(pappso::PrecisionP precision) +{ + qDebug() << "XicWindow::xicPrecisionChanged begin"; + qDebug() << "XicWindow::xicPrecisionChanged emit"; + emit reExtractXicNeeded(); + qDebug() << "XicWindow::xicPrecisionChanged end"; } -void XicWindow::xicDetect(const pappso::Xic & xic,pappso::XicDetectionSinkInterface * sink) const { - _detect_zivy.detect(xic, sink); +void +XicWindow::xicDetect(const pappso::Xic &xic, + pappso::XicDetectionSinkInterface *sink) const +{ + _detect_zivy.detect(xic, sink); } -void XicWindow::rtUnitChanged(QAbstractButton* button) { - qDebug() << "XicWindow::rtUnitChanged begin"; - emit rtUnitChangeNeeded(); - qDebug() << "XicWindow::rtUnitChanged end"; +void +XicWindow::rtUnitChanged(QAbstractButton *button) +{ + qDebug() << "XicWindow::rtUnitChanged begin"; + emit rtUnitChangeNeeded(); + qDebug() << "XicWindow::rtUnitChanged end"; } -bool XicWindow::isRetentionTimeSeconds() const { - if (ui->rt_sec_radiobutton->isChecked()) { - return true; +bool +XicWindow::isRetentionTimeSeconds() const +{ + if(ui->rt_sec_radiobutton->isChecked()) + { + return true; } - return false; + return false; } -void XicWindow::doAcceptedZivyDialog() { - _p_zivy_dialog->getZivyParams().setDetectionParameters(&_detect_zivy); - _p_zivy_dialog->getZivyParams().saveSettings(); - emit reExtractXicNeeded(); - +void +XicWindow::doAcceptedZivyDialog() +{ + _p_zivy_dialog->getZivyParams().setDetectionParameters(&_detect_zivy); + _p_zivy_dialog->getZivyParams().saveSettings(); + emit reExtractXicNeeded(); } diff --git a/src/gui/xic_view/xicwindow.h b/src/gui/xic_view/xicwindow.h index 47e30679690f753e5667c7f2ce043e60cab18a49..1598c977b97cbbbfbe0e3ee6de41c3fc7a0abf0f 100644 --- a/src/gui/xic_view/xicwindow.h +++ b/src/gui/xic_view/xicwindow.h @@ -5,26 +5,27 @@ * \brief XIC window */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 XICWINDOW_H #define XICWINDOW_H @@ -40,56 +41,59 @@ class ProjectWindow; - -namespace Ui { -class XicWindow; +namespace Ui +{ + class XicWindow; } class XicBox; -class XicWindow: public QMainWindow { - Q_OBJECT - friend XicBox; -public: - - explicit XicWindow(ProjectWindow * parent = 0); - ~XicWindow(); - - void addXic(const PeptideEvidence * p_peptide_evidence); - void addXicInMsRun(const PeptideEvidence * p_peptide_evidence, MsRunSp msrun_sp); - - pappso::PrecisionP getXicExtractPrecision() const; - - bool isRetentionTimeSeconds() const; - - void clear(); -public slots: - void xicPrecisionChanged(pappso::PrecisionP precision); - void rtUnitChanged(QAbstractButton* button); - - protected slots : - void doEditZivyParams(); - void doAcceptedZivyDialog(); - -signals : - void reExtractXicNeeded(); - void rtUnitChangeNeeded(); - - -protected: - ProjectWindow * getProjectWindow(); - void removeXicBox(XicBox * xic_box); - - void xicDetect(const pappso::Xic & xic,pappso::XicDetectionSinkInterface * sink) const; - -private: - ProjectWindow * _project_window; - Ui::XicWindow *ui; - - pappso::XicDetectionZivy _detect_zivy; - - - ZivyDialog * _p_zivy_dialog; +class XicWindow : public QMainWindow +{ + Q_OBJECT + friend XicBox; + + public: + explicit XicWindow(ProjectWindow *parent = 0); + ~XicWindow(); + + void addXic(const PeptideEvidence *p_peptide_evidence); + void addXicInMsRun(const PeptideEvidence *p_peptide_evidence, + MsRunSp msrun_sp); + + pappso::PrecisionP getXicExtractPrecision() const; + + bool isRetentionTimeSeconds() const; + + void clear(); + public slots: + void xicPrecisionChanged(pappso::PrecisionP precision); + void rtUnitChanged(QAbstractButton *button); + + protected slots: + void doEditZivyParams(); + void doAcceptedZivyDialog(); + + signals: + void reExtractXicNeeded(); + void rtUnitChangeNeeded(); + + + protected: + ProjectWindow *getProjectWindow(); + void removeXicBox(XicBox *xic_box); + + void xicDetect(const pappso::Xic &xic, + pappso::XicDetectionSinkInterface *sink) const; + + private: + ProjectWindow *_project_window; + Ui::XicWindow *ui; + + pappso::XicDetectionZivy _detect_zivy; + + + ZivyDialog *_p_zivy_dialog; }; #endif // XICWINDOW_H diff --git a/src/gui/xic_view/xicworkerthread.h b/src/gui/xic_view/xicworkerthread.h index 36f4cce343057365ba16b01e7425fe9d8b9b07f6..ec0428b4f40a98603a4a05c784e13863aac5ac2b 100644 --- a/src/gui/xic_view/xicworkerthread.h +++ b/src/gui/xic_view/xicworkerthread.h @@ -5,52 +5,56 @@ * \brief XIC worker */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 XICWORKERTHREAD_H #define XICWORKERTHREAD_H #include <pappsomspp/peptide/peptidenaturalisotopelist.h> -#include<QObject> +#include <QObject> #include "../../core/msrun.h" #include <pappsomspp/xic/xic.h> #include <pappsomspp/xicextractor/msrunxicextractor.h> class XicWorkerThread : public QObject { - Q_OBJECT -public: + Q_OBJECT + public: + public slots: + void doXicLoad(MsRunSp p_msrun, std::vector<pappso::mz> mz_list, + pappso::PrecisionP precision, pappso::XicExtractMethod method); + void doComputeIsotopeMassList(pappso::PeptideSp peptide_sp, + unsigned int charge, + pappso::PrecisionP precision, + double minimum_isotope_pattern_ratio); -public slots: - void doXicLoad(MsRunSp p_msrun, std::vector<pappso::mz> mz_list, pappso::PrecisionP precision, pappso::XicExtractMethod method); - void doComputeIsotopeMassList(pappso::PeptideSp peptide_sp, unsigned int charge, pappso::PrecisionP precision, double minimum_isotope_pattern_ratio); - -signals: - void xicLoaded(std::vector<pappso::XicSp> xic_sp_list); - void isotopeMassListComputed(std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list); - void operationFailed(QString error); - -private: - std::vector<pappso::MsRunXicExtractorSp> _extractor_list; + signals: + void xicLoaded(std::vector<pappso::XicSp> xic_sp_list); + void isotopeMassListComputed( + std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list); + void operationFailed(QString error); + private: + std::vector<pappso::MsRunXicExtractorSp> _extractor_list; }; #endif // XICWORKERTHREAD_H diff --git a/src/input/condorqxmlsaxhandler.cpp b/src/input/condorqxmlsaxhandler.cpp index 74242691edaec3d678628e1215ef5c016e238e85..0b7081d3794435b5d0297cdc249768636bedc0be 100644 --- a/src/input/condorqxmlsaxhandler.cpp +++ b/src/input/condorqxmlsaxhandler.cpp @@ -7,227 +7,297 @@ /******************************************************************************* -* 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 "condorqxmlsaxhandler.h" #include "../core/tandem_run/tandemcondorprocess.h" #include <pappsomspp/pappsoexception.h> -CondorQxmlSaxHandler::CondorQxmlSaxHandler(TandemCondorProcess * tandem_condor_process) { - _is_empty = true; - _tandem_condor_process = tandem_condor_process; +CondorQxmlSaxHandler::CondorQxmlSaxHandler( + TandemCondorProcess *tandem_condor_process) +{ + _is_empty = true; + _tandem_condor_process = tandem_condor_process; } -CondorQxmlSaxHandler::~CondorQxmlSaxHandler() { +CondorQxmlSaxHandler::~CondorQxmlSaxHandler() +{ } +bool +CondorQxmlSaxHandler::startElement(const QString &namespaceURI, + const QString &localName, + const QString &qName, + const QXmlAttributes &attributes) +{ + qDebug() << "CondorQxmlSaxHandler::startElement begin" << namespaceURI << " " + << localName << " " << qName; + _tag_stack.push_back(qName); + bool is_ok = true; -bool CondorQxmlSaxHandler::startElement(const QString & namespaceURI, const QString & localName, - const QString & qName, const QXmlAttributes & attributes) { - qDebug()<< "CondorQxmlSaxHandler::startElement begin" << namespaceURI << " " << localName << " " << qName ; - _tag_stack.push_back(qName); - bool is_ok = true; + try + { + // startElement_group - try { - //startElement_group - - if (qName == "c") { - is_ok = startElement_c(attributes); - } else if (qName == "a") { - is_ok = startElement_a(attributes); + if(qName == "c") + { + is_ok = startElement_c(attributes); + } + else if(qName == "a") + { + is_ok = startElement_a(attributes); } - _current_text.clear(); + _current_text.clear(); } - catch (pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::startElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); - return false; + catch(pappso::PappsoException exception_pappso) + { + _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::startElement tag " + "%1, PAPPSO exception:\n%2") + .arg(qName) + .arg(exception_pappso.qwhat()); + return false; } - catch (std::exception exception_std) { - _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::startElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); - return false; + catch(std::exception exception_std) + { + _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::startElement tag " + "%1, std exception:\n%2") + .arg(qName) + .arg(exception_std.what()); + return false; } - return is_ok; + return is_ok; } -bool CondorQxmlSaxHandler::endElement(const QString & namespaceURI, const QString & localName, - const QString & qName) { +bool +CondorQxmlSaxHandler::endElement(const QString &namespaceURI, + const QString &localName, const QString &qName) +{ - bool is_ok = true; - // endElement_peptide_list - try { + bool is_ok = true; + // endElement_peptide_list + try + { - if (qName == "a") + if(qName == "a") { - is_ok = endElement_a(); + is_ok = endElement_a(); } - else if (qName == "c") { - is_ok = endElement_c(); + else if(qName == "c") + { + is_ok = endElement_c(); } - else if (qName == "i") { - is_ok = endElement_i(); + else if(qName == "i") + { + is_ok = endElement_i(); } - else if (qName == "s") { - is_ok = endElement_s(); + else if(qName == "s") + { + is_ok = endElement_s(); } - } - catch (pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::endElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); - return false; + catch(pappso::PappsoException exception_pappso) + { + _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::endElement tag " + "%1, PAPPSO exception:\n%2") + .arg(qName) + .arg(exception_pappso.qwhat()); + return false; } - catch (std::exception exception_std) { - _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::endElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); - return false; + catch(std::exception exception_std) + { + _errorStr = QObject::tr("ERROR in CondorQxmlSaxHandler::endElement tag " + "%1, std exception:\n%2") + .arg(qName) + .arg(exception_std.what()); + return false; } - _current_text.clear(); - _tag_stack.pop_back(); + _current_text.clear(); + _tag_stack.pop_back(); - return is_ok; + return is_ok; } -bool CondorQxmlSaxHandler::error(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg( - exception.message()); +bool +CondorQxmlSaxHandler::error(const QXmlParseException &exception) +{ + _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" + "%3") + .arg(exception.lineNumber()) + .arg(exception.columnNumber()) + .arg(exception.message()); - return false; + return false; } -bool CondorQxmlSaxHandler::fatalError(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg( - exception.message()); - return false; +bool +CondorQxmlSaxHandler::fatalError(const QXmlParseException &exception) +{ + _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" + "%3") + .arg(exception.lineNumber()) + .arg(exception.columnNumber()) + .arg(exception.message()); + return false; } -QString CondorQxmlSaxHandler::errorString() const { - return _errorStr; +QString +CondorQxmlSaxHandler::errorString() const +{ + return _errorStr; } -bool CondorQxmlSaxHandler::endDocument() { +bool +CondorQxmlSaxHandler::endDocument() +{ - unsigned int really_completed_jobs = 0; - if (_is_empty) { - really_completed_jobs = _tandem_condor_process->getCondorJobSize(); - } else { - int total_jobs = 0; - for (std::int8_t i=0; i < 10; i++) { - total_jobs += _count_status[i]; + unsigned int really_completed_jobs = 0; + if(_is_empty) + { + really_completed_jobs = _tandem_condor_process->getCondorJobSize(); + } + else + { + int total_jobs = 0; + for(std::int8_t i = 0; i < 10; i++) + { + total_jobs += _count_status[i]; } - int diff_jobs = _tandem_condor_process->getCondorJobSize() - - total_jobs; - really_completed_jobs = _count_status[(std::int8_t) CondorJobStatus::Completed] + diff_jobs; + int diff_jobs = _tandem_condor_process->getCondorJobSize() - total_jobs; + really_completed_jobs = + _count_status[(std::int8_t)CondorJobStatus::Completed] + diff_jobs; } - _count_status[(std::int8_t) CondorJobStatus::Completed] = really_completed_jobs; + _count_status[(std::int8_t)CondorJobStatus::Completed] = + really_completed_jobs; - _tandem_condor_process->setCondorJobStatus(_count_status); - /* - xtandemCondorAnalysis.setJobCompleted(junexpanded, jidle, jrunning, - jremoved, reallyCompletedJobs, jheld, jsubmission_error); + _tandem_condor_process->setCondorJobStatus(_count_status); + /* + xtandemCondorAnalysis.setJobCompleted(junexpanded, jidle, jrunning, + jremoved, reallyCompletedJobs, jheld, jsubmission_error); - */ + */ - return true; + return true; } -bool CondorQxmlSaxHandler::startDocument() { - for (std::int8_t i=0; i < 10; i++) { - _count_status[i] = 0; +bool +CondorQxmlSaxHandler::startDocument() +{ + for(std::int8_t i = 0; i < 10; i++) + { + _count_status[i] = 0; } - _is_empty = true; - return true; + _is_empty = true; + return true; } -bool CondorQxmlSaxHandler::characters(const QString &str) { - _current_text += str; - return true; +bool +CondorQxmlSaxHandler::characters(const QString &str) +{ + _current_text += str; + return true; } -bool CondorQxmlSaxHandler::startElement_c(QXmlAttributes attributes) { - -// <c> -// <a n="ProcId"><i>0</i></a> - _condor_job_status = CondorJobStatus::Unexpanded; - _current_proc_id = 0; - _is_empty = false; - _current_remote_host = ""; - _current_last_remote_host = ""; - return true; - +bool +CondorQxmlSaxHandler::startElement_c(QXmlAttributes attributes) +{ + + // <c> + // <a n="ProcId"><i>0</i></a> + _condor_job_status = CondorJobStatus::Unexpanded; + _current_proc_id = 0; + _is_empty = false; + _current_remote_host = ""; + _current_last_remote_host = ""; + return true; } -bool CondorQxmlSaxHandler::startElement_a(QXmlAttributes attributes) { - // logger.debug("startElementgroup begin"); - // <group label="performance parameters" type="parameters"> - _in_name = attributes.value("n"); - return true; - +bool +CondorQxmlSaxHandler::startElement_a(QXmlAttributes attributes) +{ + // logger.debug("startElementgroup begin"); + // <group label="performance parameters" type="parameters"> + _in_name = attributes.value("n"); + return true; } -bool CondorQxmlSaxHandler::endElement_a() { - _in_name = ""; - return true; +bool +CondorQxmlSaxHandler::endElement_a() +{ + _in_name = ""; + return true; } -bool CondorQxmlSaxHandler::endElement_i() { - if (_in_name == "ProcId") { - _current_proc_id = _current_text.toInt(); - } else if (_in_name == "JobStatus") { - // <a n="JobStatus"><i>2</i></a> - _condor_job_status = static_cast<CondorJobStatus>(_current_text.toInt()); - // logger.debug(currentProcId); +bool +CondorQxmlSaxHandler::endElement_i() +{ + if(_in_name == "ProcId") + { + _current_proc_id = _current_text.toInt(); + } + else if(_in_name == "JobStatus") + { + // <a n="JobStatus"><i>2</i></a> + _condor_job_status = static_cast<CondorJobStatus>(_current_text.toInt()); + // logger.debug(currentProcId); } - return true; + return true; } -bool CondorQxmlSaxHandler::endElement_s() { - if (_in_name == "RemoteHost") { - // <a n="RemoteHost"><s>slot1@proteus3</s></a> - _current_remote_host = _current_text; - } else if ( _in_name == "LastRemoteHost") { - // <a n="LastRemoteHost"><s>slot1@proteus4</s></a> - _current_last_remote_host = _current_text; +bool +CondorQxmlSaxHandler::endElement_s() +{ + if(_in_name == "RemoteHost") + { + // <a n="RemoteHost"><s>slot1@proteus3</s></a> + _current_remote_host = _current_text; } - return true; - + else if(_in_name == "LastRemoteHost") + { + // <a n="LastRemoteHost"><s>slot1@proteus4</s></a> + _current_last_remote_host = _current_text; + } + return true; } -bool CondorQxmlSaxHandler::endElement_c() { - /* - * 0 Unexpanded U 1 Idle I 2 Running R 3 Removed X 4 Completed C 5 Held - * H 6 Submission_err E - */ - _count_status[(std::int8_t) _condor_job_status] += 1; - - qDebug() << "currentRemoteHost:" << _current_remote_host << - " currentLastRemoteHost" << _current_last_remote_host << " " - << (std::int8_t)_condor_job_status; - return true; +bool +CondorQxmlSaxHandler::endElement_c() +{ + /* + * 0 Unexpanded U 1 Idle I 2 Running R 3 Removed X 4 Completed C 5 Held + * H 6 Submission_err E + */ + _count_status[(std::int8_t)_condor_job_status] += 1; + + qDebug() << "currentRemoteHost:" << _current_remote_host + << " currentLastRemoteHost" << _current_last_remote_host << " " + << (std::int8_t)_condor_job_status; + return true; } /* @@ -243,7 +313,7 @@ import fr.inra.pappso.xtandempipeline.thread.XtandemCondorAnalysis; public class HandlerHTCondorQueue extends SaxBaseHandler { private static final Logger logger = Logger - .getLogger(HandlerHTCondorQueue.class); + .getLogger(HandlerHTCondorQueue.class); private Object inName; private Integer currentProcId; private Integer currentJobStatus; @@ -260,14 +330,14 @@ private XtandemCondorAnalysis xtandemCondorAnalysis; private boolean empty = true; public HandlerHTCondorQueue(XtandemCondorAnalysis xtandemCondorAnalysis) - throws MSMSException { - super(); - this.xtandemCondorAnalysis = xtandemCondorAnalysis; + throws MSMSException { + super(); + this.xtandemCondorAnalysis = xtandemCondorAnalysis; } @Override public void startDocument() throws SAXException { - this.empty = true; + this.empty = true; } diff --git a/src/input/condorqxmlsaxhandler.h b/src/input/condorqxmlsaxhandler.h index dd946473b291d18a697f382681ff8dea937ca294..4fd269c619fbc50a0cead5d997c9ec4688816fe6 100644 --- a/src/input/condorqxmlsaxhandler.h +++ b/src/input/condorqxmlsaxhandler.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef CONDORQXMLSAXHANDLER_H #define CONDORQXMLSAXHANDLER_H @@ -37,63 +38,63 @@ class TandemCondorProcess; /** \def CondorJobStatus * */ -enum class CondorJobStatus: std::int8_t { - Unexpanded =0, ///< 0 Unexpanded U - Idle =1, ///< 1 Idle I - Running=2, ///< 2 Running R - Removed=3, ///< 3 Removed X - Completed=4, ///< 4 Completed C - Held=5, ///< 5 Held H - Submission_err=6 ///< 6 Submission_err E +enum class CondorJobStatus : std::int8_t +{ + Unexpanded = 0, ///< 0 Unexpanded U + Idle = 1, ///< 1 Idle I + Running = 2, ///< 2 Running R + Removed = 3, ///< 3 Removed X + Completed = 4, ///< 4 Completed C + Held = 5, ///< 5 Held H + Submission_err = 6 ///< 6 Submission_err E }; -class CondorQxmlSaxHandler: public QXmlDefaultHandler +class CondorQxmlSaxHandler : public QXmlDefaultHandler { -public: - CondorQxmlSaxHandler(TandemCondorProcess * tandem_condor_process); - ~CondorQxmlSaxHandler(); - - bool startElement(const QString & namespaceURI, const QString & localName, - const QString & qName, const QXmlAttributes & attributes); - - bool endElement(const QString & namespaceURI, const QString & localName, - const QString & qName); - - bool startDocument(); - - bool endDocument(); - - bool characters(const QString &str); - - bool fatalError(const QXmlParseException &exception); - bool error(const QXmlParseException &exception); - - QString errorString() const; - -private: - bool startElement_c(QXmlAttributes attributes); - bool startElement_a(QXmlAttributes attributes); - bool endElement_c(); - bool endElement_a(); - bool endElement_i(); - bool endElement_s(); - -private: - TandemCondorProcess * _tandem_condor_process; - - std::vector<QString> _tag_stack; - QString _errorStr; - QString _current_text; - - QString _in_name; - CondorJobStatus _condor_job_status; - unsigned int _current_proc_id; - QString _current_remote_host; - QString _current_last_remote_host; - - std::int8_t _count_status[10]; - bool _is_empty; + public: + CondorQxmlSaxHandler(TandemCondorProcess *tandem_condor_process); + ~CondorQxmlSaxHandler(); + + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); + + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); + + bool startDocument(); + + bool endDocument(); + + bool characters(const QString &str); + + bool fatalError(const QXmlParseException &exception); + bool error(const QXmlParseException &exception); + + QString errorString() const; + + private: + bool startElement_c(QXmlAttributes attributes); + bool startElement_a(QXmlAttributes attributes); + bool endElement_c(); + bool endElement_a(); + bool endElement_i(); + bool endElement_s(); + + private: + TandemCondorProcess *_tandem_condor_process; + + std::vector<QString> _tag_stack; + QString _errorStr; + QString _current_text; + + QString _in_name; + CondorJobStatus _condor_job_status; + unsigned int _current_proc_id; + QString _current_remote_host; + QString _current_last_remote_host; + std::int8_t _count_status[10]; + bool _is_empty; }; #endif // CONDORQXMLSAXHANDLER_H diff --git a/src/input/identificationpwizreader.h b/src/input/identificationpwizreader.h index 0ff1f4266cbc04b75488427a4fb7dee50f37b91c..4738d65f668345c032277e8bbcc3090786ad65f6 100644 --- a/src/input/identificationpwizreader.h +++ b/src/input/identificationpwizreader.h @@ -46,7 +46,7 @@ namespace pwiz { class IdentDataFile; } -} +} // namespace pwiz class IdentificationPwizReader { diff --git a/src/input/mascot/mascotdatparser.cpp b/src/input/mascot/mascotdatparser.cpp index bd1ee45add8cf6333f85f7fe4457451ba16c62af..1fde28eaf9217af05778419f962f0147087358e5 100644 --- a/src/input/mascot/mascotdatparser.cpp +++ b/src/input/mascot/mascotdatparser.cpp @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "mascotdatparser.h" #include "mimeparser.h" @@ -36,572 +37,759 @@ #include "../../core/proteinmatch.h" #include "../../core/peptideevidence.h" -MascotDatParser::MascotDatParser(Project * p_project, IdentificationGroup * p_identification_group, - IdentificationDataSource * p_identification_data_source) { - _p_project = p_project; - _p_identification_group = p_identification_group; - _p_identification_data_source = p_identification_data_source; - - _regexp_header_line.setPattern("^([A-Z,a-z,0-9,_]+)=(.*)$"); +MascotDatParser::MascotDatParser( + Project *p_project, IdentificationGroup *p_identification_group, + IdentificationDataSource *p_identification_data_source) +{ + _p_project = p_project; + _p_identification_group = p_identification_group; + _p_identification_data_source = p_identification_data_source; + _regexp_header_line.setPattern("^([A-Z,a-z,0-9,_]+)=(.*)$"); } -MascotDatParser::~MascotDatParser() { +MascotDatParser::~MascotDatParser() +{ } -void MascotDatParser::parse(QIODevice * in_stream) { - qDebug() << "MascotDatParser::parse begin"; - MimeParser mime_parser(in_stream); - mime_parser.open(); - - for(bool more=mime_parser.goToFirstFile(); more; more=mime_parser.goToNextFile()) { - qDebug() << "MascotDatParser::parse mimetype=" << mime_parser.getCurrentMimeType() << " filename=" << mime_parser.getCurrentFileName(); - - if (mime_parser.getCurrentFileName() == "proteins") { - while(!mime_parser.getCurrentTextStream().atEnd()) { - parseProteinLine( mime_parser.getCurrentTextStream().readLine()); +void +MascotDatParser::parse(QIODevice *in_stream) +{ + qDebug() << "MascotDatParser::parse begin"; + MimeParser mime_parser(in_stream); + mime_parser.open(); + + for(bool more = mime_parser.goToFirstFile(); more; + more = mime_parser.goToNextFile()) + { + qDebug() << "MascotDatParser::parse mimetype=" + << mime_parser.getCurrentMimeType() + << " filename=" << mime_parser.getCurrentFileName(); + + if(mime_parser.getCurrentFileName() == "proteins") + { + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parseProteinLine(mime_parser.getCurrentTextStream().readLine()); } } - else if (mime_parser.getCurrentFileName() == "header") { - while(!mime_parser.getCurrentTextStream().atEnd()) { - parseHeaderLine( mime_parser.getCurrentTextStream().readLine()); + else if(mime_parser.getCurrentFileName() == "header") + { + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parseHeaderLine(mime_parser.getCurrentTextStream().readLine()); } } - else if (mime_parser.getCurrentFileName() == "masses") { - while(!mime_parser.getCurrentTextStream().atEnd()) { - parseMassesLine( mime_parser.getCurrentTextStream().readLine()); + else if(mime_parser.getCurrentFileName() == "masses") + { + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parseMassesLine(mime_parser.getCurrentTextStream().readLine()); } - } - else if (mime_parser.getCurrentFileName() == "summary") { - while(!mime_parser.getCurrentTextStream().atEnd()) { - parseSummaryLine( mime_parser.getCurrentTextStream().readLine()); + else if(mime_parser.getCurrentFileName() == "summary") + { + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parseSummaryLine(mime_parser.getCurrentTextStream().readLine()); } } - else if (mime_parser.getCurrentFileName() == "peptides") { - while(!mime_parser.getCurrentTextStream().atEnd()) { - parsePeptidesLine( mime_parser.getCurrentTextStream().readLine()); + else if(mime_parser.getCurrentFileName() == "peptides") + { + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parsePeptidesLine(mime_parser.getCurrentTextStream().readLine()); } - saveAndClearPeptide(); + saveAndClearPeptide(); } - else if (mime_parser.getCurrentFileName() == "decoy_summary") { - _is_decoy_section = true; - while(!mime_parser.getCurrentTextStream().atEnd()) { - parseSummaryLine( mime_parser.getCurrentTextStream().readLine()); + else if(mime_parser.getCurrentFileName() == "decoy_summary") + { + _is_decoy_section = true; + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parseSummaryLine(mime_parser.getCurrentTextStream().readLine()); } - _is_decoy_section = false; + _is_decoy_section = false; } - else if (mime_parser.getCurrentFileName() == "decoy_peptides") { - _is_decoy_section = true; - while(!mime_parser.getCurrentTextStream().atEnd()) { - parsePeptidesLine( mime_parser.getCurrentTextStream().readLine()); + else if(mime_parser.getCurrentFileName() == "decoy_peptides") + { + _is_decoy_section = true; + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parsePeptidesLine(mime_parser.getCurrentTextStream().readLine()); } - saveAndClearPeptide(); - _is_decoy_section = false; + saveAndClearPeptide(); + _is_decoy_section = false; } - else if (mime_parser.getCurrentFileName().startsWith("query")) { - _current_query_index = mime_parser.getCurrentFileName().mid(5).toUInt(); - while(!mime_parser.getCurrentTextStream().atEnd()) { - parseQueryLine( mime_parser.getCurrentTextStream().readLine()); + else if(mime_parser.getCurrentFileName().startsWith("query")) + { + _current_query_index = + mime_parser.getCurrentFileName().mid(5).toUInt(); + while(!mime_parser.getCurrentTextStream().atEnd()) + { + parseQueryLine(mime_parser.getCurrentTextStream().readLine()); } - saveQuery(); + saveQuery(); } - } - mime_parser.close(); - qDebug() << "MascotDatParser::parse end"; + mime_parser.close(); + qDebug() << "MascotDatParser::parse end"; } -void MascotDatParser::parseMassesLine(const QString & masses_line) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << masses_line; - if (_regexp_header_line.exactMatch(masses_line)) { - QStringList header_list = _regexp_header_line.capturedTexts(); - -// C_term=17.002740 -//N_term=1.007825 -//delta1=15.994915,Oxidation (M) - if (header_list[1].startsWith("delta")) { - _delta_modification_list.push_back(MascotModification()); - unsigned index = header_list[1].mid(5).toUInt(); - QStringList delta_mod_list = header_list[2].split(","); - pappso::pappso_double mass = delta_mod_list[0].toDouble(); - if (delta_mod_list[1] == "Oxidation (M)") { - _delta_modification_list[index-1].modification = pappso::AaModification::getInstance("MOD:00719"); - _delta_modification_list[index-1].residue = 'M'; +void +MascotDatParser::parseMassesLine(const QString &masses_line) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << masses_line; + if(_regexp_header_line.exactMatch(masses_line)) + { + QStringList header_list = _regexp_header_line.capturedTexts(); + + // C_term=17.002740 + // N_term=1.007825 + // delta1=15.994915,Oxidation (M) + if(header_list[1].startsWith("delta")) + { + _delta_modification_list.push_back(MascotModification()); + unsigned index = header_list[1].mid(5).toUInt(); + QStringList delta_mod_list = header_list[2].split(","); + pappso::pappso_double mass = delta_mod_list[0].toDouble(); + if(delta_mod_list[1] == "Oxidation (M)") + { + _delta_modification_list[index - 1].modification = + pappso::AaModification::getInstance("MOD:00719"); + _delta_modification_list[index - 1].residue = 'M'; } - else { - _delta_modification_list[index-1].modification = pappso::AaModification::getInstanceCustomizedMod(mass); + else + { + _delta_modification_list[index - 1].modification = + pappso::AaModification::getInstanceCustomizedMod(mass); } - //_number_of_residues = header_list[5].toUInt(); + //_number_of_residues = header_list[5].toUInt(); } -//FixedModResidues1=C - else if (header_list[1].startsWith("FixedModResidues")) { - unsigned index = header_list[1].mid(16).toUInt(); - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << index; - _fixed_modification_list[index-1].residue = header_list[2].at(0); + // FixedModResidues1=C + else if(header_list[1].startsWith("FixedModResidues")) + { + unsigned index = header_list[1].mid(16).toUInt(); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << index; + _fixed_modification_list[index - 1].residue = header_list[2].at(0); } -//NeutralLoss1=0.000000 -//NeutralLoss1_master=63.998285 -//FixedMod1=57.021464,Carbamidomethyl (C) - else if (header_list[1].startsWith("FixedMod")) { - unsigned index = header_list[1].mid(8).toUInt(); - _fixed_modification_list.push_back(MascotModification()); - QStringList fixed_mod_list = header_list[2].split(","); - pappso::pappso_double mass = fixed_mod_list[0].toDouble(); - //_number_of_residues = header_list[2].toUInt(); - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << header_list[2]; - - if (fixed_mod_list[1] == "Carbamidomethyl (C)") { - _fixed_modification_list[index-1].modification = pappso::AaModification::getInstance("MOD:00397"); - _fixed_modification_list[index-1].residue = 'C'; + // NeutralLoss1=0.000000 + // NeutralLoss1_master=63.998285 + // FixedMod1=57.021464,Carbamidomethyl (C) + else if(header_list[1].startsWith("FixedMod")) + { + unsigned index = header_list[1].mid(8).toUInt(); + _fixed_modification_list.push_back(MascotModification()); + QStringList fixed_mod_list = header_list[2].split(","); + pappso::pappso_double mass = fixed_mod_list[0].toDouble(); + //_number_of_residues = header_list[2].toUInt(); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << header_list[2]; + + if(fixed_mod_list[1] == "Carbamidomethyl (C)") + { + _fixed_modification_list[index - 1].modification = + pappso::AaModification::getInstance("MOD:00397"); + _fixed_modification_list[index - 1].residue = 'C'; } - else { - _fixed_modification_list[index-1].modification = pappso::AaModification::getInstanceCustomizedMod(mass); + else + { + _fixed_modification_list[index - 1].modification = + pappso::AaModification::getInstanceCustomizedMod(mass); } } } - else { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " QREGEXP does not work on " << masses_line; + else + { + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ + << " QREGEXP does not work on " << masses_line; } - - - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << _fixed_modification_list.size(); -} -void MascotDatParser::parseProteinLine(const QString & protein_line) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << protein_line; - ProteinXtpSp sp_xtp_protein; - //02::"tr|A0A0D9SF80|A0A0D9SF80_HUMAN"=55120.88,"General transcription factor II-I repeat domain-containing protein 2A OS=Homo sapiens GN=GTF2IRD2B PE=4 SV=1" - QRegExp regexp_protein("^(.*)::\"(.*)\"=([0-9]+\\.[0-9]+),\"(.*)\"$"); - if (regexp_protein.exactMatch(protein_line)) { - QStringList protein_list = regexp_protein.capturedTexts(); - FastaFileSp fasta_file_sp = _fasta_file_list[protein_list[1].toUInt()-1]; - _current_protein.setAccession(protein_list[2]); - _current_protein.setDescription(protein_list[4]); - _current_protein.setFastaFileP(fasta_file_sp.get()); - - sp_xtp_protein = _current_protein.makeProteinXtpSp(); - sp_xtp_protein = _p_project->getProteinStore().getInstance(sp_xtp_protein); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << _fixed_modification_list.size(); +} + +void +MascotDatParser::parseProteinLine(const QString &protein_line) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << protein_line; + ProteinXtpSp sp_xtp_protein; + // 02::"tr|A0A0D9SF80|A0A0D9SF80_HUMAN"=55120.88,"General transcription factor + // II-I repeat domain-containing protein 2A OS=Homo sapiens GN=GTF2IRD2B PE=4 + // SV=1" + QRegExp regexp_protein("^(.*)::\"(.*)\"=([0-9]+\\.[0-9]+),\"(.*)\"$"); + if(regexp_protein.exactMatch(protein_line)) + { + QStringList protein_list = regexp_protein.capturedTexts(); + FastaFileSp fasta_file_sp = + _fasta_file_list[protein_list[1].toUInt() - 1]; + _current_protein.setAccession(protein_list[2]); + _current_protein.setDescription(protein_list[4]); + _current_protein.setFastaFileP(fasta_file_sp.get()); + + sp_xtp_protein = _current_protein.makeProteinXtpSp(); + sp_xtp_protein = + _p_project->getProteinStore().getInstance(sp_xtp_protein); } - else { - QRegExp regexp_proteinb("^\"(.*)\"=([0-9]+\\.[0-9]+),\"(.*)\"$"); - if (regexp_proteinb.exactMatch(protein_line)) { - QStringList protein_list = regexp_proteinb.capturedTexts(); - FastaFileSp fasta_file_sp = _fasta_file_list[0]; - - _current_protein.setAccession(protein_list[1]); - _current_protein.setDescription(protein_list[3]); - _current_protein.setFastaFileP(fasta_file_sp.get()); - - sp_xtp_protein = _current_protein.makeProteinXtpSp(); - sp_xtp_protein = _p_project->getProteinStore().getInstance(sp_xtp_protein); + else + { + QRegExp regexp_proteinb("^\"(.*)\"=([0-9]+\\.[0-9]+),\"(.*)\"$"); + if(regexp_proteinb.exactMatch(protein_line)) + { + QStringList protein_list = regexp_proteinb.capturedTexts(); + FastaFileSp fasta_file_sp = _fasta_file_list[0]; + + _current_protein.setAccession(protein_list[1]); + _current_protein.setDescription(protein_list[3]); + _current_protein.setFastaFileP(fasta_file_sp.get()); + + sp_xtp_protein = _current_protein.makeProteinXtpSp(); + sp_xtp_protein = + _p_project->getProteinStore().getInstance(sp_xtp_protein); } - else { - qDebug() << "MascotDatParser::parseProteinLine error " << protein_line; + else + { + qDebug() << "MascotDatParser::parseProteinLine error " + << protein_line; } } } -void MascotDatParser::parseHeaderLine(const QString & header_line) { - if (_regexp_header_line.exactMatch(header_line)) { - QStringList header_list = _regexp_header_line.capturedTexts(); -//sequences=73998 -//sequences_after_tax=73998 -//residues=24900901 - if (header_list[1].startsWith("residues")) { - qDebug() << "queries=" << header_list[2]; - _number_of_residues = header_list[2].toUInt(); +void +MascotDatParser::parseHeaderLine(const QString &header_line) +{ + if(_regexp_header_line.exactMatch(header_line)) + { + QStringList header_list = _regexp_header_line.capturedTexts(); + // sequences=73998 + // sequences_after_tax=73998 + // residues=24900901 + if(header_list[1].startsWith("residues")) + { + qDebug() << "queries=" << header_list[2]; + _number_of_residues = header_list[2].toUInt(); } -//distribution=64847,0,1,576,2254,1934,1417,984,683,419,238,192,113,89,74,46,23,32,28,21,11,3,2,3,3,2,1,1,0,0,0,0,0,0,1 -//decoy_type=1 -//distribution_decoy=65162,0,1,552,2259,1891,1422,957,601,376,192,159,126,73,56,64,26,27,22,14,6,4,1,1,3,2,1 -//exec_time=484 -//date=1517587671 -//time=17:07:51 -//queries=54084 - else if (header_list[1].startsWith("queries")) { - qDebug() << "queries=" << header_list[2]; - _number_of_queries = header_list[2].toUInt(); - _query_peptide_results.resize(_number_of_queries); - _summary_list.resize(_number_of_queries); - _decoy_query_peptide_results.resize(_number_of_queries); - _decoy_summary_list.resize(_number_of_queries); + // distribution=64847,0,1,576,2254,1934,1417,984,683,419,238,192,113,89,74,46,23,32,28,21,11,3,2,3,3,2,1,1,0,0,0,0,0,0,1 + // decoy_type=1 + // distribution_decoy=65162,0,1,552,2259,1891,1422,957,601,376,192,159,126,73,56,64,26,27,22,14,6,4,1,1,3,2,1 + // exec_time=484 + // date=1517587671 + // time=17:07:51 + // queries=54084 + else if(header_list[1].startsWith("queries")) + { + qDebug() << "queries=" << header_list[2]; + _number_of_queries = header_list[2].toUInt(); + _query_peptide_results.resize(_number_of_queries); + _summary_list.resize(_number_of_queries); + _decoy_query_peptide_results.resize(_number_of_queries); + _decoy_summary_list.resize(_number_of_queries); } -//min_peaks_for_homology=6 -//max_hits=50 -//version=2.5.0 - else if (header_list[1] == "version") { - _p_identification_data_source->setIdentificationEngineVersion(header_list[2]); + // min_peaks_for_homology=6 + // max_hits=50 + // version=2.5.0 + else if(header_list[1] == "version") + { + _p_identification_data_source->setIdentificationEngineVersion( + header_list[2]); } -//fastafile=C:/inetpub/mascot/sequence/ECOLI_INRA/current/ECOLI_INRA_1.fasta - else if (header_list[1].startsWith("fastafile")) { - qDebug() << "fastafile=" << header_list[2]; - _fasta_file_list.push_back( _p_project->getFastaFileStore().getInstance(FastaFile(header_list[2]))); - - _p_identification_data_source->addFastaFile(_fasta_file_list.back()); + // fastafile=C:/inetpub/mascot/sequence/ECOLI_INRA/current/ECOLI_INRA_1.fasta + else if(header_list[1].startsWith("fastafile")) + { + qDebug() << "fastafile=" << header_list[2]; + _fasta_file_list.push_back( + _p_project->getFastaFileStore().getInstance( + FastaFile(header_list[2]))); + + _p_identification_data_source->addFastaFile(_fasta_file_list.back()); } -//release=ECOLI_INRA_1.fasta -//sequences1=4305 -//sequences_after_tax1=4305 -//residues1=1356026 -//fastafile2=C:/inetpub/mascot/sequence/HUMAN_INRA/current/HUMAN_INRA_1.fasta -//release2=HUMAN_INRA_1.fasta -//sequences2=69693 -//sequences_after_tax2=69693 -//residues2=23544875 -//taskid=151758718701 + // release=ECOLI_INRA_1.fasta + // sequences1=4305 + // sequences_after_tax1=4305 + // residues1=1356026 + // fastafile2=C:/inetpub/mascot/sequence/HUMAN_INRA/current/HUMAN_INRA_1.fasta + // release2=HUMAN_INRA_1.fasta + // sequences2=69693 + // sequences_after_tax2=69693 + // residues2=23544875 + // taskid=151758718701 } } -void MascotDatParser::parsePeptidesLine(const QString & peptide_line) { - try { - if (_regexp_header_line.exactMatch(peptide_line)) { - QStringList header_list = _regexp_header_line.capturedTexts(); - QString index = header_list[1]; - QString value = header_list[2]; - QStringList index_list = index.split("_"); - if (index_list.size() == 3) { - if (index_list[2] == "db") { - saveAndClearPeptide(); - //q1_p1_db=02 - while (value.size() > 0) { - QString fasta_str = value.mid(0,2); - _current_peptide.fasta_file_list.push_back(_fasta_file_list.at(fasta_str.toInt()-1)); - value = value.mid(2); +void +MascotDatParser::parsePeptidesLine(const QString &peptide_line) +{ + try + { + if(_regexp_header_line.exactMatch(peptide_line)) + { + QStringList header_list = _regexp_header_line.capturedTexts(); + QString index = header_list[1]; + QString value = header_list[2]; + QStringList index_list = index.split("_"); + if(index_list.size() == 3) + { + if(index_list[2] == "db") + { + saveAndClearPeptide(); + // q1_p1_db=02 + while(value.size() > 0) + { + QString fasta_str = value.mid(0, 2); + _current_peptide.fasta_file_list.push_back( + _fasta_file_list.at(fasta_str.toInt() - 1)); + value = value.mid(2); } } - //q856_p9_subst=1,X,W - else if (index_list[2] == "subst") { - _current_peptide.subst = value; + // q856_p9_subst=1,X,W + else if(index_list[2] == "subst") + { + _current_peptide.subst = value; } } - else if (index_list.size() == 2) { - if (value == "-1") { - //no result for this query + else if(index_list.size() == 2) + { + if(value == "-1") + { + // no result for this query } - else { - - QString query_index = index_list[0]; - _current_peptide.query_index = query_index.mid(1).toUInt(); - QString peptide_index = index_list[1]; - _current_peptide.peptide_index = peptide_index.mid(1).toUInt(); - //q1_p1=0,597.302322,0.997884,2,GAWHK,9,0000000,7.97,0000012000000000000,0,0;"sp|O95006|OR2F2_HUMAN":0:299:303:1 - int position = value.indexOf(";\"", 0); - QString peptide_string = value.mid(0, position); - //qDebug() << "peptide_string=" << peptide_string; - - _current_peptide.peptide_string_list = peptide_string.split(","); - - - - QString protein_string = value.mid(position+2); - //qDebug() << "protein_string=" << protein_string; - //"sp|Q9Y2I7|FYV1_HUMAN":0:670:675:2,"tr|E9PDH4|E9PDH4_HUMAN":0:614:619:2 - _current_peptide.protein_string_list = protein_string.split(",\""); + else + { + + QString query_index = index_list[0]; + _current_peptide.query_index = query_index.mid(1).toUInt(); + QString peptide_index = index_list[1]; + _current_peptide.peptide_index = + peptide_index.mid(1).toUInt(); + // q1_p1=0,597.302322,0.997884,2,GAWHK,9,0000000,7.97,0000012000000000000,0,0;"sp|O95006|OR2F2_HUMAN":0:299:303:1 + int position = value.indexOf(";\"", 0); + QString peptide_string = value.mid(0, position); + // qDebug() << "peptide_string=" << peptide_string; + + _current_peptide.peptide_string_list = + peptide_string.split(","); + + + QString protein_string = value.mid(position + 2); + // qDebug() << "protein_string=" << protein_string; + //"sp|Q9Y2I7|FYV1_HUMAN":0:670:675:2,"tr|E9PDH4|E9PDH4_HUMAN":0:614:619:2 + _current_peptide.protein_string_list = + protein_string.split(",\""); } - - } - /* - q1_p1_db=02 - q1_p1=0,597.302322,0.997884,2,GAWHK,9,0000000,7.97,0000012000000000000,0,0;"sp|O95006|OR2F2_HUMAN":0:299:303:1 - q1_p1_terms=K,L - q1_p2_db=02 - q1_p2=1,598.296219,0.003987,2,KEEPP,11,0000000,1.32,0002000000000000000,0,0;"tr|E9PNM8|E9PNM8_HUMAN":0:134:138:1 - q1_p2_terms=R,- - q2_p1_db=02 - q2_p1=1,598.380234,-0.000316,3,KAGVPK,13,00000000,17.13,0002011000000000000,0,0;"tr|H7C1P9|H7C1P9_HUMAN":0:945:950:2 - q2_p1_terms=K,K - q2_p2_db=0202 - q2_p2=1,598.380234,-0.000316,2,KQPVK,9,0000000,9.54,0002011000000000000,0,0;"sp|P33527|MRP1_HUMAN":0:270:274:1,"tr|I3L4X2|I3L4X2_HUMAN":0:169:173:1 - q2_p2_terms=R,V:R,V - q2_p3_db=02 - q2_p3=1,598.380234,-0.000316,2,KAVPGK,13,00000000,7.03,0002001000000000000,0,0;"sp|Q13061|TRDN_HUMAN":0:440:445:2 - q2_p3_terms=K,K - q2_p4_db=0202 - q2_p4=1,598.380234,-0.000316,2,IPGGKK,14,00000000,1.26,0002001000000000000,0,0;"sp|Q9Y2I7|FYV1_HUMAN":0:670:675:2,"tr|E9PDH4|E9PDH4_HUMAN":0:614:619:2 - q2_p4_terms=K,F:K,F - */ - - - /* - q856_p9_db=0202 - q856_p9=0,685.427521,-0.000117,3,XLLVR,12,0000000,13.68,0000002000000000000,0,0;"tr|V9GY00|V9GY00_HUMAN":0:1:5:1,"tr|H7C3C3|H7C3C3_HUMAN":0:1:5:1 - q856_p9_terms=-,L:-,V - q856_p9_subst=1,X,W - */ - + /* + q1_p1_db=02 + q1_p1=0,597.302322,0.997884,2,GAWHK,9,0000000,7.97,0000012000000000000,0,0;"sp|O95006|OR2F2_HUMAN":0:299:303:1 + q1_p1_terms=K,L + q1_p2_db=02 + q1_p2=1,598.296219,0.003987,2,KEEPP,11,0000000,1.32,0002000000000000000,0,0;"tr|E9PNM8|E9PNM8_HUMAN":0:134:138:1 + q1_p2_terms=R,- + q2_p1_db=02 + q2_p1=1,598.380234,-0.000316,3,KAGVPK,13,00000000,17.13,0002011000000000000,0,0;"tr|H7C1P9|H7C1P9_HUMAN":0:945:950:2 + q2_p1_terms=K,K + q2_p2_db=0202 + q2_p2=1,598.380234,-0.000316,2,KQPVK,9,0000000,9.54,0002011000000000000,0,0;"sp|P33527|MRP1_HUMAN":0:270:274:1,"tr|I3L4X2|I3L4X2_HUMAN":0:169:173:1 + q2_p2_terms=R,V:R,V + q2_p3_db=02 + q2_p3=1,598.380234,-0.000316,2,KAVPGK,13,00000000,7.03,0002001000000000000,0,0;"sp|Q13061|TRDN_HUMAN":0:440:445:2 + q2_p3_terms=K,K + q2_p4_db=0202 + q2_p4=1,598.380234,-0.000316,2,IPGGKK,14,00000000,1.26,0002001000000000000,0,0;"sp|Q9Y2I7|FYV1_HUMAN":0:670:675:2,"tr|E9PDH4|E9PDH4_HUMAN":0:614:619:2 + q2_p4_terms=K,F:K,F + */ + + + /* + q856_p9_db=0202 + q856_p9=0,685.427521,-0.000117,3,XLLVR,12,0000000,13.68,0000002000000000000,0,0;"tr|V9GY00|V9GY00_HUMAN":0:1:5:1,"tr|H7C3C3|H7C3C3_HUMAN":0:1:5:1 + q856_p9_terms=-,L:-,V + q856_p9_subst=1,X,W + */ } } - catch (pappso::PappsoException exception_pappso) { - _error_str = QObject::tr("ERROR in MascotDatParser::parsePeptidesLine %1, PAPPSO exception:\n%2").arg(peptide_line).arg(exception_pappso.qwhat()); - qDebug() << _error_str; - throw pappso::PappsoException(_error_str); + catch(pappso::PappsoException exception_pappso) + { + _error_str = QObject::tr("ERROR in MascotDatParser::parsePeptidesLine " + "%1, PAPPSO exception:\n%2") + .arg(peptide_line) + .arg(exception_pappso.qwhat()); + qDebug() << _error_str; + throw pappso::PappsoException(_error_str); } - catch (std::exception exception_std) { - _error_str = QObject::tr("ERROR in MascotDatParser::parsePeptidesLine %1, std exception:\n%2").arg(peptide_line).arg(exception_std.what()); - qDebug() << _error_str; - throw pappso::PappsoException(_error_str); + catch(std::exception exception_std) + { + _error_str = + QObject::tr( + "ERROR in MascotDatParser::parsePeptidesLine %1, std exception:\n%2") + .arg(peptide_line) + .arg(exception_std.what()); + qDebug() << _error_str; + throw pappso::PappsoException(_error_str); } } -void MascotDatParser::parseQueryLine(const QString & query_line) { - try { - if (_regexp_header_line.exactMatch(query_line)) { - QStringList header_list = _regexp_header_line.capturedTexts(); - QString index = header_list[1]; - QString value = header_list[2]; +void +MascotDatParser::parseQueryLine(const QString &query_line) +{ + try + { + if(_regexp_header_line.exactMatch(query_line)) + { + QStringList header_list = _regexp_header_line.capturedTexts(); + QString index = header_list[1]; + QString value = header_list[2]; - //title=FULL%20ISSLGSVGAGIVAVKK%20N22213%20%20%20QEP1_SpikeIn_230914_1_3ng_270914%2e35282%2e35282%2e2 - if (index == "title") { - _current_query.title = value; + // title=FULL%20ISSLGSVGAGIVAVKK%20N22213%20%20%20QEP1_SpikeIn_230914_1_3ng_270914%2e35282%2e35282%2e2 + if(index == "title") + { + _current_query.title = value; } - //rtinseconds=5703.84 - else if (index == "rtinseconds") { - _current_query.rt = value.toDouble(); + // rtinseconds=5703.84 + else if(index == "rtinseconds") + { + _current_query.rt = value.toDouble(); } - //index=44035 - else if (index == "index") { - _current_query.query_index = value.toUInt(); + // index=44035 + else if(index == "index") + { + _current_query.query_index = value.toUInt(); } - //charge=2+ - else if (index == "charge") { - _current_query.charge = value.mid(0,value.size()-1).toUInt(); + // charge=2+ + else if(index == "charge") + { + _current_query.charge = value.mid(0, value.size() - 1).toUInt(); } } - /* - mass_min=129.102051 - mass_max=1198.751099 - int_min=2327 - int_max=6.845e+005 - num_vals=44 - num_used1=-1 - Ions1=129.102051:1.111e+005,275.207306:9.008e+004,374.275299:9.717e+004,514.825623:1.929e+004,599.878906:1.472e+005,714.431519:1.356e+004,815.466003:9643,924.570435:4428,1028.645630:1.257e+005,1085.665527:6.845e+005,1198.751099:1.858e+005,147.112656:7.954e+004,261.159271:4.327e+004,357.248169:2.192e+004,506.312775:3319,543.336548:1.083e+005,655.376465:9786,1011.625977:1.747e+004,1068.641602:9.804e+004,1181.725342:2.712e+004,130.086014:3.602e+004,257.197388:1.455e+004,357.212097:3960,591.370056:2.454e+004,972.547058:3819,1069.647583:4.457e+004,201.123077:1.566e+004,299.171783:1.421e+004,534.825562:1.036e+004,1087.671631:2.374e+004,173.128418:1.512e+004,244.129089:1.052e+004,590.873291:8065,1067.656006:2.235e+004,228.133957:1.35e+004,258.180115:3194,534.333374:3635,1096.635376:1.549e+004,200.139084:1.026e+004,535.328552:3006,1070.637085:4813,183.112442:9925,131.080994:4806,211.108139:2327 - - */ + /* + mass_min=129.102051 + mass_max=1198.751099 + int_min=2327 + int_max=6.845e+005 + num_vals=44 + num_used1=-1 + Ions1=129.102051:1.111e+005,275.207306:9.008e+004,374.275299:9.717e+004,514.825623:1.929e+004,599.878906:1.472e+005,714.431519:1.356e+004,815.466003:9643,924.570435:4428,1028.645630:1.257e+005,1085.665527:6.845e+005,1198.751099:1.858e+005,147.112656:7.954e+004,261.159271:4.327e+004,357.248169:2.192e+004,506.312775:3319,543.336548:1.083e+005,655.376465:9786,1011.625977:1.747e+004,1068.641602:9.804e+004,1181.725342:2.712e+004,130.086014:3.602e+004,257.197388:1.455e+004,357.212097:3960,591.370056:2.454e+004,972.547058:3819,1069.647583:4.457e+004,201.123077:1.566e+004,299.171783:1.421e+004,534.825562:1.036e+004,1087.671631:2.374e+004,173.128418:1.512e+004,244.129089:1.052e+004,590.873291:8065,1067.656006:2.235e+004,228.133957:1.35e+004,258.180115:3194,534.333374:3635,1096.635376:1.549e+004,200.139084:1.026e+004,535.328552:3006,1070.637085:4813,183.112442:9925,131.080994:4806,211.108139:2327 + + */ } - catch (pappso::PappsoException exception_pappso) { - _error_str = QObject::tr("ERROR in MascotDatParser::parseQueryLine %1, PAPPSO exception:\n%2").arg(query_line).arg(exception_pappso.qwhat()); - qDebug() << _error_str; - throw pappso::PappsoException(_error_str); + catch(pappso::PappsoException exception_pappso) + { + _error_str = + QObject::tr( + "ERROR in MascotDatParser::parseQueryLine %1, PAPPSO exception:\n%2") + .arg(query_line) + .arg(exception_pappso.qwhat()); + qDebug() << _error_str; + throw pappso::PappsoException(_error_str); } - catch (std::exception exception_std) { - _error_str = QObject::tr("ERROR in MascotDatParser::parseQueryLine %1, std exception:\n%2").arg(query_line).arg(exception_std.what()); - qDebug() << _error_str; - throw pappso::PappsoException(_error_str); + catch(std::exception exception_std) + { + _error_str = + QObject::tr( + "ERROR in MascotDatParser::parseQueryLine %1, std exception:\n%2") + .arg(query_line) + .arg(exception_std.what()); + qDebug() << _error_str; + throw pappso::PappsoException(_error_str); } } -void MascotDatParser::parseSummaryLine(const QString & summary_line) { - std::vector<SummaryLine> * p_summary_list = & _summary_list; - if (_is_decoy_section) { - p_summary_list = & _decoy_summary_list; +void +MascotDatParser::parseSummaryLine(const QString &summary_line) +{ + std::vector<SummaryLine> *p_summary_list = &_summary_list; + if(_is_decoy_section) + { + p_summary_list = &_decoy_summary_list; } - if (_regexp_header_line.exactMatch(summary_line)) { - QStringList header_list = _regexp_header_line.capturedTexts(); - QString index = header_list[1]; - QString value = header_list[2]; - - - //qmass1=598.300206 - if (index.startsWith("qmass")) { - unsigned int query_index = index.mid(5).toUInt(); - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " " << query_index << " " << index; - //_current_query.title = value; - (*p_summary_list)[query_index-1].exp_mass=value.toDouble(); + if(_regexp_header_line.exactMatch(summary_line)) + { + QStringList header_list = _regexp_header_line.capturedTexts(); + QString index = header_list[1]; + QString value = header_list[2]; + + + // qmass1=598.300206 + if(index.startsWith("qmass")) + { + unsigned int query_index = index.mid(5).toUInt(); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << query_index << " " << index; + //_current_query.title = value; + (*p_summary_list)[query_index - 1].exp_mass = value.toDouble(); } - //qexp1=300.157379,2+ -//qintensity1=2054822.6250 -//qmatch1=73 - else if (index.startsWith("qmatch")) { - unsigned int query_index = index.mid(6).toUInt(); - //_current_query.title = value; - (*p_summary_list)[query_index-1].match=value.toDouble(); + // qexp1=300.157379,2+ + // qintensity1=2054822.6250 + // qmatch1=73 + else if(index.startsWith("qmatch")) + { + unsigned int query_index = index.mid(6).toUInt(); + //_current_query.title = value; + (*p_summary_list)[query_index - 1].match = value.toDouble(); } -//qplughole1=14.820890 - else if (index.startsWith("qplughole")) { - unsigned int query_index = index.mid(9).toUInt(); - //_current_query.title = value; - (*p_summary_list)[query_index-1].plug_hole=value.toDouble(); + // qplughole1=14.820890 + else if(index.startsWith("qplughole")) + { + unsigned int query_index = index.mid(9).toUInt(); + //_current_query.title = value; + (*p_summary_list)[query_index - 1].plug_hole = value.toDouble(); } - } } -void MascotDatParser::saveAndClearPeptide() { - //qDebug() << "MascotDatParser::saveAndClearPeptide begin"; - if (_current_peptide.query_index > 0) { - // save - if (_is_decoy_section) { - _decoy_query_peptide_results[_current_peptide.query_index-1].push_back(_current_peptide); +void +MascotDatParser::saveAndClearPeptide() +{ + // qDebug() << "MascotDatParser::saveAndClearPeptide begin"; + if(_current_peptide.query_index > 0) + { + // save + if(_is_decoy_section) + { + _decoy_query_peptide_results[_current_peptide.query_index - 1] + .push_back(_current_peptide); } - else { - _query_peptide_results[_current_peptide.query_index-1].push_back(_current_peptide); + else + { + _query_peptide_results[_current_peptide.query_index - 1].push_back( + _current_peptide); } } - //new peptide query clear - _current_peptide.peptide_string_list.clear(); - _current_peptide.fasta_file_list.clear(); - _current_peptide.query_index = 0; - _current_peptide.subst = ""; - //qDebug() << "MascotDatParser::saveAndClearPeptide end"; + // new peptide query clear + _current_peptide.peptide_string_list.clear(); + _current_peptide.fasta_file_list.clear(); + _current_peptide.query_index = 0; + _current_peptide.subst = ""; + // qDebug() << "MascotDatParser::saveAndClearPeptide end"; } -void MascotDatParser::saveQuery() { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - if (_current_query.query_index > 0) { - std::vector< PeptideLine> peptide_list = _query_peptide_results[_current_query.query_index-1]; - savePeptideList(peptide_list, false); - peptide_list = _decoy_query_peptide_results[_current_query.query_index-1]; - savePeptideList(peptide_list, true); +void +MascotDatParser::saveQuery() +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + if(_current_query.query_index > 0) + { + std::vector<PeptideLine> peptide_list = + _query_peptide_results[_current_query.query_index - 1]; + savePeptideList(peptide_list, false); + peptide_list = + _decoy_query_peptide_results[_current_query.query_index - 1]; + savePeptideList(peptide_list, true); } - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void MascotDatParser::savePeptideList(std::vector< PeptideLine> & peptide_list, bool is_decoy) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - - PeptideEvidence peptide_evidence(_p_identification_data_source->getMsRunSp().get(),_current_query.query_index); - peptide_evidence.setCharge(_current_query.charge); - peptide_evidence.setChecked(true); - peptide_evidence.setExperimentalMass(_summary_list[_current_query.query_index-1].exp_mass); - peptide_evidence.setRetentionTime(_current_query.rt); - - peptide_evidence.setIdentificationDataSource( _p_identification_data_source); - //parse and save - for(PeptideLine & peptide_line:peptide_list) { - - /* - * - 0 setMissedCleavages(Integer.parseInt(st.nextToken())); - 1 setPeptideMr(Double.parseDouble(st.nextToken())); - 2 setDeltaMass(Double.parseDouble(st.nextToken())); - 3 setNumberOfIonsMatched(Integer.parseInt(st.nextToken())); - 4 setSequence(st.nextToken()); - 5 setPeaksUsedFromIons1(Integer.parseInt(st.nextToken())); - 6 setVariableModificationsArray(st.nextToken()); - 7 setIonsScore(Double.parseDouble(st.nextToken())); - 8 parseIonSeries(st.nextToken()); - 9 setPeaksUsedFromIons2(Integer.parseInt(st.nextToken())); - 10 setPeaksUsedFromIons3(Integer.parseInt(st.nextToken())); - */ - pappso::pappso_double ion_score = peptide_line.peptide_string_list.at(7).toDouble(); - peptide_evidence.setParam(PeptideEvidenceParam::mascot_score, QVariant(ion_score)); - - if (is_decoy) { - peptide_evidence.setEvalue(getEvalue(ion_score, _decoy_summary_list.at(_current_query.query_index-1), 0.05)); +void +MascotDatParser::savePeptideList(std::vector<PeptideLine> &peptide_list, + bool is_decoy) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + + PeptideEvidence peptide_evidence( + _p_identification_data_source->getMsRunSp().get(), + _current_query.query_index); + peptide_evidence.setCharge(_current_query.charge); + peptide_evidence.setChecked(true); + peptide_evidence.setExperimentalMass( + _summary_list[_current_query.query_index - 1].exp_mass); + peptide_evidence.setRetentionTime(_current_query.rt); + + peptide_evidence.setIdentificationDataSource(_p_identification_data_source); + // parse and save + for(PeptideLine &peptide_line : peptide_list) + { + + /* + * + 0 setMissedCleavages(Integer.parseInt(st.nextToken())); + 1 setPeptideMr(Double.parseDouble(st.nextToken())); + 2 setDeltaMass(Double.parseDouble(st.nextToken())); + 3 setNumberOfIonsMatched(Integer.parseInt(st.nextToken())); + 4 setSequence(st.nextToken()); + 5 setPeaksUsedFromIons1(Integer.parseInt(st.nextToken())); + 6 setVariableModificationsArray(st.nextToken()); + 7 setIonsScore(Double.parseDouble(st.nextToken())); + 8 parseIonSeries(st.nextToken()); + 9 setPeaksUsedFromIons2(Integer.parseInt(st.nextToken())); + 10 setPeaksUsedFromIons3(Integer.parseInt(st.nextToken())); + */ + pappso::pappso_double ion_score = + peptide_line.peptide_string_list.at(7).toDouble(); + peptide_evidence.setParam(PeptideEvidenceParam::mascot_score, + QVariant(ion_score)); + + if(is_decoy) + { + peptide_evidence.setEvalue(getEvalue( + ion_score, _decoy_summary_list.at(_current_query.query_index - 1), + 0.05)); } - else { - peptide_evidence.setEvalue(getEvalue(ion_score, _summary_list.at(_current_query.query_index-1), 0.05)); + else + { + peptide_evidence.setEvalue(getEvalue( + ion_score, _summary_list.at(_current_query.query_index - 1), 0.05)); } - peptide_evidence.setParam(PeptideEvidenceParam::mascot_expectation_value, QVariant(peptide_evidence.getEvalue())); - - QString peptide_str =peptide_line.peptide_string_list.at(4); - if (!peptide_line.subst.isEmpty()) { - //q856_p9_subst=1,X,W - //q24379_p2_subst=1,B,D,8,B,D - QStringList subst_list = peptide_line.subst.split(","); - for (unsigned int i=0; i < subst_list.size(); i+=3) { - peptide_str = peptide_str.replace(subst_list.at(0+i).toInt()-1,1,subst_list.at(2+i)); + peptide_evidence.setParam(PeptideEvidenceParam::mascot_expectation_value, + QVariant(peptide_evidence.getEvalue())); + + QString peptide_str = peptide_line.peptide_string_list.at(4); + if(!peptide_line.subst.isEmpty()) + { + // q856_p9_subst=1,X,W + // q24379_p2_subst=1,B,D,8,B,D + QStringList subst_list = peptide_line.subst.split(","); + for(unsigned int i = 0; i < subst_list.size(); i += 3) + { + peptide_str = peptide_str.replace( + subst_list.at(0 + i).toInt() - 1, 1, subst_list.at(2 + i)); } } - PeptideXtpSp peptide_sp; - peptide_sp = PeptideXtp(peptide_str).makePeptideXtpSp(); - - //variable modifications : - setVariableModifications(peptide_sp, peptide_line.peptide_string_list.at(6)); - - //fixed modifications : - for (unsigned int i=0; i < peptide_str.size(); i++) { - for (MascotModification mascot_modif :_fixed_modification_list) { - if (peptide_str.at(i) == mascot_modif.residue) { - peptide_sp.get()->addAaModification(mascot_modif.modification, i); + PeptideXtpSp peptide_sp; + peptide_sp = PeptideXtp(peptide_str).makePeptideXtpSp(); + + // variable modifications : + setVariableModifications(peptide_sp, + peptide_line.peptide_string_list.at(6)); + + // fixed modifications : + for(unsigned int i = 0; i < peptide_str.size(); i++) + { + for(MascotModification mascot_modif : _fixed_modification_list) + { + if(peptide_str.at(i) == mascot_modif.residue) + { + peptide_sp.get()->addAaModification(mascot_modif.modification, + i); } } } - peptide_evidence.setPeptideXtpSp(_p_project->getPeptideStore().getInstance(peptide_sp)); + peptide_evidence.setPeptideXtpSp( + _p_project->getPeptideStore().getInstance(peptide_sp)); - //qDebug() << __FILE__ << " " << __FUNCTION__<< " peptide=" << peptide_str << " evalue=" << peptide_evidence.getEvalue() << " ionscore=" << ion_score; + // qDebug() << __FILE__ << " " << __FUNCTION__<< " peptide=" << + // peptide_str << " evalue=" << peptide_evidence.getEvalue() << " + // ionscore=" << ion_score; - if (peptide_line.protein_string_list.size() != peptide_line.fasta_file_list.size()) { - throw pappso::PappsoException(QObject::tr("ERROR (peptide_line.protein_string_list.size() != peptide_line.fasta_file_list.size()) %1").arg(peptide_line.protein_string_list.join(",\""))); + if(peptide_line.protein_string_list.size() != + peptide_line.fasta_file_list.size()) + { + throw pappso::PappsoException( + QObject::tr("ERROR (peptide_line.protein_string_list.size() != " + "peptide_line.fasta_file_list.size()) %1") + .arg(peptide_line.protein_string_list.join(",\""))); } - unsigned int i=0; - foreach (const QString &str, peptide_line.protein_string_list) { - //sp|O95006|OR2F2_HUMAN":0:299:303:1 - int position = str.indexOf("\"", 0); - QString accession = str.mid(0, position); - if (is_decoy) { - accession = QString("%1|reversed").arg(accession); + unsigned int i = 0; + foreach(const QString &str, peptide_line.protein_string_list) + { + // sp|O95006|OR2F2_HUMAN":0:299:303:1 + int position = str.indexOf("\"", 0); + QString accession = str.mid(0, position); + if(is_decoy) + { + accession = QString("%1|reversed").arg(accession); } - //qDebug() << "accession=" << accession; - QStringList position_list = str.mid(position+2).split(":"); - if (position_list.size() != 4) { - throw pappso::PappsoException(QObject::tr("ERROR position_list.size() != 4 %1").arg(str)); + // qDebug() << "accession=" << accession; + QStringList position_list = str.mid(position + 2).split(":"); + if(position_list.size() != 4) + { + throw pappso::PappsoException( + QObject::tr("ERROR position_list.size() != 4 %1").arg(str)); } - unsigned int start = position_list.at(1).toUInt()-1; - unsigned int stop = position_list.at(2).toUInt()-1; - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - ProteinXtp protein; - protein.setAccession(accession); - protein.setFastaFileP(peptide_line.fasta_file_list[i].get()); - if (is_decoy) { - protein.setIsDecoy(true); + unsigned int start = position_list.at(1).toUInt() - 1; + unsigned int stop = position_list.at(2).toUInt() - 1; + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + ProteinXtp protein; + protein.setAccession(accession); + protein.setFastaFileP(peptide_line.fasta_file_list[i].get()); + if(is_decoy) + { + protein.setIsDecoy(true); } - ProteinMatch * p_protein_match = _p_identification_group->getProteinMatchInstance(accession); - if (p_protein_match == nullptr) { - throw pappso::PappsoException(QObject::tr("ERROR (p_protein_match == nullptr) %1").arg(str)); + ProteinMatch *p_protein_match = + _p_identification_group->getProteinMatchInstance(accession); + if(p_protein_match == nullptr) + { + throw pappso::PappsoException( + QObject::tr("ERROR (p_protein_match == nullptr) %1").arg(str)); } - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - ProteinXtpSp sp_xtp_protein = protein.makeProteinXtpSp(); - p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein)); - p_protein_match->setChecked(true); - - PeptideMatch peptide_match; - peptide_match.setStart(start); - peptide_match.setPeptideEvidenceSp(_p_identification_data_source->getPeptideEvidenceStore().getInstance(&peptide_evidence)); - - p_protein_match->addPeptideMatch(peptide_match); - i++; + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + ProteinXtpSp sp_xtp_protein = protein.makeProteinXtpSp(); + p_protein_match->setProteinXtpSp( + _p_project->getProteinStore().getInstance(sp_xtp_protein)); + p_protein_match->setChecked(true); + + PeptideMatch peptide_match; + peptide_match.setStart(start); + peptide_match.setPeptideEvidenceSp( + _p_identification_data_source->getPeptideEvidenceStore() + .getInstance(&peptide_evidence)); + + p_protein_match->addPeptideMatch(peptide_match); + i++; } } - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -pappso::pappso_double MascotDatParser::getEvalue(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval) const { - pappso::pappso_double identity_threshold = (pappso::pappso_double)10.0 * std::log(summary_line.match / (confidence_interval * (pappso::pappso_double)20.0)) / log((pappso::pappso_double)10);; - return (confidence_interval * pow((pappso::pappso_double)10, ((identity_threshold - ion_score) / (pappso::pappso_double)10))); +pappso::pappso_double +MascotDatParser::getEvalue(pappso::pappso_double ion_score, + SummaryLine &summary_line, + pappso::pappso_double confidence_interval) const +{ + pappso::pappso_double identity_threshold = + (pappso::pappso_double)10.0 * + std::log(summary_line.match / + (confidence_interval * (pappso::pappso_double)20.0)) / + log((pappso::pappso_double)10); + ; + return (confidence_interval * + pow((pappso::pappso_double)10, + ((identity_threshold - ion_score) / (pappso::pappso_double)10))); } -pappso::pappso_double MascotDatParser::getEvalueExperimental(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval) const { - // Evalue experimental Homology threshold (QPlughole value from .dat file). - pappso::pappso_double eval = (ion_score - summary_line.plug_hole) / (pappso::pappso_double)10; - eval = confidence_interval / pow((pappso::pappso_double)10, eval); +pappso::pappso_double +MascotDatParser::getEvalueExperimental( + pappso::pappso_double ion_score, SummaryLine &summary_line, + pappso::pappso_double confidence_interval) const +{ + // Evalue experimental Homology threshold (QPlughole value from .dat file). + pappso::pappso_double eval = + (ion_score - summary_line.plug_hole) / (pappso::pappso_double)10; + eval = confidence_interval / pow((pappso::pappso_double)10, eval); } -void MascotDatParser::setVariableModifications(PeptideXtpSp & peptide_sp, QString variable_modifications_string) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - // - for (unsigned int i=0; i < variable_modifications_string.size() ; i++) { - if (variable_modifications_string.mid(i,1).toUInt() > 0) { - MascotModification mascot_modification = _delta_modification_list[variable_modifications_string.mid(i,1).toUInt()-1]; - peptide_sp.get()->addAaModification(mascot_modification.modification, i-1); +void +MascotDatParser::setVariableModifications(PeptideXtpSp &peptide_sp, + QString variable_modifications_string) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + // + for(unsigned int i = 0; i < variable_modifications_string.size(); i++) + { + if(variable_modifications_string.mid(i, 1).toUInt() > 0) + { + MascotModification mascot_modification = _delta_modification_list + [variable_modifications_string.mid(i, 1).toUInt() - 1]; + peptide_sp.get()->addAaModification(mascot_modification.modification, + i - 1); } } } diff --git a/src/input/mascot/mascotdatparser.h b/src/input/mascot/mascotdatparser.h index 6c345406a4689da4b3a69e44df91f2513a21124f..bd170cc00018859dab0e19e6621ec318c195ecd3 100644 --- a/src/input/mascot/mascotdatparser.h +++ b/src/input/mascot/mascotdatparser.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 MASCOTDATPARSER_H #define MASCOTDATPARSER_H @@ -34,83 +35,91 @@ class MascotDatParser { -public: - MascotDatParser(Project * p_project, IdentificationGroup * p_identification_group, - IdentificationDataSource * p_identification_data_source); - virtual ~MascotDatParser(); - void parse(QIODevice * in_stream); -private: - void parseProteinLine(const QString & protein_line); - void parseHeaderLine(const QString & protein_line); - void parsePeptidesLine(const QString & peptide_line); - void parseQueryLine(const QString & query_line); - void parseSummaryLine(const QString & summary_line); - void parseMassesLine(const QString & masses_line); - void saveQuery(); - void saveAndClearPeptide(); - void setVariableModifications(PeptideXtpSp & peptide_sp, QString variable_modifications_string); - - - - struct MascotModification { - pappso::AaModificationP modification; - QChar residue; - }; - - - struct PeptideLine { - unsigned int query_index=0; - unsigned int peptide_index=0; - QString subst; - QStringList peptide_string_list; - QStringList protein_string_list; - std::vector<FastaFileSp> fasta_file_list; - }; - struct QueryLine { - unsigned int query_index=0; - unsigned int charge=0; - pappso::pappso_double rt=0; - QString title; - }; - struct SummaryLine { - pappso::pappso_double match=0; //qmatch, identity threshold - pappso::pappso_double exp_mass=0; - pappso::pappso_double plug_hole=0; //qplughole, homology threshold - }; - void savePeptideList(std::vector< PeptideLine> & peptide_list, bool is_decoy); - pappso::pappso_double getEvalue(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval = 0.05) const; - pappso::pappso_double getEvalueExperimental(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval = 0.05) const; - -private: - Project * _p_project; - IdentificationGroup * _p_identification_group; - IdentificationDataSource * _p_identification_data_source; - - - ProteinXtp _current_protein; - std::vector<FastaFileSp> _fasta_file_list; - - - - QRegExp _regexp_header_line; - unsigned int _number_of_queries=0; - unsigned int _number_of_residues=0; - unsigned int _current_query_index=0; - QString _error_str; - bool _is_decoy_section = false; - - PeptideLine _current_peptide; - QueryLine _current_query; - - std::vector<std::vector<PeptideLine>> _query_peptide_results; - std::vector<SummaryLine> _summary_list; - std::vector<std::vector<PeptideLine>> _decoy_query_peptide_results; - std::vector<SummaryLine> _decoy_summary_list; - - std::vector<MascotModification> _delta_modification_list; - std::vector<MascotModification> _fixed_modification_list; - - + public: + MascotDatParser(Project *p_project, + IdentificationGroup *p_identification_group, + IdentificationDataSource *p_identification_data_source); + virtual ~MascotDatParser(); + void parse(QIODevice *in_stream); + + private: + void parseProteinLine(const QString &protein_line); + void parseHeaderLine(const QString &protein_line); + void parsePeptidesLine(const QString &peptide_line); + void parseQueryLine(const QString &query_line); + void parseSummaryLine(const QString &summary_line); + void parseMassesLine(const QString &masses_line); + void saveQuery(); + void saveAndClearPeptide(); + void setVariableModifications(PeptideXtpSp &peptide_sp, + QString variable_modifications_string); + + + struct MascotModification + { + pappso::AaModificationP modification; + QChar residue; + }; + + + struct PeptideLine + { + unsigned int query_index = 0; + unsigned int peptide_index = 0; + QString subst; + QStringList peptide_string_list; + QStringList protein_string_list; + std::vector<FastaFileSp> fasta_file_list; + }; + struct QueryLine + { + unsigned int query_index = 0; + unsigned int charge = 0; + pappso::pappso_double rt = 0; + QString title; + }; + struct SummaryLine + { + pappso::pappso_double match = 0; // qmatch, identity threshold + pappso::pappso_double exp_mass = 0; + pappso::pappso_double plug_hole = 0; // qplughole, homology threshold + }; + void savePeptideList(std::vector<PeptideLine> &peptide_list, bool is_decoy); + pappso::pappso_double + getEvalue(pappso::pappso_double ion_score, SummaryLine &summary_line, + pappso::pappso_double confidence_interval = 0.05) const; + pappso::pappso_double + getEvalueExperimental(pappso::pappso_double ion_score, + SummaryLine &summary_line, + pappso::pappso_double confidence_interval = 0.05) const; + + private: + Project *_p_project; + IdentificationGroup *_p_identification_group; + IdentificationDataSource *_p_identification_data_source; + + + ProteinXtp _current_protein; + std::vector<FastaFileSp> _fasta_file_list; + + + QRegExp _regexp_header_line; + unsigned int _number_of_queries = 0; + unsigned int _number_of_residues = 0; + unsigned int _current_query_index = 0; + QString _error_str; + bool _is_decoy_section = false; + + PeptideLine _current_peptide; + QueryLine _current_query; + + std::vector<std::vector<PeptideLine>> _query_peptide_results; + std::vector<SummaryLine> _summary_list; + std::vector<std::vector<PeptideLine>> _decoy_query_peptide_results; + std::vector<SummaryLine> _decoy_summary_list; + + std::vector<MascotModification> _delta_modification_list; + std::vector<MascotModification> _fixed_modification_list; }; #endif // MASCOTDATPARSER_H diff --git a/src/input/mascot/mimeparser.cpp b/src/input/mascot/mimeparser.cpp index 2b566bd0ed61a38ce1295e3d7a75a9474c6abe62..9afe6a3e3f869e02d905c83efdf20bb67e76abc3 100644 --- a/src/input/mascot/mimeparser.cpp +++ b/src/input/mascot/mimeparser.cpp @@ -6,151 +6,188 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "mimeparser.h" #include <QRegExp> #include <QDebug> #include <pappsomspp/pappsoexception.h> -MimeParser::MimeParser(QIODevice * p_inputstream) { - _p_inputstream = p_inputstream; +MimeParser::MimeParser(QIODevice *p_inputstream) +{ + _p_inputstream = p_inputstream; } -MimeParser::~MimeParser() { - close(); +MimeParser::~MimeParser() +{ + close(); } -bool MimeParser::open() { - qDebug() << "MimeParser::open begin"; - if (_p_inputstream->open(QIODevice::ReadOnly)) { - _real_in = new QTextStream(_p_inputstream); +bool +MimeParser::open() +{ + qDebug() << "MimeParser::open begin"; + if(_p_inputstream->open(QIODevice::ReadOnly)) + { + _real_in = new QTextStream(_p_inputstream); } - else { - throw pappso::PappsoException(QObject::tr("Error opening mime QIODevice")); + else + { + throw pappso::PappsoException( + QObject::tr("Error opening mime QIODevice")); } - qDebug() << "MimeParser::open end"; - + qDebug() << "MimeParser::open end"; } -bool MimeParser::close() { - qDebug() << "MimeParser::close begin"; +bool +MimeParser::close() +{ + qDebug() << "MimeParser::close begin"; - _priv_file_string = ""; - if (_p_current_file_content != nullptr) { - delete _p_current_file_content; - _p_current_file_content = nullptr; + _priv_file_string = ""; + if(_p_current_file_content != nullptr) + { + delete _p_current_file_content; + _p_current_file_content = nullptr; } - qDebug() << "MimeParser::close delete _real_in"; - if (_real_in !=nullptr) { - delete _real_in; - _real_in =nullptr; + qDebug() << "MimeParser::close delete _real_in"; + if(_real_in != nullptr) + { + delete _real_in; + _real_in = nullptr; } - qDebug() << "MimeParser::close delete _p_inputstream"; - if (_p_inputstream !=nullptr) { - _p_inputstream->close(); - //delete _p_inputstream; - _p_inputstream =nullptr; + qDebug() << "MimeParser::close delete _p_inputstream"; + if(_p_inputstream != nullptr) + { + _p_inputstream->close(); + // delete _p_inputstream; + _p_inputstream = nullptr; } - qDebug() << "MimeParser::close end"; + qDebug() << "MimeParser::close end"; } -bool MimeParser::goToFirstFile() { - qDebug() << "MimeParser::goToFirstFile begin"; +bool +MimeParser::goToFirstFile() +{ + qDebug() << "MimeParser::goToFirstFile begin"; - /* - MIME-Version: 1.0 (Generated by Mascot version 1.0) - Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p + /* + MIME-Version: 1.0 (Generated by Mascot version 1.0) + Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p - --gc0p4Jq0M2Yt08jU534c0p - Content-Type: application/x-Mascot; name="parameters" - */ - QRegExp regexp_boundary("^Content-Type:\\smultipart/mixed;\\sboundary=(.*)$"); + --gc0p4Jq0M2Yt08jU534c0p + Content-Type: application/x-Mascot; name="parameters" + */ + QRegExp regexp_boundary("^Content-Type:\\smultipart/mixed;\\sboundary=(.*)$"); - while(!_real_in->atEnd()) { - QString line = _real_in->readLine(); - qDebug() << "MimeParser::goToFirstFile line=" << line; - if (regexp_boundary.exactMatch(line)) { - QStringList boundary_list = regexp_boundary.capturedTexts(); - _boundary = QString("--%1").arg(boundary_list[1]); - break; + while(!_real_in->atEnd()) + { + QString line = _real_in->readLine(); + qDebug() << "MimeParser::goToFirstFile line=" << line; + if(regexp_boundary.exactMatch(line)) + { + QStringList boundary_list = regexp_boundary.capturedTexts(); + _boundary = QString("--%1").arg(boundary_list[1]); + break; } } - if (_boundary.isEmpty()) { - qDebug() << "MimeParser::goToFirstFile _boundary.isEmpty"; - return false; + if(_boundary.isEmpty()) + { + qDebug() << "MimeParser::goToFirstFile _boundary.isEmpty"; + return false; } - while(!_real_in->atEnd()) { - QString line = _real_in->readLine(); - if (line == _boundary) break; + while(!_real_in->atEnd()) + { + QString line = _real_in->readLine(); + if(line == _boundary) + break; } - qDebug() << "MimeParser::goToFirstFile end"; - return readFile(); + qDebug() << "MimeParser::goToFirstFile end"; + return readFile(); } -bool MimeParser::readFile() { - qDebug() << "MimeParser::readFile begin"; - _current_mime_type = ""; - _current_file_name = ""; - _priv_file_string = ""; +bool +MimeParser::readFile() +{ + qDebug() << "MimeParser::readFile begin"; + _current_mime_type = ""; + _current_file_name = ""; + _priv_file_string = ""; - if (_p_current_file_content != nullptr) { - delete _p_current_file_content; + if(_p_current_file_content != nullptr) + { + delete _p_current_file_content; } - _p_current_file_content = new QTextStream(&_priv_file_string); + _p_current_file_content = new QTextStream(&_priv_file_string); - QString line = _real_in->readLine(); - if (line.isEmpty()) return false; - //Content-Type: application/x-Mascot; name="masses" - QRegExp regexp_mimetype("^Content-Type:\\s(.*);\\sname=\"(.*)\"$"); - if (regexp_mimetype.exactMatch(line)) { - QStringList mimetype_list = regexp_mimetype.capturedTexts(); - _current_mime_type = mimetype_list[1]; - _current_file_name = mimetype_list[2]; + QString line = _real_in->readLine(); + if(line.isEmpty()) + return false; + // Content-Type: application/x-Mascot; name="masses" + QRegExp regexp_mimetype("^Content-Type:\\s(.*);\\sname=\"(.*)\"$"); + if(regexp_mimetype.exactMatch(line)) + { + QStringList mimetype_list = regexp_mimetype.capturedTexts(); + _current_mime_type = mimetype_list[1]; + _current_file_name = mimetype_list[2]; } - else { - return false; + else + { + return false; } - _real_in->readLine(); - while(!_real_in->atEnd()) { - QString line = _real_in->readLine(); - if (line == _boundary) break; - *_p_current_file_content << line << endl; + _real_in->readLine(); + while(!_real_in->atEnd()) + { + QString line = _real_in->readLine(); + if(line == _boundary) + break; + *_p_current_file_content << line << endl; } - qDebug() << "MimeParser::readFile end"; - return true; + qDebug() << "MimeParser::readFile end"; + return true; } -bool MimeParser::goToNextFile() { - return readFile(); +bool +MimeParser::goToNextFile() +{ + return readFile(); } -const QString & MimeParser::getCurrentMimeType() const { - return _current_mime_type; +const QString & +MimeParser::getCurrentMimeType() const +{ + return _current_mime_type; } -const QString & MimeParser::getCurrentFileName() const { - return _current_file_name; +const QString & +MimeParser::getCurrentFileName() const +{ + return _current_file_name; } -QTextStream & MimeParser::getCurrentTextStream() { - if (_p_current_file_content == nullptr) { - throw pappso::PappsoException(QObject::tr("Error current file content empty")); +QTextStream & +MimeParser::getCurrentTextStream() +{ + if(_p_current_file_content == nullptr) + { + throw pappso::PappsoException( + QObject::tr("Error current file content empty")); } - _p_current_file_content->reset(); - return *_p_current_file_content; + _p_current_file_content->reset(); + return *_p_current_file_content; } diff --git a/src/input/mascot/mimeparser.h b/src/input/mascot/mimeparser.h index 2c792abf47f40178a3f4548c40bcebc7483c0d15..3dccec594cdddddb02a0474a5bf696db613a7859 100644 --- a/src/input/mascot/mimeparser.h +++ b/src/input/mascot/mimeparser.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 MIMEPARSER_H #define MIMEPARSER_H @@ -35,28 +36,28 @@ class MimeParser { -public: - MimeParser(QIODevice * p_inputstream); - virtual ~MimeParser(); - bool open(); - bool close(); - bool goToFirstFile(); - bool goToNextFile(); - const QString & getCurrentMimeType() const; - const QString & getCurrentFileName() const; - QTextStream & getCurrentTextStream(); - -private: - bool readFile(); - -private: - QString _current_file_name; - QString _current_mime_type; - QIODevice * _p_inputstream = nullptr; - QTextStream * _real_in = nullptr; - QString _boundary; - QTextStream * _p_current_file_content = nullptr; - QString _priv_file_string; + public: + MimeParser(QIODevice *p_inputstream); + virtual ~MimeParser(); + bool open(); + bool close(); + bool goToFirstFile(); + bool goToNextFile(); + const QString &getCurrentMimeType() const; + const QString &getCurrentFileName() const; + QTextStream &getCurrentTextStream(); + + private: + bool readFile(); + + private: + QString _current_file_name; + QString _current_mime_type; + QIODevice *_p_inputstream = nullptr; + QTextStream *_real_in = nullptr; + QString _boundary; + QTextStream *_p_current_file_content = nullptr; + QString _priv_file_string; }; #endif // MIMEPARSER_H diff --git a/src/input/pepxmlsaxhandler.cpp b/src/input/pepxmlsaxhandler.cpp index bb5a0e0f63b1ed407a82d5a80b6acaf9dc414158..a5667416dce071bf755a0d835443d84697590d83 100644 --- a/src/input/pepxmlsaxhandler.cpp +++ b/src/input/pepxmlsaxhandler.cpp @@ -326,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 diff --git a/src/input/pepxmlsaxhandler.h b/src/input/pepxmlsaxhandler.h index 19e8bb619fd279f76f2420c8f0fd82ebf106038f..8856408c83d1c7cec5d1c68b4ff8b009174f1f18 100644 --- a/src/input/pepxmlsaxhandler.h +++ b/src/input/pepxmlsaxhandler.h @@ -77,7 +77,7 @@ class PepXmlSaxHandler : public QXmlDefaultHandler bool startElement_search_score(QXmlAttributes attributes); bool startElement_mod_aminoacid_mass(QXmlAttributes attributes); bool startElement_modification_info(QXmlAttributes attributes); - + bool endElement_search_hit(); bool endElement_modification_info(); diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 386b829f39162d0ba6af8e514a735ac42d0f7aa9..b80e79862d71de02db0e0b6248c77aa05a9a81d6 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -1,24 +1,25 @@ /******************************************************************************* -* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #include "xpipsaxhandler.h" #include <pappsomspp/exception/exceptionnotfound.h> @@ -26,406 +27,575 @@ #include "../utils/peptidestore.h" #include "../utils/proteinstore.h" -XpipSaxHandler::XpipSaxHandler(WorkMonitorInterface * p_monitor, Project * p_project):_p_project(p_project) +XpipSaxHandler::XpipSaxHandler(WorkMonitorInterface *p_monitor, + Project *p_project) + : _p_project(p_project) { - qDebug() << "XpipSaxHandler::XpipSaxHandler begin" ; - _p_monitor = p_monitor; - qDebug() << "XpipSaxHandler::XpipSaxHandler end" ; + qDebug() << "XpipSaxHandler::XpipSaxHandler begin"; + _p_monitor = p_monitor; + qDebug() << "XpipSaxHandler::XpipSaxHandler end"; } XpipSaxHandler::~XpipSaxHandler() { - } -bool XpipSaxHandler::isJavaXpip() const { - return _is_java_xpip; +bool +XpipSaxHandler::isJavaXpip() const +{ + return _is_java_xpip; } -bool XpipSaxHandler::startElement(const QString & namespaceURI, const QString & localName, - const QString & qName, const QXmlAttributes & attributes) { - qDebug()<< "XpipSaxHandler::startElement begin" << namespaceURI << " " << localName << " " << qName ; - _tag_stack.push_back(qName); - bool is_ok = true; +bool +XpipSaxHandler::startElement(const QString &namespaceURI, + const QString &localName, const QString &qName, + const QXmlAttributes &attributes) +{ + qDebug() << "XpipSaxHandler::startElement begin" << namespaceURI << " " + << localName << " " << qName; + _tag_stack.push_back(qName); + bool is_ok = true; - try { + try + { - if (_tag_stack.size() == 1) { - _is_java_xpip = true; - if (qName != "xtandem_pipeline") { - _is_java_xpip = false; - throw pappso::ExceptionNotFound(QObject::tr("ERROR this file is not an xpip file %1").arg(qName)); - } - } else - //startElement_group - if (qName == "match") { - is_ok = startElement_match(attributes); - } else if (qName == "protein") { - is_ok = startElement_protein(attributes); - } else if (qName == "identification") { - is_ok = startElement_identification(attributes); - } - //<sample value="P6_08_10"/> - else if (qName == "sample") { - is_ok = startElement_sample(attributes); - } else if (qName == "peptide") { - is_ok = startElement_peptide(attributes); - } else if (qName == "modifs_mass") { - is_ok = startElement_modifs_mass(attributes); - } else if (qName == "modif") { - is_ok = startElement_modif(attributes); - } else if (qName == "filter_params") { - is_ok = startElement_filter_params(attributes); - } else if (qName == "information") { - is_ok = startElement_information(attributes); + if(_tag_stack.size() == 1) + { + _is_java_xpip = true; + if(qName != "xtandem_pipeline") + { + _is_java_xpip = false; + throw pappso::ExceptionNotFound( + QObject::tr("ERROR this file is not an xpip file %1") + .arg(qName)); } + } + else + // startElement_group + if(qName == "match") + { + is_ok = startElement_match(attributes); + } + else if(qName == "protein") + { + is_ok = startElement_protein(attributes); + } + else if(qName == "identification") + { + is_ok = startElement_identification(attributes); + } + //<sample value="P6_08_10"/> + else if(qName == "sample") + { + is_ok = startElement_sample(attributes); + } + else if(qName == "peptide") + { + is_ok = startElement_peptide(attributes); + } + else if(qName == "modifs_mass") + { + is_ok = startElement_modifs_mass(attributes); + } + else if(qName == "modif") + { + is_ok = startElement_modif(attributes); + } + else if(qName == "filter_params") + { + is_ok = startElement_filter_params(attributes); + } + else if(qName == "information") + { + is_ok = startElement_information(attributes); + } - _current_text.clear(); + _current_text.clear(); } - catch (pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in XpipSaxHandler::startElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); - return false; + catch(pappso::PappsoException exception_pappso) + { + _errorStr = + QObject::tr( + "ERROR in XpipSaxHandler::startElement tag %1, PAPPSO exception:\n%2") + .arg(qName) + .arg(exception_pappso.qwhat()); + return false; } - catch (std::exception exception_std) { - _errorStr = QObject::tr("ERROR in XpipSaxHandler::startElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); - return false; + catch(std::exception exception_std) + { + _errorStr = + QObject::tr( + "ERROR in XpipSaxHandler::startElement tag %1, std exception:\n%2") + .arg(qName) + .arg(exception_std.what()); + return false; } - return is_ok; + return is_ok; } -bool XpipSaxHandler::endElement(const QString & namespaceURI, const QString & localName, - const QString & qName) { +bool +XpipSaxHandler::endElement(const QString &namespaceURI, + const QString &localName, const QString &qName) +{ - bool is_ok = true; - // endElement_peptide_list - try { - if (qName == "protein") + bool is_ok = true; + // endElement_peptide_list + try + { + if(qName == "protein") { - is_ok = endElement_protein(); + is_ok = endElement_protein(); } - else if (qName == "identification") { - is_ok = endElement_identification(); + else if(qName == "identification") + { + is_ok = endElement_identification(); } - else if (qName == "peptide") { - is_ok = endElement_peptide(); + else if(qName == "peptide") + { + is_ok = endElement_peptide(); } - else if (qName == "sequence") { - is_ok = endElement_sequence(); + else if(qName == "sequence") + { + is_ok = endElement_sequence(); } - else if (qName == "match") { - is_ok = endElement_match(); + else if(qName == "match") + { + is_ok = endElement_match(); } - // end of detection_moulon - // else if ((_tag_stack.size() > 1) && - // (_tag_stack[_tag_stack.size() - 2] == "detection_moulon")) + // end of detection_moulon + // else if ((_tag_stack.size() > 1) && + // (_tag_stack[_tag_stack.size() - 2] == "detection_moulon")) } - catch (pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in XpipSaxHandler::endElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); - return false; + catch(pappso::PappsoException exception_pappso) + { + _errorStr = + QObject::tr( + "ERROR in XpipSaxHandler::endElement tag %1, PAPPSO exception:\n%2") + .arg(qName) + .arg(exception_pappso.qwhat()); + return false; } - catch (std::exception exception_std) { - _errorStr = QObject::tr("ERROR in XpipSaxHandler::endElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); - return false; + catch(std::exception exception_std) + { + _errorStr = + QObject::tr( + "ERROR in XpipSaxHandler::endElement tag %1, std exception:\n%2") + .arg(qName) + .arg(exception_std.what()); + return false; } - _current_text.clear(); - _tag_stack.pop_back(); + _current_text.clear(); + _tag_stack.pop_back(); - return is_ok; + return is_ok; } -bool XpipSaxHandler::startElement_identification(QXmlAttributes attributes) { +bool +XpipSaxHandler::startElement_identification(QXmlAttributes attributes) +{ - qDebug() << "startElement_identification "; - _map_massstr_aamod.clear(); - _current_identification_group_p = _p_project->newIdentificationGroup(); - qDebug() << "startElement_identification end" ; - return true; + qDebug() << "startElement_identification "; + _map_massstr_aamod.clear(); + _current_identification_group_p = _p_project->newIdentificationGroup(); + qDebug() << "startElement_identification end"; + return true; } -bool XpipSaxHandler::startElement_filter_params(QXmlAttributes attributes) { +bool +XpipSaxHandler::startElement_filter_params(QXmlAttributes attributes) +{ -//<filter_params pep_evalue="0.01" prot_evalue="-2.0" pep_number="1" filter_to_all="false" database_filter="contaminants_standarts.fasta"/> - qDebug() << "startElement_filter_params "; - _automatic_filter_parameters.setFilterPeptideEvalue( attributes.value("pep_evalue").simplified().toDouble()); - _automatic_filter_parameters.setFilterProteinEvalue( std::pow ((double) 10.0,attributes.value("prot_evalue").simplified().toDouble())); - _automatic_filter_parameters.setFilterMinimumPeptidePerMatch( attributes.value("pep_number").simplified().toUInt()); - _automatic_filter_parameters.setFilterCrossSamplePeptideNumber(false); - if (attributes.value("filter_to_all").simplified() == "true") { - _automatic_filter_parameters.setFilterCrossSamplePeptideNumber(true); + //<filter_params pep_evalue="0.01" prot_evalue="-2.0" pep_number="1" + //filter_to_all="false" database_filter="contaminants_standarts.fasta"/> + qDebug() << "startElement_filter_params "; + _automatic_filter_parameters.setFilterPeptideEvalue( + attributes.value("pep_evalue").simplified().toDouble()); + _automatic_filter_parameters.setFilterProteinEvalue(std::pow( + (double)10.0, attributes.value("prot_evalue").simplified().toDouble())); + _automatic_filter_parameters.setFilterMinimumPeptidePerMatch( + attributes.value("pep_number").simplified().toUInt()); + _automatic_filter_parameters.setFilterCrossSamplePeptideNumber(false); + if(attributes.value("filter_to_all").simplified() == "true") + { + _automatic_filter_parameters.setFilterCrossSamplePeptideNumber(true); } - _p_project->getFastaFileStore().getInstance(FastaFile(attributes.value("database_filter"))); - qDebug() << "startElement_filter_params end" ; - return true; + _p_project->getFastaFileStore().getInstance( + FastaFile(attributes.value("database_filter"))); + qDebug() << "startElement_filter_params end"; + return true; } -bool XpipSaxHandler::startElement_information(QXmlAttributes attributes) { +bool +XpipSaxHandler::startElement_information(QXmlAttributes attributes) +{ -//<information Data_Type="indiv" match_number="223"/> - qDebug() << "startElement_information "; - _p_project->setProjectMode(ProjectMode::combined); - if (attributes.value("Data_Type").simplified() == "indiv") { - _p_project->setProjectMode(ProjectMode::individual); + //<information Data_Type="indiv" match_number="223"/> + qDebug() << "startElement_information "; + _p_project->setProjectMode(ProjectMode::combined); + if(attributes.value("Data_Type").simplified() == "indiv") + { + _p_project->setProjectMode(ProjectMode::individual); } - _total_protein_match = attributes.value("match_number").toUInt(); + _total_protein_match = attributes.value("match_number").toUInt(); - _p_monitor->setProgressMaximumValue(_total_protein_match); - qDebug() << "startElement_information end" ; - return true; + _p_monitor->setProgressMaximumValue(_total_protein_match); + qDebug() << "startElement_information end"; + return true; } -bool XpipSaxHandler::startElement_modifs_mass(QXmlAttributes attributes) { - - /* - <modifs_list_mass><modifs_mass modvalue="-18.01056"/> - <modifs_mass modvalue="-17.02655"/> - <modifs_mass modvalue="15.99491"/> - <modifs_mass modvalue="42.01057"/> - <modifs_mass modvalue="42.01056"/> - <modifs_mass modvalue="57.02146"/> - </modifs_list_mass> - */ - qDebug() << "startElement_modifs_mass "; - QString mass_str(attributes.value("modvalue").simplified()); - pappso::mz mass = mass_str.toDouble(); - - pappso::AaModificationP mod = getAaModificationP(mass); - - _map_massstr_aamod[mass_str] = mod; - qDebug() << "startElement_modifs_mass end" ; - return true; +bool +XpipSaxHandler::startElement_modifs_mass(QXmlAttributes attributes) +{ + + /* + <modifs_list_mass><modifs_mass modvalue="-18.01056"/> + <modifs_mass modvalue="-17.02655"/> + <modifs_mass modvalue="15.99491"/> + <modifs_mass modvalue="42.01057"/> + <modifs_mass modvalue="42.01056"/> + <modifs_mass modvalue="57.02146"/> + </modifs_list_mass> + */ + qDebug() << "startElement_modifs_mass "; + QString mass_str(attributes.value("modvalue").simplified()); + pappso::mz mass = mass_str.toDouble(); + + pappso::AaModificationP mod = getAaModificationP(mass); + + _map_massstr_aamod[mass_str] = mod; + qDebug() << "startElement_modifs_mass end"; + return true; } //<sample value="P6_21_23"/> -bool XpipSaxHandler::startElement_sample(QXmlAttributes attributes) { +bool +XpipSaxHandler::startElement_sample(QXmlAttributes attributes) +{ - qDebug() << "startElement_sample "; + qDebug() << "startElement_sample "; - MsRunSp ms_run = _p_project->getMsRunStore().getInstance(attributes.value("value").simplified()); - ms_run.get()->setFilename(attributes.value("value").simplified()); - //_current_identification_group_p->addMsRunSp(ms_run); - qDebug() << "startElement_sample end" ; - return true; + MsRunSp ms_run = _p_project->getMsRunStore().getInstance( + attributes.value("value").simplified()); + ms_run.get()->setFilename(attributes.value("value").simplified()); + //_current_identification_group_p->addMsRunSp(ms_run); + qDebug() << "startElement_sample end"; + return true; } -bool XpipSaxHandler::startElement_match(QXmlAttributes attributes) { +bool +XpipSaxHandler::startElement_match(QXmlAttributes attributes) +{ - qDebug() << "startElement_match "; - /* - * <match_list><match validate="true"> - */ - _p_protein_match = new ProteinMatch(); - _p_protein_match->setChecked(false); - if (attributes.value("validate").simplified().toLower() == "true") { - _p_protein_match->setChecked(true); + qDebug() << "startElement_match "; + /* + * <match_list><match validate="true"> + */ + _p_protein_match = new ProteinMatch(); + _p_protein_match->setChecked(false); + if(attributes.value("validate").simplified().toLower() == "true") + { + _p_protein_match->setChecked(true); } - qDebug() << "startElement_match end" ; - return true; + qDebug() << "startElement_match end"; + return true; } -bool XpipSaxHandler::startElement_protein(QXmlAttributes attributes) { - - qDebug() << "startElement_protein "; - /* - * <protein peptide_number="268" evalue="-432.77353" URL="Genome_Z_mays_5a.fasta" - * description="GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC 4.1.1.31) - * seq=translation; coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01; parent_gene=GRMZM2G083841"> - <protein_evalue evalue="-399.36093" sample="20120906_balliau_extract_1_A02_urzb-1"/> - <protein_evalue evalue="-384.54382" sample="20120906_balliau_extract_1_A01_urnb-1"/> - <sequence>MASTKAPGPGEKHHSIDAQLRQLVPGKVSEDDKLIEYDALLVDRFLNILQDLHGPSLREFVQECYEVSADYEGKGDTTKLGELGAKLTGLAPADAILVASSILHMLNLANLAEEVQIAHRRRNSKLKKGGFADEGSATTESDIEETLKRLVSEVGKSPEEVFEALKNQTVDLVFTAHPTQSARRSLLQKNARIRNCLTQLNAKDITDDDKQELDEALQREIQAAFRTDEIRRAQPTPQDEMRYGMSYIHETVWKGVPKFLRRVDTALKNIGINERLPYNVSLIRFSSWMGGDRDGNPRVTPEVTRDVCLLARMMAANLYIDQIEELMFELSMWRCNDELRVRAEELHSSSGSKVTKYYIEFWKQIPPNEPYRVILGHVRDKLYNTRERARHLLASGVSEISAESSFTSIEEFLEPLELCYKSLCDCGDKAIADGSLLDLLRQVFTFGLSLVKLDIRQESERHTDVIDAITTHLGIGSYREWPEDKRQEWLLSELRGKRPLLPPDLPQTDEIADVIGAFHVLAELPPDSFGPYIISMATAPSDVLAVELLQRECGVRQPLPVVPLFERLADLQSAPASVERLFSVDWYMDRIKGKQQVMVGYSDSGKDAGRLSAAWQLYRAQEEMAQVAKRYGVKLTLFHGRGGTVGRGGGPTHLAILSQPPDTINGSIRVTVQGEVIEFCFGEEHLCFQTLQRFTAATLEHGMHPPVSPKPEWRKLMDEMAVVATEEYRSVVVKEARFVEYFRSATPETEYGRMNIGSRPAKRRPGGGITTLRAIPWIFSWTQTRFHLPVWLGVGAAFKFAIDKDVRNFQVLKEMYNEWPFFRVTLDLLEMVFAKGDPGIAGLYDELLVAEELKPFGKQLRDKYVETQQLLLQIAGHKDILEGDPFLKQGLVLRNPYITTLNVFQAYTLKRIRDPNFKVTPQPPLSKEFADENKPAGLVKLNPASEYPPGLEDTLILTMKGIAAGMQNTG</sequence> - </protein> - */ - _current_protein.setCompleteDescription(attributes.value("description")); - _current_fasta_file_sp = _p_project->getFastaFileStore().getInstance(FastaFile(attributes.value("URL"))); - _current_protein.setFastaFileP(_current_fasta_file_sp.get()); - qDebug() << "startElement_protein end" ; - return true; +bool +XpipSaxHandler::startElement_protein(QXmlAttributes attributes) +{ + + qDebug() << "startElement_protein "; + /* + * <protein peptide_number="268" evalue="-432.77353" + URL="Genome_Z_mays_5a.fasta" + * description="GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 + (PEPCase 1)(PEPC 1)(EC 4.1.1.31) + * seq=translation; coord=9:61296279..61301686:1; + parent_transcript=GRMZM2G083841_T01; parent_gene=GRMZM2G083841"> + <protein_evalue evalue="-399.36093" + sample="20120906_balliau_extract_1_A02_urzb-1"/> <protein_evalue + evalue="-384.54382" sample="20120906_balliau_extract_1_A01_urnb-1"/> + <sequence>MASTKAPGPGEKHHSIDAQLRQLVPGKVSEDDKLIEYDALLVDRFLNILQDLHGPSLREFVQECYEVSADYEGKGDTTKLGELGAKLTGLAPADAILVASSILHMLNLANLAEEVQIAHRRRNSKLKKGGFADEGSATTESDIEETLKRLVSEVGKSPEEVFEALKNQTVDLVFTAHPTQSARRSLLQKNARIRNCLTQLNAKDITDDDKQELDEALQREIQAAFRTDEIRRAQPTPQDEMRYGMSYIHETVWKGVPKFLRRVDTALKNIGINERLPYNVSLIRFSSWMGGDRDGNPRVTPEVTRDVCLLARMMAANLYIDQIEELMFELSMWRCNDELRVRAEELHSSSGSKVTKYYIEFWKQIPPNEPYRVILGHVRDKLYNTRERARHLLASGVSEISAESSFTSIEEFLEPLELCYKSLCDCGDKAIADGSLLDLLRQVFTFGLSLVKLDIRQESERHTDVIDAITTHLGIGSYREWPEDKRQEWLLSELRGKRPLLPPDLPQTDEIADVIGAFHVLAELPPDSFGPYIISMATAPSDVLAVELLQRECGVRQPLPVVPLFERLADLQSAPASVERLFSVDWYMDRIKGKQQVMVGYSDSGKDAGRLSAAWQLYRAQEEMAQVAKRYGVKLTLFHGRGGTVGRGGGPTHLAILSQPPDTINGSIRVTVQGEVIEFCFGEEHLCFQTLQRFTAATLEHGMHPPVSPKPEWRKLMDEMAVVATEEYRSVVVKEARFVEYFRSATPETEYGRMNIGSRPAKRRPGGGITTLRAIPWIFSWTQTRFHLPVWLGVGAAFKFAIDKDVRNFQVLKEMYNEWPFFRVTLDLLEMVFAKGDPGIAGLYDELLVAEELKPFGKQLRDKYVETQQLLLQIAGHKDILEGDPFLKQGLVLRNPYITTLNVFQAYTLKRIRDPNFKVTPQPPLSKEFADENKPAGLVKLNPASEYPPGLEDTLILTMKGIAAGMQNTG</sequence> + </protein> + */ + _current_protein.setCompleteDescription(attributes.value("description")); + _current_fasta_file_sp = _p_project->getFastaFileStore().getInstance( + FastaFile(attributes.value("URL"))); + _current_protein.setFastaFileP(_current_fasta_file_sp.get()); + qDebug() << "startElement_protein end"; + return true; } -bool XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) { - -//<peptide sample="20120208_Blein_rep4_1_B03_DW21-4-26-328" - //sample_file="/gorgone/pappso/moulon/users/Melisande/test-param-masschroq/20120208_Blein_rep4_1_B03_DW21-4-26-328.xml" - //scan="2589" scan_in_xtandem="2589" RT="603" mhplus_obser="873.5401" mhplus_theo="873.5408" deltamass="-7.0E-4" - //sequence="IATAIEKK" pre="NPAR" post="AADA" start="331" stop="338" charge="2" evalue="9.2E-4" hypercorr="35.2" validate="true"> -//<modifs></modifs></peptide> - - //<modifs><modif aa="M" modvalue="15.99491" posi="17" posi_in_prot="49"/> -//</modifs> - qDebug() << "startElement_peptide "; - _current_peptide_sp = PeptideXtp(attributes.value("sequence").simplified()).makePeptideXtpSp(); - MsRunSp ms_run_id = _p_project->getMsRunStore().getInstance(attributes.value("sample").simplified()); - _p_peptide_evidence = new PeptideEvidence(ms_run_id.get(), attributes.value("scan").simplified().toUInt()); - _p_peptide_evidence->setRetentionTime(attributes.value("RT").simplified().toDouble()); - _p_peptide_evidence->setEvalue(attributes.value("evalue").simplified().toDouble()); - pappso::pappso_double exp_mass = attributes.value("mhplus_obser").simplified().toDouble() - pappso::MHPLUS; - _p_peptide_evidence->setExperimentalMass(exp_mass); - _current_peptide_match.setStart(attributes.value("start").simplified().toUInt()-1); - _p_peptide_evidence->setCharge(attributes.value("charge").simplified().toUInt()); - _p_peptide_evidence->setParam(PeptideEvidenceParam::tandem_hyperscore, QVariant( attributes.value("hypercorr").toDouble())); - - IdentificationDataSource* p_identification_data_source = _p_project->getIdentificationDataSourceStore().getInstance(attributes.value("sample_file").simplified()).get(); - _p_peptide_evidence->setIdentificationDataSource( p_identification_data_source); - if (p_identification_data_source->getMsRunSp().get() == nullptr) { - p_identification_data_source->setMsRunSp(ms_run_id); +bool +XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) +{ + + //<peptide sample="20120208_Blein_rep4_1_B03_DW21-4-26-328" + // sample_file="/gorgone/pappso/moulon/users/Melisande/test-param-masschroq/20120208_Blein_rep4_1_B03_DW21-4-26-328.xml" + // scan="2589" scan_in_xtandem="2589" RT="603" mhplus_obser="873.5401" + // mhplus_theo="873.5408" deltamass="-7.0E-4" sequence="IATAIEKK" pre="NPAR" + // post="AADA" start="331" stop="338" charge="2" evalue="9.2E-4" + // hypercorr="35.2" validate="true"> + //<modifs></modifs></peptide> + + //<modifs><modif aa="M" modvalue="15.99491" posi="17" posi_in_prot="49"/> + //</modifs> + qDebug() << "startElement_peptide "; + _current_peptide_sp = + PeptideXtp(attributes.value("sequence").simplified()).makePeptideXtpSp(); + MsRunSp ms_run_id = _p_project->getMsRunStore().getInstance( + attributes.value("sample").simplified()); + _p_peptide_evidence = new PeptideEvidence( + ms_run_id.get(), attributes.value("scan").simplified().toUInt()); + _p_peptide_evidence->setRetentionTime( + attributes.value("RT").simplified().toDouble()); + _p_peptide_evidence->setEvalue( + attributes.value("evalue").simplified().toDouble()); + pappso::pappso_double exp_mass = + attributes.value("mhplus_obser").simplified().toDouble() - pappso::MHPLUS; + _p_peptide_evidence->setExperimentalMass(exp_mass); + _current_peptide_match.setStart( + attributes.value("start").simplified().toUInt() - 1); + _p_peptide_evidence->setCharge( + attributes.value("charge").simplified().toUInt()); + _p_peptide_evidence->setParam( + PeptideEvidenceParam::tandem_hyperscore, + QVariant(attributes.value("hypercorr").toDouble())); + + IdentificationDataSource *p_identification_data_source = + _p_project->getIdentificationDataSourceStore() + .getInstance(attributes.value("sample_file").simplified()) + .get(); + _p_peptide_evidence->setIdentificationDataSource( + p_identification_data_source); + if(p_identification_data_source->getMsRunSp().get() == nullptr) + { + p_identification_data_source->setMsRunSp(ms_run_id); } - if (p_identification_data_source->getMsRunSp().get() != ms_run_id.get()) { - throw pappso::PappsoException(QObject::tr("p_identification_data_source->getMsRunSp().get() != ms_run_id.get()")); + if(p_identification_data_source->getMsRunSp().get() != ms_run_id.get()) + { + throw pappso::PappsoException(QObject::tr( + "p_identification_data_source->getMsRunSp().get() != ms_run_id.get()")); } - _current_identification_group_p->addIdentificationDataSourceP(p_identification_data_source); - p_identification_data_source->addFastaFile(_current_fasta_file_sp); - _p_peptide_evidence->setChecked(false); - if (attributes.value("validate").simplified().toLower() == "true") { - _p_peptide_evidence->setChecked(true); + _current_identification_group_p->addIdentificationDataSourceP( + p_identification_data_source); + p_identification_data_source->addFastaFile(_current_fasta_file_sp); + _p_peptide_evidence->setChecked(false); + if(attributes.value("validate").simplified().toLower() == "true") + { + _p_peptide_evidence->setChecked(true); } - qDebug() << "startElement_peptide end" ; - return true; + qDebug() << "startElement_peptide end"; + return true; } -bool XpipSaxHandler::startElement_modif(QXmlAttributes attributes) { +bool +XpipSaxHandler::startElement_modif(QXmlAttributes attributes) +{ - //<modifs><modif aa="M" modvalue="15.99491" posi="17" posi_in_prot="49"/> - qDebug() << "startElement_modif "; - pappso::AaModificationP modif = _map_massstr_aamod[attributes.value("modvalue").simplified()]; - unsigned int position = attributes.value("posi").simplified().toUInt(); - _current_peptide_sp.get()->addAaModification(modif, position-1); - qDebug() << "startElement_modif end" ; - return true; + //<modifs><modif aa="M" modvalue="15.99491" posi="17" posi_in_prot="49"/> + qDebug() << "startElement_modif "; + pappso::AaModificationP modif = + _map_massstr_aamod[attributes.value("modvalue").simplified()]; + unsigned int position = attributes.value("posi").simplified().toUInt(); + _current_peptide_sp.get()->addAaModification(modif, position - 1); + qDebug() << "startElement_modif end"; + return true; } -bool XpipSaxHandler::endElement_peptide() { - qDebug() << "endElement_peptide "; - PeptideXtpSp peptide_const = PeptideXtp(*(_current_peptide_sp.get())).makePeptideXtpSp(); - peptide_const = _p_project->getPeptideStore().getInstance(peptide_const); - _p_peptide_evidence->setPeptideXtpSp(peptide_const); - _current_peptide_match.setPeptideEvidenceSp(_p_peptide_evidence->getIdentificationDataSource()->getPeptideEvidenceStore().getInstance(_p_peptide_evidence)); - _p_protein_match->addPeptideMatch(_current_peptide_match); - delete _p_peptide_evidence; - return true; +bool +XpipSaxHandler::endElement_peptide() +{ + qDebug() << "endElement_peptide "; + PeptideXtpSp peptide_const = + PeptideXtp(*(_current_peptide_sp.get())).makePeptideXtpSp(); + peptide_const = _p_project->getPeptideStore().getInstance(peptide_const); + _p_peptide_evidence->setPeptideXtpSp(peptide_const); + _current_peptide_match.setPeptideEvidenceSp( + _p_peptide_evidence->getIdentificationDataSource() + ->getPeptideEvidenceStore() + .getInstance(_p_peptide_evidence)); + _p_protein_match->addPeptideMatch(_current_peptide_match); + delete _p_peptide_evidence; + return true; } -bool XpipSaxHandler::endElement_sequence() { - //if ((_tag_stack.size() > 1) && (_tag_stack[_tag_stack.size() - 1] == "protein")) { - - //._sequence.replace(QRegExp("\\*"), "")).removeTranslationStop() - _current_protein.setSequence(_current_text); - //} - //else { - // XtandemHyperscore hyperscore(_curent_spectrum, _current_peptide_sp, _precision, _ion_list, _max_charge,_refine_spectrum_synthesis); - //} - return true; +bool +XpipSaxHandler::endElement_sequence() +{ + // if ((_tag_stack.size() > 1) && (_tag_stack[_tag_stack.size() - 1] == + // "protein")) { + + //._sequence.replace(QRegExp("\\*"), "")).removeTranslationStop() + _current_protein.setSequence(_current_text); + //} + // else { + // XtandemHyperscore hyperscore(_curent_spectrum, _current_peptide_sp, + // _precision, _ion_list, _max_charge,_refine_spectrum_synthesis); + //} + return true; } -bool XpipSaxHandler::endElement_protein() { +bool +XpipSaxHandler::endElement_protein() +{ - ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp(); + ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp(); - _p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein)); + _p_protein_match->setProteinXtpSp( + _p_project->getProteinStore().getInstance(sp_xtp_protein)); - return true; + return true; } -bool XpipSaxHandler::endElement_identification() { +bool +XpipSaxHandler::endElement_identification() +{ - return true; + return true; } -bool XpipSaxHandler::endElement_match() { - _count_protein_match++; - _p_monitor->message(QObject::tr("reading match %1").arg(_count_protein_match), _count_protein_match); - _current_identification_group_p->addProteinMatch(_p_protein_match); - _p_protein_match = nullptr; - return true; +bool +XpipSaxHandler::endElement_match() +{ + _count_protein_match++; + _p_monitor->message(QObject::tr("reading match %1").arg(_count_protein_match), + _count_protein_match); + _current_identification_group_p->addProteinMatch(_p_protein_match); + _p_protein_match = nullptr; + return true; } -bool XpipSaxHandler::error(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg( - exception.message()); +bool +XpipSaxHandler::error(const QXmlParseException &exception) +{ + _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" + "%3") + .arg(exception.lineNumber()) + .arg(exception.columnNumber()) + .arg(exception.message()); - return false; + return false; } -bool XpipSaxHandler::fatalError(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg( - exception.message()); - return false; +bool +XpipSaxHandler::fatalError(const QXmlParseException &exception) +{ + _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" + "%3") + .arg(exception.lineNumber()) + .arg(exception.columnNumber()) + .arg(exception.message()); + return false; } -QString XpipSaxHandler::errorString() const { - return _errorStr; +QString +XpipSaxHandler::errorString() const +{ + return _errorStr; } -bool XpipSaxHandler::endDocument() { - //_p_project->getProteinStore().setRegexpDecoyPattern(_p_project->getProteinStore().getRegexpDecoy().pattern()); - _p_project->updateAutomaticFilters(_automatic_filter_parameters); - return true; +bool +XpipSaxHandler::endDocument() +{ + //_p_project->getProteinStore().setRegexpDecoyPattern(_p_project->getProteinStore().getRegexpDecoy().pattern()); + _p_project->updateAutomaticFilters(_automatic_filter_parameters); + return true; } -bool XpipSaxHandler::startDocument() { - _count_protein_match=0; - return true; +bool +XpipSaxHandler::startDocument() +{ + _count_protein_match = 0; + return true; } -bool XpipSaxHandler::characters(const QString &str) { - _current_text += str; - return true; +bool +XpipSaxHandler::characters(const QString &str) +{ + _current_text += str; + return true; } -pappso::AaModificationP XpipSaxHandler::getAaModificationP(pappso::mz mass) const { - pappso::PrecisionP precision = pappso::Precision::getDaltonInstance(0.01); +pappso::AaModificationP +XpipSaxHandler::getAaModificationP(pappso::mz mass) const +{ + 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("XpipSaxHandler::getAaModificationP => modification not found for mass %1").arg(mass)); + throw pappso::ExceptionNotFound( + QObject::tr("XpipSaxHandler::getAaModificationP => modification not found " + "for mass %1") + .arg(mass)); } - - diff --git a/src/input/xpipsaxhandler.h b/src/input/xpipsaxhandler.h index e5187702f63bd862b77d5cc978a5bc615812290a..fdb335a17cb62e970ed5d29ae3d93e5c8612ec87 100644 --- a/src/input/xpipsaxhandler.h +++ b/src/input/xpipsaxhandler.h @@ -1,24 +1,25 @@ /******************************************************************************* -* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation -******************************************************************************/ + * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and + *implementation + ******************************************************************************/ #ifndef XPIPSAXHANDLER_H #define XPIPSAXHANDLER_H @@ -32,70 +33,70 @@ #include "../core/proteinmatch.h" #include "../utils/workmonitor.h" -class XpipSaxHandler: public QXmlDefaultHandler +class XpipSaxHandler : public QXmlDefaultHandler { -public: - XpipSaxHandler(WorkMonitorInterface * p_monitor, Project * p_project); - ~XpipSaxHandler(); - - bool startElement(const QString & namespaceURI, const QString & localName, - const QString & qName, const QXmlAttributes & attributes); - - bool endElement(const QString & namespaceURI, const QString & localName, - const QString & qName); - - bool startDocument(); - - bool endDocument(); - - bool characters(const QString &str); - - bool fatalError(const QXmlParseException &exception); - bool error(const QXmlParseException &exception); - - QString errorString() const; - bool isJavaXpip() const; - - -private: - bool startElement_filter_params(QXmlAttributes attributes); - bool startElement_information(QXmlAttributes attributes); - bool startElement_identification(QXmlAttributes attributes); - bool startElement_match(QXmlAttributes attributes); - bool startElement_peptide(QXmlAttributes attributes); - bool startElement_protein(QXmlAttributes attributes); - bool startElement_sample(QXmlAttributes attributes); - bool startElement_modifs_mass(QXmlAttributes attributes); - bool startElement_modif(QXmlAttributes attributes); - bool endElement_identification(); - bool endElement_sequence(); - bool endElement_protein(); - bool endElement_peptide(); - bool endElement_match(); - - pappso::AaModificationP getAaModificationP(pappso::mz mass) const; - -private: - WorkMonitorInterface * _p_monitor; - std::vector<QString> _tag_stack; - QString _errorStr; - QString _current_text; - AutomaticFilterParameters _automatic_filter_parameters; - - Project * _p_project; - ProteinMatch * _p_protein_match; - PeptideEvidence * _p_peptide_evidence; - PeptideMatch _current_peptide_match; - ProteinXtp _current_protein; - PeptideXtpSp _current_peptide_sp; - IdentificationGroup * _current_identification_group_p; - FastaFileSp _current_fasta_file_sp; - - QMap<QString, pappso::AaModificationP> _map_massstr_aamod; - uint _count_protein_match=0; - uint _total_protein_match; - - bool _is_java_xpip = false; + public: + XpipSaxHandler(WorkMonitorInterface *p_monitor, Project *p_project); + ~XpipSaxHandler(); + + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); + + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); + + bool startDocument(); + + bool endDocument(); + + bool characters(const QString &str); + + bool fatalError(const QXmlParseException &exception); + bool error(const QXmlParseException &exception); + + QString errorString() const; + bool isJavaXpip() const; + + + private: + bool startElement_filter_params(QXmlAttributes attributes); + bool startElement_information(QXmlAttributes attributes); + bool startElement_identification(QXmlAttributes attributes); + bool startElement_match(QXmlAttributes attributes); + bool startElement_peptide(QXmlAttributes attributes); + bool startElement_protein(QXmlAttributes attributes); + bool startElement_sample(QXmlAttributes attributes); + bool startElement_modifs_mass(QXmlAttributes attributes); + bool startElement_modif(QXmlAttributes attributes); + bool endElement_identification(); + bool endElement_sequence(); + bool endElement_protein(); + bool endElement_peptide(); + bool endElement_match(); + + pappso::AaModificationP getAaModificationP(pappso::mz mass) const; + + private: + WorkMonitorInterface *_p_monitor; + std::vector<QString> _tag_stack; + QString _errorStr; + QString _current_text; + AutomaticFilterParameters _automatic_filter_parameters; + + Project *_p_project; + ProteinMatch *_p_protein_match; + PeptideEvidence *_p_peptide_evidence; + PeptideMatch _current_peptide_match; + ProteinXtp _current_protein; + PeptideXtpSp _current_peptide_sp; + IdentificationGroup *_current_identification_group_p; + FastaFileSp _current_fasta_file_sp; + + QMap<QString, pappso::AaModificationP> _map_massstr_aamod; + uint _count_protein_match = 0; + uint _total_protein_match; + + bool _is_java_xpip = false; }; #endif // XTANDEMRESULTSHANDLER_H diff --git a/src/input/xtandemparamsaxhandler.cpp b/src/input/xtandemparamsaxhandler.cpp index 06e44a24258b5f4e20dc39f545f6214bde652c53..08b9feed0efd9aa3ac6fa1b0126c0fa6ed2a75e7 100644 --- a/src/input/xtandemparamsaxhandler.cpp +++ b/src/input/xtandemparamsaxhandler.cpp @@ -6,164 +6,225 @@ */ /******************************************************************************* -* 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 "xtandemparamsaxhandler.h" #include <pappsomspp/pappsoexception.h> #include <QDebug> -XtandemParamSaxHandler::XtandemParamSaxHandler(TandemParameters * p_tandem_parameters) { - _p_tandem_parameters = p_tandem_parameters; +XtandemParamSaxHandler::XtandemParamSaxHandler( + TandemParameters *p_tandem_parameters) +{ + _p_tandem_parameters = p_tandem_parameters; - //<note type="input" label="output, xsl path">tandem-style.xsl</note> - _p_tandem_parameters->setParamLabelValue("output, xsl path", "tandem-style.xsl"); - //<note type="input" label="output, mzid">no</note> - _p_tandem_parameters->setParamLabelValue("output, mzid", "no"); + //<note type="input" label="output, xsl path">tandem-style.xsl</note> + _p_tandem_parameters->setParamLabelValue("output, xsl path", + "tandem-style.xsl"); + //<note type="input" label="output, mzid">no</note> + _p_tandem_parameters->setParamLabelValue("output, mzid", "no"); } -XtandemParamSaxHandler::~XtandemParamSaxHandler() { +XtandemParamSaxHandler::~XtandemParamSaxHandler() +{ } - -bool XtandemParamSaxHandler::startElement(const QString & namespaceURI, const QString & localName, - const QString & qName, const QXmlAttributes & attributes) { - //qDebug()<< "XtandemParamSaxHandler::startElement begin" << namespaceURI << " " << localName << " " << qName ; - _tag_stack.push_back(qName); - bool is_ok = true; - - try { - //<bioml label="example api document"> - if (_tag_stack.size() == 1) { - if (qName != "bioml") { - _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::startElement root tag %1 is not <bioml>").arg(qName); - return false; +bool +XtandemParamSaxHandler::startElement(const QString &namespaceURI, + const QString &localName, + const QString &qName, + const QXmlAttributes &attributes) +{ + // qDebug()<< "XtandemParamSaxHandler::startElement begin" << namespaceURI << + // " " << localName << " " << qName ; + _tag_stack.push_back(qName); + bool is_ok = true; + + try + { + //<bioml label="example api document"> + if(_tag_stack.size() == 1) + { + if(qName != "bioml") + { + _errorStr = + QObject::tr("ERROR in XtandemParamSaxHandler::startElement " + "root tag %1 is not <bioml>") + .arg(qName); + return false; } } - //startElement_group + // startElement_group - if (qName == "note") { - is_ok = startElement_note(attributes); + if(qName == "note") + { + is_ok = startElement_note(attributes); } - _current_text.clear(); + _current_text.clear(); } - catch (pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::startElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); - return false; + catch(pappso::PappsoException exception_pappso) + { + _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::startElement " + "tag %1, PAPPSO exception:\n%2") + .arg(qName) + .arg(exception_pappso.qwhat()); + return false; } - catch (std::exception exception_std) { - _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::startElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); - return false; + catch(std::exception exception_std) + { + _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::startElement " + "tag %1, std exception:\n%2") + .arg(qName) + .arg(exception_std.what()); + return false; } - return is_ok; + return is_ok; } -bool XtandemParamSaxHandler::endElement(const QString & namespaceURI, const QString & localName, - const QString & qName) { +bool +XtandemParamSaxHandler::endElement(const QString &namespaceURI, + const QString &localName, + const QString &qName) +{ - bool is_ok = true; - // endElement_peptide_list - try { + bool is_ok = true; + // endElement_peptide_list + try + { - if (qName == "note") + if(qName == "note") { - is_ok = endElement_note(); + is_ok = endElement_note(); } - } - catch (pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::endElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); - return false; + catch(pappso::PappsoException exception_pappso) + { + _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::endElement tag " + "%1, PAPPSO exception:\n%2") + .arg(qName) + .arg(exception_pappso.qwhat()); + return false; } - catch (std::exception exception_std) { - _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::endElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); - return false; + catch(std::exception exception_std) + { + _errorStr = QObject::tr("ERROR in XtandemParamSaxHandler::endElement tag " + "%1, std exception:\n%2") + .arg(qName) + .arg(exception_std.what()); + return false; } - _current_text.clear(); - _tag_stack.pop_back(); + _current_text.clear(); + _tag_stack.pop_back(); - return is_ok; + return is_ok; } -bool XtandemParamSaxHandler::error(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg( - exception.message()); - qDebug() << "XtandemParamSaxHandler::error " << _errorStr; - return false; +bool +XtandemParamSaxHandler::error(const QXmlParseException &exception) +{ + _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" + "%3") + .arg(exception.lineNumber()) + .arg(exception.columnNumber()) + .arg(exception.message()); + qDebug() << "XtandemParamSaxHandler::error " << _errorStr; + return false; } -bool XtandemParamSaxHandler::fatalError(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg( - exception.message()); - qDebug() << "XtandemParamSaxHandler::fatalError " << _errorStr; - return false; +bool +XtandemParamSaxHandler::fatalError(const QXmlParseException &exception) +{ + _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" + "%3") + .arg(exception.lineNumber()) + .arg(exception.columnNumber()) + .arg(exception.message()); + qDebug() << "XtandemParamSaxHandler::fatalError " << _errorStr; + return false; } -QString XtandemParamSaxHandler::errorString() const { - return _errorStr; +QString +XtandemParamSaxHandler::errorString() const +{ + return _errorStr; } -bool XtandemParamSaxHandler::endDocument() { +bool +XtandemParamSaxHandler::endDocument() +{ - return true; + return true; } -bool XtandemParamSaxHandler::startDocument() { - /*<?xml version="1.0" encoding="UTF-8"?> - <bioml label="example api document"> - <note type="input" label="spectrum, parent monoisotopic mass error units">ppm</note> - <note type="input" label="spectrum, parent monoisotopic mass error minus">10</note> - */ - return true; +bool +XtandemParamSaxHandler::startDocument() +{ + /*<?xml version="1.0" encoding="UTF-8"?> + <bioml label="example api document"> + <note type="input" label="spectrum, parent monoisotopic mass error + units">ppm</note> <note type="input" label="spectrum, parent monoisotopic mass + error minus">10</note> + */ + return true; } -bool XtandemParamSaxHandler::characters(const QString &str) { - _current_text += str; - return true; +bool +XtandemParamSaxHandler::characters(const QString &str) +{ + _current_text += str; + return true; } -bool XtandemParamSaxHandler::startElement_note(QXmlAttributes attributes) { - //qDebug() << "XtandemParamSaxHandler::startElement_note begin " << attributes.value("type"); - _current_label = ""; +bool +XtandemParamSaxHandler::startElement_note(QXmlAttributes attributes) +{ + // qDebug() << "XtandemParamSaxHandler::startElement_note begin " << + // attributes.value("type"); + _current_label = ""; - if (attributes.value("type") == "input") { - _current_label = attributes.value("label"); + if(attributes.value("type") == "input") + { + _current_label = attributes.value("label"); } - // qDebug() << "XtandemParamSaxHandler::startElement_note _current_label " << _current_label; - return true; - + // qDebug() << "XtandemParamSaxHandler::startElement_note _current_label " << + // _current_label; + return true; } -bool XtandemParamSaxHandler::endElement_note() { -// qDebug() << "XtandemParamSaxHandler::endElement_note begin " << _current_label << " " << _current_text.simplified(); - if (!_current_label.isEmpty()) { - _p_tandem_parameters->setParamLabelValue( _current_label, _current_text.simplified()); +bool +XtandemParamSaxHandler::endElement_note() +{ + // qDebug() << "XtandemParamSaxHandler::endElement_note begin " << + // _current_label << " " << _current_text.simplified(); + if(!_current_label.isEmpty()) + { + _p_tandem_parameters->setParamLabelValue(_current_label, + _current_text.simplified()); } - return true; + return true; } diff --git a/src/input/xtandemparamsaxhandler.h b/src/input/xtandemparamsaxhandler.h index 88791ee5984a3b76cb06a1a13db8140d4a29befe..398f516ca4c03dd9551c99d7c9a6e5d7df30939f 100644 --- a/src/input/xtandemparamsaxhandler.h +++ b/src/input/xtandemparamsaxhandler.h @@ -6,26 +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 + ******************************************************************************/ #ifndef XTANDEMPARAMSAXHANDLER_H #define XTANDEMPARAMSAXHANDLER_H @@ -34,42 +35,41 @@ #include <vector> #include "../core/tandem_run/tandemparameters.h" -class XtandemParamSaxHandler: public QXmlDefaultHandler +class XtandemParamSaxHandler : public QXmlDefaultHandler { -public: - XtandemParamSaxHandler(TandemParameters * p_tandem_parameters); - ~XtandemParamSaxHandler(); - - bool startElement(const QString & namespaceURI, const QString & localName, - const QString & qName, const QXmlAttributes & attributes); + public: + XtandemParamSaxHandler(TandemParameters *p_tandem_parameters); + ~XtandemParamSaxHandler(); - bool endElement(const QString & namespaceURI, const QString & localName, - const QString & qName); + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); - bool startDocument(); + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); - bool endDocument(); + bool startDocument(); - bool characters(const QString &str); + bool endDocument(); - bool fatalError(const QXmlParseException &exception); - bool error(const QXmlParseException &exception); + bool characters(const QString &str); - QString errorString() const; - -private: - bool startElement_note(QXmlAttributes attributes); - bool endElement_note(); + bool fatalError(const QXmlParseException &exception); + bool error(const QXmlParseException &exception); -private: - TandemParameters * _p_tandem_parameters; - - std::vector<QString> _tag_stack; - QString _errorStr; - QString _current_text; - - QString _current_label; + QString errorString() const; + private: + bool startElement_note(QXmlAttributes attributes); + bool endElement_note(); + + private: + TandemParameters *_p_tandem_parameters; + + std::vector<QString> _tag_stack; + QString _errorStr; + QString _current_text; + + QString _current_label; }; #endif // XTANDEMPARAMSAXHANDLER_H diff --git a/src/input/xtandemsaxhandler.cpp b/src/input/xtandemsaxhandler.cpp index a7fd35aeaa14ef6abbe8273ac312f1f256359e47..57b17071e31ba50749e20ec2597256a1b0d68f92 100644 --- a/src/input/xtandemsaxhandler.cpp +++ b/src/input/xtandemsaxhandler.cpp @@ -165,9 +165,9 @@ bool XtandemSaxHandler::startElement_group(QXmlAttributes attrs) { //<group id="1976" mh="1120.529471" z="2" rt="PT667.022S" expect="9.7e-04" - //label="GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase - //1)(PEPC 1)(EC..." type="model" sumI="5.34" maxI="35986.9" fI="359.869" - //act="0" > + // label="GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase + // 1)(PEPC 1)(EC..." type="model" sumI="5.34" maxI="35986.9" fI="359.869" + // act="0" > bool is_ok = true; // logger.debug("startElementgroup begin"); // <group label="performance parameters" type="parameters"> @@ -190,8 +190,8 @@ bool XtandemSaxHandler::startElement_note(QXmlAttributes attributes) { //<note label="description">GRMZM2G083841_P01 P04711 Phosphoenolpyruvate - //carboxylase 1 (PEPCase 1)(PEPC 1)(EC //4.1.1.31) seq=translation; - //coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01; + // carboxylase 1 (PEPCase 1)(PEPC 1)(EC //4.1.1.31) seq=translation; + // coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01; ////parent_gene=GRMZM2G083841</note> bool is_ok = true; _current_note_label = attributes.value("label"); @@ -212,7 +212,7 @@ XtandemSaxHandler::startElement_file(QXmlAttributes attributes) { bool is_ok = true; //<file type="peptide" - //URL="/gorgone/pappso/formation/TD/Database/Genome_Z_mays_5a.fasta"/> + // URL="/gorgone/pappso/formation/TD/Database/Genome_Z_mays_5a.fasta"/> if(attributes.value("type") == "peptide") { // prot_.setDatabase(identification_.getDatabaseSet().getInstance( @@ -238,7 +238,8 @@ XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) { // mh="1120.529471" //<domain id="1976.1.1" start="620" end="629" expect="9.7e-04" mh="1120.5307" - //delta="-0.0012" hyperscore="29.9" nextscore="10.2" y_score="10.4" y_ions="7" + // delta="-0.0012" hyperscore="29.9" nextscore="10.2" y_score="10.4" + // y_ions="7" // b_score="11.2" b_ions="3" pre="QLYR" post="RYGV" seq="AQEEMAQVAK" // missed_cleavages="0"> qDebug() << "startElement_domain "; bool is_ok = true; @@ -430,13 +431,14 @@ bool XtandemSaxHandler::startElement_protein(QXmlAttributes attributes) { //<protein expect="-704.6" id="1976.1" uid="195701" label="GRMZM2G083841_P01 - //P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC..." - //sumI="9.36" > + // P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC..." + // sumI="9.36" > bool is_ok = true; // the protein label could be truncated => we must wait for the <note - // label="description">sp|P11413|G6PD_HUMAN Glucose-6-phosphate 1-dehydrogenase - // OS=Homo sapiens GN=G6PD PE=1 SV=4</note> to get the real protein + // label="description">sp|P11413|G6PD_HUMAN Glucose-6-phosphate + // 1-dehydrogenase OS=Homo sapiens GN=G6PD PE=1 SV=4</note> to get the real + // protein _p_protein_match = nullptr; // qDebug() << "startElement_protein end" ; return is_ok; @@ -447,8 +449,8 @@ bool XtandemSaxHandler::endElement_note() { //<note label="description">GRMZM2G083841_P01 P04711 Phosphoenolpyruvate - //carboxylase 1 (PEPCase 1)(PEPC 1)(EC //4.1.1.31) seq=translation; - //coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01; + // carboxylase 1 (PEPCase 1)(PEPC 1)(EC //4.1.1.31) seq=translation; + // coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01; ////parent_gene=GRMZM2G083841</note> bool is_ok = true; if(_is_protein_description) @@ -495,7 +497,7 @@ XtandemSaxHandler::endElement_note() //<group label="input parameters" type="parameters"> //<note type="input" label="list path, default - //parameters">/gorgone/pappso/tmp/temp_condor_job8533994640337729751189420695540169/QExactive_analysis_FDR_nosemi.xml</note> + // parameters">/gorgone/pappso/tmp/temp_condor_job8533994640337729751189420695540169/QExactive_analysis_FDR_nosemi.xml</note> if(_current_note_label == "list path, default parameters") { _p_identification_data_source->setIdentificationEngineParam( @@ -579,7 +581,7 @@ XtandemSaxHandler::endElement_note() monoisotopic mass isotope error">yes</note> */ //<note type="input" label="spectrum, - //path">/gorgone/pappso/formation/TD/mzXML/20120906_balliau_extract_1_A02_urzb-1.mzXML</note> + // path">/gorgone/pappso/formation/TD/mzXML/20120906_balliau_extract_1_A02_urzb-1.mzXML</note> if(_current_note_label == "spectrum, path") { diff --git a/src/input/xtpxpipsaxhandler.cpp b/src/input/xtpxpipsaxhandler.cpp index db9234736a8be2eb7f596ef5518d67861d5a2e6b..d577fd393c8f94d1baf0ad5cd725c305c84f116a 100644 --- a/src/input/xtpxpipsaxhandler.cpp +++ b/src/input/xtpxpipsaxhandler.cpp @@ -504,8 +504,8 @@ bool XtpXpipSaxHandler::startElement_identification_source(QXmlAttributes attributes) { //<identification_source id="identa0" msrun_id="sampa0" - //path="/espace/bio/tandem/20120906_balliau_extract_1_A01_urnb-1.xml" - //engine="1" version="2017.2.1.4" fasta_ids="fastaa0"> + // path="/espace/bio/tandem/20120906_balliau_extract_1_A01_urnb-1.xml" + // engine="1" version="2017.2.1.4" fasta_ids="fastaa0"> qDebug() << "startElement_identification_source "; @@ -542,7 +542,7 @@ bool XtpXpipSaxHandler::startElement_msrun(QXmlAttributes attributes) { //<msrun id="sampa0" name="20120906_balliau_extract_1_A01_urnb-1" format="0" - //path="20120906_balliau_extract_1_A01_urnb-1"/> + // path="20120906_balliau_extract_1_A01_urnb-1"/> qDebug() << "startElement_msrun "; diff --git a/src/input/xtpxpipsaxhandler.h b/src/input/xtpxpipsaxhandler.h index ed62a4f0eb4f597aa6976dd4e447c228d0dadc08..29f8767953cd2be02758081304c1080004e956a7 100644 --- a/src/input/xtpxpipsaxhandler.h +++ b/src/input/xtpxpipsaxhandler.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef XTPXPIPSAXHANDLER_H #define XTPXPIPSAXHANDLER_H @@ -40,104 +41,104 @@ #include "../core/proteinmatch.h" #include "../utils/workmonitor.h" -class XtpXpipSaxHandler: public QXmlDefaultHandler +class XtpXpipSaxHandler : public QXmlDefaultHandler { -public: - XtpXpipSaxHandler(WorkMonitorInterface * p_monitor, Project * p_project); - ~XtpXpipSaxHandler(); - - bool startElement(const QString & namespaceURI, const QString & localName, - const QString & qName, const QXmlAttributes & attributes); - - bool endElement(const QString & namespaceURI, const QString & localName, - const QString & qName); - - bool startDocument(); - - bool endDocument(); - - bool characters(const QString &str); - - bool fatalError(const QXmlParseException &exception); - bool error(const QXmlParseException &exception); - - QString errorString() const; - bool isXtpXpip() const; - - -private: - bool startElement_filter_params(QXmlAttributes attributes); - bool startElement_description(QXmlAttributes attributes); - bool startElement_fasta_file(QXmlAttributes attributes); - bool startElement_protein_match(QXmlAttributes attributes); - bool startElement_peptide_match(QXmlAttributes attributes); - bool startElement_peptide(QXmlAttributes attributes); - bool startElement_peptide_evidence(QXmlAttributes attributes); - bool startElement_peptide_evidence_list(QXmlAttributes attributes); - bool startElement_protein(QXmlAttributes attributes); - bool startElement_msrun(QXmlAttributes attributes); - bool startElement_identification_source(QXmlAttributes attributes); - bool startElement_identification_group(QXmlAttributes attributes); - - bool startElement_modification(QXmlAttributes attributes); - bool startElement_mod(QXmlAttributes attributes); - bool startElement_param(QXmlAttributes attributes); - bool startElement_stat(QXmlAttributes attributes); - bool startElement_counts(QXmlAttributes attributes); - bool startElement_label_method(QXmlAttributes attributes); - bool startElement_contaminants(QXmlAttributes attributes); - bool startElement_decoys(QXmlAttributes attributes); - - //bool endElement_identification(); - bool endElement_sequence(); - bool endElement_msrun(); - bool endElement_protein(); - bool endElement_peptide(); - bool endElement_protein_match(); - bool endElement_peptide_evidence(); - bool endElement_peptide_evidence_list(); - bool endElement_identification_group(); - bool endElement_identification_source(); - -private: - WorkMonitorInterface * _p_monitor; - std::vector<QString> _tag_stack; - QString _errorStr; - QString _current_text; - AutomaticFilterParameters _automatic_filter_parameters; - - Project * _p_project; - ProteinMatch * _p_protein_match; - PeptideEvidence * _p_peptide_evidence; - IdentificationGroup * _current_identification_group_p; - - std::map<QString, pappso::AaModificationP> _map_modifs; - std::map<QString, FastaFileSp> _map_fasta_files; - std::map<QString, ProteinXtpSp> _map_proteins; - std::map<QString, MsRunSp> _map_msruns; - std::map<QString, IdentificationDataSourceSp> _map_ident_sources; - std::map<QString, PeptideEvidenceSp> _map_peptide_evidences; - PeptideEvidenceSp _sp_current_peptide_evidence; - ProteinXtpSp _sp_current_protein; - PeptideXtpSp _current_peptide_sp; - IdentificationDataSourceSp _sp_current_identification_source; - LabelingMethodSp _sp_labeling_method; - MsRunSp _sp_msrun; - std::map<QString, PeptideXtpSp> _map_peptides; - bool _is_xtpcpp_xpip = false; - QString _current_id; - - - std::size_t _count_proteins=0; - std::size_t _count_peptides=0; - std::size_t _count_peptide_evidences=0; - std::size_t _count_protein_matches=0; - std::size_t _count_total=0; - std::size_t _total_proteins; - std::size_t _total_peptides; - std::size_t _total_peptide_evidences; - std::size_t _total_protein_matches; - std::size_t _total; + public: + XtpXpipSaxHandler(WorkMonitorInterface *p_monitor, Project *p_project); + ~XtpXpipSaxHandler(); + + bool startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attributes); + + bool endElement(const QString &namespaceURI, const QString &localName, + const QString &qName); + + bool startDocument(); + + bool endDocument(); + + bool characters(const QString &str); + + bool fatalError(const QXmlParseException &exception); + bool error(const QXmlParseException &exception); + + QString errorString() const; + bool isXtpXpip() const; + + + private: + bool startElement_filter_params(QXmlAttributes attributes); + bool startElement_description(QXmlAttributes attributes); + bool startElement_fasta_file(QXmlAttributes attributes); + bool startElement_protein_match(QXmlAttributes attributes); + bool startElement_peptide_match(QXmlAttributes attributes); + bool startElement_peptide(QXmlAttributes attributes); + bool startElement_peptide_evidence(QXmlAttributes attributes); + bool startElement_peptide_evidence_list(QXmlAttributes attributes); + bool startElement_protein(QXmlAttributes attributes); + bool startElement_msrun(QXmlAttributes attributes); + bool startElement_identification_source(QXmlAttributes attributes); + bool startElement_identification_group(QXmlAttributes attributes); + + bool startElement_modification(QXmlAttributes attributes); + bool startElement_mod(QXmlAttributes attributes); + bool startElement_param(QXmlAttributes attributes); + bool startElement_stat(QXmlAttributes attributes); + bool startElement_counts(QXmlAttributes attributes); + bool startElement_label_method(QXmlAttributes attributes); + bool startElement_contaminants(QXmlAttributes attributes); + bool startElement_decoys(QXmlAttributes attributes); + + // bool endElement_identification(); + bool endElement_sequence(); + bool endElement_msrun(); + bool endElement_protein(); + bool endElement_peptide(); + bool endElement_protein_match(); + bool endElement_peptide_evidence(); + bool endElement_peptide_evidence_list(); + bool endElement_identification_group(); + bool endElement_identification_source(); + + private: + WorkMonitorInterface *_p_monitor; + std::vector<QString> _tag_stack; + QString _errorStr; + QString _current_text; + AutomaticFilterParameters _automatic_filter_parameters; + + Project *_p_project; + ProteinMatch *_p_protein_match; + PeptideEvidence *_p_peptide_evidence; + IdentificationGroup *_current_identification_group_p; + + std::map<QString, pappso::AaModificationP> _map_modifs; + std::map<QString, FastaFileSp> _map_fasta_files; + std::map<QString, ProteinXtpSp> _map_proteins; + std::map<QString, MsRunSp> _map_msruns; + std::map<QString, IdentificationDataSourceSp> _map_ident_sources; + std::map<QString, PeptideEvidenceSp> _map_peptide_evidences; + PeptideEvidenceSp _sp_current_peptide_evidence; + ProteinXtpSp _sp_current_protein; + PeptideXtpSp _current_peptide_sp; + IdentificationDataSourceSp _sp_current_identification_source; + LabelingMethodSp _sp_labeling_method; + MsRunSp _sp_msrun; + std::map<QString, PeptideXtpSp> _map_peptides; + bool _is_xtpcpp_xpip = false; + QString _current_id; + + + std::size_t _count_proteins = 0; + std::size_t _count_peptides = 0; + std::size_t _count_peptide_evidences = 0; + std::size_t _count_protein_matches = 0; + std::size_t _count_total = 0; + std::size_t _total_proteins; + std::size_t _total_peptides; + std::size_t _total_peptide_evidences; + std::size_t _total_protein_matches; + std::size_t _total; }; #endif // XTPXPIPSAXHANDLER_H diff --git a/src/output/masschroqml.cpp b/src/output/masschroqml.cpp index f993f7359f4d45d8711d96caa52f07ebcea3b1e6..570c75c25039639920dcc88a24c57ecfdc551b64 100644 --- a/src/output/masschroqml.cpp +++ b/src/output/masschroqml.cpp @@ -6,26 +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 "masschroqml.h" #include <pappsomspp/pappsoexception.h> @@ -35,486 +36,598 @@ #include <QStringList> #include <QSettings> -struct McqObserved { - bool operator ==(const McqObserved &other) const { - return (msrun==other.msrun && scan==other.scan && charge==other.charge); - }; - const MsRun * msrun; - unsigned int scan; - unsigned int charge; +struct McqObserved +{ + bool + operator==(const McqObserved &other) const + { + return (msrun == other.msrun && scan == other.scan && + charge == other.charge); + }; + const MsRun *msrun; + unsigned int scan; + unsigned int charge; }; -struct McqPeptide { - QString id; - QStringList mods; - QStringList prot_ids; - QString seq; - const pappso::Peptide * native_peptide; - std::vector<McqObserved> observed_in; +struct McqPeptide +{ + QString id; + QStringList mods; + QStringList prot_ids; + QString seq; + const pappso::Peptide *native_peptide; + std::vector<McqObserved> observed_in; }; -struct McqPsimod { - unsigned int at; - QString accession; +struct McqPsimod +{ + unsigned int at; + QString accession; }; -MassChroQml::MassChroQml(const QString & out_filename) +MassChroQml::MassChroQml(const QString &out_filename) { - //_p_digestion_pipeline = p_digestion_pipeline; + //_p_digestion_pipeline = p_digestion_pipeline; - //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; - QString complete_out_filename = out_filename; - _output_file = new QFile(complete_out_filename); + //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; + QString complete_out_filename = out_filename; + _output_file = new QFile(complete_out_filename); - if (_output_file->open(QIODevice::WriteOnly)) + if(_output_file->open(QIODevice::WriteOnly)) { - _output_stream = new QXmlStreamWriter(); - _output_stream->setDevice(_output_file); - } else + _output_stream = new QXmlStreamWriter(); + _output_stream->setDevice(_output_file); + } + else { - throw pappso::PappsoException(QObject::tr("error : cannot open the MassChroqML output file : %1\n").arg(out_filename)); + throw pappso::PappsoException( + QObject::tr("error : cannot open the MassChroqML output file : %1\n") + .arg(out_filename)); } - _output_stream->setAutoFormatting(true); - _output_stream->writeStartDocument("1.0"); - - _detect_zivy.loadSettings(); + _output_stream->setAutoFormatting(true); + _output_stream->writeStartDocument("1.0"); + _detect_zivy.loadSettings(); } MassChroQml::~MassChroQml() { - delete _output_file; - delete _output_stream; + delete _output_file; + delete _output_stream; } -void MassChroQml::close() { - _output_stream->writeEndDocument(); - _output_file->close(); +void +MassChroQml::close() +{ + _output_stream->writeEndDocument(); + _output_file->close(); } -void MassChroQml::write(ProjectSp sp_project) { +void +MassChroQml::write(ProjectSp sp_project) +{ - _sp_project = sp_project; - if (_sp_project.get() == nullptr) { - throw pappso::PappsoException(QObject::tr("Error writing MassChroqML file :\n project is empty")); + _sp_project = sp_project; + if(_sp_project.get() == nullptr) + { + throw pappso::PappsoException( + QObject::tr("Error writing MassChroqML file :\n project is empty")); } - //<masschroq> - _output_stream->writeStartElement("masschroq"); - _output_stream->writeAttribute("type","input"); - _output_stream->writeAttribute("version","2.2"); - //_output_stream->writeAttribute("creationDate", QDateTime::currentDateTime().toString( Qt::ISODate)); - //_output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance","xsi"); - //_output_stream->writeAttribute("xmlns","http://pappso.inra.fr/xsd/masschroqml/2.2"); - //_output_stream->writeAttribute("http://www.w3.org/2001/XMLSchema-instance","schemaLocation","http://pappso.inra.fr/xsd/masschroqml/2.2 http://pappso.inra.fr/xsd/masschroq-2.2.xsd"); - - // <rawdata><!-- time_values_dir="directory" to read retention time corrections--> - _output_stream->writeStartElement("rawdata"); - _output_stream->writeComment("time_values_dir=\"directory\" to read retention time corrections"); - - std::vector<MsRunSp> msrun_list = _sp_project.get()->getMsRunStore().getMsRunList(); - for (MsRunSp & msrun : msrun_list) { - - //<data_file id="samp0" format="mzxml" path="bsa1.mzXML" type="centroid" /> - _output_stream->writeStartElement("data_file"); - _output_stream->writeAttribute("id",msrun.get()->getXmlId()); - if(msrun.get()->getMzFormat() == pappso::MzFormat::mzXML) { - _output_stream->writeAttribute("format","mzxml"); + //<masschroq> + _output_stream->writeStartElement("masschroq"); + _output_stream->writeAttribute("type", "input"); + _output_stream->writeAttribute("version", "2.2"); + //_output_stream->writeAttribute("creationDate", + //QDateTime::currentDateTime().toString( Qt::ISODate)); + //_output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance","xsi"); + //_output_stream->writeAttribute("xmlns","http://pappso.inra.fr/xsd/masschroqml/2.2"); + //_output_stream->writeAttribute("http://www.w3.org/2001/XMLSchema-instance","schemaLocation","http://pappso.inra.fr/xsd/masschroqml/2.2 + //http://pappso.inra.fr/xsd/masschroq-2.2.xsd"); + + // <rawdata><!-- time_values_dir="directory" to read retention time + // corrections--> + _output_stream->writeStartElement("rawdata"); + _output_stream->writeComment( + "time_values_dir=\"directory\" to read retention time corrections"); + + std::vector<MsRunSp> msrun_list = + _sp_project.get()->getMsRunStore().getMsRunList(); + for(MsRunSp &msrun : msrun_list) + { + + //<data_file id="samp0" format="mzxml" path="bsa1.mzXML" type="centroid" + ///> + _output_stream->writeStartElement("data_file"); + _output_stream->writeAttribute("id", msrun.get()->getXmlId()); + if(msrun.get()->getMzFormat() == pappso::MzFormat::mzXML) + { + _output_stream->writeAttribute("format", "mzxml"); } - _output_stream->writeAttribute("path",msrun.get()->getFilename()); - _output_stream->writeAttribute("type","centroid"); - // <data_file id="samp1" format="mzxml" path="bsa2.mzXML" type="profile" /> - _output_stream->writeEndElement(); + _output_stream->writeAttribute("path", msrun.get()->getFilename()); + _output_stream->writeAttribute("type", "centroid"); + // <data_file id="samp1" format="mzxml" path="bsa2.mzXML" type="profile" + // /> + _output_stream->writeEndElement(); } - // <data_file id="samp2" format="mzml" path="/home/user/bsa3.mzml" type="profile" /> -//<data_file id="samp3" format="mzml" path="/home/user/bsa4.mzml" type="profile" /> - // _output_stream.writeEndElement(); - // </rawdata> - _output_stream->writeEndElement(); - - - writeGroups(); - writeProteinList(); - writePeptideList(); - writeIsotopeLabelList(); - writeAlignments(); - writeQuantificationMethods(); - _output_stream->writeStartElement("quantification"); - writeQuantificationResults(); - writeQuantificationTraces(); - writeQuantify(); - _output_stream->writeEndElement(); - - - _output_stream->writeEndDocument(); + // <data_file id="samp2" format="mzml" path="/home/user/bsa3.mzml" + // type="profile" /> + //<data_file id="samp3" format="mzml" path="/home/user/bsa4.mzml" + //type="profile" /> + // _output_stream.writeEndElement(); + // </rawdata> + _output_stream->writeEndElement(); + + + writeGroups(); + writeProteinList(); + writePeptideList(); + writeIsotopeLabelList(); + writeAlignments(); + writeQuantificationMethods(); + _output_stream->writeStartElement("quantification"); + writeQuantificationResults(); + writeQuantificationTraces(); + writeQuantify(); + _output_stream->writeEndElement(); + + + _output_stream->writeEndDocument(); } - -void MassChroQml::writeQuantificationResults() { - //<quantification_results> - _output_stream->writeStartElement("quantification_results"); - //<quantification_result output_file="result1" - // format="tsv" /> - _output_stream->writeStartElement("quantification_result"); - _output_stream->writeAttribute("output_file","result1"); - _output_stream->writeAttribute("format","tsv"); - _output_stream->writeEndElement(); - //<quantification_result output_file="result2" - // format="ods" /> - _output_stream->writeComment("<quantification_result output_file=\"result2\" format=\"ods\" />"); - //<compar_result output_file="compar" - // format="ods" /> - - _output_stream->writeStartElement("compar_result"); - _output_stream->writeAttribute("output_file","result1"); - _output_stream->writeAttribute("format","ods"); - _output_stream->writeEndElement(); - //</quantification_results> - _output_stream->writeEndElement(); +void +MassChroQml::writeQuantificationResults() +{ + //<quantification_results> + _output_stream->writeStartElement("quantification_results"); + //<quantification_result output_file="result1" + // format="tsv" /> + _output_stream->writeStartElement("quantification_result"); + _output_stream->writeAttribute("output_file", "result1"); + _output_stream->writeAttribute("format", "tsv"); + _output_stream->writeEndElement(); + //<quantification_result output_file="result2" + // format="ods" /> + _output_stream->writeComment( + "<quantification_result output_file=\"result2\" format=\"ods\" />"); + //<compar_result output_file="compar" + // format="ods" /> + + _output_stream->writeStartElement("compar_result"); + _output_stream->writeAttribute("output_file", "result1"); + _output_stream->writeAttribute("format", "ods"); + _output_stream->writeEndElement(); + //</quantification_results> + _output_stream->writeEndElement(); } -void MassChroQml::writeQuantificationTraces() { - //<quantification_traces> - - _output_stream->writeStartElement("quantification_traces"); - //<peptide_traces peptide_ids="pep0 pep1" output_dir="pep_traces" - // format="tsv" /> - _output_stream->writeComment("<peptide_traces peptide_ids=\"pep0 pep1\" output_dir=\"pep_traces\" format=\"tsv\" />"); - /* - <all_xics_traces output_dir="all_xics_traces" format="tsv" /> - <mz_traces mz_values="634.635 449.754 552.234" output_dir="mz_traces" - format="tsv" /> - <mzrt_traces output_dir="mzrt_traces" format="tsv"> - <mzrt_values> - <mzrt_value mz="732.317" rt="230.712" /> - <mzrt_value mz="575.256" rt="254.788" /> - </mzrt_values> - </mzrt_traces>*/ - //</quantification_traces> - - _output_stream->writeEndElement(); +void +MassChroQml::writeQuantificationTraces() +{ + //<quantification_traces> + + _output_stream->writeStartElement("quantification_traces"); + //<peptide_traces peptide_ids="pep0 pep1" output_dir="pep_traces" + // format="tsv" /> + _output_stream->writeComment("<peptide_traces peptide_ids=\"pep0 pep1\" " + "output_dir=\"pep_traces\" format=\"tsv\" />"); + /* + <all_xics_traces output_dir="all_xics_traces" format="tsv" /> + <mz_traces mz_values="634.635 449.754 552.234" output_dir="mz_traces" + format="tsv" /> + <mzrt_traces output_dir="mzrt_traces" format="tsv"> + <mzrt_values> + <mzrt_value mz="732.317" rt="230.712" /> + <mzrt_value mz="575.256" rt="254.788" /> + </mzrt_values> + </mzrt_traces>*/ + //</quantification_traces> + + _output_stream->writeEndElement(); } -void MassChroQml::writeQuantify() { - //<quantify id="q1" withingroup="G1" quantification_method_id="my_qzivy"> - _output_stream->writeStartElement("quantify"); - _output_stream->writeAttribute("id","q1"); - _output_stream->writeAttribute("withingroup","fractiona1"); - _output_stream->writeAttribute("quantification_method_id","quant1"); - //<peptides_in_peptide_list mode="real_or_mean" /> - //</quantify> - //<quantify id="q2" withingroup="G2" quantification_method_id="my_moulon"> - //<peptides_in_peptide_list mode="post_matching" - // isotope_label_refs="iso1 iso2" /> - - _output_stream->writeStartElement("peptides_in_peptide_list"); - _output_stream->writeAttribute("mode","post_matching"); - _output_stream->writeAttribute("ni_min_abundance","0.8"); - if (_sp_project.get()->getLabelingMethodSp().get() != nullptr) { - QStringList isotope_label_ref; - for (const Label * p_label :_sp_project.get()->getLabelingMethodSp().get()->getLabelList()) { - isotope_label_ref << p_label->getXmlId(); +void +MassChroQml::writeQuantify() +{ + //<quantify id="q1" withingroup="G1" quantification_method_id="my_qzivy"> + _output_stream->writeStartElement("quantify"); + _output_stream->writeAttribute("id", "q1"); + _output_stream->writeAttribute("withingroup", "fractiona1"); + _output_stream->writeAttribute("quantification_method_id", "quant1"); + //<peptides_in_peptide_list mode="real_or_mean" /> + //</quantify> + //<quantify id="q2" withingroup="G2" quantification_method_id="my_moulon"> + //<peptides_in_peptide_list mode="post_matching" + // isotope_label_refs="iso1 iso2" /> + + _output_stream->writeStartElement("peptides_in_peptide_list"); + _output_stream->writeAttribute("mode", "post_matching"); + _output_stream->writeAttribute("ni_min_abundance", "0.8"); + if(_sp_project.get()->getLabelingMethodSp().get() != nullptr) + { + QStringList isotope_label_ref; + for(const Label *p_label : + _sp_project.get()->getLabelingMethodSp().get()->getLabelList()) + { + isotope_label_ref << p_label->getXmlId(); } - _output_stream->writeAttribute("isotope_label_refs",isotope_label_ref.join(" ")); + _output_stream->writeAttribute("isotope_label_refs", + isotope_label_ref.join(" ")); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); - _output_stream->writeComment("<mz_list>732.317 449.754 552.234 464.251 381.577 569.771 575.256</mz_list>"); - _output_stream->writeComment("<mzrt_list>\n <mzrt mz=\"732.317\" rt=\"230.712\" />\n <mzrt mz=\"575.256\" rt=\"254.788\" />\n </mzrt_list>"); + _output_stream->writeComment("<mz_list>732.317 449.754 552.234 464.251 " + "381.577 569.771 575.256</mz_list>"); + _output_stream->writeComment( + "<mzrt_list>\n <mzrt mz=\"732.317\" rt=\"230.712\" />\n <mzrt " + "mz=\"575.256\" rt=\"254.788\" />\n </mzrt_list>"); - //</quantify> - _output_stream->writeEndElement(); + //</quantify> + _output_stream->writeEndElement(); } -void MassChroQml::writeQuantificationMethods() { - //<quantification_methods> - _output_stream->writeStartElement("quantification_methods"); - //<quantification_method id="my_qzivy"> - _output_stream->writeStartElement("quantification_method"); - _output_stream->writeAttribute("id","quant1"); - //<xic_extraction xic_type="sum"> - _output_stream->writeStartElement("xic_extraction"); - _output_stream->writeAttribute("xic_type","max"); - _output_stream->writeComment("max : XIC on BasePeak; sum : XIC on TIC"); - //<ppm_range min="10" max="10"/><!--For XIC extraction on Da use: mz_range--> - - - _output_stream->writeComment("For XIC extraction on Da use: mz_range"); - _output_stream->writeStartElement("ppm_range"); - _output_stream->writeAttribute("min","10"); - _output_stream->writeAttribute("max","10"); - _output_stream->writeEndElement(); - //</xic_extraction> - _output_stream->writeEndElement(); - //<xic_filters> - _output_stream->writeStartElement("xic_filters"); - //<anti_spike half="5"/> - _output_stream->writeStartElement("anti_spike"); - _output_stream->writeAttribute("half","5"); - _output_stream->writeEndElement(); - //<background half_mediane="5" half_min_max="20"/> - _output_stream->writeComment("<background half_mediane=\"5\" half_min_max=\"20\"/>"); - //</xic_filters> - _output_stream->writeEndElement(); - //<peak_detection> - - _output_stream->writeStartElement("peak_detection"); - //<detection_zivy> - _output_stream->writeStartElement("detection_zivy"); - //<mean_filter_half_edge>1</mean_filter_half_edge> - _output_stream->writeStartElement("mean_filter_half_edge"); - _output_stream->writeCharacters(QString("%1").arg(_detect_zivy._smoothing_half_window)); - _output_stream->writeEndElement(); - //<minmax_half_edge>3</minmax_half_edge> - _output_stream->writeStartElement("minmax_half_edge"); - _output_stream->writeCharacters(QString("%1").arg(_detect_zivy._minmax_half_window)); - _output_stream->writeEndElement(); - //<maxmin_half_edge>2</maxmin_half_edge> - _output_stream->writeStartElement("maxmin_half_edge"); - _output_stream->writeCharacters(QString("%1").arg(_detect_zivy._maxmin_half_window)); - _output_stream->writeEndElement(); - //<detection_threshold_on_max>5000</detection_threshold_on_max> - _output_stream->writeStartElement("detection_threshold_on_max"); - _output_stream->writeCharacters(QString("%1").arg(_detect_zivy._minmax_threshold)); - _output_stream->writeEndElement(); - //<detection_threshold_on_min>3000</detection_threshold_on_min> - _output_stream->writeStartElement("detection_threshold_on_min"); - _output_stream->writeCharacters(QString("%1").arg(_detect_zivy._maxmin_threshold)); - _output_stream->writeEndElement(); - //</detection_zivy> - _output_stream->writeEndElement(); - //</peak_detection> - - _output_stream->writeEndElement(); - //</quantification_method> - _output_stream->writeEndElement(); - //</quantification_methods> - _output_stream->writeEndElement(); +void +MassChroQml::writeQuantificationMethods() +{ + //<quantification_methods> + _output_stream->writeStartElement("quantification_methods"); + //<quantification_method id="my_qzivy"> + _output_stream->writeStartElement("quantification_method"); + _output_stream->writeAttribute("id", "quant1"); + //<xic_extraction xic_type="sum"> + _output_stream->writeStartElement("xic_extraction"); + _output_stream->writeAttribute("xic_type", "max"); + _output_stream->writeComment("max : XIC on BasePeak; sum : XIC on TIC"); + //<ppm_range min="10" max="10"/><!--For XIC extraction on Da use: mz_range--> + + + _output_stream->writeComment("For XIC extraction on Da use: mz_range"); + _output_stream->writeStartElement("ppm_range"); + _output_stream->writeAttribute("min", "10"); + _output_stream->writeAttribute("max", "10"); + _output_stream->writeEndElement(); + //</xic_extraction> + _output_stream->writeEndElement(); + //<xic_filters> + _output_stream->writeStartElement("xic_filters"); + //<anti_spike half="5"/> + _output_stream->writeStartElement("anti_spike"); + _output_stream->writeAttribute("half", "5"); + _output_stream->writeEndElement(); + //<background half_mediane="5" half_min_max="20"/> + _output_stream->writeComment( + "<background half_mediane=\"5\" half_min_max=\"20\"/>"); + //</xic_filters> + _output_stream->writeEndElement(); + //<peak_detection> + + _output_stream->writeStartElement("peak_detection"); + //<detection_zivy> + _output_stream->writeStartElement("detection_zivy"); + //<mean_filter_half_edge>1</mean_filter_half_edge> + _output_stream->writeStartElement("mean_filter_half_edge"); + _output_stream->writeCharacters( + QString("%1").arg(_detect_zivy._smoothing_half_window)); + _output_stream->writeEndElement(); + //<minmax_half_edge>3</minmax_half_edge> + _output_stream->writeStartElement("minmax_half_edge"); + _output_stream->writeCharacters( + QString("%1").arg(_detect_zivy._minmax_half_window)); + _output_stream->writeEndElement(); + //<maxmin_half_edge>2</maxmin_half_edge> + _output_stream->writeStartElement("maxmin_half_edge"); + _output_stream->writeCharacters( + QString("%1").arg(_detect_zivy._maxmin_half_window)); + _output_stream->writeEndElement(); + //<detection_threshold_on_max>5000</detection_threshold_on_max> + _output_stream->writeStartElement("detection_threshold_on_max"); + _output_stream->writeCharacters( + QString("%1").arg(_detect_zivy._minmax_threshold)); + _output_stream->writeEndElement(); + //<detection_threshold_on_min>3000</detection_threshold_on_min> + _output_stream->writeStartElement("detection_threshold_on_min"); + _output_stream->writeCharacters( + QString("%1").arg(_detect_zivy._maxmin_threshold)); + _output_stream->writeEndElement(); + //</detection_zivy> + _output_stream->writeEndElement(); + //</peak_detection> + + _output_stream->writeEndElement(); + //</quantification_method> + _output_stream->writeEndElement(); + //</quantification_methods> + _output_stream->writeEndElement(); } -void MassChroQml::writeAlignments() { - //<alignments> - _output_stream->writeStartElement("alignments"); - //<alignment_methods> - _output_stream->writeStartElement("alignment_methods"); - //<alignment_method id="my_ms2"> - _output_stream->writeStartElement("alignment_method"); - _output_stream->writeAttribute("id","my_ms2"); - - //<ms2><!-- write_time_values_output_dir="directory" to write retention time corrections --> - - _output_stream->writeStartElement("ms2"); - _output_stream->writeComment("write_time_values_output_dir=\"directory\" to write retention time corrections"); - //<ms2_tendency_halfwindow>10</ms2_tendency_halfwindow> - _output_stream->writeStartElement("ms2_tendency_halfwindow"); - _output_stream->writeCharacters("10"); - _output_stream->writeEndElement(); - //<ms2_smoothing_halfwindow>5</ms2_smoothing_halfwindow> - - _output_stream->writeStartElement("ms2_smoothing_halfwindow"); - _output_stream->writeCharacters("15"); - _output_stream->writeEndElement(); - //<ms1_smoothing_halfwindow>3</ms1_smoothing_halfwindow> - - _output_stream->writeStartElement("ms1_smoothing_halfwindow"); - _output_stream->writeCharacters("0"); - _output_stream->writeEndElement(); - //</ms2> - _output_stream->writeEndElement(); - //</alignment_method> - _output_stream->writeEndElement(); - _output_stream->writeComment("<alignment_method id=\"my_obiwarp\"> \n<obiwarp>\n <lmat_precision>1</lmat_precision>\n <mz_start>500</mz_start>\n <mz_stop>1200</mz_stop>\n </obiwarp>\n </alignment_method>"); - //</alignment_methods> - _output_stream->writeEndElement(); - //<align group_id="G1" method_id="my_ms2" reference_data_id="samp0" /> - //<align group_id="G2" method_id="my_obiwarp" reference_data_id="samp2" /> - _output_stream->writeStartElement("align"); - _output_stream->writeAttribute("group_id","fractiona1"); - _output_stream->writeAttribute("method_id","my_ms2"); - _output_stream->writeAttribute("reference_data_id","msruna1"); - _output_stream->writeEndElement(); - //</alignments> - _output_stream->writeEndElement(); +void +MassChroQml::writeAlignments() +{ + //<alignments> + _output_stream->writeStartElement("alignments"); + //<alignment_methods> + _output_stream->writeStartElement("alignment_methods"); + //<alignment_method id="my_ms2"> + _output_stream->writeStartElement("alignment_method"); + _output_stream->writeAttribute("id", "my_ms2"); + + //<ms2><!-- write_time_values_output_dir="directory" to write retention time + //corrections --> + + _output_stream->writeStartElement("ms2"); + _output_stream->writeComment("write_time_values_output_dir=\"directory\" to " + "write retention time corrections"); + //<ms2_tendency_halfwindow>10</ms2_tendency_halfwindow> + _output_stream->writeStartElement("ms2_tendency_halfwindow"); + _output_stream->writeCharacters("10"); + _output_stream->writeEndElement(); + //<ms2_smoothing_halfwindow>5</ms2_smoothing_halfwindow> + + _output_stream->writeStartElement("ms2_smoothing_halfwindow"); + _output_stream->writeCharacters("15"); + _output_stream->writeEndElement(); + //<ms1_smoothing_halfwindow>3</ms1_smoothing_halfwindow> + + _output_stream->writeStartElement("ms1_smoothing_halfwindow"); + _output_stream->writeCharacters("0"); + _output_stream->writeEndElement(); + //</ms2> + _output_stream->writeEndElement(); + //</alignment_method> + _output_stream->writeEndElement(); + _output_stream->writeComment( + "<alignment_method id=\"my_obiwarp\"> \n<obiwarp>\n " + "<lmat_precision>1</lmat_precision>\n <mz_start>500</mz_start>\n " + " <mz_stop>1200</mz_stop>\n </obiwarp>\n " + "</alignment_method>"); + //</alignment_methods> + _output_stream->writeEndElement(); + //<align group_id="G1" method_id="my_ms2" reference_data_id="samp0" /> + //<align group_id="G2" method_id="my_obiwarp" reference_data_id="samp2" /> + _output_stream->writeStartElement("align"); + _output_stream->writeAttribute("group_id", "fractiona1"); + _output_stream->writeAttribute("method_id", "my_ms2"); + _output_stream->writeAttribute("reference_data_id", "msruna1"); + _output_stream->writeEndElement(); + //</alignments> + _output_stream->writeEndElement(); } -void MassChroQml::writeIsotopeLabelList() { - LabelingMethod * p_labeling_method = _sp_project.get()->getLabelingMethodSp().get(); - if (p_labeling_method != nullptr) { - //<isotope_label_list> - p_labeling_method->writeMassChroqMl(_output_stream); +void +MassChroQml::writeIsotopeLabelList() +{ + LabelingMethod *p_labeling_method = + _sp_project.get()->getLabelingMethodSp().get(); + if(p_labeling_method != nullptr) + { + //<isotope_label_list> + p_labeling_method->writeMassChroqMl(_output_stream); } } -void MassChroQml::writePeptideList() { -//<peptide_list> - _output_stream->writeStartElement("peptide_list"); - const std::map<unsigned int, GroupingGroupSp> & group_store = _p_identification_group->getGroupStore().getGroupMap(); +void +MassChroQml::writePeptideList() +{ + //<peptide_list> + _output_stream->writeStartElement("peptide_list"); + const std::map<unsigned int, GroupingGroupSp> &group_store = + _p_identification_group->getGroupStore().getGroupMap(); - for (auto & group_pair :group_store) { - writePeptideListInGroup(group_pair.second.get()); + for(auto &group_pair : group_store) + { + writePeptideListInGroup(group_pair.second.get()); } - //</peptide_list> - _output_stream->writeEndElement(); + //</peptide_list> + _output_stream->writeEndElement(); } -void MassChroQml::writePeptideListInGroup(const GroupingGroup * p_group) { - - const std::vector<std::pair<unsigned int, const PeptideEvidence *>> & sg_peptide_evidence_list = p_group->getPairSgNumberPeptideEvidenceList(); - std::vector<McqPeptide> mcq_peptide_list; - - for (auto & sg_peptide_pair :sg_peptide_evidence_list) { - unsigned int sg_number = sg_peptide_pair.first; - const PeptideEvidence * peptide_evidence = sg_peptide_pair.second; - - McqPeptide mcq_peptide; - mcq_peptide.id = peptide_evidence->getGrpPeptideSp().get()->getGroupingId(); - mcq_peptide.mods << peptide_evidence->getPeptideXtpSp().get()->getModifString(); - mcq_peptide.prot_ids << p_group->getProteinGroupingIdOfSubgroup(sg_number); - mcq_peptide.seq = peptide_evidence->getPeptideXtpSp().get()->getSequence(); - mcq_peptide.native_peptide = peptide_evidence->getPeptideXtpSp().get()->getNativePeptideP(); - McqObserved observed = {peptide_evidence->getMsRunP(),peptide_evidence->getScan(),peptide_evidence->getCharge() }; - mcq_peptide.observed_in.push_back(observed); - mcq_peptide_list.push_back(mcq_peptide); +void +MassChroQml::writePeptideListInGroup(const GroupingGroup *p_group) +{ + const std::vector<std::pair<unsigned int, const PeptideEvidence *>> + &sg_peptide_evidence_list = p_group->getPairSgNumberPeptideEvidenceList(); + std::vector<McqPeptide> mcq_peptide_list; + for(auto &sg_peptide_pair : sg_peptide_evidence_list) + { + unsigned int sg_number = sg_peptide_pair.first; + const PeptideEvidence *peptide_evidence = sg_peptide_pair.second; + + McqPeptide mcq_peptide; + mcq_peptide.id = + peptide_evidence->getGrpPeptideSp().get()->getGroupingId(); + mcq_peptide.mods + << peptide_evidence->getPeptideXtpSp().get()->getModifString(); + mcq_peptide.prot_ids << p_group->getProteinGroupingIdOfSubgroup( + sg_number); + mcq_peptide.seq = + peptide_evidence->getPeptideXtpSp().get()->getSequence(); + mcq_peptide.native_peptide = + peptide_evidence->getPeptideXtpSp().get()->getNativePeptideP(); + McqObserved observed = {peptide_evidence->getMsRunP(), + peptide_evidence->getScan(), + peptide_evidence->getCharge()}; + mcq_peptide.observed_in.push_back(observed); + mcq_peptide_list.push_back(mcq_peptide); } - //sort list - std::sort(mcq_peptide_list.begin(),mcq_peptide_list.end(),[](const McqPeptide & first, const McqPeptide & second) { - return (first.id < second.id) ; - }); + // sort list + std::sort(mcq_peptide_list.begin(), mcq_peptide_list.end(), + [](const McqPeptide &first, const McqPeptide &second) { + return (first.id < second.id); + }); - std::vector<McqPeptide> cumul_mcq_peptide_list; - if (mcq_peptide_list.size() > 0) { - McqPeptide cumul = mcq_peptide_list[0]; - for (McqPeptide & mcq_peptide : mcq_peptide_list) { - if (cumul.id == mcq_peptide.id) { + std::vector<McqPeptide> cumul_mcq_peptide_list; + if(mcq_peptide_list.size() > 0) + { + McqPeptide cumul = mcq_peptide_list[0]; + for(McqPeptide &mcq_peptide : mcq_peptide_list) + { + if(cumul.id == mcq_peptide.id) + { - cumul.observed_in.push_back(mcq_peptide.observed_in[0]); + cumul.observed_in.push_back(mcq_peptide.observed_in[0]); - if (!cumul.prot_ids.contains(mcq_peptide.prot_ids[0])) { - cumul.prot_ids << mcq_peptide.prot_ids[0]; + if(!cumul.prot_ids.contains(mcq_peptide.prot_ids[0])) + { + cumul.prot_ids << mcq_peptide.prot_ids[0]; } - if (!cumul.mods.contains(mcq_peptide.mods[0])) { - cumul.mods << mcq_peptide.mods[0]; + if(!cumul.mods.contains(mcq_peptide.mods[0])) + { + cumul.mods << mcq_peptide.mods[0]; } } - else { - cumul_mcq_peptide_list.push_back(cumul); - cumul = mcq_peptide; + else + { + cumul_mcq_peptide_list.push_back(cumul); + cumul = mcq_peptide; } } - cumul_mcq_peptide_list.push_back(cumul); + cumul_mcq_peptide_list.push_back(cumul); } - for (McqPeptide mcq_peptide : cumul_mcq_peptide_list) { - //<peptide id="pep0" mh="1463.626" mods="114.08" prot_ids="P1.1" - // seq="TCVADESHAGCEK"> - _output_stream->writeStartElement("peptide"); - _output_stream->writeAttribute("id",mcq_peptide.id); - _output_stream->writeAttribute("mods",mcq_peptide.mods.join("|")); - _output_stream->writeAttribute("prot_ids",mcq_peptide.prot_ids.join(" ")); - _output_stream->writeAttribute("mh",QString::number(mcq_peptide.native_peptide->getMz(1), 'f', 10)); - _output_stream->writeAttribute("seq",mcq_peptide.seq); - - //<modifications><!-- this tag is optional but gives an exact mass computation --> - std::vector<McqPsimod> mod_list; - unsigned int pos=1; - for (const pappso::Aa & aa: *(mcq_peptide.native_peptide)) { - const std::list<pappso::AaModificationP> aa_mod_list = aa.getModificationList(); - for (pappso::AaModificationP mod : aa_mod_list) { - if (!mod->isInternal()) { - McqPsimod psimod; - psimod.accession = mod->getAccession(); - psimod.at = pos; - mod_list.push_back(psimod); + for(McqPeptide mcq_peptide : cumul_mcq_peptide_list) + { + //<peptide id="pep0" mh="1463.626" mods="114.08" prot_ids="P1.1" + // seq="TCVADESHAGCEK"> + _output_stream->writeStartElement("peptide"); + _output_stream->writeAttribute("id", mcq_peptide.id); + _output_stream->writeAttribute("mods", mcq_peptide.mods.join("|")); + _output_stream->writeAttribute("prot_ids", + mcq_peptide.prot_ids.join(" ")); + _output_stream->writeAttribute( + "mh", QString::number(mcq_peptide.native_peptide->getMz(1), 'f', 10)); + _output_stream->writeAttribute("seq", mcq_peptide.seq); + + //<modifications><!-- this tag is optional but gives an exact mass + //computation --> + std::vector<McqPsimod> mod_list; + unsigned int pos = 1; + for(const pappso::Aa &aa : *(mcq_peptide.native_peptide)) + { + const std::list<pappso::AaModificationP> aa_mod_list = + aa.getModificationList(); + for(pappso::AaModificationP mod : aa_mod_list) + { + if(!mod->isInternal()) + { + McqPsimod psimod; + psimod.accession = mod->getAccession(); + psimod.at = pos; + mod_list.push_back(psimod); } } - pos++; + pos++; } - if (mod_list.size() > 0) { - _output_stream->writeStartElement("modifications"); - for (McqPsimod & psimod :mod_list) { - //<psimod at="2" acc="MOD:00397"></psimod> - _output_stream->writeStartElement("psimod"); - _output_stream->writeAttribute("at",QString("%1").arg(psimod.at)); - _output_stream->writeAttribute("acc",psimod.accession); - //<psimod at="11" acc="MOD:00397"></psimod> - _output_stream->writeEndElement(); + if(mod_list.size() > 0) + { + _output_stream->writeStartElement("modifications"); + for(McqPsimod &psimod : mod_list) + { + //<psimod at="2" acc="MOD:00397"></psimod> + _output_stream->writeStartElement("psimod"); + _output_stream->writeAttribute("at", + QString("%1").arg(psimod.at)); + _output_stream->writeAttribute("acc", psimod.accession); + //<psimod at="11" acc="MOD:00397"></psimod> + _output_stream->writeEndElement(); } - //</modifications> - _output_stream->writeEndElement(); + //</modifications> + _output_stream->writeEndElement(); } - //<observed_in data="samp0" scan="655" z="2" /> - std::sort(mcq_peptide.observed_in.begin(), mcq_peptide.observed_in.end(),[](const McqObserved & first, const McqObserved & second) { - return std::tie(first.charge, first.scan, first.msrun) < std::tie(second.charge, second.scan, second.msrun); - }); - auto last = std::unique(mcq_peptide.observed_in.begin(), mcq_peptide.observed_in.end()); - mcq_peptide.observed_in.erase(last, mcq_peptide.observed_in.end()); - - for (McqObserved observed_in : mcq_peptide.observed_in) { - _output_stream->writeStartElement("observed_in"); - _output_stream->writeAttribute("data",observed_in.msrun->getXmlId()); - _output_stream->writeAttribute("scan",QString("%1").arg(observed_in.scan)); - _output_stream->writeAttribute("z",QString("%1").arg(observed_in.charge)); - _output_stream->writeEndElement(); + //<observed_in data="samp0" scan="655" z="2" /> + std::sort(mcq_peptide.observed_in.begin(), mcq_peptide.observed_in.end(), + [](const McqObserved &first, const McqObserved &second) { + return std::tie(first.charge, first.scan, first.msrun) < + std::tie(second.charge, second.scan, second.msrun); + }); + auto last = std::unique(mcq_peptide.observed_in.begin(), + mcq_peptide.observed_in.end()); + mcq_peptide.observed_in.erase(last, mcq_peptide.observed_in.end()); + + for(McqObserved observed_in : mcq_peptide.observed_in) + { + _output_stream->writeStartElement("observed_in"); + _output_stream->writeAttribute("data", observed_in.msrun->getXmlId()); + _output_stream->writeAttribute("scan", + QString("%1").arg(observed_in.scan)); + _output_stream->writeAttribute("z", + QString("%1").arg(observed_in.charge)); + _output_stream->writeEndElement(); } - //<observed_in data="samp1" scan="798" z="2" />*/ - //</peptide> - _output_stream->writeEndElement(); + //<observed_in data="samp1" scan="798" z="2" />*/ + //</peptide> + _output_stream->writeEndElement(); } } -void MassChroQml::writeGroups() { -//<groups> - _output_stream->writeStartElement("groups"); - //<group data_ids="samp0 samp1" id="G1" /> - _output_stream->writeStartElement("group"); - _output_stream->writeAttribute("id",QString("fractiona1")); - std::vector<MsRunSp> msrun_list = _sp_project.get()->getMsRunStore().getMsRunList(); - QStringList list; - for (MsRunSp & msrun : msrun_list) { - list << msrun.get()->getXmlId(); +void +MassChroQml::writeGroups() +{ + //<groups> + _output_stream->writeStartElement("groups"); + //<group data_ids="samp0 samp1" id="G1" /> + _output_stream->writeStartElement("group"); + _output_stream->writeAttribute("id", QString("fractiona1")); + std::vector<MsRunSp> msrun_list = + _sp_project.get()->getMsRunStore().getMsRunList(); + QStringList list; + for(MsRunSp &msrun : msrun_list) + { + list << msrun.get()->getXmlId(); } - _output_stream->writeAttribute("data_ids",list.join(" ")); - _output_stream->writeEndElement(); - //<group data_ids="samp2 samp3" id="G2" /> -// </groups> - _output_stream->writeEndElement(); + _output_stream->writeAttribute("data_ids", list.join(" ")); + _output_stream->writeEndElement(); + //<group data_ids="samp2 samp3" id="G2" /> + // </groups> + _output_stream->writeEndElement(); } -void MassChroQml::writeProteinList() { -//<protein_list> - _output_stream->writeStartElement("protein_list"); - std::vector<IdentificationGroup *> identification_list = _sp_project.get()->getIdentificationGroupList(); - if (identification_list.size() == 0) { - throw pappso::PappsoException(QObject::tr("Error writing MassChroqML file :\n no protein list")); +void +MassChroQml::writeProteinList() +{ + //<protein_list> + _output_stream->writeStartElement("protein_list"); + std::vector<IdentificationGroup *> identification_list = + _sp_project.get()->getIdentificationGroupList(); + if(identification_list.size() == 0) + { + throw pappso::PappsoException( + QObject::tr("Error writing MassChroqML file :\n no protein list")); } - if (identification_list.size() > 1) { - throw pappso::PappsoException(QObject::tr("Error writing MassChroqML file :\n only available in combine mode")); + if(identification_list.size() > 1) + { + throw pappso::PappsoException(QObject::tr( + "Error writing MassChroqML file :\n only available in combine mode")); } - _p_identification_group = identification_list[0]; - for (ProteinMatch * p_protein_match :_p_identification_group->getProteinMatchList()) { - if (!p_protein_match->isGrouped()) continue; - //<protein desc="conta|P02769|ALBU_BOVIN SERUM ALBUMIN PRECURSOR." - // id="P1.1" /> - pappso::GrpProteinSp grp_protein = p_protein_match->getGrpProteinSp(); - if (grp_protein.get()->getRank() == 1) { - _output_stream->writeStartElement("protein"); - _output_stream->writeAttribute("id",grp_protein.get()->getGroupingId()); - QStringList list; - list << p_protein_match->getProteinXtpSp().get()->getAccession(); - list << p_protein_match->getProteinXtpSp().get()->getDescription(); - _output_stream->writeAttribute("desc",list.join(" ")); - //<protein desc="conta|P02770|ALBU_RAT SERUM ALBUMIN PRECURSOR." - // id="P1.2" /> - _output_stream->writeEndElement(); + _p_identification_group = identification_list[0]; + for(ProteinMatch *p_protein_match : + _p_identification_group->getProteinMatchList()) + { + if(!p_protein_match->isGrouped()) + continue; + //<protein desc="conta|P02769|ALBU_BOVIN SERUM ALBUMIN PRECURSOR." + // id="P1.1" /> + pappso::GrpProteinSp grp_protein = p_protein_match->getGrpProteinSp(); + if(grp_protein.get()->getRank() == 1) + { + _output_stream->writeStartElement("protein"); + _output_stream->writeAttribute("id", + grp_protein.get()->getGroupingId()); + QStringList list; + list << p_protein_match->getProteinXtpSp().get()->getAccession(); + list << p_protein_match->getProteinXtpSp().get()->getDescription(); + _output_stream->writeAttribute("desc", list.join(" ")); + //<protein desc="conta|P02770|ALBU_RAT SERUM ALBUMIN PRECURSOR." + // id="P1.2" /> + _output_stream->writeEndElement(); } } - //</protein_list> - _output_stream->writeEndElement(); + //</protein_list> + _output_stream->writeEndElement(); } diff --git a/src/output/masschroqml.h b/src/output/masschroqml.h index d46ce93ff91add2ee3b4e251f30f6087dca594b6..bfe3226901c8ec903f263a647736617322c770d7 100644 --- a/src/output/masschroqml.h +++ b/src/output/masschroqml.h @@ -6,26 +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 + ******************************************************************************/ #ifndef MASSCHROQML_H #define MASSCHROQML_H @@ -40,30 +41,31 @@ class MassChroQml { - public: - MassChroQml(const QString & out_filename); - ~MassChroQml(); + public: + MassChroQml(const QString &out_filename); + ~MassChroQml(); - void write(ProjectSp sp_project); - void close(); -private: - void writeGroups(); - void writeProteinList(); - void writePeptideList(); - void writePeptideListInGroup(const GroupingGroup * p_group); - void writeIsotopeLabelList(); - void writeAlignments(); - void writeQuantificationMethods(); - void writeQuantificationResults(); - void writeQuantificationTraces(); - void writeQuantify(); - -private : - QFile * _output_file; - QXmlStreamWriter * _output_stream; - ProjectSp _sp_project; - IdentificationGroup * _p_identification_group; - ZivyParams _detect_zivy; + void write(ProjectSp sp_project); + void close(); + + private: + void writeGroups(); + void writeProteinList(); + void writePeptideList(); + void writePeptideListInGroup(const GroupingGroup *p_group); + void writeIsotopeLabelList(); + void writeAlignments(); + void writeQuantificationMethods(); + void writeQuantificationResults(); + void writeQuantificationTraces(); + void writeQuantify(); + + private: + QFile *_output_file; + QXmlStreamWriter *_output_stream; + ProjectSp _sp_project; + IdentificationGroup *_p_identification_group; + ZivyParams _detect_zivy; }; #endif // MASSCHROQML_H diff --git a/src/output/masschroqprm.cpp b/src/output/masschroqprm.cpp index 8f5c272c972aae4183616952d27229a0107d21be..3bd5d50f0de3cdda761445b1e6642e1985a0b187 100644 --- a/src/output/masschroqprm.cpp +++ b/src/output/masschroqprm.cpp @@ -6,159 +6,199 @@ */ /******************************************************************************* -* 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 "masschroqprm.h" #include <pappsomspp/pappsoexception.h> #include <pappsomspp/utils.h> -MassChroqPrm::MassChroqPrm(const QString & out_filename) { - //_p_digestion_pipeline = p_digestion_pipeline; +MassChroqPrm::MassChroqPrm(const QString &out_filename) +{ + //_p_digestion_pipeline = p_digestion_pipeline; - //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; - QString complete_out_filename = out_filename; - _output_file = new QFile(complete_out_filename); + //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; + QString complete_out_filename = out_filename; + _output_file = new QFile(complete_out_filename); - if (_output_file->open(QIODevice::WriteOnly)) + if(_output_file->open(QIODevice::WriteOnly)) { - _output_stream = new QXmlStreamWriter(); - _output_stream->setDevice(_output_file); - } else + _output_stream = new QXmlStreamWriter(); + _output_stream->setDevice(_output_file); + } + else { - throw pappso::PappsoException(QObject::tr("error : cannot open the MassChroqPRM output file : %1\n").arg(out_filename)); + throw pappso::PappsoException( + QObject::tr("error : cannot open the MassChroqPRM output file : %1\n") + .arg(out_filename)); } - _output_stream->setAutoFormatting(true); - _output_stream->writeStartDocument("1.0"); - - + _output_stream->setAutoFormatting(true); + _output_stream->writeStartDocument("1.0"); } MassChroqPrm::~MassChroqPrm() { - delete _output_file; - delete _output_stream; + delete _output_file; + delete _output_stream; } -void MassChroqPrm::close() { - _output_stream->writeEndDocument(); - _output_file->close(); +void +MassChroqPrm::close() +{ + _output_stream->writeEndDocument(); + _output_file->close(); } -void MassChroqPrm::write(ProjectSp sp_project) { +void +MassChroqPrm::write(ProjectSp sp_project) +{ - _sp_project = sp_project; - if (_sp_project.get() == nullptr) { - throw pappso::PappsoException(QObject::tr("Error writing MassChroqPRM file :\n project is empty")); + _sp_project = sp_project; + if(_sp_project.get() == nullptr) + { + throw pappso::PappsoException( + QObject::tr("Error writing MassChroqPRM file :\n project is empty")); } - //<masschroq> - _output_stream->writeStartElement("masschroqprm"); - /* - * - <parameters> - <parentIonMassTolerance> - <daltonPrecision value="1.5"/> - </parentIonMassTolerance> - <fragmentIonMassTolerance> - <daltonPrecision value="0.02"/> - </fragmentIonMassTolerance> - </parameters> - */ - _output_stream->writeStartElement("parameters"); - _output_stream->writeStartElement("parentIonMassTolerance"); - _output_stream->writeComment("choose dalton or ppm mass precision to select parent ions based on the precursor mass of each MS/MS spectrum"); - _output_stream->writeStartElement("ppmPrecision"); - _output_stream->writeAttribute("value", "10"); - _output_stream->writeEndElement(); - _output_stream->writeEndElement(); - _output_stream->writeStartElement("fragmentIonMassTolerance"); - _output_stream->writeComment("choose dalton or ppm mass precision to MS/MS fragment ion observed mass with theoretical mass"); - _output_stream->writeStartElement("daltonPrecision"); - _output_stream->writeAttribute("value", "0.02"); - _output_stream->writeEndElement(); - _output_stream->writeEndElement(); - _output_stream->writeEndElement(); - - writePeptides(); + //<masschroq> + _output_stream->writeStartElement("masschroqprm"); + /* + * + <parameters> + <parentIonMassTolerance> + <daltonPrecision value="1.5"/> + </parentIonMassTolerance> + <fragmentIonMassTolerance> + <daltonPrecision value="0.02"/> + </fragmentIonMassTolerance> + </parameters> + */ + _output_stream->writeStartElement("parameters"); + _output_stream->writeStartElement("parentIonMassTolerance"); + _output_stream->writeComment( + "choose dalton or ppm mass precision to select parent ions based on the " + "precursor mass of each MS/MS spectrum"); + _output_stream->writeStartElement("ppmPrecision"); + _output_stream->writeAttribute("value", "10"); + _output_stream->writeEndElement(); + _output_stream->writeEndElement(); + _output_stream->writeStartElement("fragmentIonMassTolerance"); + _output_stream->writeComment( + "choose dalton or ppm mass precision to MS/MS fragment ion observed mass " + "with theoretical mass"); + _output_stream->writeStartElement("daltonPrecision"); + _output_stream->writeAttribute("value", "0.02"); + _output_stream->writeEndElement(); + _output_stream->writeEndElement(); + _output_stream->writeEndElement(); + + writePeptides(); } -void MassChroqPrm::writePeptides() { - - /* - * - * - * <peptide seq="TCVADESHAGCEK" id="p1"> <psimod at="2" - * acc="MOD:00397"/> <psimod at="11" acc="MOD:00397"/> </peptide> - */ - try { - - _output_stream->writeStartElement("peptideList"); - - for (IdentificationDataSourceSp identification_data_source_sp :_sp_project.get()->getIdentificationDataSourceStore().getIdentificationDataSourceList()) { - for (const PeptideEvidenceSp & peptide_evidence_sp: identification_data_source_sp.get()->getPeptideEvidenceStore().getPeptideEvidenceList()) { - const pappso::GrpPeptide * p_grp_peptide =peptide_evidence_sp.get()->getGrpPeptideSp().get(); - - if (p_grp_peptide != nullptr) { - std::set<const pappso::GrpPeptide *> _already_writed; - if (_already_writed.find(p_grp_peptide) == _already_writed.end()) { - _already_writed.insert(p_grp_peptide); - PeptideXtp * p_peptide = peptide_evidence_sp.get()->getPeptideXtpSp().get(); - _output_stream->writeStartElement("peptide"); - _output_stream->writeAttribute("id",p_grp_peptide->getGroupingId()); - _output_stream->writeAttribute("seq", p_peptide->getSequence()); - - - unsigned int i=0; - for (const pappso::Aa & amino_acid: *p_peptide) { - - std::list<pappso::AaModificationP> aa_modif_list = amino_acid.getModificationList(); +void +MassChroqPrm::writePeptides() +{ + /* + * + * + * <peptide seq="TCVADESHAGCEK" id="p1"> <psimod at="2" + * acc="MOD:00397"/> <psimod at="11" acc="MOD:00397"/> </peptide> + */ + try + { - for (auto && aa_modif : aa_modif_list) { - if (!aa_modif->isInternal()) { - _output_stream->writeStartElement("psimod"); - _output_stream->writeAttribute("acc", aa_modif->getAccession()); - _output_stream->writeAttribute("at", QString ("%1").arg(i)); - _output_stream->writeEndElement();// mod + _output_stream->writeStartElement("peptideList"); + + for(IdentificationDataSourceSp identification_data_source_sp : + _sp_project.get() + ->getIdentificationDataSourceStore() + .getIdentificationDataSourceList()) + { + for(const PeptideEvidenceSp &peptide_evidence_sp : + identification_data_source_sp.get() + ->getPeptideEvidenceStore() + .getPeptideEvidenceList()) + { + const pappso::GrpPeptide *p_grp_peptide = + peptide_evidence_sp.get()->getGrpPeptideSp().get(); + + if(p_grp_peptide != nullptr) + { + std::set<const pappso::GrpPeptide *> _already_writed; + if(_already_writed.find(p_grp_peptide) == + _already_writed.end()) + { + _already_writed.insert(p_grp_peptide); + PeptideXtp *p_peptide = + peptide_evidence_sp.get()->getPeptideXtpSp().get(); + _output_stream->writeStartElement("peptide"); + _output_stream->writeAttribute( + "id", p_grp_peptide->getGroupingId()); + _output_stream->writeAttribute("seq", + p_peptide->getSequence()); + + + unsigned int i = 0; + for(const pappso::Aa &amino_acid : *p_peptide) + { + + std::list<pappso::AaModificationP> aa_modif_list = + amino_acid.getModificationList(); + + + for(auto &&aa_modif : aa_modif_list) + { + if(!aa_modif->isInternal()) + { + _output_stream->writeStartElement("psimod"); + _output_stream->writeAttribute( + "acc", aa_modif->getAccession()); + _output_stream->writeAttribute( + "at", QString("%1").arg(i)); + _output_stream->writeEndElement(); // mod } } - i++; + i++; } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } } } } - //peptideList - _output_stream->writeEndElement(); + // peptideList + _output_stream->writeEndElement(); } - catch (pappso::PappsoException &error) + catch(pappso::PappsoException &error) { - throw pappso::PappsoException(QObject::tr("Error in MassChroqPrm::writePeptides :\n%1").arg(error.qwhat())); + throw pappso::PappsoException( + QObject::tr("Error in MassChroqPrm::writePeptides :\n%1") + .arg(error.qwhat())); } - catch (std::exception &error) + catch(std::exception &error) { - throw pappso::PappsoException(QObject::tr("Error in MassChroqPrm::writePeptides stdex :\n%1").arg(error.what())); + throw pappso::PappsoException( + QObject::tr("Error in MassChroqPrm::writePeptides stdex :\n%1") + .arg(error.what())); } - } diff --git a/src/output/masschroqprm.h b/src/output/masschroqprm.h index bc2e8e04c05ac89d4840c18626ee031482e68d0c..f3081a5e612c9dce09a4b852457dc83f47947996 100644 --- a/src/output/masschroqprm.h +++ b/src/output/masschroqprm.h @@ -6,26 +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 + ******************************************************************************/ #ifndef MASSCHROQPRM_H #define MASSCHROQPRM_H @@ -38,20 +39,21 @@ class MassChroqPrm { - public: - MassChroqPrm(const QString & out_filename); - ~MassChroqPrm(); - - void write(ProjectSp sp_project); - void close(); -private: - void writePeptides(); - -private : - QFile * _output_file; - QXmlStreamWriter * _output_stream; - ProjectSp _sp_project; - IdentificationGroup * _p_identification_group; + public: + MassChroqPrm(const QString &out_filename); + ~MassChroqPrm(); + + void write(ProjectSp sp_project); + void close(); + + private: + void writePeptides(); + + private: + QFile *_output_file; + QXmlStreamWriter *_output_stream; + ProjectSp _sp_project; + IdentificationGroup *_p_identification_group; }; #endif // MASSCHROQPRM_H diff --git a/src/output/mcqr/mcqrscpeptide.cpp b/src/output/mcqr/mcqrscpeptide.cpp index 1557a21e97d1d4829a5baa902b1c04fe023cc49c..e63951cc2beb35bcbb7ce8481b43b3771d03b25f 100644 --- a/src/output/mcqr/mcqrscpeptide.cpp +++ b/src/output/mcqr/mcqrscpeptide.cpp @@ -6,143 +6,195 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "mcqrscpeptide.h" #include <pappsomspp/pappsoexception.h> -bool ScPeptideLabel::operator<(const ScPeptideLabel& other) const { - return tie(_p_grp_peptide, _p_label) < tie(other._p_grp_peptide, other._p_label) ; +bool +ScPeptideLabel::operator<(const ScPeptideLabel &other) const +{ + return tie(_p_grp_peptide, _p_label) < + tie(other._p_grp_peptide, other._p_label); } -McqRscPeptide::McqRscPeptide (CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - _p_writer = p_writer; +McqRscPeptide::McqRscPeptide(CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + _p_writer = p_writer; } -void McqRscPeptide::writeSheet () { - _p_writer->writeSheet("peptide_sc"); - - std::vector<IdentificationGroup *> identification_list = _p_project->getIdentificationGroupList(); - if (identification_list.size() > 1) { - throw pappso::PappsoException(QObject::tr("error : cannot write MassChroqR spectral count file in individual mode")); +void +McqRscPeptide::writeSheet() +{ + _p_writer->writeSheet("peptide_sc"); + + std::vector<IdentificationGroup *> identification_list = + _p_project->getIdentificationGroupList(); + if(identification_list.size() > 1) + { + throw pappso::PappsoException( + QObject::tr("error : cannot write MassChroqR spectral count file in " + "individual mode")); } - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -void McqRscPeptide::writeHeaders(IdentificationGroup * p_ident) { - -//ProteinID, msrun, msrunfile, accession, description, q - _p_writer->writeCell("peptide"); - _p_writer->writeCell("label"); - _p_writer->writeCell("msrun"); - _p_writer->writeCell("msrunfile"); - //_p_writer->writeCell("sequence"); - _p_writer->writeCell("sc"); - //_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); +void +McqRscPeptide::writeHeaders(IdentificationGroup *p_ident) +{ + // ProteinID, msrun, msrunfile, accession, description, q + _p_writer->writeCell("peptide"); + _p_writer->writeCell("label"); + _p_writer->writeCell("msrun"); + _p_writer->writeCell("msrunfile"); + //_p_writer->writeCell("sequence"); + _p_writer->writeCell("sc"); + //_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); } +void +McqRscPeptide::writeIdentificationGroup(IdentificationGroup *p_ident) +{ + ValidationState validation_state = ValidationState::grouped; -void McqRscPeptide::writeIdentificationGroup(IdentificationGroup * p_ident) { - ValidationState validation_state = ValidationState::grouped; + std::vector<MsRunSp> ms_run_sp_list = p_ident->getMsRunSpList(); + writeHeaders(p_ident); + for(const std::pair<unsigned int, GroupingGroupSp> &group_pair : + p_ident->getGroupStore().getGroupMap()) + { - std::vector<MsRunSp> ms_run_sp_list = p_ident->getMsRunSpList(); - writeHeaders(p_ident); - for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) { + std::vector<const ProteinMatch *> protein_match_list = + group_pair.second.get()->getProteinMatchList(); - std::vector<const ProteinMatch *> protein_match_list = group_pair.second.get()->getProteinMatchList(); + std::sort(protein_match_list.begin(), protein_match_list.end(), + [](const ProteinMatch *a, const ProteinMatch *b) { + return a->getGrpProteinSp().get()->getSubGroupNumber() < + b->getGrpProteinSp().get()->getSubGroupNumber(); + }); - std::sort(protein_match_list.begin(), protein_match_list.end(), - [](const ProteinMatch * a, const ProteinMatch * b) + for(auto &protein_match : protein_match_list) { - return a->getGrpProteinSp().get()->getSubGroupNumber() < b->getGrpProteinSp().get()->getSubGroupNumber(); - }); - for (auto & protein_match:protein_match_list) { - - //count number of scan fore each GrpPeptide - std::map<ScPeptideLabel, std::size_t> count_scan_zero; - for (const PeptideMatch & peptide_match:protein_match->getPeptideMatchList(validation_state) ) { - count_scan_zero.insert ( std::pair<ScPeptideLabel, std::size_t>({peptide_match.getPeptideEvidence()->getGrpPeptideSp().get(), peptide_match.getPeptideEvidence()->getPeptideXtpSp()->getLabel()},0) ); + // count number of scan fore each GrpPeptide + std::map<ScPeptideLabel, std::size_t> count_scan_zero; + for(const PeptideMatch &peptide_match : + protein_match->getPeptideMatchList(validation_state)) + { + count_scan_zero.insert(std::pair<ScPeptideLabel, std::size_t>( + {peptide_match.getPeptideEvidence()->getGrpPeptideSp().get(), + peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + ->getLabel()}, + 0)); } - for (auto & msrun_sp : ms_run_sp_list) { - std::vector<PeptideMatch> peptide_match_in_msrun = protein_match->getPeptideMatchList(validation_state, msrun_sp.get()); - writePeptidesInMsrun(msrun_sp.get(), peptide_match_in_msrun, count_scan_zero); + for(auto &msrun_sp : ms_run_sp_list) + { + std::vector<PeptideMatch> peptide_match_in_msrun = + protein_match->getPeptideMatchList(validation_state, + msrun_sp.get()); + writePeptidesInMsrun(msrun_sp.get(), peptide_match_in_msrun, + count_scan_zero); } } - } - _p_writer->writeLine(); + _p_writer->writeLine(); } -void McqRscPeptide::writePeptidesInMsrun(const MsRun * p_msrun,const std::vector<PeptideMatch> & peptide_match_in_msrun, const std::map<ScPeptideLabel, std::size_t> & count_scan_zero) { - try { +void +McqRscPeptide::writePeptidesInMsrun( + const MsRun *p_msrun, const std::vector<PeptideMatch> &peptide_match_in_msrun, + const std::map<ScPeptideLabel, std::size_t> &count_scan_zero) +{ + try + { - qDebug() << "McqRscPeptide::writePeptidesInMsrun begin" ; - //count number of scan fore each GrpPeptide - std::map<ScPeptideLabel, std::size_t> count_scan(count_scan_zero); + qDebug() << "McqRscPeptide::writePeptidesInMsrun begin"; + // count number of scan fore each GrpPeptide + std::map<ScPeptideLabel, std::size_t> count_scan(count_scan_zero); - for (const PeptideMatch & peptide_match:peptide_match_in_msrun) { - std::pair<std::map<ScPeptideLabel, std::size_t>::iterator,bool> ret; - ret = count_scan.insert ( std::pair<ScPeptideLabel, std::size_t>({peptide_match.getPeptideEvidence()->getGrpPeptideSp().get(),peptide_match.getPeptideEvidence()->getPeptideXtpSp()->getLabel()},0) ); - if (ret.second==false) { - //already exists - ret.first->second++; + for(const PeptideMatch &peptide_match : peptide_match_in_msrun) + { + std::pair<std::map<ScPeptideLabel, std::size_t>::iterator, bool> ret; + ret = count_scan.insert(std::pair<ScPeptideLabel, std::size_t>( + {peptide_match.getPeptideEvidence()->getGrpPeptideSp().get(), + peptide_match.getPeptideEvidence()->getPeptideXtpSp()->getLabel()}, + 0)); + if(ret.second == false) + { + // already exists + ret.first->second++; } - else { - //error : it should exists - throw pappso::PappsoException(QObject::tr("error in %1 %2 %3").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__)); + else + { + // error : it should exists + throw pappso::PappsoException(QObject::tr("error in %1 %2 %3") + .arg(__FILE__) + .arg(__FUNCTION__) + .arg(__LINE__)); } } - for (const std::pair<ScPeptideLabel, std::size_t> & pair_count :count_scan) { - _p_writer->writeLine(); + for(const std::pair<ScPeptideLabel, std::size_t> &pair_count : count_scan) + { + _p_writer->writeLine(); - _p_writer->writeCell(pair_count.first._p_grp_peptide->getGroupingId()); - if (pair_count.first._p_label == nullptr) { - _p_writer->writeEmptyCell(); + _p_writer->writeCell( + pair_count.first._p_grp_peptide->getGroupingId()); + if(pair_count.first._p_label == nullptr) + { + _p_writer->writeEmptyCell(); } - else { - _p_writer->writeCell(pair_count.first._p_label->getXmlId()); + else + { + _p_writer->writeCell(pair_count.first._p_label->getXmlId()); } - - _p_writer->writeCell(p_msrun->getXmlId()); - _p_writer->writeCell(p_msrun->getSampleName()); - //_p_writer->writeCell(pair.first->getSequence()); - _p_writer->writeCell((unsigned int) pair_count.second); + + _p_writer->writeCell(p_msrun->getXmlId()); + _p_writer->writeCell(p_msrun->getSampleName()); + //_p_writer->writeCell(pair.first->getSequence()); + _p_writer->writeCell((unsigned int)pair_count.second); } - qDebug() << "McqRscPeptide::writePeptidesInMsrun end" ; + qDebug() << "McqRscPeptide::writePeptidesInMsrun end"; } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("Error writing scan count in msrun %1 :\n%2").arg(p_msrun->getXmlId()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("Error writing scan count in msrun %1 :\n%2") + .arg(p_msrun->getXmlId()) + .arg(error.qwhat())); } } diff --git a/src/output/mcqr/mcqrscpeptide.h b/src/output/mcqr/mcqrscpeptide.h index ea42e19968b215da8e3d6aab0b3b231fe68f4991..ca774b80710d7fd491fe02cb0c22e739debe800b 100644 --- a/src/output/mcqr/mcqrscpeptide.h +++ b/src/output/mcqr/mcqrscpeptide.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 MCQRSCPEPTIDE_H #define MCQRSCPEPTIDE_H @@ -35,27 +36,32 @@ #include <pappsomspp/grouping/grppeptide.h> -struct ScPeptideLabel { - bool operator<(const ScPeptideLabel& other) const; - - const pappso::GrpPeptide * _p_grp_peptide=nullptr; - const Label * _p_label=nullptr; +struct ScPeptideLabel +{ + bool operator<(const ScPeptideLabel &other) const; + + const pappso::GrpPeptide *_p_grp_peptide = nullptr; + const Label *_p_label = nullptr; }; class McqRscPeptide { -public : - McqRscPeptide (CalcWriterInterface * p_writer, const Project * p_project); - - void writeSheet(); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writePeptidesInMsrun(const MsRun * p_msrun,const std::vector<PeptideMatch> & peptide_match_in_msrun, const std::map<ScPeptideLabel, std::size_t> & count_scan_zero); - -private : - const Project * _p_project; - CalcWriterInterface * _p_writer; + public: + McqRscPeptide(CalcWriterInterface *p_writer, const Project *p_project); + + void writeSheet(); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writePeptidesInMsrun( + const MsRun *p_msrun, + const std::vector<PeptideMatch> &peptide_match_in_msrun, + const std::map<ScPeptideLabel, std::size_t> &count_scan_zero); + + private: + const Project *_p_project; + CalcWriterInterface *_p_writer; }; #endif // MCQRSCPEPTIDE_H diff --git a/src/output/mcqr/mcqrscprotein.cpp b/src/output/mcqr/mcqrscprotein.cpp index 03fcd5cd3bf854c7c961c1dbc4c27633c515774c..b77b4830c2fe473ac7351abeb13bdd746bd55c36 100644 --- a/src/output/mcqr/mcqrscprotein.cpp +++ b/src/output/mcqr/mcqrscprotein.cpp @@ -6,115 +6,144 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "mcqrscprotein.h" #include <pappsomspp/pappsoexception.h> - -McqRscProtein::McqRscProtein (CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - _p_writer = p_writer; +McqRscProtein::McqRscProtein(CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + _p_writer = p_writer; } -void McqRscProtein::writeSheet () { - _p_writer->writeSheet("protein_sc"); - - std::vector<IdentificationGroup *> identification_list = _p_project->getIdentificationGroupList(); - if (identification_list.size() > 1) { - throw pappso::PappsoException(QObject::tr("error : cannot write MassChroqR spectral count file in individual mode")); +void +McqRscProtein::writeSheet() +{ + _p_writer->writeSheet("protein_sc"); + + std::vector<IdentificationGroup *> identification_list = + _p_project->getIdentificationGroupList(); + if(identification_list.size() > 1) + { + throw pappso::PappsoException( + QObject::tr("error : cannot write MassChroqR spectral count file in " + "individual mode")); } - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -void McqRscProtein::writeHeaders(IdentificationGroup * p_ident) { - -//ProteinID, msrun, msrunfile, accession, description, q - _p_writer->writeCell("peptide"); - _p_writer->writeCell("protein"); - _p_writer->writeCell("accession"); - _p_writer->writeCell("description"); - //_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); +void +McqRscProtein::writeHeaders(IdentificationGroup *p_ident) +{ + // ProteinID, msrun, msrunfile, accession, description, q + _p_writer->writeCell("peptide"); + _p_writer->writeCell("protein"); + _p_writer->writeCell("accession"); + _p_writer->writeCell("description"); + //_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); } +void +McqRscProtein::writeIdentificationGroup(IdentificationGroup *p_ident) +{ -void McqRscProtein::writeIdentificationGroup(IdentificationGroup * p_ident) { + _ms_run_sp_list = p_ident->getMsRunSpList(); + writeHeaders(p_ident); + for(const std::pair<unsigned int, GroupingGroupSp> &group_pair : + p_ident->getGroupStore().getGroupMap()) + { - _ms_run_sp_list = p_ident->getMsRunSpList(); - writeHeaders(p_ident); - for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) { + std::vector<const ProteinMatch *> protein_match_list = + group_pair.second.get()->getProteinMatchList(); - std::vector<const ProteinMatch *> protein_match_list = group_pair.second.get()->getProteinMatchList(); + std::sort(protein_match_list.begin(), protein_match_list.end(), + [](const ProteinMatch *a, const ProteinMatch *b) { + return a->getGrpProteinSp().get()->getSubGroupNumber() < + b->getGrpProteinSp().get()->getSubGroupNumber(); + }); - std::sort(protein_match_list.begin(), protein_match_list.end(), - [](const ProteinMatch * a, const ProteinMatch * b) + for(auto &protein_match : protein_match_list) { - return a->getGrpProteinSp().get()->getSubGroupNumber() < b->getGrpProteinSp().get()->getSubGroupNumber(); - }); - - for (auto & protein_match:protein_match_list) { - writeOneProtein(group_pair.second.get(), protein_match); + writeOneProtein(group_pair.second.get(), protein_match); } - } - _p_writer->writeLine(); + _p_writer->writeLine(); } -void McqRscProtein::writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match) { - try { +void +McqRscProtein::writeOneProtein(const GroupingGroup *p_group, + const ProteinMatch *p_protein_match) +{ + try + { - qDebug() << "McqRscProtein::writeOneProtein begin" ; - ValidationState validation_state = ValidationState::grouped; + qDebug() << "McqRscProtein::writeOneProtein begin"; + ValidationState validation_state = ValidationState::grouped; - pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get(); + pappso::GrpProtein *p_grp_protein = + p_protein_match->getGrpProteinSp().get(); - ProteinXtp * p_protein = p_protein_match->getProteinXtpSp().get(); + ProteinXtp *p_protein = p_protein_match->getProteinXtpSp().get(); - //for (MsRunSp & msrun_sp : _ms_run_sp_list) { - std::set<QString> peptide_list; - for (PeptideMatch & peptide_match : p_protein_match->getPeptideMatchList(validation_state)) { - peptide_list.insert( peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()->getGroupingId()); + // for (MsRunSp & msrun_sp : _ms_run_sp_list) { + std::set<QString> peptide_list; + for(PeptideMatch &peptide_match : + p_protein_match->getPeptideMatchList(validation_state)) + { + peptide_list.insert(peptide_match.getPeptideEvidence() + ->getGrpPeptideSp() + .get() + ->getGroupingId()); } - - for (const QString & peptide_str :peptide_list) { - _p_writer->writeLine(); - - _p_writer->writeCell(peptide_str); - _p_writer->writeCell(p_grp_protein->getGroupingId()); - _p_writer->writeCell(p_protein->getAccession()); - _p_writer->writeCell(p_protein->getDescription()); + + for(const QString &peptide_str : peptide_list) + { + _p_writer->writeLine(); + + _p_writer->writeCell(peptide_str); + _p_writer->writeCell(p_grp_protein->getGroupingId()); + _p_writer->writeCell(p_protein->getAccession()); + _p_writer->writeCell(p_protein->getDescription()); } - qDebug() << "McqRscProtein::writeOneProtein end" ; + qDebug() << "McqRscProtein::writeOneProtein end"; } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("Error writing protein %1 :\n%2").arg(p_protein_match->getProteinXtpSp().get()->getAccession()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("Error writing protein %1 :\n%2") + .arg(p_protein_match->getProteinXtpSp().get()->getAccession()) + .arg(error.qwhat())); } } - diff --git a/src/output/mcqr/mcqrscprotein.h b/src/output/mcqr/mcqrscprotein.h index 259a6393a91d648e078b7571cb8bc3708b3f1bb4..947e85819b277f6f049bee7a53382f10ecf4763e 100644 --- a/src/output/mcqr/mcqrscprotein.h +++ b/src/output/mcqr/mcqrscprotein.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 MCQRSCPROTEIN_H #define MCQRSCPROTEIN_H @@ -35,19 +36,21 @@ class McqRscProtein { -public : - McqRscProtein (CalcWriterInterface * p_writer, const Project * p_project); - - void writeSheet(); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match); - -private : - const Project * _p_project; - CalcWriterInterface * _p_writer; - std::vector<MsRunSp> _ms_run_sp_list; + public: + McqRscProtein(CalcWriterInterface *p_writer, const Project *p_project); + + void writeSheet(); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writeOneProtein(const GroupingGroup *p_group, + const ProteinMatch *p_protein_match); + + private: + const Project *_p_project; + CalcWriterInterface *_p_writer; + std::vector<MsRunSp> _ms_run_sp_list; }; #endif // MCQRSCPROTEIN_H diff --git a/src/output/mcqrspectralcount.cpp b/src/output/mcqrspectralcount.cpp index 3e5b1377422138daeca754781e733bb9333c0dad..c1593519933ed0b14593319b30378e3d4fc16057 100644 --- a/src/output/mcqrspectralcount.cpp +++ b/src/output/mcqrspectralcount.cpp @@ -6,121 +6,147 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "mcqrspectralcount.h" #include <pappsomspp/pappsoexception.h> - -McqrSpectralCount::McqrSpectralCount (CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - _p_writer = p_writer; +McqrSpectralCount::McqrSpectralCount(CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + _p_writer = p_writer; } -void McqrSpectralCount::writeSheet () { - _p_writer->writeSheet("MassChroqR spectral counting"); - - std::vector<IdentificationGroup *> identification_list = _p_project->getIdentificationGroupList(); - if (identification_list.size() > 1) { - throw pappso::PappsoException(QObject::tr("error : cannot write MassChroqR spectral count file in individual mode")); +void +McqrSpectralCount::writeSheet() +{ + _p_writer->writeSheet("MassChroqR spectral counting"); + + std::vector<IdentificationGroup *> identification_list = + _p_project->getIdentificationGroupList(); + if(identification_list.size() > 1) + { + throw pappso::PappsoException( + QObject::tr("error : cannot write MassChroqR spectral count file in " + "individual mode")); } - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -void McqrSpectralCount::writeHeaders(IdentificationGroup * p_ident) { - -//ProteinID, msrun, msrunfile, accession, description, q - _p_writer->writeCell("protein"); - _p_writer->writeCell("msrun"); - _p_writer->writeCell("msrunfile"); - _p_writer->writeCell("accession"); - _p_writer->writeCell("description"); - _p_writer->writeCell("sc"); - //_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); +void +McqrSpectralCount::writeHeaders(IdentificationGroup *p_ident) +{ + // ProteinID, msrun, msrunfile, accession, description, q + _p_writer->writeCell("protein"); + _p_writer->writeCell("msrun"); + _p_writer->writeCell("msrunfile"); + _p_writer->writeCell("accession"); + _p_writer->writeCell("description"); + _p_writer->writeCell("sc"); + //_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); } +void +McqrSpectralCount::writeIdentificationGroup(IdentificationGroup *p_ident) +{ -void McqrSpectralCount::writeIdentificationGroup(IdentificationGroup * p_ident) { + _ms_run_sp_list = p_ident->getMsRunSpList(); + writeHeaders(p_ident); + for(const std::pair<unsigned int, GroupingGroupSp> &group_pair : + p_ident->getGroupStore().getGroupMap()) + { - _ms_run_sp_list = p_ident->getMsRunSpList(); - writeHeaders(p_ident); - for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) { + std::vector<const ProteinMatch *> protein_match_list = + group_pair.second.get()->getProteinMatchList(); - std::vector<const ProteinMatch *> protein_match_list = group_pair.second.get()->getProteinMatchList(); + std::sort(protein_match_list.begin(), protein_match_list.end(), + [](const ProteinMatch *a, const ProteinMatch *b) { + return a->getGrpProteinSp().get()->getSubGroupNumber() < + b->getGrpProteinSp().get()->getSubGroupNumber(); + }); - std::sort(protein_match_list.begin(), protein_match_list.end(), - [](const ProteinMatch * a, const ProteinMatch * b) + for(auto &protein_match : protein_match_list) { - return a->getGrpProteinSp().get()->getSubGroupNumber() < b->getGrpProteinSp().get()->getSubGroupNumber(); - }); - - for (auto & protein_match:protein_match_list) { - writeOneProtein(group_pair.second.get(), protein_match); + writeOneProtein(group_pair.second.get(), protein_match); } - } - _p_writer->writeLine(); + _p_writer->writeLine(); } -void McqrSpectralCount::writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match) { - try { +void +McqrSpectralCount::writeOneProtein(const GroupingGroup *p_group, + const ProteinMatch *p_protein_match) +{ + try + { - qDebug() << "McqrSpectralCount::writeOneProtein begin" ; - ValidationState validation_state = ValidationState::validAndChecked; + qDebug() << "McqrSpectralCount::writeOneProtein begin"; + ValidationState validation_state = ValidationState::validAndChecked; - pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get(); + pappso::GrpProtein *p_grp_protein = + p_protein_match->getGrpProteinSp().get(); - ProteinXtp * p_protein = p_protein_match->getProteinXtpSp().get(); + ProteinXtp *p_protein = p_protein_match->getProteinXtpSp().get(); - for (MsRunSp & msrun_sp : _ms_run_sp_list) { - _p_writer->writeLine(); - - _p_writer->writeCell(p_grp_protein->getGroupingId()); - - _p_writer->writeCell(msrun_sp.get()->getXmlId()); - _p_writer->writeCell(msrun_sp.get()->getFilename()); - - //const std::list<DbXref> & dbxref_list = p_protein->getDbxrefList(); - //if (dbxref_list.size() == 0) { - _p_writer->writeCell(p_protein->getAccession()); - //} - //else { - // _p_writer->writeCell(dbxref_list.front().getUrl(), p_protein->getAccession()); - //} - _p_writer->writeCell(p_protein->getDescription()); - _p_writer->writeCell(p_protein_match->countSampleScan(validation_state, msrun_sp.get())); + for(MsRunSp &msrun_sp : _ms_run_sp_list) + { + _p_writer->writeLine(); + + _p_writer->writeCell(p_grp_protein->getGroupingId()); + + _p_writer->writeCell(msrun_sp.get()->getXmlId()); + _p_writer->writeCell(msrun_sp.get()->getFilename()); + + // const std::list<DbXref> & dbxref_list = p_protein->getDbxrefList(); + // if (dbxref_list.size() == 0) { + _p_writer->writeCell(p_protein->getAccession()); + //} + // else { + // _p_writer->writeCell(dbxref_list.front().getUrl(), + // p_protein->getAccession()); + //} + _p_writer->writeCell(p_protein->getDescription()); + _p_writer->writeCell( + p_protein_match->countSampleScan(validation_state, msrun_sp.get())); } - qDebug() << "McqrSpectralCount::writeOneProtein end" ; + qDebug() << "McqrSpectralCount::writeOneProtein end"; } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("Error writing protein %1 :\n%2").arg(p_protein_match->getProteinXtpSp().get()->getAccession()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("Error writing protein %1 :\n%2") + .arg(p_protein_match->getProteinXtpSp().get()->getAccession()) + .arg(error.qwhat())); } } - diff --git a/src/output/mcqrspectralcount.h b/src/output/mcqrspectralcount.h index 1a3d6c3ed2b2e45d68eaefc32e8a555403c10ba6..a59c71c151660b6f1679ef49543d759eeef48975 100644 --- a/src/output/mcqrspectralcount.h +++ b/src/output/mcqrspectralcount.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 MCQRSPECTRALCOUNT_H #define MCQRSPECTRALCOUNT_H @@ -35,19 +36,21 @@ class McqrSpectralCount { -public : - McqrSpectralCount (CalcWriterInterface * p_writer, const Project * p_project); - - void writeSheet(); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match); - -private : - const Project * _p_project; - CalcWriterInterface * _p_writer; - std::vector<MsRunSp> _ms_run_sp_list; + public: + McqrSpectralCount(CalcWriterInterface *p_writer, const Project *p_project); + + void writeSheet(); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writeOneProtein(const GroupingGroup *p_group, + const ProteinMatch *p_protein_match); + + private: + const Project *_p_project; + CalcWriterInterface *_p_writer; + std::vector<MsRunSp> _ms_run_sp_list; }; #endif // MCQRSPECTRALCOUNT_H diff --git a/src/output/ods/comparbasesheet.h b/src/output/ods/comparbasesheet.h index c0fc4f4606ddfac6069730a396cb967ee5198f86..3881628e66b680bd6abdb750b626cc6852d80db3 100644 --- a/src/output/ods/comparbasesheet.h +++ b/src/output/ods/comparbasesheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef COMPARBASESHEET_H #define COMPARBASESHEET_H @@ -37,29 +38,34 @@ class ComparBaseSheet { -public : - ComparBaseSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); -public : - void writeSheet(); -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun)=0; - void writeProteinMatch(const ProteinMatch * p_protein_match); + public: + ComparBaseSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); -protected : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; - std::vector<MsRunSp> _msrun_list; - QString _title_sheet; - - QString _first_cell_coordinate; - - IdentificationGroup * _p_current_identification_group; - + public: + void writeSheet(); + + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) = 0; + void writeProteinMatch(const ProteinMatch *p_protein_match); + + + protected: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; + std::vector<MsRunSp> _msrun_list; + QString _title_sheet; + + QString _first_cell_coordinate; + + IdentificationGroup *_p_current_identification_group; }; #endif // COMPARBASESHEET_H diff --git a/src/output/ods/comparspecificspectrasheet.cpp b/src/output/ods/comparspecificspectrasheet.cpp index 0e041c3bad25fe95777f5f6f520a1bbe37cf8911..3dfde052324db8093fad2e4b51b4f6b73eebce10 100644 --- a/src/output/ods/comparspecificspectrasheet.cpp +++ b/src/output/ods/comparspecificspectrasheet.cpp @@ -6,48 +6,71 @@ */ /******************************************************************************* -* 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 "comparspecificspectrasheet.h" -ComparSpecificSpectraSheet::ComparSpecificSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) { - _title_sheet = "compar specific spectra"; +ComparSpecificSpectraSheet::ComparSpecificSpectraSheet( + OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project) + : ComparBaseSheet(p_ods_export, p_writer, p_project) +{ + _title_sheet = "compar specific spectra"; } -void ComparSpecificSpectraSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) { - qDebug() << "ComparSpecificSpectraSheet::writeComparValue begin"; - _p_writer->writeCell((unsigned int) p_protein_match->getGroupingGroupSp().get()->countSpecificSampleScan(p_protein_match, state, p_msrun)); - qDebug() << "ComparSpecificSpectraSheet::writeComparValue end"; +void +ComparSpecificSpectraSheet::writeComparValue( + const ProteinMatch *p_protein_match, ValidationState state, + const MsRun *p_msrun) +{ + qDebug() << "ComparSpecificSpectraSheet::writeComparValue begin"; + _p_writer->writeCell( + (unsigned int)p_protein_match->getGroupingGroupSp() + .get() + ->countSpecificSampleScan(p_protein_match, state, p_msrun)); + qDebug() << "ComparSpecificSpectraSheet::writeComparValue end"; } -ComparSpecificSequenceSheet::ComparSpecificSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) { - _title_sheet = "compar specific unique sequence"; +ComparSpecificSequenceSheet::ComparSpecificSequenceSheet( + OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project) + : ComparBaseSheet(p_ods_export, p_writer, p_project) +{ + _title_sheet = "compar specific unique sequence"; } -void ComparSpecificSequenceSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) { - qDebug() << "ComparSpecificSequenceSheet::writeComparValue begin"; - _p_writer->writeCell((unsigned int) p_protein_match->getGroupingGroupSp().get()->countSpecificSequenceLi(p_protein_match, state, p_msrun)); - qDebug() << "ComparSpecificSequenceSheet::writeComparValue end"; +void +ComparSpecificSequenceSheet::writeComparValue( + const ProteinMatch *p_protein_match, ValidationState state, + const MsRun *p_msrun) +{ + qDebug() << "ComparSpecificSequenceSheet::writeComparValue begin"; + _p_writer->writeCell( + (unsigned int)p_protein_match->getGroupingGroupSp() + .get() + ->countSpecificSequenceLi(p_protein_match, state, p_msrun)); + qDebug() << "ComparSpecificSequenceSheet::writeComparValue end"; } diff --git a/src/output/ods/comparspecificspectrasheet.h b/src/output/ods/comparspecificspectrasheet.h index eeab2ee9e0eaf21061585e9213c15d5836358548..c94310ea54ac6c2a4b50ff8ee1971c494572c711 100644 --- a/src/output/ods/comparspecificspectrasheet.h +++ b/src/output/ods/comparspecificspectrasheet.h @@ -6,46 +6,56 @@ */ /******************************************************************************* -* 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 COMPARSPECIFICSPECTRASHEET_H #define COMPARSPECIFICSPECTRASHEET_H #include "comparbasesheet.h" -class ComparSpecificSpectraSheet: public ComparBaseSheet +class ComparSpecificSpectraSheet : public ComparBaseSheet { -public : - ComparSpecificSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; + public: + ComparSpecificSpectraSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project); + + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) override; }; -class ComparSpecificSequenceSheet:public ComparBaseSheet +class ComparSpecificSequenceSheet : public ComparBaseSheet { -public : - ComparSpecificSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); + public: + ComparSpecificSequenceSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project); -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) override; }; #endif // COMPARSPECIFICSPECTRASHEET_H diff --git a/src/output/ods/comparspectrasheet.cpp b/src/output/ods/comparspectrasheet.cpp index fb5c82395e5f2ee707045df58a5bc76b953964ba..a5fbc14db572b510a4fc277234e58b9921a306b5 100644 --- a/src/output/ods/comparspectrasheet.cpp +++ b/src/output/ods/comparspectrasheet.cpp @@ -6,26 +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 "comparspectrasheet.h" @@ -34,64 +35,107 @@ #include <QDebug> -ComparSpectraSheet::ComparSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) { - _title_sheet = "compar spectra"; +ComparSpectraSheet::ComparSpectraSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : ComparBaseSheet(p_ods_export, p_writer, p_project) +{ + _title_sheet = "compar spectra"; } -void ComparSpectraSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) { - qDebug() << "ComparSpectraSheet::writeComparValue begin"; - _p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); - qDebug() << "ComparSpectraSheet::writeComparValue end"; +void +ComparSpectraSheet::writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) +{ + qDebug() << "ComparSpectraSheet::writeComparValue begin"; + _p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun)); + qDebug() << "ComparSpectraSheet::writeComparValue end"; } -ComparSequenceSheet::ComparSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) { - _title_sheet = "compar unique sequence"; +ComparSequenceSheet::ComparSequenceSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : ComparBaseSheet(p_ods_export, p_writer, p_project) +{ + _title_sheet = "compar unique sequence"; } -void ComparSequenceSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) { - qDebug() << "ComparSequenceSheet::writeComparValue begin"; - _p_writer->writeCell((unsigned int) p_protein_match->countSequenceLi(state, p_msrun)); - qDebug() << "ComparSequenceSheet::writeComparValue end"; +void +ComparSequenceSheet::writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) +{ + qDebug() << "ComparSequenceSheet::writeComparValue begin"; + _p_writer->writeCell( + (unsigned int)p_protein_match->countSequenceLi(state, p_msrun)); + qDebug() << "ComparSequenceSheet::writeComparValue end"; } -ComparPaiSheet::ComparPaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) { - _title_sheet = "compar PAI"; +ComparPaiSheet::ComparPaiSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : ComparBaseSheet(p_ods_export, p_writer, p_project) +{ + _title_sheet = "compar PAI"; } -void ComparPaiSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) { - qDebug() << "ComparPaiSheet::writeComparValue begin"; - _p_writer->writeCell(p_protein_match->getPAI(p_msrun)); - qDebug() << "ComparPaiSheet::writeComparValue end"; +void +ComparPaiSheet::writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, const MsRun *p_msrun) +{ + qDebug() << "ComparPaiSheet::writeComparValue begin"; + _p_writer->writeCell(p_protein_match->getPAI(p_msrun)); + qDebug() << "ComparPaiSheet::writeComparValue end"; } -ComparEmpaiSheet::ComparEmpaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) { - _title_sheet = "compar emPAI"; +ComparEmpaiSheet::ComparEmpaiSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : ComparBaseSheet(p_ods_export, p_writer, p_project) +{ + _title_sheet = "compar emPAI"; } -void ComparEmpaiSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) { - qDebug() << "ComparEmpaiSheet::writeComparValue begin"; - _p_writer->writeCell(p_protein_match->getEmPAI(p_msrun)); - qDebug() << "ComparEmpaiSheet::writeComparValue end"; +void +ComparEmpaiSheet::writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, const MsRun *p_msrun) +{ + qDebug() << "ComparEmpaiSheet::writeComparValue begin"; + _p_writer->writeCell(p_protein_match->getEmPAI(p_msrun)); + qDebug() << "ComparEmpaiSheet::writeComparValue end"; } -ComparNsafSheet::ComparNsafSheet(OdsExport* p_ods_export, CalcWriterInterface* p_writer, const Project* p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) { - _title_sheet = "compar NSAF"; +ComparNsafSheet::ComparNsafSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : ComparBaseSheet(p_ods_export, p_writer, p_project) +{ + _title_sheet = "compar NSAF"; } -void ComparNsafSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) { - qDebug() << "ComparNsafSheet::writeComparValue begin"; - pappso::pappso_double proto_nsaf_sum=0; - std::pair<std::map<const MsRun *,pappso::pappso_double>::iterator,bool> ret = _map_proto_nsaf_sum_by_msrun.insert(std::pair<const MsRun *,pappso::pappso_double>(p_msrun,0)); - if (ret.second==false) { - //"element 'z' already existed"; - proto_nsaf_sum = ret.first->second; - } - else { - proto_nsaf_sum = _p_current_identification_group->computeProtoNsafSum(p_msrun); +void +ComparNsafSheet::writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, const MsRun *p_msrun) +{ + qDebug() << "ComparNsafSheet::writeComparValue begin"; + pappso::pappso_double proto_nsaf_sum = 0; + std::pair<std::map<const MsRun *, pappso::pappso_double>::iterator, bool> + ret = _map_proto_nsaf_sum_by_msrun.insert( + std::pair<const MsRun *, pappso::pappso_double>(p_msrun, 0)); + if(ret.second == false) + { + //"element 'z' already existed"; + proto_nsaf_sum = ret.first->second; + } + else + { + proto_nsaf_sum = + _p_current_identification_group->computeProtoNsafSum(p_msrun); ret.first->second = proto_nsaf_sum; - } + } - _p_writer->writeCell(p_protein_match->getNsaf(proto_nsaf_sum,p_msrun)); - qDebug() << "ComparNsafSheet::writeComparValue end"; + _p_writer->writeCell(p_protein_match->getNsaf(proto_nsaf_sum, p_msrun)); + qDebug() << "ComparNsafSheet::writeComparValue end"; } diff --git a/src/output/ods/comparspectrasheet.h b/src/output/ods/comparspectrasheet.h index 29653e279fafad17320b4b59449e39f27ff7220a..ced41c2a2d5c7311178b6abb0ac6892cf9b0685d 100644 --- a/src/output/ods/comparspectrasheet.h +++ b/src/output/ods/comparspectrasheet.h @@ -6,79 +6,95 @@ */ /******************************************************************************* -* 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 COMPARSPECTRASHEET_H #define COMPARSPECTRASHEET_H #include "comparbasesheet.h" -class ComparSpectraSheet:public ComparBaseSheet +class ComparSpectraSheet : public ComparBaseSheet { -public : - ComparSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); + public: + ComparSpectraSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) override; }; -class ComparSequenceSheet:public ComparBaseSheet +class ComparSequenceSheet : public ComparBaseSheet { -public : - ComparSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); + public: + ComparSequenceSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) override; }; -class ComparPaiSheet:public ComparBaseSheet +class ComparPaiSheet : public ComparBaseSheet { -public : - ComparPaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); + public: + ComparPaiSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) override; }; -class ComparEmpaiSheet:public ComparBaseSheet +class ComparEmpaiSheet : public ComparBaseSheet { -public : - ComparEmpaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); + public: + ComparEmpaiSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) override; }; -class ComparNsafSheet:public ComparBaseSheet +class ComparNsafSheet : public ComparBaseSheet { -public : - ComparNsafSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); - -protected : - virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; -private: - - std::map<const MsRun *, pappso::pappso_double> _map_proto_nsaf_sum_by_msrun; + public: + ComparNsafSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); + + protected: + virtual void writeComparValue(const ProteinMatch *p_protein_match, + ValidationState state, + const MsRun *p_msrun) override; + + private: + std::map<const MsRun *, pappso::pappso_double> _map_proto_nsaf_sum_by_msrun; }; #endif // COMPARSPECTRASHEET_H diff --git a/src/output/ods/groupingsheet.cpp b/src/output/ods/groupingsheet.cpp index e3ca9d302f5afdde5d7e849e85059681f12a836d..4b7d3095aedc65059c172acb502e5f924e6653a1 100644 --- a/src/output/ods/groupingsheet.cpp +++ b/src/output/ods/groupingsheet.cpp @@ -6,90 +6,111 @@ */ /******************************************************************************* -* 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 "groupingsheet.h" -GroupingSheet::GroupingSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - _p_writer = p_writer; - _p_ods_export = p_ods_export; - p_writer->writeSheet("groups"); +GroupingSheet::GroupingSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + _p_writer = p_writer; + _p_ods_export = p_ods_export; + p_writer->writeSheet("groups"); - - OdsTableSettings table_settings; - table_settings.setVerticalSplit(1); - _p_writer->setCurrentOdsTableSettings(table_settings); - writeHeaders(); + OdsTableSettings table_settings; + table_settings.setVerticalSplit(1); + _p_writer->setCurrentOdsTableSettings(table_settings); - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); + writeHeaders(); + + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -void GroupingSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { - _p_writer->writeLine(); - if (_p_project->getProjectMode() == ProjectMode::individual) { - _p_writer->writeCell(p_ident->getMsRunSpList().at(0).get()->getSampleName()); +void +GroupingSheet::writeIdentificationGroup(IdentificationGroup *p_ident) +{ + _p_writer->writeLine(); + if(_p_project->getProjectMode() == ProjectMode::individual) + { + _p_writer->writeCell( + p_ident->getMsRunSpList().at(0).get()->getSampleName()); } - _p_writer->writeCell((unsigned int) p_ident->countGroup()); - _p_writer->writeCell((unsigned int) p_ident->countSubGroup()); - _p_writer->writeCell(p_ident->countProteinMatch(ValidationState::grouped)); - _p_writer->writeCell(p_ident->countPeptideMass(ValidationState::grouped)); - _p_writer->writeCell(p_ident->countPeptideMatch(ValidationState::grouped)); - //_p_writer->writeCell(p_ident->countSequence(ValidationState::grouped)); - _p_writer->writeCell(p_ident->countPeptideMassSample(ValidationState::grouped)); - _p_writer->writeCell(p_ident->getProteinFdr(ValidationState::valid)); - _p_writer->writeCell(p_ident->getPeptideMassFdr(ValidationState::valid)); + _p_writer->writeCell((unsigned int)p_ident->countGroup()); + _p_writer->writeCell((unsigned int)p_ident->countSubGroup()); + _p_writer->writeCell(p_ident->countProteinMatch(ValidationState::grouped)); + _p_writer->writeCell(p_ident->countPeptideMass(ValidationState::grouped)); + _p_writer->writeCell(p_ident->countPeptideMatch(ValidationState::grouped)); + //_p_writer->writeCell(p_ident->countSequence(ValidationState::grouped)); + _p_writer->writeCell( + p_ident->countPeptideMassSample(ValidationState::grouped)); + _p_writer->writeCell(p_ident->getProteinFdr(ValidationState::valid)); + _p_writer->writeCell(p_ident->getPeptideMassFdr(ValidationState::valid)); } -void GroupingSheet::writeHeaders() { - // groups, subgroups, proteins, psm, sequence, peptide/mass, pep FDR, prot FDR +void +GroupingSheet::writeHeaders() +{ + // groups, subgroups, proteins, psm, sequence, peptide/mass, pep FDR, prot FDR - _p_writer->writeLine(); - if (_p_project->getProjectMode() == ProjectMode::individual) { - _p_writer->writeCell("sample"); + _p_writer->writeLine(); + if(_p_project->getProjectMode() == ProjectMode::individual) + { + _p_writer->writeCell("sample"); } - _p_writer->setCellAnnotation("number of groups"); - _p_writer->writeCell("groups"); - _p_writer->setCellAnnotation("number of subgroups"); - _p_writer->writeCell("subgroups"); - _p_writer->setCellAnnotation("number of grouped proteins"); - _p_writer->writeCell("proteins"); - _p_writer->setCellAnnotation("number of distinct grouped peptides in the whole experiment"); - _p_writer->writeCell("peptides"); - _p_writer->setCellAnnotation("number of peptide hits : each grouped peptide spectrum match given by the identification engine"); - _p_writer->writeCell("psm"); - //_p_writer->writeCell("sequences"); - _p_writer->setCellAnnotation("number of unique combinations : grouped peptide sequence+modifications+sample name"); - _p_writer->writeCell("peptide/mass/sample"); - _p_writer->setCellAnnotation("FDR at the protein level (number of decoy valid proteins / totale number of valid proteins)"); - _p_writer->writeCell("prot FDR"); - _p_writer->setCellAnnotation("FDR at the peptide level (number of decoy valid peptides / totale number of valid peptides)"); - _p_writer->writeCell("pep FDR"); - - + _p_writer->setCellAnnotation("number of groups"); + _p_writer->writeCell("groups"); + _p_writer->setCellAnnotation("number of subgroups"); + _p_writer->writeCell("subgroups"); + _p_writer->setCellAnnotation("number of grouped proteins"); + _p_writer->writeCell("proteins"); + _p_writer->setCellAnnotation( + "number of distinct grouped peptides in the whole experiment"); + _p_writer->writeCell("peptides"); + _p_writer->setCellAnnotation( + "number of peptide hits : each grouped peptide spectrum match given by the " + "identification engine"); + _p_writer->writeCell("psm"); + //_p_writer->writeCell("sequences"); + _p_writer->setCellAnnotation("number of unique combinations : grouped " + "peptide sequence+modifications+sample name"); + _p_writer->writeCell("peptide/mass/sample"); + _p_writer->setCellAnnotation( + "FDR at the protein level (number of decoy valid proteins / totale number " + "of valid proteins)"); + _p_writer->writeCell("prot FDR"); + _p_writer->setCellAnnotation( + "FDR at the peptide level (number of decoy valid peptides / totale number " + "of valid peptides)"); + _p_writer->writeCell("pep FDR"); } diff --git a/src/output/ods/groupingsheet.h b/src/output/ods/groupingsheet.h index d73bbc86b15a14f8bb4dc952f4c9a3150c16aee3..9202bc4fd7b64a0bcebd3537502c0ea891849218 100644 --- a/src/output/ods/groupingsheet.h +++ b/src/output/ods/groupingsheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef GROUPINGSHEET_H #define GROUPINGSHEET_H @@ -36,17 +37,18 @@ class GroupingSheet { -public : - GroupingSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); -private: - - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(); - -private : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; + public: + GroupingSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(); + + private: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; }; #endif // GROUPINGSHEET_H diff --git a/src/output/ods/infosheet.h b/src/output/ods/infosheet.h index 313399d5b25cc5a88cc495bd01e17ff877704d07..e3ec4d4200dc6ff9ebbca015bf0989fd05f5fd13 100644 --- a/src/output/ods/infosheet.h +++ b/src/output/ods/infosheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef INFOSHEET_H #define INFOSHEET_H @@ -37,13 +38,14 @@ class InfoSheet { -public : - InfoSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); + public: + InfoSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); -private : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; + private: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; }; #endif // INFOSHEET_H diff --git a/src/output/ods/odsexport.h b/src/output/ods/odsexport.h index 52564aa37221eaf04d60a9290a81fd5a675fa287..9c0294d1de0a975c20f08b6f7d539b1c6a850421 100644 --- a/src/output/ods/odsexport.h +++ b/src/output/ods/odsexport.h @@ -6,26 +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 + ******************************************************************************/ #ifndef ODSEXPORT_H #define ODSEXPORT_H @@ -36,17 +37,17 @@ class OdsExport { -public: - OdsExport(const Project * project); - - void write(CalcWriterInterface * p_writer, WorkMonitorInterface * p_monitor); - - void setEvenOrOddStyle(unsigned int number, CalcWriterInterface * p_writer); - -private: - const Project * _p_project; - OdsTableCellStyleRef _even_style; - OdsTableCellStyleRef _odd_style; + public: + OdsExport(const Project *project); + + void write(CalcWriterInterface *p_writer, WorkMonitorInterface *p_monitor); + + void setEvenOrOddStyle(unsigned int number, CalcWriterInterface *p_writer); + + private: + const Project *_p_project; + OdsTableCellStyleRef _even_style; + OdsTableCellStyleRef _odd_style; }; #endif // ODSEXPORT_H diff --git a/src/output/ods/peptidepossheet.cpp b/src/output/ods/peptidepossheet.cpp index d9f17a9f8ea1860fc42704c0ea759a79c6ae96a2..65279b1c72b8a7ec6b526b0836e99e916477a3a0 100644 --- a/src/output/ods/peptidepossheet.cpp +++ b/src/output/ods/peptidepossheet.cpp @@ -6,26 +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 "peptidepossheet.h" #include <tuple> @@ -33,156 +34,200 @@ #include <QDebug> -PeptidePosSheet::PeptidePosSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - _p_ods_export = p_ods_export; - _p_writer = p_writer; - p_writer->writeSheet("peptide pos"); - - OdsTableSettings table_settings; - table_settings.setVerticalSplit(1); - _p_writer->setCurrentOdsTableSettings(table_settings); - - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); +PeptidePosSheet::PeptidePosSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + _p_ods_export = p_ods_export; + _p_writer = p_writer; + p_writer->writeSheet("peptide pos"); + + OdsTableSettings table_settings; + table_settings.setVerticalSplit(1); + _p_writer->setCurrentOdsTableSettings(table_settings); + + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -void PeptidePosSheet::writeHeaders(IdentificationGroup * p_ident) { - // Peptide ID Protein ID accession description Sequence Modifs Start Stop MH+ theo +void +PeptidePosSheet::writeHeaders(IdentificationGroup *p_ident) +{ + // Peptide ID Protein ID accession description Sequence Modifs Start Stop MH+ + // theo - //MS Sample : 20120906_balliau_extract_1_A01_urnb-1 - const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); - if (msrun_list.size() == 1) { - _p_writer->writeCell("sample"); - _p_writer->writeLine(); - _p_writer->writeCell(msrun_list[0].get()->getSampleName()); - _p_writer->writeLine(); + // MS Sample : 20120906_balliau_extract_1_A01_urnb-1 + const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); + if(msrun_list.size() == 1) + { + _p_writer->writeCell("sample"); + _p_writer->writeLine(); + _p_writer->writeCell(msrun_list[0].get()->getSampleName()); + _p_writer->writeLine(); } - _p_writer->writeLine(); - _p_writer->writeCell("Group ID"); - _p_writer->writeCell("Subgroup ID"); - //_p_writer->setCellAnnotation("MS sample name (MS run)"); - _p_writer->writeCell("Protein ID"); - _p_writer->writeCell("accession"); - _p_writer->writeCell("description"); - _p_writer->writeCell("Peptide ID"); - _p_writer->writeCell("Sequence"); - _p_writer->writeCell("Modifs"); - _p_writer->writeCell("Start"); - _p_writer->writeCell("Stop"); - _p_writer->writeCell("MH+ theo"); - - + _p_writer->writeLine(); + _p_writer->writeCell("Group ID"); + _p_writer->writeCell("Subgroup ID"); + //_p_writer->setCellAnnotation("MS sample name (MS run)"); + _p_writer->writeCell("Protein ID"); + _p_writer->writeCell("accession"); + _p_writer->writeCell("description"); + _p_writer->writeCell("Peptide ID"); + _p_writer->writeCell("Sequence"); + _p_writer->writeCell("Modifs"); + _p_writer->writeCell("Start"); + _p_writer->writeCell("Stop"); + _p_writer->writeCell("MH+ theo"); } -void PeptidePosSheet::writeBestPeptideMatch(const ProteinMatch * p_protein_match,const PeptideMatch & peptide_match) { - - _p_writer->writeLine(); - const PeptideEvidence * p_peptide_evidence = peptide_match.getPeptideEvidence(); - - - unsigned int group_number = p_protein_match->getGrpProteinSp().get()->getGroupNumber(); - unsigned int subgroup_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); - unsigned int rank_number = p_protein_match->getGrpProteinSp().get()->getRank(); - - _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); - _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); - _p_ods_export->setEvenOrOddStyle(subgroup_number, _p_writer); - _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(subgroup_number)); - _p_ods_export->setEvenOrOddStyle(rank_number, _p_writer); - _p_writer->writeCell(p_protein_match->getGrpProteinSp().get()->getGroupingId()); - _p_writer->clearTableCellStyleRef(); - _p_writer->writeCell(p_protein_match->getProteinXtpSp().get()->getAccession()); - _p_writer->writeCell(p_protein_match->getProteinXtpSp().get()->getDescription()); - _p_writer->writeCell(p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getSequence()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); - _p_writer->writeCell(peptide_match.getStart()+1); - _p_writer->writeCell(peptide_match.getStart()+p_peptide_evidence->getPeptideXtpSp().get()->getSequence().size()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getMz(1)); - - +void +PeptidePosSheet::writeBestPeptideMatch(const ProteinMatch *p_protein_match, + const PeptideMatch &peptide_match) +{ + + _p_writer->writeLine(); + const PeptideEvidence *p_peptide_evidence = + peptide_match.getPeptideEvidence(); + + + unsigned int group_number = + p_protein_match->getGrpProteinSp().get()->getGroupNumber(); + unsigned int subgroup_number = + p_protein_match->getGrpProteinSp().get()->getSubGroupNumber(); + unsigned int rank_number = + p_protein_match->getGrpProteinSp().get()->getRank(); + + _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); + _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); + _p_ods_export->setEvenOrOddStyle(subgroup_number, _p_writer); + _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(subgroup_number)); + _p_ods_export->setEvenOrOddStyle(rank_number, _p_writer); + _p_writer->writeCell( + p_protein_match->getGrpProteinSp().get()->getGroupingId()); + _p_writer->clearTableCellStyleRef(); + _p_writer->writeCell( + p_protein_match->getProteinXtpSp().get()->getAccession()); + _p_writer->writeCell( + p_protein_match->getProteinXtpSp().get()->getDescription()); + _p_writer->writeCell( + p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getSequence()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); + _p_writer->writeCell(peptide_match.getStart() + 1); + _p_writer->writeCell( + peptide_match.getStart() + + p_peptide_evidence->getPeptideXtpSp().get()->getSequence().size()); + _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getMz(1)); } -void PeptidePosSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { - qDebug() << "PeptidePosSheet::writeIdentificationGroup begin"; - writeHeaders(p_ident); +void +PeptidePosSheet::writeIdentificationGroup(IdentificationGroup *p_ident) +{ + qDebug() << "PeptidePosSheet::writeIdentificationGroup begin"; + writeHeaders(p_ident); - std::vector<ProteinMatch *> protein_match_list; + std::vector<ProteinMatch *> protein_match_list; - for (ProteinMatch * p_protein_match: p_ident->getProteinMatchList()) { - if (p_protein_match->getValidationState() < ValidationState::grouped) continue; - protein_match_list.push_back(p_protein_match); + for(ProteinMatch *p_protein_match : p_ident->getProteinMatchList()) + { + if(p_protein_match->getValidationState() < ValidationState::grouped) + continue; + protein_match_list.push_back(p_protein_match); } - std::sort(protein_match_list.begin(), protein_match_list.end(), - [](const ProteinMatch * a, const ProteinMatch * b) - { - unsigned int agroup = a->getGrpProteinSp().get()->getGroupNumber(); - unsigned int asubgroup = a->getGrpProteinSp().get()->getSubGroupNumber(); - unsigned int arank = a->getGrpProteinSp().get()->getRank(); - unsigned int bgroup = b->getGrpProteinSp().get()->getGroupNumber(); - unsigned int bsubgroup = b->getGrpProteinSp().get()->getSubGroupNumber(); - unsigned int brank = b->getGrpProteinSp().get()->getRank(); - return std::tie(agroup, asubgroup, arank) < std::tie(bgroup, bsubgroup, brank); - }); + std::sort( + protein_match_list.begin(), protein_match_list.end(), + [](const ProteinMatch *a, const ProteinMatch *b) { + unsigned int agroup = a->getGrpProteinSp().get()->getGroupNumber(); + unsigned int asubgroup = a->getGrpProteinSp().get()->getSubGroupNumber(); + unsigned int arank = a->getGrpProteinSp().get()->getRank(); + unsigned int bgroup = b->getGrpProteinSp().get()->getGroupNumber(); + unsigned int bsubgroup = b->getGrpProteinSp().get()->getSubGroupNumber(); + unsigned int brank = b->getGrpProteinSp().get()->getRank(); + return std::tie(agroup, asubgroup, arank) < + std::tie(bgroup, bsubgroup, brank); + }); - for (ProteinMatch * p_protein_match : protein_match_list) { + for(ProteinMatch *p_protein_match : protein_match_list) + { - std::vector<PeptideMatch> peptide_match_list; + std::vector<PeptideMatch> peptide_match_list; - for (auto & peptide_match: p_protein_match->getPeptideMatchList()) { - if (peptide_match.getPeptideEvidence()->getValidationState() < ValidationState::grouped) continue; - peptide_match_list.push_back(peptide_match); + for(auto &peptide_match : p_protein_match->getPeptideMatchList()) + { + if(peptide_match.getPeptideEvidence()->getValidationState() < + ValidationState::grouped) + continue; + peptide_match_list.push_back(peptide_match); } - std::sort(peptide_match_list.begin(), peptide_match_list.end(), - [](const PeptideMatch & a, const PeptideMatch & b) + std::sort(peptide_match_list.begin(), peptide_match_list.end(), + [](const PeptideMatch &a, const PeptideMatch &b) { + unsigned int arank = + a.getPeptideEvidence()->getGrpPeptideSp().get()->getRank(); + unsigned int aposition = a.getStart(); + unsigned int brank = + b.getPeptideEvidence()->getGrpPeptideSp().get()->getRank(); + unsigned int bposition = b.getStart(); + return std::tie(arank, aposition) < + std::tie(brank, bposition); + }); + + const PeptideMatch *p_best_peptide_match = nullptr; + + for(auto &peptide_match : peptide_match_list) { - unsigned int arank = a.getPeptideEvidence()->getGrpPeptideSp().get()->getRank(); - unsigned int aposition = a.getStart(); - unsigned int brank = b.getPeptideEvidence()->getGrpPeptideSp().get()->getRank(); - unsigned int bposition = b.getStart(); - return std::tie(arank, aposition) < std::tie(brank, bposition); - }); - - const PeptideMatch * p_best_peptide_match = nullptr; - - for (auto & peptide_match:peptide_match_list) { - if (p_best_peptide_match == nullptr) { - p_best_peptide_match = &peptide_match; + if(p_best_peptide_match == nullptr) + { + p_best_peptide_match = &peptide_match; } - //change spectra : - unsigned int arank = p_best_peptide_match->getPeptideEvidence()->getGrpPeptideSp().get()->getRank(); - unsigned int aposition = p_best_peptide_match->getStart(); - unsigned int brank = peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()->getRank(); - unsigned int bposition = peptide_match.getStart(); - - if (std::tie(arank, aposition) != std::tie(brank, bposition)) { - //write p_best_peptide_match - writeBestPeptideMatch(p_protein_match, *p_best_peptide_match); - p_best_peptide_match = &peptide_match; + // change spectra : + unsigned int arank = p_best_peptide_match->getPeptideEvidence() + ->getGrpPeptideSp() + .get() + ->getRank(); + unsigned int aposition = p_best_peptide_match->getStart(); + unsigned int brank = peptide_match.getPeptideEvidence() + ->getGrpPeptideSp() + .get() + ->getRank(); + unsigned int bposition = peptide_match.getStart(); + + if(std::tie(arank, aposition) != std::tie(brank, bposition)) + { + // write p_best_peptide_match + writeBestPeptideMatch(p_protein_match, *p_best_peptide_match); + p_best_peptide_match = &peptide_match; } - else { - if (p_best_peptide_match->getPeptideEvidence()->getEvalue()> peptide_match.getPeptideEvidence()->getEvalue()) { - p_best_peptide_match = &peptide_match; + else + { + if(p_best_peptide_match->getPeptideEvidence()->getEvalue() > + peptide_match.getPeptideEvidence()->getEvalue()) + { + p_best_peptide_match = &peptide_match; } } } - if (p_best_peptide_match != nullptr) { - writeBestPeptideMatch(p_protein_match, *p_best_peptide_match); - + if(p_best_peptide_match != nullptr) + { + writeBestPeptideMatch(p_protein_match, *p_best_peptide_match); } } - _p_writer->writeLine(); - _p_writer->writeLine(); - qDebug() << "PeptidePosSheet::writeIdentificationGroup end"; + _p_writer->writeLine(); + _p_writer->writeLine(); + qDebug() << "PeptidePosSheet::writeIdentificationGroup end"; } diff --git a/src/output/ods/peptidepossheet.h b/src/output/ods/peptidepossheet.h index 0e9d47c286dcddd3ffee8aa868a5768d7e672ea8..a7b32bf8cfc34ea6a970f7abc372fb21d37ceaf1 100644 --- a/src/output/ods/peptidepossheet.h +++ b/src/output/ods/peptidepossheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PEPTIDEPOSSHEET_H @@ -39,17 +40,20 @@ class PeptidePosSheet { -public : - PeptidePosSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writeBestPeptideMatch(const ProteinMatch * p_protein_match, const PeptideMatch & peptide_match); - -private : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; + public: + PeptidePosSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writeBestPeptideMatch(const ProteinMatch *p_protein_match, + const PeptideMatch &peptide_match); + + private: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; }; #endif // PEPTIDEPOSSHEET_H diff --git a/src/output/ods/peptidesheet.cpp b/src/output/ods/peptidesheet.cpp index 7010c69fb1ad94a968ddbb80b9e729bbc8019341..847e6d7ef94c9efa222fb0479063f0f930298c43 100644 --- a/src/output/ods/peptidesheet.cpp +++ b/src/output/ods/peptidesheet.cpp @@ -6,142 +6,176 @@ */ /******************************************************************************* -* 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 "peptidesheet.h" #include <pappsomspp/utils.h> -PeptideSheet::PeptideSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - _p_ods_export = p_ods_export; - _p_writer = p_writer; - p_writer->writeSheet("peptides"); - - OdsTableSettings table_settings; - table_settings.setVerticalSplit(1); - _p_writer->setCurrentOdsTableSettings(table_settings); - - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); +PeptideSheet::PeptideSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + _p_ods_export = p_ods_export; + _p_writer = p_writer; + p_writer->writeSheet("peptides"); + + OdsTableSettings table_settings; + table_settings.setVerticalSplit(1); + _p_writer->setCurrentOdsTableSettings(table_settings); + + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -void PeptideSheet::writeHeaders(IdentificationGroup * p_ident) { - // Group ID Peptide ID SequenceLI Modifs Charge MH+ theo Number of subgroups Subgroup ids Number of spectra - //MS Sample : 20120906_balliau_extract_1_A01_urnb-1 - const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); - if (msrun_list.size() == 1) { - _p_writer->writeCell("sample"); - _p_writer->writeLine(); - _p_writer->writeCell(msrun_list[0].get()->getSampleName()); - _p_writer->writeLine(); +void +PeptideSheet::writeHeaders(IdentificationGroup *p_ident) +{ + // Group ID Peptide ID SequenceLI Modifs Charge MH+ theo Number of subgroups + // Subgroup ids Number of spectra + // MS Sample : 20120906_balliau_extract_1_A01_urnb-1 + const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); + if(msrun_list.size() == 1) + { + _p_writer->writeCell("sample"); + _p_writer->writeLine(); + _p_writer->writeCell(msrun_list[0].get()->getSampleName()); + _p_writer->writeLine(); } - _p_writer->writeLine(); - _p_writer->writeCell("Group ID"); - _p_writer->writeCell("Peptide ID"); - _p_writer->setCellAnnotation("peptide sequence where all leucine are turned into isoleucine"); - _p_writer->writeCell("SequenceLI"); - _p_writer->writeCell("Modifs"); - _p_writer->setCellAnnotation("the charge associated to the best peptide Evalue for this sequenceLI"); - _p_writer->writeCell("Charge"); - _p_writer->setCellAnnotation("theoretical mh"); - _p_writer->writeCell("MH+ theo"); - _p_writer->writeCell("Number of subgroups"); - _p_writer->writeCell("Subgroup ids"); - _p_writer->setCellAnnotation("number of scans associated to this peptide"); - _p_writer->writeCell("Number of spectra"); - - + _p_writer->writeLine(); + _p_writer->writeCell("Group ID"); + _p_writer->writeCell("Peptide ID"); + _p_writer->setCellAnnotation( + "peptide sequence where all leucine are turned into isoleucine"); + _p_writer->writeCell("SequenceLI"); + _p_writer->writeCell("Modifs"); + _p_writer->setCellAnnotation( + "the charge associated to the best peptide Evalue for this sequenceLI"); + _p_writer->writeCell("Charge"); + _p_writer->setCellAnnotation("theoretical mh"); + _p_writer->writeCell("MH+ theo"); + _p_writer->writeCell("Number of subgroups"); + _p_writer->writeCell("Subgroup ids"); + _p_writer->setCellAnnotation("number of scans associated to this peptide"); + _p_writer->writeCell("Number of spectra"); } -void PeptideSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { +void +PeptideSheet::writeIdentificationGroup(IdentificationGroup *p_ident) +{ - writeHeaders(p_ident); - for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) { + writeHeaders(p_ident); + for(const std::pair<unsigned int, GroupingGroupSp> &group_pair : + p_ident->getGroupStore().getGroupMap()) + { - std::vector<const PeptideEvidence *> peptide_evidence_list = group_pair.second.get()->getPeptideEvidenceList(); + std::vector<const PeptideEvidence *> peptide_evidence_list = + group_pair.second.get()->getPeptideEvidenceList(); - std::sort(peptide_evidence_list.begin(), peptide_evidence_list.end(), - [](const PeptideEvidence * a, const PeptideEvidence * b) - { - return a->getGrpPeptideSp().get()->getRank() < b->getGrpPeptideSp().get()->getRank(); - }); + std::sort(peptide_evidence_list.begin(), peptide_evidence_list.end(), + [](const PeptideEvidence *a, const PeptideEvidence *b) { + return a->getGrpPeptideSp().get()->getRank() < + b->getGrpPeptideSp().get()->getRank(); + }); - const PeptideEvidence * p_best_peptide_evidence = nullptr; - _sample_scan_list.clear(); + const PeptideEvidence *p_best_peptide_evidence = nullptr; + _sample_scan_list.clear(); - for (auto & peptide_evidence: peptide_evidence_list) { - if (p_best_peptide_evidence == nullptr) { - p_best_peptide_evidence = peptide_evidence; + for(auto &peptide_evidence : peptide_evidence_list) + { + if(p_best_peptide_evidence == nullptr) + { + p_best_peptide_evidence = peptide_evidence; } - if (p_best_peptide_evidence->getGrpPeptideSp().get() != peptide_evidence->getGrpPeptideSp().get()) { - //write p_best_peptide_match - writeBestPeptideEvidence(group_pair.second.get(), p_best_peptide_evidence); - p_best_peptide_evidence = peptide_evidence; + if(p_best_peptide_evidence->getGrpPeptideSp().get() != + peptide_evidence->getGrpPeptideSp().get()) + { + // write p_best_peptide_match + writeBestPeptideEvidence(group_pair.second.get(), + p_best_peptide_evidence); + p_best_peptide_evidence = peptide_evidence; } - else { - if (p_best_peptide_evidence->getEvalue()> peptide_evidence->getEvalue()) { - p_best_peptide_evidence = peptide_evidence; + else + { + if(p_best_peptide_evidence->getEvalue() > + peptide_evidence->getEvalue()) + { + p_best_peptide_evidence = peptide_evidence; } } - _sample_scan_list.push_back(peptide_evidence->getHashSampleScan()); + _sample_scan_list.push_back(peptide_evidence->getHashSampleScan()); } - if (p_best_peptide_evidence != nullptr) { - writeBestPeptideEvidence(group_pair.second.get(), p_best_peptide_evidence); + if(p_best_peptide_evidence != nullptr) + { + writeBestPeptideEvidence(group_pair.second.get(), + p_best_peptide_evidence); } } - _p_writer->writeLine(); - _p_writer->writeLine(); + _p_writer->writeLine(); + _p_writer->writeLine(); } -void PeptideSheet::writeBestPeptideEvidence(const GroupingGroup * p_group,const PeptideEvidence * p_peptide_evidence) { - - std::sort(_sample_scan_list.begin(), _sample_scan_list.end()); - auto last = std::unique(_sample_scan_list.begin(), _sample_scan_list.end()); - _sample_scan_list.erase(last, _sample_scan_list.end()); - - _p_writer->writeLine(); - - - unsigned int group_number = p_peptide_evidence->getGrpPeptideSp().get()->getGroupNumber(); - - _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); - _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); - _p_writer->clearTableCellStyleRef(); - _p_writer->writeCell(p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); - _p_writer->writeCell(p_peptide_evidence->getGrpPeptideSp().get()->getSequence()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); - _p_writer->writeCell(p_peptide_evidence->getCharge()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getNativePeptideP()->getMz(1)); - QStringList sg_list = p_group->getSubgroupIdList(p_peptide_evidence); - _p_writer->writeCell((unsigned int) sg_list.size()); - _p_writer->writeCell(sg_list.join(" ")); - _p_writer->writeCell((unsigned int) _sample_scan_list.size()); - - _sample_scan_list.clear(); +void +PeptideSheet::writeBestPeptideEvidence( + const GroupingGroup *p_group, const PeptideEvidence *p_peptide_evidence) +{ + + std::sort(_sample_scan_list.begin(), _sample_scan_list.end()); + auto last = std::unique(_sample_scan_list.begin(), _sample_scan_list.end()); + _sample_scan_list.erase(last, _sample_scan_list.end()); + + _p_writer->writeLine(); + + + unsigned int group_number = + p_peptide_evidence->getGrpPeptideSp().get()->getGroupNumber(); + + _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); + _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); + _p_writer->clearTableCellStyleRef(); + _p_writer->writeCell( + p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); + _p_writer->writeCell( + p_peptide_evidence->getGrpPeptideSp().get()->getSequence()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); + _p_writer->writeCell(p_peptide_evidence->getCharge()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getNativePeptideP()->getMz(1)); + QStringList sg_list = p_group->getSubgroupIdList(p_peptide_evidence); + _p_writer->writeCell((unsigned int)sg_list.size()); + _p_writer->writeCell(sg_list.join(" ")); + _p_writer->writeCell((unsigned int)_sample_scan_list.size()); + + _sample_scan_list.clear(); } diff --git a/src/output/ods/peptidesheet.h b/src/output/ods/peptidesheet.h index 8820e7e1b67c003dbed65375ec523bf24e5e808a..7db49c459755b1ee2c01ea27459fa19d643ae125 100644 --- a/src/output/ods/peptidesheet.h +++ b/src/output/ods/peptidesheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PEPTIDESHEET_H #define PEPTIDESHEET_H @@ -37,18 +38,21 @@ class PeptideSheet { -public : - PeptideSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writeBestPeptideEvidence(const GroupingGroup * p_group, const PeptideEvidence * p_peptide_evidence); - -private : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; - std::vector<size_t> _sample_scan_list; + public: + PeptideSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writeBestPeptideEvidence(const GroupingGroup *p_group, + const PeptideEvidence *p_peptide_evidence); + + private: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; + std::vector<size_t> _sample_scan_list; }; diff --git a/src/output/ods/proteinsheet.cpp b/src/output/ods/proteinsheet.cpp index 0bc93d1e1fcfbb45e206a68ccddcdbe2692b81a6..5a67f8ef9b5f3a65d2ddf5e739c5a5b86f78af59 100644 --- a/src/output/ods/proteinsheet.cpp +++ b/src/output/ods/proteinsheet.cpp @@ -84,12 +84,13 @@ ProteinSheet::writeHeaders(IdentificationGroup *p_ident) _p_writer->writeCell("Group ID"); _p_writer->setCellAnnotation("subgroup number"); _p_writer->writeCell("Sub-group ID"); - - _p_writer->setCellAnnotation(ProteinTableModel::getDescription(ProteinListColumn::protein_grouping_id)); + + _p_writer->setCellAnnotation( + ProteinTableModel::getDescription(ProteinListColumn::protein_grouping_id)); _p_writer->writeCell("Protein ID"); - //writeCellHeader(ProteinListColumn::protein_grouping_id); + // writeCellHeader(ProteinListColumn::protein_grouping_id); //_p_writer->setCellAnnotation("unique protein identifier within this grouping - //experiment"); _p_writer->writeCell("Protein ID"); + // experiment"); _p_writer->writeCell("Protein ID"); writeCellHeader(ProteinListColumn::accession); writeCellHeader(ProteinListColumn::description); @@ -103,7 +104,7 @@ ProteinSheet::writeHeaders(IdentificationGroup *p_ident) writeCellHeader(ProteinListColumn::spectrum); //_p_writer->setCellAnnotation("number of scans (spectra) attributed to this - //protein"); + // protein"); // _p_writer->writeCell("Spectra"); writeCellHeader(ProteinListColumn::specific_spectrum); diff --git a/src/output/ods/ptm/ptmislandsheet.cpp b/src/output/ods/ptm/ptmislandsheet.cpp index 6aa43fa81731455e8badc5936dc3f1f26c9ad0a3..70fa50a757927289128db809bb12ede2da74f14f 100644 --- a/src/output/ods/ptm/ptmislandsheet.cpp +++ b/src/output/ods/ptm/ptmislandsheet.cpp @@ -6,26 +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 "ptmislandsheet.h" @@ -33,149 +34,197 @@ #include <pappsomspp/utils.h> #include <pappsomspp/pappsoexception.h> -PtmIslandSheet::PtmIslandSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - qDebug() << "PtmIslandSheet::PtmIslandSheet begin" ; - _p_writer = p_writer; - _p_ods_export = p_ods_export; - p_writer->writeSheet("PTM islands"); - - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); +PtmIslandSheet::PtmIslandSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + qDebug() << "PtmIslandSheet::PtmIslandSheet begin"; + _p_writer = p_writer; + _p_ods_export = p_ods_export; + p_writer->writeSheet("PTM islands"); + + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } - qDebug() << "PtmIslandSheet::PtmIslandSheet end" ; + qDebug() << "PtmIslandSheet::PtmIslandSheet end"; } -void PtmIslandSheet::writeCellHeader(PtmIslandListColumn column) { - qDebug() << "PtmIslandSheet::writeCellHeader begin " << (std::int8_t) column; - _p_writer->setCellAnnotation(PtmIslandTableModel::getDescription(column)); - _p_writer->writeCell(PtmIslandTableModel::getTitle(column)); - qDebug() << "PtmIslandSheet::writeCellHeader end" ; +void +PtmIslandSheet::writeCellHeader(PtmIslandListColumn column) +{ + qDebug() << "PtmIslandSheet::writeCellHeader begin " << (std::int8_t)column; + _p_writer->setCellAnnotation(PtmIslandTableModel::getDescription(column)); + _p_writer->writeCell(PtmIslandTableModel::getTitle(column)); + qDebug() << "PtmIslandSheet::writeCellHeader end"; } -void PtmIslandSheet::writeHeaders(IdentificationGroup * p_ident) { - - //ptm - -//Group ID Sub-group ID PhosphoIsland ID Description MW Phosphosites positions Spectra Uniques number of proteins sharing these phosphosites -//a1 a1.a1 a1.a1.a1 AT1G01100.1 | Symbols: | 60S acidic ribosomal protein family | chr1:50284-50954 REVERSE LENGTH=112 11,1000003814697 102 435 3 6 - qDebug() << "PtmIslandSheet::writeHeaders begin" ; - const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); - if (msrun_list.size() == 1) { - _p_writer->writeCell("sample"); - _p_writer->writeLine(); - _p_writer->writeCell(msrun_list[0].get()->getSampleName()); - _p_writer->writeLine(); - } - _p_writer->writeLine(); - - _p_writer->setCellAnnotation("PTM group number"); - _p_writer->writeCell("PTM group ID"); - _p_writer->setCellAnnotation("PTM subgroup number"); - _p_writer->writeCell("PTM sub-group ID"); - writeCellHeader(PtmIslandListColumn::ptm_island_id); - //_p_writer->PtmIslandListColumn("unique protein identifier within this grouping experiment"); - //_p_writer->writeCell("Protein ID"); - - writeCellHeader(PtmIslandListColumn::accession); - writeCellHeader(PtmIslandListColumn::description); - _p_writer->setCellAnnotation("computed molecular weight for this protein (sum of amino acid masses)"); - _p_writer->writeCell("MW"); - writeCellHeader(PtmIslandListColumn::ptm_position_list); - - writeCellHeader(PtmIslandListColumn::spectrum); - //_p_writer->setCellAnnotation("number of scans (spectra) attributed to this protein"); - // _p_writer->writeCell("Spectra"); - writeCellHeader(PtmIslandListColumn::sequence); +void +PtmIslandSheet::writeHeaders(IdentificationGroup *p_ident) +{ - _p_writer->setCellAnnotation("Number of proteins sharing this PTM island"); - _p_writer->writeCell("Number of proteins"); - - qDebug() << "PtmIslandSheet::writeHeaders end" ; + // ptm + // Group ID Sub-group ID PhosphoIsland ID Description MW Phosphosites + // positions Spectra Uniques number of proteins sharing these phosphosites a1 + // a1.a1 a1.a1.a1 AT1G01100.1 | Symbols: | 60S acidic ribosomal protein + // family | chr1:50284-50954 REVERSE LENGTH=112 11,1000003814697 102 435 3 6 + qDebug() << "PtmIslandSheet::writeHeaders begin"; + const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); + if(msrun_list.size() == 1) + { + _p_writer->writeCell("sample"); + _p_writer->writeLine(); + _p_writer->writeCell(msrun_list[0].get()->getSampleName()); + _p_writer->writeLine(); + } + _p_writer->writeLine(); + + _p_writer->setCellAnnotation("PTM group number"); + _p_writer->writeCell("PTM group ID"); + _p_writer->setCellAnnotation("PTM subgroup number"); + _p_writer->writeCell("PTM sub-group ID"); + writeCellHeader(PtmIslandListColumn::ptm_island_id); + //_p_writer->PtmIslandListColumn("unique protein identifier within this + //grouping experiment"); _p_writer->writeCell("Protein ID"); + + writeCellHeader(PtmIslandListColumn::accession); + writeCellHeader(PtmIslandListColumn::description); + _p_writer->setCellAnnotation( + "computed molecular weight for this protein (sum of amino acid masses)"); + _p_writer->writeCell("MW"); + writeCellHeader(PtmIslandListColumn::ptm_position_list); + + writeCellHeader(PtmIslandListColumn::spectrum); + //_p_writer->setCellAnnotation("number of scans (spectra) attributed to this + //protein"); + // _p_writer->writeCell("Spectra"); + writeCellHeader(PtmIslandListColumn::sequence); + + _p_writer->setCellAnnotation("Number of proteins sharing this PTM island"); + _p_writer->writeCell("Number of proteins"); + + qDebug() << "PtmIslandSheet::writeHeaders end"; } -void PtmIslandSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { +void +PtmIslandSheet::writeIdentificationGroup(IdentificationGroup *p_ident) +{ - qDebug() << "PtmIslandSheet::writeIdentificationGroup begin" ; - _p_ptm_grouping_experiment = p_ident->getPtmGroupingExperiment(); - if (_p_ptm_grouping_experiment == nullptr) { - throw pappso::PappsoException(QObject::tr("Error writing PTM island :\n_p_ptm_grouping_experiment = nullptr")); + qDebug() << "PtmIslandSheet::writeIdentificationGroup begin"; + _p_ptm_grouping_experiment = p_ident->getPtmGroupingExperiment(); + if(_p_ptm_grouping_experiment == nullptr) + { + throw pappso::PappsoException(QObject::tr( + "Error writing PTM island :\n_p_ptm_grouping_experiment = nullptr")); } - writeHeaders(p_ident); + writeHeaders(p_ident); - qDebug() << "PtmIslandSheet::writeIdentificationGroup getPtmIslandList" ; - std::vector<PtmIslandSp> ptm_island_list; - for (auto ptm_island_sp : _p_ptm_grouping_experiment->getPtmIslandList() ) { - qDebug() << "PtmIslandSheet::writeIdentificationGroup getPtmIslandList copy" ; - ptm_island_list.push_back(ptm_island_sp); + qDebug() << "PtmIslandSheet::writeIdentificationGroup getPtmIslandList"; + std::vector<PtmIslandSp> ptm_island_list; + for(auto ptm_island_sp : _p_ptm_grouping_experiment->getPtmIslandList()) + { + qDebug() + << "PtmIslandSheet::writeIdentificationGroup getPtmIslandList copy"; + ptm_island_list.push_back(ptm_island_sp); } - qDebug() << "PtmIslandSheet::writeIdentificationGroup sort" ; - std::sort(ptm_island_list.begin(), ptm_island_list.end(), - [](PtmIslandSp & a, PtmIslandSp & b) + qDebug() << "PtmIslandSheet::writeIdentificationGroup sort"; + std::sort(ptm_island_list.begin(), ptm_island_list.end(), + [](PtmIslandSp &a, PtmIslandSp &b) { + return a.get()->getGroupingId() < b.get()->getGroupingId(); + }); + + qDebug() << "PtmIslandSheet::writeIdentificationGroup 2"; + for(auto &ptm_island : ptm_island_list) { - return a.get()->getGroupingId() < b.get()->getGroupingId(); - }); - - qDebug() << "PtmIslandSheet::writeIdentificationGroup 2" ; - for (auto & ptm_island:ptm_island_list) { - writeOnePtmIsland(ptm_island); + writeOnePtmIsland(ptm_island); } - _p_writer->writeLine(); - qDebug() << "PtmIslandSheet::writeIdentificationGroup end" ; + _p_writer->writeLine(); + qDebug() << "PtmIslandSheet::writeIdentificationGroup end"; } -void PtmIslandSheet::writeOnePtmIsland(PtmIslandSp & sp_ptm_island) { - try { - _p_writer->writeLine(); - - qDebug() << "PtmIslandSheet::writeOnePtmIsland begin" ; - ValidationState validation_state = ValidationState::validAndChecked; - - //pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get(); - - ProteinXtp * p_protein = sp_ptm_island.get()->getProteinMatch()->getProteinXtpSp().get(); - - const PtmIslandSubgroup * p_ptm_island_subgroup = sp_ptm_island.get()->getPtmIslandSubroup(); - const PtmIslandGroup * p_ptm_island_group = p_ptm_island_subgroup->getPtmIslandGroup(); - unsigned int group_number = p_ptm_island_group->getGroupNumber(); - unsigned int subgroup_number = p_ptm_island_subgroup->getSubgroupNumber(); - - _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); - _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); - _p_ods_export->setEvenOrOddStyle(subgroup_number, _p_writer); - _p_writer->writeCell(QString("%1.%2").arg(pappso::Utils::getLexicalOrderedString(group_number)).arg(pappso::Utils::getLexicalOrderedString(subgroup_number))); - _p_writer->clearTableCellStyleRef(); - _p_writer->writeCell(sp_ptm_island.get()->getGroupingId()); - const std::list<DbXref> & dbxref_list = p_protein->getDbxrefList(); - if (dbxref_list.size() == 0) { - _p_writer->writeCell(p_protein->getAccession()); +void +PtmIslandSheet::writeOnePtmIsland(PtmIslandSp &sp_ptm_island) +{ + try + { + _p_writer->writeLine(); + + qDebug() << "PtmIslandSheet::writeOnePtmIsland begin"; + ValidationState validation_state = ValidationState::validAndChecked; + + // pappso::GrpProtein * p_grp_protein = + // p_protein_match->getGrpProteinSp().get(); + + ProteinXtp *p_protein = + sp_ptm_island.get()->getProteinMatch()->getProteinXtpSp().get(); + + const PtmIslandSubgroup *p_ptm_island_subgroup = + sp_ptm_island.get()->getPtmIslandSubroup(); + const PtmIslandGroup *p_ptm_island_group = + p_ptm_island_subgroup->getPtmIslandGroup(); + unsigned int group_number = p_ptm_island_group->getGroupNumber(); + unsigned int subgroup_number = p_ptm_island_subgroup->getSubgroupNumber(); + + _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); + _p_writer->writeCell( + pappso::Utils::getLexicalOrderedString(group_number)); + _p_ods_export->setEvenOrOddStyle(subgroup_number, _p_writer); + _p_writer->writeCell( + QString("%1.%2") + .arg(pappso::Utils::getLexicalOrderedString(group_number)) + .arg(pappso::Utils::getLexicalOrderedString(subgroup_number))); + _p_writer->clearTableCellStyleRef(); + _p_writer->writeCell(sp_ptm_island.get()->getGroupingId()); + const std::list<DbXref> &dbxref_list = p_protein->getDbxrefList(); + if(dbxref_list.size() == 0) + { + _p_writer->writeCell(p_protein->getAccession()); } - else { - _p_writer->writeCell(dbxref_list.front().getUrl(), p_protein->getAccession()); + else + { + _p_writer->writeCell(dbxref_list.front().getUrl(), + p_protein->getAccession()); } - _p_writer->writeCell(p_protein->getDescription()); - _p_writer->writeCell(p_protein->getMass()); + _p_writer->writeCell(p_protein->getDescription()); + _p_writer->writeCell(p_protein->getMass()); - QStringList position_list; - for (unsigned int position : sp_ptm_island.get()->getPositionList()) { - position_list << QString("%1").arg(position+1); + QStringList position_list; + for(unsigned int position : sp_ptm_island.get()->getPositionList()) + { + position_list << QString("%1").arg(position + 1); } - _p_writer->writeCell(position_list.join(" ")); - // _p_writer->writeCell("Spectra"); - _p_writer->writeCell((unsigned int) sp_ptm_island.get()->getPtmIslandSubroup()->countSampleScan()); - // _p_writer->writeCell("Uniques"); - _p_writer->writeCell((unsigned int) sp_ptm_island.get()->countSequence()); - _p_writer->writeCell((unsigned int) sp_ptm_island.get()->getPtmIslandSubroup()->getPtmIslandList().size()); - - - qDebug() << "ProteinSheet::writeOneProtein end" ; + _p_writer->writeCell(position_list.join(" ")); + // _p_writer->writeCell("Spectra"); + _p_writer->writeCell((unsigned int)sp_ptm_island.get() + ->getPtmIslandSubroup() + ->countSampleScan()); + // _p_writer->writeCell("Uniques"); + _p_writer->writeCell((unsigned int)sp_ptm_island.get()->countSequence()); + _p_writer->writeCell((unsigned int)sp_ptm_island.get() + ->getPtmIslandSubroup() + ->getPtmIslandList() + .size()); + + + qDebug() << "ProteinSheet::writeOneProtein end"; } - catch (pappso::PappsoException error) { - throw pappso::PappsoException(QObject::tr("Error writing PTM island of protein %1 :\n%2").arg(sp_ptm_island.get()->getProteinMatch()->getProteinXtpSp().get()->getAccession()).arg(error.qwhat())); + catch(pappso::PappsoException error) + { + throw pappso::PappsoException( + QObject::tr("Error writing PTM island of protein %1 :\n%2") + .arg(sp_ptm_island.get() + ->getProteinMatch() + ->getProteinXtpSp() + .get() + ->getAccession()) + .arg(error.qwhat())); } } diff --git a/src/output/ods/ptm/ptmislandsheet.h b/src/output/ods/ptm/ptmislandsheet.h index 247d650f3bf1dc4efa425a52ad04d3796821e072..b9e9071fd792d0f03e6d77670e9c0efd38cdf9f8 100644 --- a/src/output/ods/ptm/ptmislandsheet.h +++ b/src/output/ods/ptm/ptmislandsheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PTMISLANDSHEET_H #define PTMISLANDSHEET_H @@ -38,20 +39,23 @@ class PtmIslandSheet { -public : - PtmIslandSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writeOnePtmIsland(PtmIslandSp & sp_ptm_island); - -protected: - void writeCellHeader(PtmIslandListColumn column); -private : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; - const PtmGroupingExperiment * _p_ptm_grouping_experiment; + public: + PtmIslandSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writeOnePtmIsland(PtmIslandSp &sp_ptm_island); + + protected: + void writeCellHeader(PtmIslandListColumn column); + + private: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; + const PtmGroupingExperiment *_p_ptm_grouping_experiment; }; #endif // PTMISLANDSHEET_H diff --git a/src/output/ods/ptm/ptmspectrasheet.cpp b/src/output/ods/ptm/ptmspectrasheet.cpp index c1ecba40e626557cda654551b003cebadd51d908..015382f70db4356ce90424dea7ce6b79fcb73e16 100644 --- a/src/output/ods/ptm/ptmspectrasheet.cpp +++ b/src/output/ods/ptm/ptmspectrasheet.cpp @@ -6,267 +6,331 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 "ptmspectrasheet.h" #include <tuple> #include <pappsomspp/utils.h> -PtmSpectraSheet::PtmSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project, const QString & sheet_name): _p_project(p_project) { - _p_ods_export = p_ods_export; - _p_writer = p_writer; - p_writer->writeSheet(sheet_name); - - OdsTableSettings table_settings; - table_settings.setVerticalSplit(1); - _p_writer->setCurrentOdsTableSettings(table_settings); - - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); +PtmSpectraSheet::PtmSpectraSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project, + const QString &sheet_name) + : _p_project(p_project) +{ + _p_ods_export = p_ods_export; + _p_writer = p_writer; + p_writer->writeSheet(sheet_name); + + OdsTableSettings table_settings; + table_settings.setVerticalSplit(1); + _p_writer->setCurrentOdsTableSettings(table_settings); + + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -PtmSpectraSheet::PtmSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): PtmSpectraSheet(p_ods_export, p_writer, p_project, QString("PTM spectra")) { +PtmSpectraSheet::PtmSpectraSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : PtmSpectraSheet(p_ods_export, p_writer, p_project, QString("PTM spectra")) +{ } -void PtmSpectraSheet::writeCellHeader(PeptideListColumn column) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - _p_writer->setCellAnnotation(PeptideTableModel::getDescription(column)); - _p_writer->writeCell(PeptideTableModel::getTitle(column)); - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; +void +PtmSpectraSheet::writeCellHeader(PeptideListColumn column) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _p_writer->setCellAnnotation(PeptideTableModel::getDescription(column)); + _p_writer->writeCell(PeptideTableModel::getTitle(column)); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void PtmSpectraSheet::writeHeaders(IdentificationGroup * p_ident) { - // Group ID Sub-group ID Phosphopeptide ID Sample Scan Rt Sequence (top) Modifs (top) Best position in peptide All observed positions in phosphopeptide Number of phosphoislands Phosphoislands Ids Best e-value Charge MH+ Obs MH+ theo DeltaMH+ Delta-ppm +void +PtmSpectraSheet::writeHeaders(IdentificationGroup *p_ident) +{ + // Group ID Sub-group ID Phosphopeptide ID Sample Scan Rt Sequence (top) + // Modifs (top) Best position in peptide All observed positions in + // phosphopeptide Number of phosphoislands Phosphoislands Ids Best e-value + // Charge MH+ Obs MH+ theo DeltaMH+ Delta-ppm - //MS Sample : 20120906_balliau_extract_1_A01_urnb-1 - const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); - if (msrun_list.size() == 1) { - _p_writer->writeCell("sample"); - _p_writer->writeLine(); - _p_writer->writeCell(msrun_list[0].get()->getSampleName()); - _p_writer->writeLine(); + // MS Sample : 20120906_balliau_extract_1_A01_urnb-1 + const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); + if(msrun_list.size() == 1) + { + _p_writer->writeCell("sample"); + _p_writer->writeLine(); + _p_writer->writeCell(msrun_list[0].get()->getSampleName()); + _p_writer->writeLine(); } - _p_writer->writeLine(); + _p_writer->writeLine(); - // Group ID - _p_writer->writeCell("group ID"); + // Group ID + _p_writer->writeCell("group ID"); - // Sub-group ID + // Sub-group ID - // Phosphopeptide ID - writeCellHeader(PeptideListColumn::peptide_grouping_id); + // Phosphopeptide ID + writeCellHeader(PeptideListColumn::peptide_grouping_id); - // Modifs (top) Best position in peptide All observed positions in phosphopeptide Number of phosphoislands Phosphoislands Ids Best e-value Charge MH+ Obs MH+ theo DeltaMH+ Delta-ppm + // Modifs (top) Best position in peptide All observed positions in + // phosphopeptide Number of phosphoislands Phosphoislands Ids Best e-value + // Charge MH+ Obs MH+ theo DeltaMH+ Delta-ppm - // Sample - writeCellHeader(PeptideListColumn::sample); + // Sample + writeCellHeader(PeptideListColumn::sample); - // Scan - writeCellHeader(PeptideListColumn::scan); + // Scan + writeCellHeader(PeptideListColumn::scan); - // Rt - writeCellHeader(PeptideListColumn::rt); + // Rt + writeCellHeader(PeptideListColumn::rt); - writeCellHeader(PeptideListColumn::charge); + writeCellHeader(PeptideListColumn::charge); - writeCellHeader(PeptideListColumn::experimental_mz); + writeCellHeader(PeptideListColumn::experimental_mz); - // Sequence (top) - _p_writer->setCellAnnotation("peptide sequence (best match)"); - _p_writer->writeCell("sequence (top)"); + // Sequence (top) + _p_writer->setCellAnnotation("peptide sequence (best match)"); + _p_writer->writeCell("sequence (top)"); - // Modifs (top) - _p_writer->setCellAnnotation("peptide modification list (best match)"); - _p_writer->writeCell("modifs (top)"); + // Modifs (top) + _p_writer->setCellAnnotation("peptide modification list (best match)"); + _p_writer->writeCell("modifs (top)"); - if (_p_project->getLabelingMethodSp().get() != nullptr) { - _p_writer->setCellAnnotation("peptide label (best match)"); - _p_writer->writeCell("Label (top)"); + if(_p_project->getLabelingMethodSp().get() != nullptr) + { + _p_writer->setCellAnnotation("peptide label (best match)"); + _p_writer->writeCell("Label (top)"); } - // Best position in peptide - _p_writer->setCellAnnotation("best PTM positions for this sample/scan"); - _p_writer->writeCell("best positions in peptide"); + // Best position in peptide + _p_writer->setCellAnnotation("best PTM positions for this sample/scan"); + _p_writer->writeCell("best positions in peptide"); - // All observed positions in phosphopeptide - _p_writer->setCellAnnotation("All observed positions for this sample/scan"); - _p_writer->writeCell("all positions in peptide"); + // All observed positions in phosphopeptide + _p_writer->setCellAnnotation("All observed positions for this sample/scan"); + _p_writer->writeCell("all positions in peptide"); - // Number of phosphoislands - _p_writer->setCellAnnotation("Number of phosphoislands share this sample/scan"); - _p_writer->writeCell("number of phosphoislands"); + // Number of phosphoislands + _p_writer->setCellAnnotation( + "Number of phosphoislands share this sample/scan"); + _p_writer->writeCell("number of phosphoislands"); - // Phosphoislands Ids - _p_writer->setCellAnnotation("Phosphoislands id list"); - _p_writer->writeCell("phosphoislands"); + // Phosphoislands Ids + _p_writer->setCellAnnotation("Phosphoislands id list"); + _p_writer->writeCell("phosphoislands"); - // Best e-value - _p_writer->writeCell("best E-value"); + // Best e-value + _p_writer->writeCell("best E-value"); - _p_writer->writeCell("best hyperscore"); + _p_writer->writeCell("best hyperscore"); - // MH+ Obs - writeCellHeader(PeptideListColumn::experimental_mhplus); + // MH+ Obs + writeCellHeader(PeptideListColumn::experimental_mhplus); - // MH+ theo - writeCellHeader(PeptideListColumn::theoretical_mhplus); - - // DeltaMH+ - writeCellHeader(PeptideListColumn::delta_mhplus); - - // Delta-ppm - writeCellHeader(PeptideListColumn::delta_ppm); + // MH+ theo + writeCellHeader(PeptideListColumn::theoretical_mhplus); + // DeltaMH+ + writeCellHeader(PeptideListColumn::delta_mhplus); + // Delta-ppm + writeCellHeader(PeptideListColumn::delta_ppm); } -void PtmSpectraSheet::writeBestPeptideEvidence(const PtmSampleScan & ptm_sample_scan , std::set<const PtmIsland *> & ptmisland_occurence_list) { - - _p_writer->writeLine(); - - const PeptideEvidence * p_peptide_evidence = ptm_sample_scan.getRepresentativePeptideMatch().getPeptideEvidence(); - - unsigned int group_number = p_peptide_evidence->getGrpPeptideSp().get()->getGroupNumber(); - unsigned int rank_number = p_peptide_evidence->getGrpPeptideSp().get()->getRank(); - - _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); - _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); - _p_ods_export->setEvenOrOddStyle(rank_number, _p_writer); - _p_writer->writeCell(p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); - _p_writer->clearTableCellStyleRef(); - _p_writer->writeCell(p_peptide_evidence->getMsRunP()->getSampleName()); - _p_writer->writeCell(p_peptide_evidence->getScan()); - _p_writer->writeCell(p_peptide_evidence->getRetentionTime()); - _p_writer->writeCell(p_peptide_evidence->getCharge()); - _p_writer->writeCell(p_peptide_evidence->getExperimentalMz()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getSequence()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); - if (_p_project->getLabelingMethodSp().get() != nullptr) { - const Label * p_label = p_peptide_evidence->getPeptideXtpSp().get()->getLabel(); - if (p_label != nullptr) { - _p_writer->writeCell(p_label->getXmlId()); +void +PtmSpectraSheet::writeBestPeptideEvidence( + const PtmSampleScan &ptm_sample_scan, + std::set<const PtmIsland *> &ptmisland_occurence_list) +{ + + _p_writer->writeLine(); + + const PeptideEvidence *p_peptide_evidence = + ptm_sample_scan.getRepresentativePeptideMatch().getPeptideEvidence(); + + unsigned int group_number = + p_peptide_evidence->getGrpPeptideSp().get()->getGroupNumber(); + unsigned int rank_number = + p_peptide_evidence->getGrpPeptideSp().get()->getRank(); + + _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); + _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); + _p_ods_export->setEvenOrOddStyle(rank_number, _p_writer); + _p_writer->writeCell( + p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); + _p_writer->clearTableCellStyleRef(); + _p_writer->writeCell(p_peptide_evidence->getMsRunP()->getSampleName()); + _p_writer->writeCell(p_peptide_evidence->getScan()); + _p_writer->writeCell(p_peptide_evidence->getRetentionTime()); + _p_writer->writeCell(p_peptide_evidence->getCharge()); + _p_writer->writeCell(p_peptide_evidence->getExperimentalMz()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getSequence()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); + if(_p_project->getLabelingMethodSp().get() != nullptr) + { + const Label *p_label = + p_peptide_evidence->getPeptideXtpSp().get()->getLabel(); + if(p_label != nullptr) + { + _p_writer->writeCell(p_label->getXmlId()); } - else { - _p_writer->writeEmptyCell(); + else + { + _p_writer->writeEmptyCell(); } } - QStringList position_list; - for (unsigned int position :ptm_sample_scan.getBestPtmPositionList(_p_ptm_grouping_experiment)) { - position_list << QString("%1").arg(position+1); + QStringList position_list; + for(unsigned int position : + ptm_sample_scan.getBestPtmPositionList(_p_ptm_grouping_experiment)) + { + position_list << QString("%1").arg(position + 1); } - _p_writer->writeCell(position_list.join(" ")); - - position_list.clear(); - //return _ptm_sample_scan_list.at(row).get()->getObservedPtmPositionList(); - for (unsigned int position :ptm_sample_scan.getObservedPtmPositionList(_p_ptm_grouping_experiment)) { - position_list << QString("%1").arg(position+1); + _p_writer->writeCell(position_list.join(" ")); + + position_list.clear(); + // return _ptm_sample_scan_list.at(row).get()->getObservedPtmPositionList(); + for(unsigned int position : + ptm_sample_scan.getObservedPtmPositionList(_p_ptm_grouping_experiment)) + { + position_list << QString("%1").arg(position + 1); } - _p_writer->writeCell(position_list.join(" ")); - - _p_writer->writeCell((unsigned int) ptmisland_occurence_list.size()); - position_list.clear(); - //return _ptm_sample_scan_list.at(row).get()->getObservedPtmPositionList(); - for (const PtmIsland * ptm_island:ptmisland_occurence_list) { - position_list << ptm_island->getGroupingId(); + _p_writer->writeCell(position_list.join(" ")); + + _p_writer->writeCell((unsigned int)ptmisland_occurence_list.size()); + position_list.clear(); + // return _ptm_sample_scan_list.at(row).get()->getObservedPtmPositionList(); + for(const PtmIsland *ptm_island : ptmisland_occurence_list) + { + position_list << ptm_island->getGroupingId(); } - _p_writer->writeCell(position_list.join(" ")); - - _p_writer->writeCell(p_peptide_evidence->getEvalue()); - _p_writer->writeCell(p_peptide_evidence->getParam(PeptideEvidenceParam::tandem_hyperscore).toDouble()); - - _p_writer->writeCell(p_peptide_evidence->getExperimentalMass()+pappso::MHPLUS); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getMz(1)); - _p_writer->writeCell(p_peptide_evidence->getDeltaMass()); - _p_writer->writeCell(p_peptide_evidence->getPpmDeltaMass()); - - + _p_writer->writeCell(position_list.join(" ")); + + _p_writer->writeCell(p_peptide_evidence->getEvalue()); + _p_writer->writeCell( + p_peptide_evidence->getParam(PeptideEvidenceParam::tandem_hyperscore) + .toDouble()); + + _p_writer->writeCell(p_peptide_evidence->getExperimentalMass() + + pappso::MHPLUS); + _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getMz(1)); + _p_writer->writeCell(p_peptide_evidence->getDeltaMass()); + _p_writer->writeCell(p_peptide_evidence->getPpmDeltaMass()); } -void PtmSpectraSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - _p_ptm_grouping_experiment = p_ident->getPtmGroupingExperiment(); - - writeHeaders(p_ident); - for (const PtmIslandSubgroupSp & ptm_island_subgroup_sp : _p_ptm_grouping_experiment->getPtmIslandSubgroupList() ) { - writePtmIslandSubgroupSp(ptm_island_subgroup_sp); +void +PtmSpectraSheet::writeIdentificationGroup(IdentificationGroup *p_ident) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _p_ptm_grouping_experiment = p_ident->getPtmGroupingExperiment(); + + writeHeaders(p_ident); + for(const PtmIslandSubgroupSp &ptm_island_subgroup_sp : + _p_ptm_grouping_experiment->getPtmIslandSubgroupList()) + { + writePtmIslandSubgroupSp(ptm_island_subgroup_sp); } - _p_writer->writeLine(); - _p_writer->writeLine(); - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + _p_writer->writeLine(); + _p_writer->writeLine(); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void PtmSpectraSheet::writePtmIslandSubgroupSp(const PtmIslandSubgroupSp & ptm_island_subgroup_sp) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - struct PtmSampleScanOccurence { - PtmSampleScan ptm_sample_scan; - std::set<const PtmIsland *> ptmisland_occurence_list; - }; - std::vector<PtmSampleScanOccurence> ptm_sample_scan_occurence_list; - - for (PtmIslandSp ptm_island_sp :ptm_island_subgroup_sp.get()->getPtmIslandList()) { - - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - for (PeptideMatch peptide_match: ptm_island_sp.get()->getPeptideMatchList()) { - - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - std::vector<PtmSampleScanOccurence>::iterator it_ptm = ptm_sample_scan_occurence_list.begin(); - std::vector<PtmSampleScanOccurence>::iterator it_ptm_end = ptm_sample_scan_occurence_list.end(); - while ((it_ptm != it_ptm_end) && (it_ptm->ptm_sample_scan.add(peptide_match) == false)) { - //peptide added - it_ptm++; +void +PtmSpectraSheet::writePtmIslandSubgroupSp( + const PtmIslandSubgroupSp &ptm_island_subgroup_sp) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + struct PtmSampleScanOccurence + { + PtmSampleScan ptm_sample_scan; + std::set<const PtmIsland *> ptmisland_occurence_list; + }; + std::vector<PtmSampleScanOccurence> ptm_sample_scan_occurence_list; + + for(PtmIslandSp ptm_island_sp : + ptm_island_subgroup_sp.get()->getPtmIslandList()) + { + + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + for(PeptideMatch peptide_match : + ptm_island_sp.get()->getPeptideMatchList()) + { + + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + std::vector<PtmSampleScanOccurence>::iterator it_ptm = + ptm_sample_scan_occurence_list.begin(); + std::vector<PtmSampleScanOccurence>::iterator it_ptm_end = + ptm_sample_scan_occurence_list.end(); + while((it_ptm != it_ptm_end) && + (it_ptm->ptm_sample_scan.add(peptide_match) == false)) + { + // peptide added + it_ptm++; } - if (it_ptm == it_ptm_end) { - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - //peptide NOT added - PtmSampleScanOccurence new_occurence = {PtmSampleScan(peptide_match),std::set<const PtmIsland *>()}; - new_occurence.ptmisland_occurence_list.insert(ptm_island_sp.get()); - ptm_sample_scan_occurence_list.push_back(new_occurence); - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + if(it_ptm == it_ptm_end) + { + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + // peptide NOT added + PtmSampleScanOccurence new_occurence = { + PtmSampleScan(peptide_match), std::set<const PtmIsland *>()}; + new_occurence.ptmisland_occurence_list.insert( + ptm_island_sp.get()); + ptm_sample_scan_occurence_list.push_back(new_occurence); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } - else { - //peptide added - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - it_ptm->ptmisland_occurence_list.insert(ptm_island_sp.get()); + else + { + // peptide added + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + it_ptm->ptmisland_occurence_list.insert(ptm_island_sp.get()); - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } } } - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - for (PtmSampleScanOccurence & occurence: ptm_sample_scan_occurence_list) { - writeBestPeptideEvidence(occurence.ptm_sample_scan, occurence.ptmisland_occurence_list); + for(PtmSampleScanOccurence &occurence : ptm_sample_scan_occurence_list) + { + writeBestPeptideEvidence(occurence.ptm_sample_scan, + occurence.ptmisland_occurence_list); } - qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } diff --git a/src/output/ods/ptm/ptmspectrasheet.h b/src/output/ods/ptm/ptmspectrasheet.h index 444aa68d45bca1a974845e95b8096170d100769c..6b589c045e6ee0e065899167e3416511a66a29ed 100644 --- a/src/output/ods/ptm/ptmspectrasheet.h +++ b/src/output/ods/ptm/ptmspectrasheet.h @@ -6,26 +6,27 @@ */ /******************************************************************************* -* Copyright (c) 2018 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) 2018 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 PTMSPECTRASHEET_H #define PTMSPECTRASHEET_H @@ -38,22 +39,28 @@ class PtmSpectraSheet { -public : - PtmSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); - -protected : - PtmSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project, const QString & sheet_name); - virtual void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writeBestPeptideEvidence(const PtmSampleScan & ptm_sample_scan , std::set<const PtmIsland *> & ptmisland_occurence_list); - void writeCellHeader(PeptideListColumn column); - - void writePtmIslandSubgroupSp(const PtmIslandSubgroupSp & ptm_island_subgroup_sp); -protected : - OdsExport * _p_ods_export; - const PtmGroupingExperiment * _p_ptm_grouping_experiment; - const Project * _p_project; - CalcWriterInterface * _p_writer; + public: + PtmSpectraSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); + + protected: + PtmSpectraSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project, const QString &sheet_name); + virtual void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writeBestPeptideEvidence( + const PtmSampleScan &ptm_sample_scan, + std::set<const PtmIsland *> &ptmisland_occurence_list); + void writeCellHeader(PeptideListColumn column); + + void + writePtmIslandSubgroupSp(const PtmIslandSubgroupSp &ptm_island_subgroup_sp); + + protected: + OdsExport *_p_ods_export; + const PtmGroupingExperiment *_p_ptm_grouping_experiment; + const Project *_p_project; + CalcWriterInterface *_p_writer; }; #endif // PTMSPECTRASHEET_H diff --git a/src/output/ods/samplesheet.cpp b/src/output/ods/samplesheet.cpp index c90b0bd6842cc01f85e74a2033e3e181ffd907a1..5a579ef90de84a13f12e78fe8b78109b9f77a41c 100644 --- a/src/output/ods/samplesheet.cpp +++ b/src/output/ods/samplesheet.cpp @@ -274,7 +274,7 @@ SampleSheet::writeIdentificationDataSource( { _p_writer->writeCell(var_sample.toInt()); } - + var_sample = msrun_sp.get()->getMsRunStatistics(MsRunStatistics::tic_spectra_ms1); if(var_sample.isNull()) diff --git a/src/output/ods/samplesheet.h b/src/output/ods/samplesheet.h index 345d1629e356d9b77134489f4fcc51c71dd846a9..12677f5f2186c78196fda60434185f57c15b0f59 100644 --- a/src/output/ods/samplesheet.h +++ b/src/output/ods/samplesheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef SAMPLESHEET_H #define SAMPLESHEET_H @@ -36,17 +37,20 @@ class SampleSheet { -public : - SampleSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); + public: + SampleSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); -private: - void writeHeaders(); - void writeIdentificationDataSource(IdentificationDataSource * p_ident_data_source); -private : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; - bool _msrun_statistics = true; + private: + void writeHeaders(); + void + writeIdentificationDataSource(IdentificationDataSource *p_ident_data_source); + + private: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; + bool _msrun_statistics = true; }; #endif // SAMPLESHEET_H diff --git a/src/output/ods/simplesheet.cpp b/src/output/ods/simplesheet.cpp index 7f4517be5c3b9c8cb21107d7dca0e05f8655c454..a6f96f101b038fe0cc80605f80ece98f67ccb496 100644 --- a/src/output/ods/simplesheet.cpp +++ b/src/output/ods/simplesheet.cpp @@ -6,60 +6,70 @@ */ /******************************************************************************* -* 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 "simplesheet.h" #include "../../core/identificationgroup.h" -SimpleSheet::SimpleSheet (CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) { - _p_writer = p_writer; - p_writer->writeSheet("simple"); - - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - - for (IdentificationGroup * p_ident:identification_list) { - writeIdentificationGroup(p_ident); +SimpleSheet::SimpleSheet(CalcWriterInterface *p_writer, + const Project *p_project) + : _p_project(p_project) +{ + _p_writer = p_writer; + p_writer->writeSheet("simple"); + + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + + for(IdentificationGroup *p_ident : identification_list) + { + writeIdentificationGroup(p_ident); } } -void SimpleSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { - - //_p_writer->writeSheet("simple"); - const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); - _p_writer->writeCell("protein"); - _p_writer->writeLine(); - _p_writer->writeEmptyCell(); - _p_writer->writeCell("peptide"); - _p_writer->writeLine(); - if (msrun_list.size() == 1) { - _p_writer->writeCell("sample"); - _p_writer->writeLine(); - _p_writer->writeCell(msrun_list[0].get()->getSampleName()); - _p_writer->writeLine(); +void +SimpleSheet::writeIdentificationGroup(IdentificationGroup *p_ident) +{ + + //_p_writer->writeSheet("simple"); + const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); + _p_writer->writeCell("protein"); + _p_writer->writeLine(); + _p_writer->writeEmptyCell(); + _p_writer->writeCell("peptide"); + _p_writer->writeLine(); + if(msrun_list.size() == 1) + { + _p_writer->writeCell("sample"); + _p_writer->writeLine(); + _p_writer->writeCell(msrun_list[0].get()->getSampleName()); + _p_writer->writeLine(); } - - for (ProteinMatch * p_protein_match :p_ident->getProteinMatchList()) { - _p_writer->writeCell(p_protein_match->getProteinXtpSp().get()->getAccession()); - _p_writer->writeLine(); + + for(ProteinMatch *p_protein_match : p_ident->getProteinMatchList()) + { + _p_writer->writeCell( + p_protein_match->getProteinXtpSp().get()->getAccession()); + _p_writer->writeLine(); } - } diff --git a/src/output/ods/simplesheet.h b/src/output/ods/simplesheet.h index 447172b7352706d712097cd0d97b8de07f32be11..2d3b98ebb10adea1da7849ebed05d45ba5cae26e 100644 --- a/src/output/ods/simplesheet.h +++ b/src/output/ods/simplesheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef SIMPLESHEET_H #define SIMPLESHEET_H @@ -36,13 +37,15 @@ class SimpleSheet { - public : - SimpleSheet (CalcWriterInterface * p_writer, const Project * p_project); -private : - void writeIdentificationGroup(IdentificationGroup * p_ident); -private : - const Project * _p_project; - CalcWriterInterface * _p_writer; + public: + SimpleSheet(CalcWriterInterface *p_writer, const Project *p_project); + + private: + void writeIdentificationGroup(IdentificationGroup *p_ident); + + private: + const Project *_p_project; + CalcWriterInterface *_p_writer; }; #endif // SIMPLESHEET_H diff --git a/src/output/ods/spectrasheet.cpp b/src/output/ods/spectrasheet.cpp index e75b4e0c3d9f1ef78776e04e3f73903d75fed82d..c56f6b1e61b55e562cf25551ebf94aa8a9bcd2dd 100644 --- a/src/output/ods/spectrasheet.cpp +++ b/src/output/ods/spectrasheet.cpp @@ -6,177 +6,227 @@ */ /******************************************************************************* -* 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 "spectrasheet.h" #include <tuple> #include <pappsomspp/utils.h> -SpectraSheet::SpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project, const QString & sheet_name): _p_project(p_project) { - _p_ods_export = p_ods_export; - _p_writer = p_writer; - p_writer->writeSheet(sheet_name); - - OdsTableSettings table_settings; - table_settings.setVerticalSplit(1); - _p_writer->setCurrentOdsTableSettings(table_settings); - - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - for (IdentificationGroup * p_ident:identification_list) { - //writeHeaders(p_ident); - writeIdentificationGroup(p_ident); +SpectraSheet::SpectraSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project, const QString &sheet_name) + : _p_project(p_project) +{ + _p_ods_export = p_ods_export; + _p_writer = p_writer; + p_writer->writeSheet(sheet_name); + + OdsTableSettings table_settings; + table_settings.setVerticalSplit(1); + _p_writer->setCurrentOdsTableSettings(table_settings); + + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + for(IdentificationGroup *p_ident : identification_list) + { + // writeHeaders(p_ident); + writeIdentificationGroup(p_ident); } } -SpectraSheet::SpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): SpectraSheet(p_ods_export, p_writer, p_project, QString("spectra")) { +SpectraSheet::SpectraSheet(OdsExport *p_ods_export, + CalcWriterInterface *p_writer, + const Project *p_project) + : SpectraSheet(p_ods_export, p_writer, p_project, QString("spectra")) +{ } -void SpectraSheet::writeCellHeader(PeptideListColumn column) { - qDebug() << "SpectraSheet::writeCellHeader begin " << (std::int8_t) column; - _p_writer->setCellAnnotation(PeptideTableModel::getDescription(column)); - _p_writer->writeCell(PeptideTableModel::getTitle(column)); - qDebug() << "SpectraSheet::writeCellHeader end" ; +void +SpectraSheet::writeCellHeader(PeptideListColumn column) +{ + qDebug() << "SpectraSheet::writeCellHeader begin " << (std::int8_t)column; + _p_writer->setCellAnnotation(PeptideTableModel::getDescription(column)); + _p_writer->writeCell(PeptideTableModel::getTitle(column)); + qDebug() << "SpectraSheet::writeCellHeader end"; } -void SpectraSheet::writeHeaders(IdentificationGroup * p_ident) { - // Group ID Peptide ID Sample Scan Rt (minutes) Sequence (top) Modifs (top) Number of subgroups Sub-groups Ids Best E-value Best hyperscore m/z Obs Charge MH+ Obs MH+ theo DeltaMH+ Delta-ppm - - //MS Sample : 20120906_balliau_extract_1_A01_urnb-1 - const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); - if (msrun_list.size() == 1) { - _p_writer->writeCell("sample"); - _p_writer->writeLine(); - _p_writer->writeCell(msrun_list[0].get()->getSampleName()); - _p_writer->writeLine(); +void +SpectraSheet::writeHeaders(IdentificationGroup *p_ident) +{ + // Group ID Peptide ID Sample Scan Rt (minutes) Sequence (top) Modifs (top) + // Number of subgroups Sub-groups Ids Best E-value Best hyperscore m/z Obs + // Charge MH+ Obs MH+ theo DeltaMH+ Delta-ppm + + // MS Sample : 20120906_balliau_extract_1_A01_urnb-1 + const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList(); + if(msrun_list.size() == 1) + { + _p_writer->writeCell("sample"); + _p_writer->writeLine(); + _p_writer->writeCell(msrun_list[0].get()->getSampleName()); + _p_writer->writeLine(); } - _p_writer->writeLine(); - _p_writer->writeCell("Group ID"); - _p_writer->writeCell("Peptide ID"); - - writeCellHeader(PeptideListColumn::sample); - writeCellHeader(PeptideListColumn::scan); - writeCellHeader(PeptideListColumn::rt); - writeCellHeader(PeptideListColumn::experimental_mz); - _p_writer->setCellAnnotation("peptide sequence (best match)"); - _p_writer->writeCell("Sequence (top)"); - _p_writer->setCellAnnotation("peptide charge (best match)"); - _p_writer->writeCell("Charge (top)"); - _p_writer->setCellAnnotation("peptide modifications (best match)"); - _p_writer->writeCell("Modifs (top)"); - if (_p_project->getLabelingMethodSp().get() != nullptr) { - _p_writer->setCellAnnotation("peptide label (best match)"); - _p_writer->writeCell("Label (top)"); + _p_writer->writeLine(); + _p_writer->writeCell("Group ID"); + _p_writer->writeCell("Peptide ID"); + + writeCellHeader(PeptideListColumn::sample); + writeCellHeader(PeptideListColumn::scan); + writeCellHeader(PeptideListColumn::rt); + writeCellHeader(PeptideListColumn::experimental_mz); + _p_writer->setCellAnnotation("peptide sequence (best match)"); + _p_writer->writeCell("Sequence (top)"); + _p_writer->setCellAnnotation("peptide charge (best match)"); + _p_writer->writeCell("Charge (top)"); + _p_writer->setCellAnnotation("peptide modifications (best match)"); + _p_writer->writeCell("Modifs (top)"); + if(_p_project->getLabelingMethodSp().get() != nullptr) + { + _p_writer->setCellAnnotation("peptide label (best match)"); + _p_writer->writeCell("Label (top)"); } - _p_writer->writeCell("Best E-value"); - _p_writer->writeCell("Best hyperscore"); - writeCellHeader(PeptideListColumn::delta_mhplus); - - + _p_writer->writeCell("Best E-value"); + _p_writer->writeCell("Best hyperscore"); + writeCellHeader(PeptideListColumn::delta_mhplus); } -void SpectraSheet::writeBestPeptideEvidence(const GroupingGroup * p_group,const PeptideEvidence * p_peptide_evidence) { - - _p_writer->writeLine(); - - unsigned int group_number = p_peptide_evidence->getGrpPeptideSp().get()->getGroupNumber(); - unsigned int rank_number = p_peptide_evidence->getGrpPeptideSp().get()->getRank(); - - _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); - _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); - _p_ods_export->setEvenOrOddStyle(rank_number, _p_writer); - _p_writer->writeCell(p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); - _p_writer->clearTableCellStyleRef(); - _p_writer->writeCell(p_peptide_evidence->getMsRunP()->getSampleName()); - _p_writer->writeCell(p_peptide_evidence->getScan()); - _p_writer->writeCell(p_peptide_evidence->getRetentionTime()); - _p_writer->writeCell(p_peptide_evidence->getExperimentalMz()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getSequence()); - _p_writer->writeCell(p_peptide_evidence->getCharge()); - _p_writer->writeCell(p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); - if (_p_project->getLabelingMethodSp().get() != nullptr) { - const Label * p_label = p_peptide_evidence->getPeptideXtpSp().get()->getLabel(); - if (p_label != nullptr) { - _p_writer->writeCell(p_label->getXmlId()); +void +SpectraSheet::writeBestPeptideEvidence( + const GroupingGroup *p_group, const PeptideEvidence *p_peptide_evidence) +{ + + _p_writer->writeLine(); + + unsigned int group_number = + p_peptide_evidence->getGrpPeptideSp().get()->getGroupNumber(); + unsigned int rank_number = + p_peptide_evidence->getGrpPeptideSp().get()->getRank(); + + _p_ods_export->setEvenOrOddStyle(group_number, _p_writer); + _p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number)); + _p_ods_export->setEvenOrOddStyle(rank_number, _p_writer); + _p_writer->writeCell( + p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()); + _p_writer->clearTableCellStyleRef(); + _p_writer->writeCell(p_peptide_evidence->getMsRunP()->getSampleName()); + _p_writer->writeCell(p_peptide_evidence->getScan()); + _p_writer->writeCell(p_peptide_evidence->getRetentionTime()); + _p_writer->writeCell(p_peptide_evidence->getExperimentalMz()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getSequence()); + _p_writer->writeCell(p_peptide_evidence->getCharge()); + _p_writer->writeCell( + p_peptide_evidence->getPeptideXtpSp().get()->getModifString()); + if(_p_project->getLabelingMethodSp().get() != nullptr) + { + const Label *p_label = + p_peptide_evidence->getPeptideXtpSp().get()->getLabel(); + if(p_label != nullptr) + { + _p_writer->writeCell(p_label->getXmlId()); } - else { - _p_writer->writeEmptyCell(); + else + { + _p_writer->writeEmptyCell(); } } - _p_writer->writeCell(p_peptide_evidence->getEvalue()); - _p_writer->writeCell(p_peptide_evidence->getParam(PeptideEvidenceParam::tandem_hyperscore).toDouble()); - _p_writer->writeCell(p_peptide_evidence->getDeltaMass()); - - + _p_writer->writeCell(p_peptide_evidence->getEvalue()); + _p_writer->writeCell( + p_peptide_evidence->getParam(PeptideEvidenceParam::tandem_hyperscore) + .toDouble()); + _p_writer->writeCell(p_peptide_evidence->getDeltaMass()); } -void SpectraSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { - - writeHeaders(p_ident); - for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) { - - std::vector<const PeptideEvidence *> peptide_evidence_list = group_pair.second.get()->getPeptideEvidenceList(); - - std::sort(peptide_evidence_list.begin(), peptide_evidence_list.end(), - [](const PeptideEvidence * a, const PeptideEvidence * b) - { - unsigned int arank = a->getGrpPeptideSp().get()->getRank(); - unsigned int ascan = a->getScan(); - unsigned int brank = b->getGrpPeptideSp().get()->getRank(); - unsigned int bscan = b->getScan(); - return std::tie(arank, a->getMsRunP()->getSampleName(), ascan) < std::tie(brank, b->getMsRunP()->getSampleName(), bscan); +void +SpectraSheet::writeIdentificationGroup(IdentificationGroup *p_ident) +{ + + writeHeaders(p_ident); + for(const std::pair<unsigned int, GroupingGroupSp> &group_pair : + p_ident->getGroupStore().getGroupMap()) + { + + std::vector<const PeptideEvidence *> peptide_evidence_list = + group_pair.second.get()->getPeptideEvidenceList(); + + std::sort( + peptide_evidence_list.begin(), peptide_evidence_list.end(), + [](const PeptideEvidence *a, const PeptideEvidence *b) { + unsigned int arank = a->getGrpPeptideSp().get()->getRank(); + unsigned int ascan = a->getScan(); + unsigned int brank = b->getGrpPeptideSp().get()->getRank(); + unsigned int bscan = b->getScan(); + return std::tie(arank, a->getMsRunP()->getSampleName(), ascan) < + std::tie(brank, b->getMsRunP()->getSampleName(), bscan); }); - const PeptideEvidence * p_best_peptide_evidence = nullptr; + const PeptideEvidence *p_best_peptide_evidence = nullptr; - for (auto & peptide_evidence:peptide_evidence_list) { - if (p_best_peptide_evidence == nullptr) { - p_best_peptide_evidence = peptide_evidence; + for(auto &peptide_evidence : peptide_evidence_list) + { + if(p_best_peptide_evidence == nullptr) + { + p_best_peptide_evidence = peptide_evidence; } - //change spectra : - unsigned int arank = p_best_peptide_evidence->getGrpPeptideSp().get()->getRank(); - unsigned int ascan = p_best_peptide_evidence->getScan(); - unsigned int brank = peptide_evidence->getGrpPeptideSp().get()->getRank(); - unsigned int bscan = peptide_evidence->getScan(); - - if (std::tie(arank, p_best_peptide_evidence->getMsRunP()->getSampleName(), ascan) != std::tie(brank, peptide_evidence->getMsRunP()->getSampleName(), bscan)) { - //write p_best_peptide_match - writeBestPeptideEvidence(group_pair.second.get(), p_best_peptide_evidence); - p_best_peptide_evidence = peptide_evidence; + // change spectra : + unsigned int arank = + p_best_peptide_evidence->getGrpPeptideSp().get()->getRank(); + unsigned int ascan = p_best_peptide_evidence->getScan(); + unsigned int brank = + peptide_evidence->getGrpPeptideSp().get()->getRank(); + unsigned int bscan = peptide_evidence->getScan(); + + if(std::tie(arank, + p_best_peptide_evidence->getMsRunP()->getSampleName(), + ascan) != + std::tie(brank, peptide_evidence->getMsRunP()->getSampleName(), + bscan)) + { + // write p_best_peptide_match + writeBestPeptideEvidence(group_pair.second.get(), + p_best_peptide_evidence); + p_best_peptide_evidence = peptide_evidence; } - else { - if (p_best_peptide_evidence->getEvalue()> peptide_evidence->getEvalue()) { - p_best_peptide_evidence = peptide_evidence; + else + { + if(p_best_peptide_evidence->getEvalue() > + peptide_evidence->getEvalue()) + { + p_best_peptide_evidence = peptide_evidence; } } } - if (p_best_peptide_evidence != nullptr) { - writeBestPeptideEvidence(group_pair.second.get(), p_best_peptide_evidence); + if(p_best_peptide_evidence != nullptr) + { + writeBestPeptideEvidence(group_pair.second.get(), + p_best_peptide_evidence); } } - _p_writer->writeLine(); - _p_writer->writeLine(); + _p_writer->writeLine(); + _p_writer->writeLine(); } diff --git a/src/output/ods/spectrasheet.h b/src/output/ods/spectrasheet.h index 356798d31819bc8bb042ac9763b4b1038bd968e1..5035d45aed2ce9f09695a7d67b70fa3c7d4dc20c 100644 --- a/src/output/ods/spectrasheet.h +++ b/src/output/ods/spectrasheet.h @@ -6,26 +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 + ******************************************************************************/ #ifndef SPECTRASHEET_H #define SPECTRASHEET_H @@ -38,20 +39,23 @@ class SpectraSheet { -public : - SpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project); -protected : - SpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project, const QString & sheet_name); - virtual void writeIdentificationGroup(IdentificationGroup * p_ident); - void writeHeaders(IdentificationGroup * p_ident); - void writeBestPeptideEvidence(const GroupingGroup * p_group, const PeptideEvidence * p_peptide_evidence); - void writeCellHeader(PeptideListColumn column); + public: + SpectraSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project); -protected : - OdsExport * _p_ods_export; - const Project * _p_project; - CalcWriterInterface * _p_writer; + protected: + SpectraSheet(OdsExport *p_ods_export, CalcWriterInterface *p_writer, + const Project *p_project, const QString &sheet_name); + virtual void writeIdentificationGroup(IdentificationGroup *p_ident); + void writeHeaders(IdentificationGroup *p_ident); + void writeBestPeptideEvidence(const GroupingGroup *p_group, + const PeptideEvidence *p_peptide_evidence); + void writeCellHeader(PeptideListColumn column); + + protected: + OdsExport *_p_ods_export; + const Project *_p_project; + CalcWriterInterface *_p_writer; }; #endif // SPECTRASHEET_H - diff --git a/src/output/proticdbml.cpp b/src/output/proticdbml.cpp index c2a59cc76b6d238b48348fcbe78ef00f842b1782..9648842e50dfa7cc8c35759fd263e4d518ceff97 100644 --- a/src/output/proticdbml.cpp +++ b/src/output/proticdbml.cpp @@ -6,26 +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 "proticdbml.h" #include <pappsomspp/pappsoexception.h> @@ -36,705 +37,940 @@ #include "../config.h" #include "../utils/utils.h" -ProticdbMl::ProticdbMl(const QString & out_filename) +ProticdbMl::ProticdbMl(const QString &out_filename) { - //_p_digestion_pipeline = p_digestion_pipeline; + //_p_digestion_pipeline = p_digestion_pipeline; - //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; - QString complete_out_filename = out_filename; - _output_file = new QFile(complete_out_filename); + //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; + QString complete_out_filename = out_filename; + _output_file = new QFile(complete_out_filename); - if (_output_file->open(QIODevice::WriteOnly)) + if(_output_file->open(QIODevice::WriteOnly)) { - _output_stream = new QXmlStreamWriter(); - _output_stream->setDevice(_output_file); - } else + _output_stream = new QXmlStreamWriter(); + _output_stream->setDevice(_output_file); + } + else { - throw pappso::PappsoException(QObject::tr("error : cannot open the PROTICdbML output file : %1\n").arg(out_filename)); + throw pappso::PappsoException( + QObject::tr("error : cannot open the PROTICdbML output file : %1\n") + .arg(out_filename)); } - _output_stream->setAutoFormatting(true); - _output_stream->writeStartDocument("1.0"); - - + _output_stream->setAutoFormatting(true); + _output_stream->writeStartDocument("1.0"); } ProticdbMl::~ProticdbMl() { - delete _output_file; - delete _output_stream; + delete _output_file; + delete _output_stream; } -void ProticdbMl::close() { - _output_stream->writeEndDocument(); - _output_file->close(); +void +ProticdbMl::close() +{ + _output_stream->writeEndDocument(); + _output_file->close(); - qDebug() << "ProticdbMl::close end duration = " << _duracel.elapsed() << "ms"; + qDebug() << "ProticdbMl::close end duration = " << _duracel.elapsed() << "ms"; } +void +ProticdbMl::write(ProjectSp sp_project) +{ -void ProticdbMl::write(ProjectSp sp_project) { - - qDebug() << "ProticdbMl::write begin"; - _duracel.start(); - _sp_project = sp_project; - if (_sp_project.get() == nullptr) { - throw pappso::PappsoException(QObject::tr("Error writing PROTICdbML file :\n project is empty")); + qDebug() << "ProticdbMl::write begin"; + _duracel.start(); + _sp_project = sp_project; + if(_sp_project.get() == nullptr) + { + throw pappso::PappsoException( + QObject::tr("Error writing PROTICdbML file :\n project is empty")); } - _output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance","xsi"); - // writer.setDefaultNamespace(namespaceURI); - _output_stream->writeStartElement("PROTICdb"); - //_output_stream->writeAttribute("xmlns","http://pappso.inra.fr/xsd/masschroqml/2.2"); - //_output_stream->writeAttribute("http://www.w3.org/2001/XMLSchema-instance","schemaLocation","http://pappso.inra.fr/xsd/masschroqml/2.2 http://pappso.inra.fr/xsd/masschroq-2.2.xsd"); + _output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance", + "xsi"); + // writer.setDefaultNamespace(namespaceURI); + _output_stream->writeStartElement("PROTICdb"); + //_output_stream->writeAttribute("xmlns","http://pappso.inra.fr/xsd/masschroqml/2.2"); + //_output_stream->writeAttribute("http://www.w3.org/2001/XMLSchema-instance","schemaLocation","http://pappso.inra.fr/xsd/masschroqml/2.2 + //http://pappso.inra.fr/xsd/masschroq-2.2.xsd"); - //writer.writeAttribute(xmlnsxsi, "noNamespaceSchemaLocation", xsischemaLocation); + // writer.writeAttribute(xmlnsxsi, "noNamespaceSchemaLocation", + // xsischemaLocation); - _output_stream->writeAttribute("version", "1.0"); + _output_stream->writeAttribute("version", "1.0"); - _output_stream->writeAttribute("type", "MSidentificationResults"); + _output_stream->writeAttribute("type", "MSidentificationResults"); - writeIdentMethod(); - _output_stream->writeStartElement("sequences"); - for (IdentificationGroup * p_ident_group : sp_project.get()->getIdentificationGroupList()) { + writeIdentMethod(); + _output_stream->writeStartElement("sequences"); + for(IdentificationGroup *p_ident_group : + sp_project.get()->getIdentificationGroupList()) + { - for (ProteinMatch * p_protein_match: p_ident_group->getProteinMatchList()) { - writeSequence(p_protein_match); + for(ProteinMatch *p_protein_match : p_ident_group->getProteinMatchList()) + { + writeSequence(p_protein_match); } } - //</sequences> - _output_stream->writeEndElement(); - - writeProject(); + //</sequences> + _output_stream->writeEndElement(); + writeProject(); } -void ProticdbMl::writeSequence(ProteinMatch * p_protein_match) { - qDebug() << "ProticdbMl::writeSequence begin"; - if (p_protein_match->getValidationState() != ValidationState::grouped) return; - pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get(); - - if (_map_accession2xmlid.find(p_grp_protein->getAccession()) == _map_accession2xmlid.end()) { - //not found - - QString id = QString("seq%1").arg(_map_accession2xmlid.size()); - _output_stream->writeStartElement("sequence"); - _output_stream->writeAttribute("id", id); - QString display_id = QString("%1 %2").arg(p_grp_protein->getAccession()).arg(p_protein_match->getProteinXtpSp().get()->getDescription()); - _output_stream->writeAttribute("display_id", display_id.left(60)); - // <dbxref key="AT5G16390" - // dbname="AGI_LocusCode"></dbxref> - //if (prot.get_dbxref_type().equals("no") == false) { - for (const DbXref & dbxref :p_protein_match->getProteinXtpSp().get()->getDbxrefList()) { - _output_stream->writeStartElement("dbxref"); - _output_stream->writeAttribute("dbname", Utils::getDatabaseName(dbxref.database)); - _output_stream->writeAttribute("key", - dbxref.accession); - _output_stream->writeEndElement();// dbxref - } - _output_stream->writeStartElement("description"); - _output_stream->writeCharacters(p_protein_match->getProteinXtpSp().get()->getDescription()); - _output_stream->writeEndElement();// description - _output_stream->writeStartElement("seq"); - _output_stream->writeCharacters(p_protein_match->getProteinXtpSp().get()->getSequence()); - _output_stream->writeEndElement();// seq - - _output_stream->writeEndElement();// sequence - - _map_accession2xmlid.insert(std::pair<QString, QString>(p_grp_protein->getAccession(), id)); +void +ProticdbMl::writeSequence(ProteinMatch *p_protein_match) +{ + qDebug() << "ProticdbMl::writeSequence begin"; + if(p_protein_match->getValidationState() != ValidationState::grouped) + return; + pappso::GrpProtein *p_grp_protein = p_protein_match->getGrpProteinSp().get(); + if(_map_accession2xmlid.find(p_grp_protein->getAccession()) == + _map_accession2xmlid.end()) + { + // not found + + QString id = QString("seq%1").arg(_map_accession2xmlid.size()); + _output_stream->writeStartElement("sequence"); + _output_stream->writeAttribute("id", id); + QString display_id = + QString("%1 %2") + .arg(p_grp_protein->getAccession()) + .arg(p_protein_match->getProteinXtpSp().get()->getDescription()); + _output_stream->writeAttribute("display_id", display_id.left(60)); + // <dbxref key="AT5G16390" + // dbname="AGI_LocusCode"></dbxref> + // if (prot.get_dbxref_type().equals("no") == false) { + for(const DbXref &dbxref : + p_protein_match->getProteinXtpSp().get()->getDbxrefList()) + { + _output_stream->writeStartElement("dbxref"); + _output_stream->writeAttribute( + "dbname", Utils::getDatabaseName(dbxref.database)); + _output_stream->writeAttribute("key", dbxref.accession); + _output_stream->writeEndElement(); // dbxref + } + _output_stream->writeStartElement("description"); + _output_stream->writeCharacters( + p_protein_match->getProteinXtpSp().get()->getDescription()); + _output_stream->writeEndElement(); // description + _output_stream->writeStartElement("seq"); + _output_stream->writeCharacters( + p_protein_match->getProteinXtpSp().get()->getSequence()); + _output_stream->writeEndElement(); // seq + + _output_stream->writeEndElement(); // sequence + + _map_accession2xmlid.insert( + std::pair<QString, QString>(p_grp_protein->getAccession(), id)); } - qDebug() << "ProticdbMl::writeSequence end"; + qDebug() << "ProticdbMl::writeSequence end"; } -void ProticdbMl::writeProject() { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeStartElement("project"); - _output_stream->writeAttribute("name", ""); - _output_stream->writeAttribute("id", "p1"); - // ajout des echantillons_msrun - writeSamples(); - writeMsRuns(); - - _output_stream->writeStartElement("identificationRuns"); - - for (IdentificationGroup * p_identification : _sp_project.get()->getIdentificationGroupList()) { - _output_stream->writeStartElement("identificationRun"); - // ajout d'une mnip d'identification - writeIdentificationRun(p_identification); +void +ProticdbMl::writeProject() +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeStartElement("project"); + _output_stream->writeAttribute("name", ""); + _output_stream->writeAttribute("id", "p1"); + // ajout des echantillons_msrun + writeSamples(); + writeMsRuns(); + + _output_stream->writeStartElement("identificationRuns"); + + for(IdentificationGroup *p_identification : + _sp_project.get()->getIdentificationGroupList()) + { + _output_stream->writeStartElement("identificationRun"); + // ajout d'une mnip d'identification + writeIdentificationRun(p_identification); - // ajout des petides - writepeptideHits(p_identification); + // ajout des petides + writepeptideHits(p_identification); - // ajout des mathces - writeMatchs(p_identification); + // ajout des mathces + writeMatchs(p_identification); - _output_stream->writeEndElement();// identificationRun + _output_stream->writeEndElement(); // identificationRun } - _output_stream->writeEndElement();// identificationRuns - _output_stream->writeEndElement();// project + _output_stream->writeEndElement(); // identificationRuns + _output_stream->writeEndElement(); // project - _output_stream->writeEndDocument(); + _output_stream->writeEndDocument(); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProticdbMl::writeIdentMethod() { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - // Ajout des méthodes - _output_stream->writeStartElement("identMeth"); - _output_stream->writeAttribute("name", ""); - _output_stream->writeAttribute("id", "m1"); - _output_stream->writeEndElement(); - - // Ajout des base de données - _output_stream->writeStartElement("customDb"); - _output_stream->writeAttribute("name", ""); - _output_stream->writeAttribute("id", "customdb0"); - _output_stream->writeEndElement(); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - - +void +ProticdbMl::writeIdentMethod() +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + // Ajout des méthodes + _output_stream->writeStartElement("identMeth"); + _output_stream->writeAttribute("name", ""); + _output_stream->writeAttribute("id", "m1"); + _output_stream->writeEndElement(); + + // Ajout des base de données + _output_stream->writeStartElement("customDb"); + _output_stream->writeAttribute("name", ""); + _output_stream->writeAttribute("id", "customdb0"); + _output_stream->writeEndElement(); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProticdbMl::writeSamples() { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeStartElement("samples"); - for (MsRunSp msrun_sp : _sp_project.get()->getMsRunStore().getMsRunList()) { - _output_stream->writeStartElement("sample"); - QString id_samp = "bsamp" + pappso::Utils::getLexicalOrderedString(_sample_to_id.size()); - QString id_msrun = msrun_sp.get()->getXmlId(); - QString name = msrun_sp.get()->getSampleName(); - // balise sample - _output_stream->writeAttribute("name", name); - _output_stream->writeAttribute("id", id_samp); - _output_stream->writeEmptyElement("description"); - _sample_to_id.insert(std::pair<QString, QString>( name, id_samp)); - - // Element spectrumList = doc.createElement("spectrumList"); - // msRun.appendChild(spectrumList); - - //msrun_to_id.put(samp.getSampleName(), id_msrun); - _output_stream->writeEndElement();// sample - +void +ProticdbMl::writeSamples() +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeStartElement("samples"); + for(MsRunSp msrun_sp : _sp_project.get()->getMsRunStore().getMsRunList()) + { + _output_stream->writeStartElement("sample"); + QString id_samp = + "bsamp" + pappso::Utils::getLexicalOrderedString(_sample_to_id.size()); + QString id_msrun = msrun_sp.get()->getXmlId(); + QString name = msrun_sp.get()->getSampleName(); + // balise sample + _output_stream->writeAttribute("name", name); + _output_stream->writeAttribute("id", id_samp); + _output_stream->writeEmptyElement("description"); + _sample_to_id.insert(std::pair<QString, QString>(name, id_samp)); + + // Element spectrumList = doc.createElement("spectrumList"); + // msRun.appendChild(spectrumList); + + // msrun_to_id.put(samp.getSampleName(), id_msrun); + _output_stream->writeEndElement(); // sample } - _output_stream->writeEndElement();// samples - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeEndElement(); // samples + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProticdbMl::writeMsRuns() { - - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeStartElement("msRuns"); - for (MsRunSp msrun_sp : _sp_project.get()->getMsRunStore().getMsRunList()) { +void +ProticdbMl::writeMsRuns() +{ - QString name = msrun_sp.get()->getSampleName(); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeStartElement("msRuns"); + for(MsRunSp msrun_sp : _sp_project.get()->getMsRunStore().getMsRunList()) + { - QString id_samp = _sample_to_id.at(name); + QString name = msrun_sp.get()->getSampleName(); - // Element spectrumList = doc.createElement("spectrumList"); - // msRun.appendChild(spectrumList); + QString id_samp = _sample_to_id.at(name); - QString id_msrun = msrun_sp.get()->getXmlId(); + // Element spectrumList = doc.createElement("spectrumList"); + // msRun.appendChild(spectrumList); - // balise MsRun - _output_stream->writeStartElement("msRun"); - _output_stream->writeAttribute("sample_id", id_samp); - _output_stream->writeAttribute("id", id_msrun); + QString id_msrun = msrun_sp.get()->getXmlId(); - _output_stream->writeStartElement("description"); - _output_stream->writeStartElement("admin"); - // writer.writeStartElement("contact"); - // writer.writeStartElement("email"); - // writer.writeCharacters("valot@moulon.inra.fr"); - // writer.writeEndElement();// email + // balise MsRun + _output_stream->writeStartElement("msRun"); + _output_stream->writeAttribute("sample_id", id_samp); + _output_stream->writeAttribute("id", id_msrun); - // writer.writeStartElement("name"); - // writer.writeCharacters("Valot Benoit"); - // writer.writeEndElement();// name - // writer.writeEndElement();// contact + _output_stream->writeStartElement("description"); + _output_stream->writeStartElement("admin"); + // writer.writeStartElement("contact"); + // writer.writeStartElement("email"); + // writer.writeCharacters("valot@moulon.inra.fr"); + // writer.writeEndElement();// email - _output_stream->writeStartElement("sourceFile"); - _output_stream->writeStartElement("nameOfFile"); - _output_stream->writeCharacters(name + ".RAW"); - _output_stream->writeEndElement();// nameOfFile - _output_stream->writeEndElement();// sourceFile + // writer.writeStartElement("name"); + // writer.writeCharacters("Valot Benoit"); + // writer.writeEndElement();// name + // writer.writeEndElement();// contact - _output_stream->writeStartElement("sampleName"); - _output_stream->writeCharacters(name); - _output_stream->writeEndElement();// sampleName - _output_stream->writeEndElement();// admin - _output_stream->writeEndElement();// description + _output_stream->writeStartElement("sourceFile"); + _output_stream->writeStartElement("nameOfFile"); + _output_stream->writeCharacters(name + ".RAW"); + _output_stream->writeEndElement(); // nameOfFile + _output_stream->writeEndElement(); // sourceFile - _output_stream->writeEndElement();// msRun + _output_stream->writeStartElement("sampleName"); + _output_stream->writeCharacters(name); + _output_stream->writeEndElement(); // sampleName + _output_stream->writeEndElement(); // admin + _output_stream->writeEndElement(); // description + _output_stream->writeEndElement(); // msRun } - _output_stream->writeEndElement();// msRuns - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeEndElement(); // msRuns + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProticdbMl::writeIdentificationDataSource(IdentificationDataSource * p_identification_data_source) { +void +ProticdbMl::writeIdentificationDataSource( + IdentificationDataSource *p_identification_data_source) +{ - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeStartElement("dataProcessing"); - _output_stream->writeStartElement("software"); - _output_stream->writeStartElement("name"); - if (p_identification_data_source->getIdentificationEngine() == IdentificationEngine::XTandem) { - _output_stream->writeAttribute("acc", "PROTICdbO:0000283"); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeStartElement("dataProcessing"); + _output_stream->writeStartElement("software"); + _output_stream->writeStartElement("name"); + if(p_identification_data_source->getIdentificationEngine() == + IdentificationEngine::XTandem) + { + _output_stream->writeAttribute("acc", "PROTICdbO:0000283"); } - _output_stream->writeCharacters(p_identification_data_source->getIdentificationEngineName()); - - _output_stream->writeEndElement();// name - _output_stream->writeStartElement("version"); - _output_stream->writeCharacters(p_identification_data_source->getIdentificationEngineVersion()); - _output_stream->writeEndElement();// version - _output_stream->writeEndElement();// software - _output_stream->writeStartElement("processingMethod"); - // mzXml source file name - writeCvParam("PROTICdbO:0000343",p_identification_data_source->getMsRunSp().get()->getFilename(), - "MS/MS data source file name"); - if (p_identification_data_source->getIdentificationEngine() == IdentificationEngine::XTandem) { - // model file name - writeCvParam("PROTICdbO:0000342", p_identification_data_source->getIdentificationEngineParam(IdentificationEngineParam::tandem_param).toString(), - "X!tandem xml model file name"); - // xtandem result file name - writeCvParam("PROTICdbO:0000341", p_identification_data_source->getResourceName(), - "X!tandem xml result file name"); + _output_stream->writeCharacters( + p_identification_data_source->getIdentificationEngineName()); + + _output_stream->writeEndElement(); // name + _output_stream->writeStartElement("version"); + _output_stream->writeCharacters( + p_identification_data_source->getIdentificationEngineVersion()); + _output_stream->writeEndElement(); // version + _output_stream->writeEndElement(); // software + _output_stream->writeStartElement("processingMethod"); + // mzXml source file name + writeCvParam("PROTICdbO:0000343", + p_identification_data_source->getMsRunSp().get()->getFilename(), + "MS/MS data source file name"); + if(p_identification_data_source->getIdentificationEngine() == + IdentificationEngine::XTandem) + { + // model file name + writeCvParam("PROTICdbO:0000342", + p_identification_data_source + ->getIdentificationEngineParam( + IdentificationEngineParam::tandem_param) + .toString(), + "X!tandem xml model file name"); + // xtandem result file name + writeCvParam("PROTICdbO:0000341", + p_identification_data_source->getResourceName(), + "X!tandem xml result file name"); } - _output_stream->writeEndElement();// processingMethod - _output_stream->writeEndElement();// dataProcessing - /* - _output_stream->writeStartElement("dataProcessing"); - _output_stream->writeStartElement("software"); - _output_stream->writeStartElement("name"); - _output_stream->writeAttribute("acc", "PROTICdbO:0000283"); - _output_stream->writeCharacters("X!Tandem"); - _output_stream->writeEndElement();// name - _output_stream->writeStartElement("version"); - _output_stream->writeCharacters(XtandemPipelineSession.getInstance() - .getConfig().getXtandemVersion()); - _output_stream->writeEndElement();// version - _output_stream->writeEndElement();// software - _output_stream->writeStartElement("processingMethod"); - _output_stream->writeEndElement();// processingMethod - _output_stream->writeEndElement();// dataProcessing - */ - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeEndElement(); // processingMethod + _output_stream->writeEndElement(); // dataProcessing + /* + _output_stream->writeStartElement("dataProcessing"); + _output_stream->writeStartElement("software"); + _output_stream->writeStartElement("name"); + _output_stream->writeAttribute("acc", "PROTICdbO:0000283"); + _output_stream->writeCharacters("X!Tandem"); + _output_stream->writeEndElement();// name + _output_stream->writeStartElement("version"); + _output_stream->writeCharacters(XtandemPipelineSession.getInstance() + .getConfig().getXtandemVersion()); + _output_stream->writeEndElement();// version + _output_stream->writeEndElement();// software + _output_stream->writeStartElement("processingMethod"); + _output_stream->writeEndElement();// processingMethod + _output_stream->writeEndElement();// dataProcessing + */ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProticdbMl::writeIdentificationRun(IdentificationGroup * p_identification) { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeAttribute("ident_method_id", "m1"); - _output_stream->writeAttribute("customdb_id", "customdb0"); - - _output_stream->writeStartElement("description"); - _output_stream->writeStartElement("admin"); - // writer.writeStartElement("contact"); - // writer.writeStartElement("email"); - // writer.writeCharacters("valot@moulon.inra.fr"); - // writer.writeEndElement();// email - - // writer.writeStartElement("name"); - // writer.writeCharacters("Valot Benoit"); - // writer.writeEndElement();// name - // writer.writeEndElement();// contact - /* - this.xpipFile = XtandemPipelineSession.getInstance() - .getCurrentXpipFile(); - - _output_stream->writeStartElement("sourceFile"); - _output_stream->writeStartElement("nameOfFile"); - // TODO - // get the loaded xpip file name - _output_stream->writeCharacters(this.xpipFile.getName()); - _output_stream->writeEndElement();// nameOfFile - _output_stream->writeStartElement("pathToFile"); - _output_stream->writeCharacters(this.xpipFile.getAbsolutePath()); - _output_stream->writeEndElement();// pathToFile - _output_stream->writeStartElement("fileType"); - _output_stream->writeCharacters("XPIP file"); - _output_stream->writeEndElement();// fileType - _output_stream->writeEndElement();// sourceFile - */ - _output_stream->writeEndElement();// admin - - // if we can retrieve original informations in xml xtandem results - // - for (IdentificationDataSource * p_identification_data_source : p_identification->getIdentificationDataSourceList()) { - writeIdentificationDataSource(p_identification_data_source); +void +ProticdbMl::writeIdentificationRun(IdentificationGroup *p_identification) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeAttribute("ident_method_id", "m1"); + _output_stream->writeAttribute("customdb_id", "customdb0"); + + _output_stream->writeStartElement("description"); + _output_stream->writeStartElement("admin"); + // writer.writeStartElement("contact"); + // writer.writeStartElement("email"); + // writer.writeCharacters("valot@moulon.inra.fr"); + // writer.writeEndElement();// email + + // writer.writeStartElement("name"); + // writer.writeCharacters("Valot Benoit"); + // writer.writeEndElement();// name + // writer.writeEndElement();// contact + /* + this.xpipFile = XtandemPipelineSession.getInstance() + .getCurrentXpipFile(); + + _output_stream->writeStartElement("sourceFile"); + _output_stream->writeStartElement("nameOfFile"); + // TODO + // get the loaded xpip file name + _output_stream->writeCharacters(this.xpipFile.getName()); + _output_stream->writeEndElement();// nameOfFile + _output_stream->writeStartElement("pathToFile"); + _output_stream->writeCharacters(this.xpipFile.getAbsolutePath()); + _output_stream->writeEndElement();// pathToFile + _output_stream->writeStartElement("fileType"); + _output_stream->writeCharacters("XPIP file"); + _output_stream->writeEndElement();// fileType + _output_stream->writeEndElement();// sourceFile + */ + _output_stream->writeEndElement(); // admin + + // if we can retrieve original informations in xml xtandem results + // + for(IdentificationDataSource *p_identification_data_source : + p_identification->getIdentificationDataSourceList()) + { + writeIdentificationDataSource(p_identification_data_source); } - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - -// id: PROTICdbO:0000316 -// name: X!TandemPipeline - - _output_stream->writeStartElement("dataProcessing"); - _output_stream->writeStartElement("software"); - _output_stream->writeStartElement("name"); - _output_stream->writeAttribute("acc", "PROTICdbO:0000316"); - _output_stream->writeCharacters("X!TandemPipeline"); - _output_stream->writeEndElement();// name - _output_stream->writeStartElement("version"); - _output_stream->writeCharacters(XTPCPP_VERSION); - _output_stream->writeEndElement();// version - _output_stream->writeEndElement();// software - _output_stream->writeStartElement("processingMethod"); -// cvParams - - writeCvParam("PROTICdbO:0000323", QString("%1").arg(_sp_project.get()->getAutomaticFilterParameters().getFilterProteinEvalue()), - "X!TandemPipeline filter on protein evalue (log)"); - -// indi -// combine -// phospho - if (_sp_project.get()->getProjectMode() == ProjectMode::combined) { - writeCvParam("PROTICdbO:0000320", "combine", ""); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + + // id: PROTICdbO:0000316 + // name: X!TandemPipeline + + _output_stream->writeStartElement("dataProcessing"); + _output_stream->writeStartElement("software"); + _output_stream->writeStartElement("name"); + _output_stream->writeAttribute("acc", "PROTICdbO:0000316"); + _output_stream->writeCharacters("X!TandemPipeline"); + _output_stream->writeEndElement(); // name + _output_stream->writeStartElement("version"); + _output_stream->writeCharacters(XTPCPP_VERSION); + _output_stream->writeEndElement(); // version + _output_stream->writeEndElement(); // software + _output_stream->writeStartElement("processingMethod"); + // cvParams + + writeCvParam("PROTICdbO:0000323", + QString("%1").arg(_sp_project.get() + ->getAutomaticFilterParameters() + .getFilterProteinEvalue()), + "X!TandemPipeline filter on protein evalue (log)"); + + // indi + // combine + // phospho + if(_sp_project.get()->getProjectMode() == ProjectMode::combined) + { + writeCvParam("PROTICdbO:0000320", "combine", ""); } - else { - writeCvParam("PROTICdbO:0000319", "indiv", ""); + else + { + writeCvParam("PROTICdbO:0000319", "indiv", ""); } - //if (xtpExperimentType.equals("phospho")) { - // this.writeCvParam("PROTICdbO:0000321", xtpExperimentType, ""); - //} - - writeCvParam("PROTICdbO:0000325", QString("%1").arg(_sp_project.get()->getAutomaticFilterParameters().getFilterMinimumPeptidePerMatch()), - "X!TandemPipeline filter on minimal number of peptide per protein"); - - writeCvParam("PROTICdbO:0000324", QString("%1").arg(_sp_project.get()->getAutomaticFilterParameters().getFilterPeptideEvalue()), - "X!TandemPipeline filter on peptide evalue"); - -// TODO write database filter -// this.writeCvParam("PROTICdbO:0000324", "" -// + -// XtandemPipelineSession.getInstance().getConfig().get_database_filter(), -// "X!TandemPipeline filter on peptide evalue"); - - _output_stream->writeEndElement();// processingMethod - - _output_stream->writeEndElement();// dataProcessing - - _output_stream->writeEndElement();// description - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + // if (xtpExperimentType.equals("phospho")) { + // this.writeCvParam("PROTICdbO:0000321", xtpExperimentType, ""); + //} + + writeCvParam( + "PROTICdbO:0000325", + QString("%1").arg(_sp_project.get() + ->getAutomaticFilterParameters() + .getFilterMinimumPeptidePerMatch()), + "X!TandemPipeline filter on minimal number of peptide per protein"); + + writeCvParam("PROTICdbO:0000324", + QString("%1").arg(_sp_project.get() + ->getAutomaticFilterParameters() + .getFilterPeptideEvalue()), + "X!TandemPipeline filter on peptide evalue"); + + // TODO write database filter + // this.writeCvParam("PROTICdbO:0000324", "" + // + + // XtandemPipelineSession.getInstance().getConfig().get_database_filter(), + // "X!TandemPipeline filter on peptide evalue"); + + _output_stream->writeEndElement(); // processingMethod + + _output_stream->writeEndElement(); // dataProcessing + + _output_stream->writeEndElement(); // description + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProticdbMl::writepeptideHits(IdentificationGroup * p_identification) { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeStartElement("peptideHits"); - for (std::pair <unsigned int, GroupingGroupSp > group_pair : p_identification->getGroupStore().getGroupMap()) { - writepeptideHitsbyGroup(group_pair.second.get()); +void +ProticdbMl::writepeptideHits(IdentificationGroup *p_identification) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeStartElement("peptideHits"); + for(std::pair<unsigned int, GroupingGroupSp> group_pair : + p_identification->getGroupStore().getGroupMap()) + { + writepeptideHitsbyGroup(group_pair.second.get()); } - _output_stream->writeEndElement();// "peptideHits"); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeEndElement(); // "peptideHits"); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -QString getProticPeptideHitKey(const PeptideEvidence * p_peptide_evidence) { - return (QString ("%1 %2 %3").arg(p_peptide_evidence->getHashSampleScan()).arg(p_peptide_evidence->getPeptideXtpSp().get()->toAbsoluteString()).arg(p_peptide_evidence->getIdentificationDataSource()->getResourceName())); +QString +getProticPeptideHitKey(const PeptideEvidence *p_peptide_evidence) +{ + return ( + QString("%1 %2 %3") + .arg(p_peptide_evidence->getHashSampleScan()) + .arg(p_peptide_evidence->getPeptideXtpSp().get()->toAbsoluteString()) + .arg( + p_peptide_evidence->getIdentificationDataSource()->getResourceName())); } -struct ProticPeptideHit { - bool operator ==(const ProticPeptideHit &other) const { - return (key == other.key); - }; - /** key = getProticPeptideHitKey - * */ - QString key; - PeptideMatch peptide_match; +struct ProticPeptideHit +{ + bool + operator==(const ProticPeptideHit &other) const + { + return (key == other.key); + }; + /** key = getProticPeptideHitKey + * */ + QString key; + PeptideMatch peptide_match; }; -void ProticdbMl::writepeptideHitsbyGroup(GroupingGroup * p_group) { +void +ProticdbMl::writepeptideHitsbyGroup(GroupingGroup *p_group) +{ - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - std::vector <ProticPeptideHit> protic_peptide_hit_list; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + std::vector<ProticPeptideHit> protic_peptide_hit_list; - for (const ProteinMatch* p_protein_match : p_group->getProteinMatchList()) { - for (const PeptideMatch & peptide_match : p_protein_match->getPeptideMatchList(ValidationState::grouped)) { - ProticPeptideHit protic_peptide_hit = {getProticPeptideHitKey(peptide_match.getPeptideEvidence()), peptide_match}; - protic_peptide_hit_list.push_back(protic_peptide_hit); + for(const ProteinMatch *p_protein_match : p_group->getProteinMatchList()) + { + for(const PeptideMatch &peptide_match : + p_protein_match->getPeptideMatchList(ValidationState::grouped)) + { + ProticPeptideHit protic_peptide_hit = { + getProticPeptideHitKey(peptide_match.getPeptideEvidence()), + peptide_match}; + protic_peptide_hit_list.push_back(protic_peptide_hit); } } - std::sort(protic_peptide_hit_list.begin(),protic_peptide_hit_list.end(),[](const ProticPeptideHit & first, const ProticPeptideHit & second) { - return (first.key < second.key) ; - }); - auto last = std::unique(protic_peptide_hit_list.begin(), protic_peptide_hit_list.end()); - protic_peptide_hit_list.erase(last, protic_peptide_hit_list.end()); - - for (ProticPeptideHit & protic_peptide_hit :protic_peptide_hit_list) { - QString xml_id = QString("pep%1").arg(_peptidekey_to_id.size()+1); - writePeptideHit(xml_id, protic_peptide_hit); - _peptidekey_to_id.insert(std::pair<QString, QString>(protic_peptide_hit.key, xml_id)); + std::sort(protic_peptide_hit_list.begin(), protic_peptide_hit_list.end(), + [](const ProticPeptideHit &first, const ProticPeptideHit &second) { + return (first.key < second.key); + }); + auto last = + std::unique(protic_peptide_hit_list.begin(), protic_peptide_hit_list.end()); + protic_peptide_hit_list.erase(last, protic_peptide_hit_list.end()); + + for(ProticPeptideHit &protic_peptide_hit : protic_peptide_hit_list) + { + QString xml_id = QString("pep%1").arg(_peptidekey_to_id.size() + 1); + writePeptideHit(xml_id, protic_peptide_hit); + _peptidekey_to_id.insert( + std::pair<QString, QString>(protic_peptide_hit.key, xml_id)); } - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } +void +ProticdbMl::writePeptideHit(QString xml_id, + ProticPeptideHit &protic_peptide_hit) +{ -void ProticdbMl::writePeptideHit(QString xml_id, ProticPeptideHit & protic_peptide_hit) { - - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - if (protic_peptide_hit.peptide_match.getPeptideEvidence() == nullptr) { - throw pappso::PappsoException(QObject::tr("Error protic_peptide_hit.peptide_match->getPeptideEvidence() == nullptr : \n%1 %2 %3").arg(__FILE__) - .arg(__FUNCTION__) - .arg(__LINE__) - ); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + if(protic_peptide_hit.peptide_match.getPeptideEvidence() == nullptr) + { + throw pappso::PappsoException( + QObject::tr( + "Error protic_peptide_hit.peptide_match->getPeptideEvidence() == " + "nullptr : \n%1 %2 %3") + .arg(__FILE__) + .arg(__FUNCTION__) + .arg(__LINE__)); } - if (protic_peptide_hit.peptide_match.getPeptideEvidence()->getPeptideXtpSp().get() == nullptr) { - throw pappso::PappsoException(QObject::tr("Error protic_peptide_hit.peptide_match->getPeptideEvidence()->getPeptideXtpSp().get() == nullptr : \n%1 %2 %3").arg(__FILE__) - .arg(__FUNCTION__) - .arg(__LINE__) - ); + if(protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() == nullptr) + { + throw pappso::PappsoException( + QObject::tr("Error " + "protic_peptide_hit.peptide_match->getPeptideEvidence()->" + "getPeptideXtpSp().get() == nullptr : \n%1 %2 %3") + .arg(__FILE__) + .arg(__FUNCTION__) + .arg(__LINE__)); } - // param par default - _output_stream->writeStartElement("peptideHit"); - _output_stream->writeAttribute("calc_mr", Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getMass())); - _output_stream->writeAttribute("exp_mz", Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence()->getExperimentalMz())); - _output_stream->writeAttribute("delta", Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence()->getDeltaMass())); - _output_stream->writeAttribute("exp_mr", Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence()->getExperimentalMass())); - _output_stream->writeAttribute("acq_number", QString ("%1").arg(protic_peptide_hit.peptide_match.getPeptideEvidence()->getScan())); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeAttribute("ms_run_id", protic_peptide_hit.peptide_match.getPeptideEvidence()->getMsRunP()->getXmlId()); - _output_stream->writeAttribute("id", xml_id); - _output_stream->writeAttribute("exp_z", QString ("%1").arg(protic_peptide_hit.peptide_match.getPeptideEvidence()->getCharge())); - - writeCvParam("PROTICdbO:0000339",protic_peptide_hit.peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()->getGroupingId(), - "peptide mass id"); - /* - if (xtpExperimentType.equals("phospho")) { - this.writeCvParam("PROTICdbO:0000349", - Utils.getPappsoPhosphoPeptideMassId(group, peptideMass), - "phosphopeptide mass id"); - } - */ - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - // pep.getMsRun(). - IdentificationEngine identification_engine = protic_peptide_hit.peptide_match.getPeptideEvidence()->getIdentificationDataSource()->getIdentificationEngine(); - if (identification_engine == IdentificationEngine::XTandem) { - // cvparam specifique xtandem - - writeCvParam("PROTICdbO:0000287", Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence()->getEvalue()), - "xtandem peptide evalue"); - - writeCvParam("PROTICdbO:0000288", Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence()->getParam(PeptideEvidenceParam::tandem_hyperscore).toDouble()), - "xtandem peptide hyperscore"); + // param par default + _output_stream->writeStartElement("peptideHit"); + _output_stream->writeAttribute( + "calc_mr", + Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getMass())); + _output_stream->writeAttribute( + "exp_mz", + Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getExperimentalMz())); + _output_stream->writeAttribute( + "delta", + Utils::getXmlDouble( + protic_peptide_hit.peptide_match.getPeptideEvidence()->getDeltaMass())); + _output_stream->writeAttribute( + "exp_mr", + Utils::getXmlDouble(protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getExperimentalMass())); + _output_stream->writeAttribute( + "acq_number", + QString("%1").arg( + protic_peptide_hit.peptide_match.getPeptideEvidence()->getScan())); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeAttribute( + "ms_run_id", protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getMsRunP() + ->getXmlId()); + _output_stream->writeAttribute("id", xml_id); + _output_stream->writeAttribute( + "exp_z", + QString("%1").arg( + protic_peptide_hit.peptide_match.getPeptideEvidence()->getCharge())); + + writeCvParam("PROTICdbO:0000339", + protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getGrpPeptideSp() + .get() + ->getGroupingId(), + "peptide mass id"); + /* + if (xtpExperimentType.equals("phospho")) { + this.writeCvParam("PROTICdbO:0000349", + Utils.getPappsoPhosphoPeptideMassId(group, + peptideMass), "phosphopeptide mass id"); + } + */ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + // pep.getMsRun(). + IdentificationEngine identification_engine = + protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getIdentificationDataSource() + ->getIdentificationEngine(); + if(identification_engine == IdentificationEngine::XTandem) + { + // cvparam specifique xtandem + + writeCvParam( + "PROTICdbO:0000287", + Utils::getXmlDouble( + protic_peptide_hit.peptide_match.getPeptideEvidence()->getEvalue()), + "xtandem peptide evalue"); + + writeCvParam("PROTICdbO:0000288", + Utils::getXmlDouble( + protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getParam(PeptideEvidenceParam::tandem_hyperscore) + .toDouble()), + "xtandem peptide hyperscore"); } - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - writeCvParam("PROTICdbO:0000289",QString ("%1").arg(protic_peptide_hit.peptide_match.getPeptideEvidence()->getRetentionTime()), - "xtandem peptide retention time"); - - // sequences avec les modifs - _output_stream->writeStartElement("pepSeq"); - _output_stream->writeStartElement("peptide"); - _output_stream->writeCharacters(protic_peptide_hit.peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequence()); - _output_stream->writeEndElement();// peptide - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - if (!protic_peptide_hit.peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getModifString().isEmpty()) { - writePtms(protic_peptide_hit.peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + writeCvParam( + "PROTICdbO:0000289", + QString("%1").arg(protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getRetentionTime()), + "xtandem peptide retention time"); + + // sequences avec les modifs + _output_stream->writeStartElement("pepSeq"); + _output_stream->writeStartElement("peptide"); + _output_stream->writeCharacters( + protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getSequence()); + _output_stream->writeEndElement(); // peptide + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + if(!protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->getModifString() + .isEmpty()) + { + writePtms(protic_peptide_hit.peptide_match.getPeptideEvidence() + ->getPeptideXtpSp() + .get()); } - _output_stream->writeEndElement();// pepSeq - _output_stream->writeEndElement();// peptideHit - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeEndElement(); // pepSeq + _output_stream->writeEndElement(); // peptideHit + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -void ProticdbMl::writePtms(PeptideXtp * p_peptide) { - _output_stream->writeStartElement("ptms"); - QStringList modif_list; - unsigned int i=1; - for (const pappso::Aa & amino_acid: *p_peptide) { - std::list<pappso::AaModificationP> aa_modif_list = amino_acid.getModificationList(); - QStringList aamodif; - for (auto && aa_modif : aa_modif_list) { - if (!aa_modif->isInternal()) { - aamodif << QString::number(aa_modif->getMass(), 'f', 2); - _output_stream->writeStartElement("ptm"); - _output_stream->writeAttribute("diff_mono", Utils::getXmlDouble(aa_modif->getMass())); - _output_stream->writeAttribute("position", QString ("%1").arg(i)); - _output_stream->writeAttribute("aa", QString(amino_acid.getLetter())); - _output_stream->writeEndElement();// ptm +void +ProticdbMl::writePtms(PeptideXtp *p_peptide) +{ + _output_stream->writeStartElement("ptms"); + QStringList modif_list; + unsigned int i = 1; + for(const pappso::Aa &amino_acid : *p_peptide) + { + std::list<pappso::AaModificationP> aa_modif_list = + amino_acid.getModificationList(); + QStringList aamodif; + for(auto &&aa_modif : aa_modif_list) + { + if(!aa_modif->isInternal()) + { + aamodif << QString::number(aa_modif->getMass(), 'f', 2); + _output_stream->writeStartElement("ptm"); + _output_stream->writeAttribute( + "diff_mono", Utils::getXmlDouble(aa_modif->getMass())); + _output_stream->writeAttribute("position", QString("%1").arg(i)); + _output_stream->writeAttribute("aa", + QString(amino_acid.getLetter())); + _output_stream->writeEndElement(); // ptm } } - i++; + i++; } - _output_stream->writeEndElement();// ptms + _output_stream->writeEndElement(); // ptms } -void ProticdbMl::writeMatchs(IdentificationGroup * p_identification) { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; +void +ProticdbMl::writeMatchs(IdentificationGroup *p_identification) +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; - _output_stream->writeStartElement("matchs"); - for (std::pair <unsigned int, GroupingGroupSp > group_pair : p_identification->getGroupStore().getGroupMap()) { - //for (Group group : identification.getGrouping().getGroupList()) { - std::vector<const ProteinMatch *> protein_match_list = group_pair.second.get()->getProteinMatchList(); - //sort protein match by subgroup - std::sort(protein_match_list.begin(), protein_match_list.end(), - [](const ProteinMatch * a, const ProteinMatch * b) + _output_stream->writeStartElement("matchs"); + for(std::pair<unsigned int, GroupingGroupSp> group_pair : + p_identification->getGroupStore().getGroupMap()) + { + // for (Group group : identification.getGrouping().getGroupList()) { + std::vector<const ProteinMatch *> protein_match_list = + group_pair.second.get()->getProteinMatchList(); + // sort protein match by subgroup + std::sort(protein_match_list.begin(), protein_match_list.end(), + [](const ProteinMatch *a, const ProteinMatch *b) { + return a->getGrpProteinSp().get()->getSubGroupNumber() < + b->getGrpProteinSp().get()->getSubGroupNumber(); + }); + + std::vector<const ProteinMatch *> protein_match_subgroup_list; + for(const ProteinMatch *p_protein_match : protein_match_list) { - return a->getGrpProteinSp().get()->getSubGroupNumber() < b->getGrpProteinSp().get()->getSubGroupNumber(); - }); - - std::vector<const ProteinMatch *> protein_match_subgroup_list; - for (const ProteinMatch * p_protein_match: protein_match_list) { - if (protein_match_subgroup_list.size() == 0) { - protein_match_subgroup_list.push_back(p_protein_match); + if(protein_match_subgroup_list.size() == 0) + { + protein_match_subgroup_list.push_back(p_protein_match); } - else { - if (protein_match_subgroup_list[0]->getGrpProteinSp().get()->getSubGroupNumber() != p_protein_match->getGrpProteinSp().get()->getSubGroupNumber()) { - writeMatch(protein_match_subgroup_list); - protein_match_subgroup_list.clear(); - protein_match_subgroup_list.push_back(p_protein_match); + else + { + if(protein_match_subgroup_list[0] + ->getGrpProteinSp() + .get() + ->getSubGroupNumber() != + p_protein_match->getGrpProteinSp().get()->getSubGroupNumber()) + { + writeMatch(protein_match_subgroup_list); + protein_match_subgroup_list.clear(); + protein_match_subgroup_list.push_back(p_protein_match); } - else { - protein_match_subgroup_list.push_back(p_protein_match); + else + { + protein_match_subgroup_list.push_back(p_protein_match); } } } - writeMatch(protein_match_subgroup_list); + writeMatch(protein_match_subgroup_list); } - _output_stream->writeEndElement();// "matchs"); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + _output_stream->writeEndElement(); // "matchs"); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; } -const QString & ProticdbMl::getPeptideXmlId(const PeptideMatch* p_peptide_match) const { - QString peptide_key = getProticPeptideHitKey(p_peptide_match->getPeptideEvidence()); - auto it = _peptidekey_to_id.find(peptide_key); - if (it == _peptidekey_to_id.end()) { - throw pappso::PappsoException(QObject::tr("Error peptide key %1 not found for peptide match %2 sample=%3 scan=%4 start=%5").arg(peptide_key) - .arg(p_peptide_match->getPeptideEvidence()->getPeptideXtpSp().get()->toString()) - .arg(p_peptide_match->getPeptideEvidence()->getMsRunP()->getXmlId()) - .arg(p_peptide_match->getPeptideEvidence()->getScan()) - .arg(p_peptide_match->getStart()) - ); +const QString & +ProticdbMl::getPeptideXmlId(const PeptideMatch *p_peptide_match) const +{ + QString peptide_key = + getProticPeptideHitKey(p_peptide_match->getPeptideEvidence()); + auto it = _peptidekey_to_id.find(peptide_key); + if(it == _peptidekey_to_id.end()) + { + throw pappso::PappsoException( + QObject::tr("Error peptide key %1 not found for peptide match %2 " + "sample=%3 scan=%4 start=%5") + .arg(peptide_key) + .arg(p_peptide_match->getPeptideEvidence() + ->getPeptideXtpSp() + .get() + ->toString()) + .arg(p_peptide_match->getPeptideEvidence()->getMsRunP()->getXmlId()) + .arg(p_peptide_match->getPeptideEvidence()->getScan()) + .arg(p_peptide_match->getStart())); } - return it->second; - + return it->second; } -const QString & ProticdbMl::getProteinXmlId(const ProteinMatch* p_protein_match) const { - auto it = _map_accession2xmlid.find(p_protein_match->getProteinXtpSp().get()->getAccession()); - if (it == _map_accession2xmlid.end()) { - throw pappso::PappsoException(QObject::tr("Error protein accession %1 not found for protein %2") - .arg(p_protein_match->getProteinXtpSp().get()->getAccession()) - .arg(p_protein_match->getProteinXtpSp().get()->getAccession())); +const QString & +ProticdbMl::getProteinXmlId(const ProteinMatch *p_protein_match) const +{ + auto it = _map_accession2xmlid.find( + p_protein_match->getProteinXtpSp().get()->getAccession()); + if(it == _map_accession2xmlid.end()) + { + throw pappso::PappsoException( + QObject::tr("Error protein accession %1 not found for protein %2") + .arg(p_protein_match->getProteinXtpSp().get()->getAccession()) + .arg(p_protein_match->getProteinXtpSp().get()->getAccession())); } - return it->second; + return it->second; } -void ProticdbMl::writeMatch(std::vector<const ProteinMatch *> & protein_match_sg_list) { - try { - if (protein_match_sg_list.size() == 0) return; - //for (SubGroup sg : group.getSubGroupSet().getSubGroupList()) { - _output_stream->writeStartElement("match"); - - // samples - QStringList sample_name_list; - for (const PeptideMatch & peptide_match: protein_match_sg_list[0]->getPeptideMatchList(ValidationState::grouped)) { - sample_name_list << peptide_match.getPeptideEvidence()->getMsRunP()->getSampleName(); +void +ProticdbMl::writeMatch(std::vector<const ProteinMatch *> &protein_match_sg_list) +{ + try + { + if(protein_match_sg_list.size() == 0) + return; + // for (SubGroup sg : group.getSubGroupSet().getSubGroupList()) { + _output_stream->writeStartElement("match"); + + // samples + QStringList sample_name_list; + for(const PeptideMatch &peptide_match : + protein_match_sg_list[0]->getPeptideMatchList( + ValidationState::grouped)) + { + sample_name_list + << peptide_match.getPeptideEvidence()->getMsRunP()->getSampleName(); } - sample_name_list = sample_name_list.toSet().toList(); - for (QString sample_name :sample_name_list) { - _output_stream->writeStartElement("matchSample"); - _output_stream->writeAttribute( - "sample_id",_sample_to_id[sample_name]); - _output_stream->writeAttribute("name", sample_name); - _output_stream->writeEndElement();// "matchSample"); + sample_name_list = sample_name_list.toSet().toList(); + for(QString sample_name : sample_name_list) + { + _output_stream->writeStartElement("matchSample"); + _output_stream->writeAttribute("sample_id", + _sample_to_id[sample_name]); + _output_stream->writeAttribute("name", sample_name); + _output_stream->writeEndElement(); // "matchSample"); } - // proteins - for (const ProteinMatch * p_protein_match: protein_match_sg_list) { - _output_stream->writeStartElement("proteinHit"); - _output_stream->writeAttribute("sequence_id",QString("%1 %2").arg(p_protein_match->getProteinXtpSp().get()->getAccession()).arg(p_protein_match->getProteinXtpSp().get()->getDescription())); - // proteinHit.setAttribute("score", ""); - _output_stream->writeAttribute("rank", QString("%1").arg(p_protein_match->getGrpProteinSp().get()->getRank())); - - // //cvparam - writeCvParam("PROTICdbO:0000284",QString("%1").arg(p_protein_match->getProteinXtpSp().get()->getMass()), - "MW computation"); - // evalue - writeCvParam("PROTICdbO:0000291", Utils::getXmlDouble(p_protein_match->getLogEvalue()) - , "Xtandem log evalue"); - - // coverage - writeCvParam( - "PROTICdbO:0000285", Utils::getXmlDouble(p_protein_match->getCoverage()), - "protein coverage"); - - // [Term] - // id: PROTICdbO:0000335 - // name: X!TandemPipeline PAI - writeCvParam("PROTICdbO:0000335",Utils::getXmlDouble(p_protein_match->getPAI()), "PAI"); - - // [Term] - // id: PROTICdbO:0000337 - // name: protein group number - writeCvParam("PROTICdbO:0000337",p_protein_match->getGrpProteinSp().get()->getGroupingId(), "grouping number"); - - _output_stream->writeEndElement();// "proteinHit"); + // proteins + for(const ProteinMatch *p_protein_match : protein_match_sg_list) + { + _output_stream->writeStartElement("proteinHit"); + _output_stream->writeAttribute( + "sequence_id", + QString("%1 %2") + .arg(p_protein_match->getProteinXtpSp().get()->getAccession()) + .arg(p_protein_match->getProteinXtpSp().get()->getDescription())); + // proteinHit.setAttribute("score", ""); + _output_stream->writeAttribute( + "rank", QString("%1").arg( + p_protein_match->getGrpProteinSp().get()->getRank())); + + // //cvparam + writeCvParam("PROTICdbO:0000284", + QString("%1").arg( + p_protein_match->getProteinXtpSp().get()->getMass()), + "MW computation"); + // evalue + writeCvParam("PROTICdbO:0000291", + Utils::getXmlDouble(p_protein_match->getLogEvalue()), + "Xtandem log evalue"); + + // coverage + writeCvParam("PROTICdbO:0000285", + Utils::getXmlDouble(p_protein_match->getCoverage()), + "protein coverage"); + + // [Term] + // id: PROTICdbO:0000335 + // name: X!TandemPipeline PAI + writeCvParam("PROTICdbO:0000335", + Utils::getXmlDouble(p_protein_match->getPAI()), "PAI"); + + // [Term] + // id: PROTICdbO:0000337 + // name: protein group number + writeCvParam( + "PROTICdbO:0000337", + p_protein_match->getGrpProteinSp().get()->getGroupingId(), + "grouping number"); + + _output_stream->writeEndElement(); // "proteinHit"); } - for (const ProteinMatch * p_protein_match: protein_match_sg_list) { - //peptides - for (const PeptideMatch & peptide_match: p_protein_match->getPeptideMatchList(ValidationState::grouped)) { - // peptidesHitRef - QString peptide_xml_id = getPeptideXmlId(&peptide_match); - - _output_stream->writeStartElement("peptideHitRef"); - _output_stream->writeAttribute("peptide_hit_id", peptide_xml_id); - - _output_stream->writeStartElement("fromSeq"); - _output_stream->writeAttribute( - "seq_id", getProteinXmlId(p_protein_match)); - _output_stream->writeAttribute("start", QString("%1").arg(peptide_match.getStart()+1)); - _output_stream->writeAttribute("stop", QString("%1").arg(peptide_match.getStop()+1)); - QString residue_before_nter = "-"; - if (peptide_match.getStart() > 0) { - residue_before_nter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(peptide_match.getStart()-1,1); + for(const ProteinMatch *p_protein_match : protein_match_sg_list) + { + // peptides + for(const PeptideMatch &peptide_match : + p_protein_match->getPeptideMatchList(ValidationState::grouped)) + { + // peptidesHitRef + QString peptide_xml_id = getPeptideXmlId(&peptide_match); + + _output_stream->writeStartElement("peptideHitRef"); + _output_stream->writeAttribute("peptide_hit_id", peptide_xml_id); + + _output_stream->writeStartElement("fromSeq"); + _output_stream->writeAttribute("seq_id", + getProteinXmlId(p_protein_match)); + _output_stream->writeAttribute( + "start", QString("%1").arg(peptide_match.getStart() + 1)); + _output_stream->writeAttribute( + "stop", QString("%1").arg(peptide_match.getStop() + 1)); + QString residue_before_nter = "-"; + if(peptide_match.getStart() > 0) + { + residue_before_nter = + p_protein_match->getProteinXtpSp().get()->getSequence().mid( + peptide_match.getStart() - 1, 1); } - _output_stream->writeAttribute("residue_before_nter", residue_before_nter); - QString residue_after_cter = "-"; - if (peptide_match.getStop() < (p_protein_match->getProteinXtpSp().get()->getSequence().size()-1)) { - residue_after_cter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(peptide_match.getStop(),1); + _output_stream->writeAttribute("residue_before_nter", + residue_before_nter); + QString residue_after_cter = "-"; + if(peptide_match.getStop() < (p_protein_match->getProteinXtpSp() + .get() + ->getSequence() + .size() - + 1)) + { + residue_after_cter = + p_protein_match->getProteinXtpSp().get()->getSequence().mid( + peptide_match.getStop(), 1); } - _output_stream->writeAttribute("residue_after_cter", residue_after_cter); + _output_stream->writeAttribute("residue_after_cter", + residue_after_cter); - _output_stream->writeEndElement();// fromSeq - _output_stream->writeEndElement();// peptideHitRef + _output_stream->writeEndElement(); // fromSeq + _output_stream->writeEndElement(); // peptideHitRef } - } - _output_stream->writeEndElement();// "match"); + _output_stream->writeEndElement(); // "match"); } - catch (pappso::PappsoException &error) + catch(pappso::PappsoException &error) { - throw pappso::PappsoException(QObject::tr("Error in ProticdbMl::writeMatch :\n%1").arg(error.qwhat())); + throw pappso::PappsoException( + QObject::tr("Error in ProticdbMl::writeMatch :\n%1") + .arg(error.qwhat())); } - catch (std::exception &error) + catch(std::exception &error) { - throw pappso::PappsoException(QObject::tr("Error in ProticdbMl::writeMatch stdex :\n%1").arg(error.what())); + throw pappso::PappsoException( + QObject::tr("Error in ProticdbMl::writeMatch stdex :\n%1") + .arg(error.what())); } } -void ProticdbMl::writeOboModif(pappso::AaModificationP mod) { - _output_stream->writeStartElement("cvParam"); - _output_stream->writeAttribute("name", mod->getName()); - _output_stream->writeAttribute("cvLabel", "MOD"); - _output_stream->writeAttribute("accession", mod->getAccession()); - _output_stream->writeEndElement();// cvParam +void +ProticdbMl::writeOboModif(pappso::AaModificationP mod) +{ + _output_stream->writeStartElement("cvParam"); + _output_stream->writeAttribute("name", mod->getName()); + _output_stream->writeAttribute("cvLabel", "MOD"); + _output_stream->writeAttribute("accession", mod->getAccession()); + _output_stream->writeEndElement(); // cvParam } -void ProticdbMl::writeCvParam(QString acc, QString value, QString description) { - _output_stream->writeStartElement("cvParam"); +void +ProticdbMl::writeCvParam(QString acc, QString value, QString description) +{ + _output_stream->writeStartElement("cvParam"); - _output_stream->writeAttribute("value",value); - if (description.isEmpty()) { - _output_stream->writeAttribute("name", "N.A."); - } else { - _output_stream->writeAttribute("name", description); + _output_stream->writeAttribute("value", value); + if(description.isEmpty()) + { + _output_stream->writeAttribute("name", "N.A."); } - _output_stream->writeAttribute("cvLabel", "PROTICdbO"); - _output_stream->writeAttribute("accession", acc); - _output_stream->writeEndElement();// cvParam - + else + { + _output_stream->writeAttribute("name", description); + } + _output_stream->writeAttribute("cvLabel", "PROTICdbO"); + _output_stream->writeAttribute("accession", acc); + _output_stream->writeEndElement(); // cvParam } - diff --git a/src/output/proticdbml.h b/src/output/proticdbml.h index df91fcb066716e9b917ae34249b4e16e98585b00..6292e320f1a25057bd2684d4d466773aa890d5e6 100644 --- a/src/output/proticdbml.h +++ b/src/output/proticdbml.h @@ -6,26 +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 + ******************************************************************************/ #ifndef PROTICDBML_H #define PROTICDBML_H @@ -42,42 +43,43 @@ struct ProticPeptideHit; class ProticdbMl { - public: - ProticdbMl(const QString & out_filename); - ~ProticdbMl(); + public: + ProticdbMl(const QString &out_filename); + ~ProticdbMl(); - void write(ProjectSp sp_project); - void close(); - -private : - void writeOboModif(pappso::AaModificationP mod); - void writeCvParam(QString acc, QString value, QString description); - void writeSequence(ProteinMatch * p_protein_match); - void writeProject(); - void writeIdentMethod(); - void writeSamples(); - void writeMsRuns(); - void writeIdentificationRun(IdentificationGroup * p_identification); - void writeIdentificationDataSource(IdentificationDataSource * p_identification_data_source); - void writepeptideHits(IdentificationGroup * p_identification); - void writepeptideHitsbyGroup(GroupingGroup * p_group); - void writePeptideHit(QString xml_id, ProticPeptideHit & protic_peptide_hit); - void writePtms(PeptideXtp * p_peptide); - void writeMatchs(IdentificationGroup * p_identification); - void writeMatch(std::vector<const ProteinMatch *> & protein_match_sg_list); - - const QString & getPeptideXmlId(const PeptideMatch* p_peptide_match) const; - const QString & getProteinXmlId(const ProteinMatch* p_protein_match) const; - -private : - QFile * _output_file; - QXmlStreamWriter * _output_stream; - ProjectSp _sp_project; - IdentificationGroup * _p_identification_group; - QTime _duracel; - std::map<QString, QString> _map_accession2xmlid; - std::map<QString, QString> _sample_to_id; - std::map<QString, QString> _peptidekey_to_id; + void write(ProjectSp sp_project); + void close(); + + private: + void writeOboModif(pappso::AaModificationP mod); + void writeCvParam(QString acc, QString value, QString description); + void writeSequence(ProteinMatch *p_protein_match); + void writeProject(); + void writeIdentMethod(); + void writeSamples(); + void writeMsRuns(); + void writeIdentificationRun(IdentificationGroup *p_identification); + void writeIdentificationDataSource( + IdentificationDataSource *p_identification_data_source); + void writepeptideHits(IdentificationGroup *p_identification); + void writepeptideHitsbyGroup(GroupingGroup *p_group); + void writePeptideHit(QString xml_id, ProticPeptideHit &protic_peptide_hit); + void writePtms(PeptideXtp *p_peptide); + void writeMatchs(IdentificationGroup *p_identification); + void writeMatch(std::vector<const ProteinMatch *> &protein_match_sg_list); + + const QString &getPeptideXmlId(const PeptideMatch *p_peptide_match) const; + const QString &getProteinXmlId(const ProteinMatch *p_protein_match) const; + + private: + QFile *_output_file; + QXmlStreamWriter *_output_stream; + ProjectSp _sp_project; + IdentificationGroup *_p_identification_group; + QTime _duracel; + std::map<QString, QString> _map_accession2xmlid; + std::map<QString, QString> _sample_to_id; + std::map<QString, QString> _peptidekey_to_id; }; #endif // PROTICDBML_H diff --git a/src/output/xpip.cpp b/src/output/xpip.cpp index 5a7761cd36823433091b8773036c945394123e2c..5cc8afa9675d6b9261797efd1a75a53fa1dcd04b 100644 --- a/src/output/xpip.cpp +++ b/src/output/xpip.cpp @@ -6,26 +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 "xpip.h" #include "../config.h" @@ -34,490 +35,672 @@ #include <pappsomspp/utils.h> #include <QDebug> -Xpip::Xpip(const QString & out_filename) +Xpip::Xpip(const QString &out_filename) { - //_p_digestion_pipeline = p_digestion_pipeline; + //_p_digestion_pipeline = p_digestion_pipeline; - //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; - QString complete_out_filename = out_filename; - _output_file = new QFile(complete_out_filename); + //_mzidentml = "http://psidev.info/psi/pi/mzIdentML/1.1"; + QString complete_out_filename = out_filename; + _output_file = new QFile(complete_out_filename); - if (_output_file->open(QIODevice::WriteOnly)) + if(_output_file->open(QIODevice::WriteOnly)) { - _output_stream = new QXmlStreamWriter(); - _output_stream->setDevice(_output_file); - } else + _output_stream = new QXmlStreamWriter(); + _output_stream->setDevice(_output_file); + } + else { - throw pappso::PappsoException(QObject::tr("error : cannot open the XPIP output file : %1\n").arg(out_filename)); + throw pappso::PappsoException( + QObject::tr("error : cannot open the XPIP output file : %1\n") + .arg(out_filename)); } - _output_stream->setAutoFormatting(true); - _output_stream->writeStartDocument("1.0"); - - + _output_stream->setAutoFormatting(true); + _output_stream->writeStartDocument("1.0"); } Xpip::~Xpip() { - delete _output_file; - delete _output_stream; + delete _output_file; + delete _output_stream; } -void Xpip::close() { - _output_file->close(); +void +Xpip::close() +{ + _output_file->close(); } -void Xpip::write(ProjectSp sp_project) { +void +Xpip::write(ProjectSp sp_project) +{ - _sp_project = sp_project; - if (_sp_project.get() == nullptr) { - throw pappso::PappsoException(QObject::tr("Error writing XPIP :\n project is empty")); + _sp_project = sp_project; + if(_sp_project.get() == nullptr) + { + throw pappso::PappsoException( + QObject::tr("Error writing XPIP :\n project is empty")); } -//<xtandem_pipeline version="3.3.5"> - _output_stream->writeStartElement("xpip"); - _output_stream->writeAttribute("version","4.0"); - //_output_stream->writeAttribute("creationDate", QDateTime::currentDateTime().toString( Qt::ISODate)); - _output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance","xsi"); - //_output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance","xsi"); - _output_stream->writeAttribute("xmlns","http://pappso.inra.fr/xsd/xpip/4.0"); - //xsi:schemaLocation="http://psidev.info/psi/pi/mzIdentML/1.1 http://www.psidev.info/files/mzIdentML1.1.0.xsd" - _output_stream->writeAttribute("http://www.w3.org/2001/XMLSchema-instance","schemaLocation","http://pappso.inra.fr/xsd/xpip/4.0 http://pappso.inra.fr/xsd/xpip-4.0.xsd"); - - - //<information Data_Type="combi" match_number="6807"/> - // _output_stream->writeStartElement("information"); - // _output_stream->writeAttribute("Data_Type","combi"); - // _output_stream->writeEndElement(); - writeDescription(); - writeCounts(); - - //<filter_params pep_evalue="0.01" prot_evalue="-2.0" pep_number="2" filter_to_all="false" database_filter="/gorgone/pappso/jouy/raw/2013_Orbitrap/2013_07_04_Chanat/contaminants_standarts.fasta"/> - //const AutomaticFilterParameters & getAutomaticFilterParameters() const; - writeFilterParameters(_sp_project.get()->getAutomaticFilterParameters()); - writeFastaFileList(_sp_project.get()->getFastaFileStore()); - - _output_stream->writeStartElement("contaminants"); - std::vector<const FastaFile *> conta_file_list = _sp_project.get()->getProteinStore().getContaminantFastaFileList(); - _output_stream->writeAttribute("regexp",_sp_project.get()->getProteinStore().getRegexpContaminant().pattern()); - QStringList fasta_list; - for (const FastaFile * fasta_file : conta_file_list) { - fasta_list << fasta_file->getXmlId(); + //<xtandem_pipeline version="3.3.5"> + _output_stream->writeStartElement("xpip"); + _output_stream->writeAttribute("version", "4.0"); + //_output_stream->writeAttribute("creationDate", + //QDateTime::currentDateTime().toString( Qt::ISODate)); + _output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance", + "xsi"); + //_output_stream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance","xsi"); + _output_stream->writeAttribute("xmlns", "http://pappso.inra.fr/xsd/xpip/4.0"); + // xsi:schemaLocation="http://psidev.info/psi/pi/mzIdentML/1.1 + // http://www.psidev.info/files/mzIdentML1.1.0.xsd" + _output_stream->writeAttribute("http://www.w3.org/2001/XMLSchema-instance", + "schemaLocation", + "http://pappso.inra.fr/xsd/xpip/4.0 " + "http://pappso.inra.fr/xsd/xpip-4.0.xsd"); + + + //<information Data_Type="combi" match_number="6807"/> + // _output_stream->writeStartElement("information"); + // _output_stream->writeAttribute("Data_Type","combi"); + // _output_stream->writeEndElement(); + writeDescription(); + writeCounts(); + + //<filter_params pep_evalue="0.01" prot_evalue="-2.0" pep_number="2" + //filter_to_all="false" + //database_filter="/gorgone/pappso/jouy/raw/2013_Orbitrap/2013_07_04_Chanat/contaminants_standarts.fasta"/> + // const AutomaticFilterParameters & getAutomaticFilterParameters() const; + writeFilterParameters(_sp_project.get()->getAutomaticFilterParameters()); + writeFastaFileList(_sp_project.get()->getFastaFileStore()); + + _output_stream->writeStartElement("contaminants"); + std::vector<const FastaFile *> conta_file_list = + _sp_project.get()->getProteinStore().getContaminantFastaFileList(); + _output_stream->writeAttribute( + "regexp", + _sp_project.get()->getProteinStore().getRegexpContaminant().pattern()); + QStringList fasta_list; + for(const FastaFile *fasta_file : conta_file_list) + { + fasta_list << fasta_file->getXmlId(); } - _output_stream->writeAttribute("fasta_id",fasta_list.join(" ")); - _output_stream->writeEndElement(); - - _output_stream->writeStartElement("decoys"); - std::vector<const FastaFile *> decoy_file_list = _sp_project.get()->getProteinStore().getDecoyFastaFileList(); - _output_stream->writeAttribute("regexp",_sp_project.get()->getProteinStore().getRegexpDecoy().pattern()); - QStringList fasta_conta_list; - for (const FastaFile * fasta_file : conta_file_list) { - fasta_conta_list << fasta_file->getXmlId(); + _output_stream->writeAttribute("fasta_id", fasta_list.join(" ")); + _output_stream->writeEndElement(); + + _output_stream->writeStartElement("decoys"); + std::vector<const FastaFile *> decoy_file_list = + _sp_project.get()->getProteinStore().getDecoyFastaFileList(); + _output_stream->writeAttribute( + "regexp", _sp_project.get()->getProteinStore().getRegexpDecoy().pattern()); + QStringList fasta_conta_list; + for(const FastaFile *fasta_file : conta_file_list) + { + fasta_conta_list << fasta_file->getXmlId(); } - _output_stream->writeAttribute("fasta_id",fasta_conta_list.join(" ")); - _output_stream->writeEndElement(); + _output_stream->writeAttribute("fasta_id", fasta_conta_list.join(" ")); + _output_stream->writeEndElement(); - writeMsrunList(_sp_project.get()->getMsRunStore()); - writeIdentificationDataSourceList(_sp_project.get()->getIdentificationDataSourceStore()); + writeMsrunList(_sp_project.get()->getMsRunStore()); + writeIdentificationDataSourceList( + _sp_project.get()->getIdentificationDataSourceStore()); - writeProteinList(); - writePeptideList(); + writeProteinList(); + writePeptideList(); - writeIdentificationGroupList(); - _output_stream->writeEndDocument(); + writeIdentificationGroupList(); + _output_stream->writeEndDocument(); } -void Xpip::writeDoubleAttribute(const QString & attribute, pappso::pappso_double value) { - _output_stream->writeAttribute(attribute,QString::number(value, 'g', 10)); - +void +Xpip::writeDoubleAttribute(const QString &attribute, + pappso::pappso_double value) +{ + _output_stream->writeAttribute(attribute, QString::number(value, 'g', 10)); } -void Xpip::writeBooleanAttribute(const QString & attribute, bool value) { - if (value) { - _output_stream->writeAttribute(attribute,"true"); +void +Xpip::writeBooleanAttribute(const QString &attribute, bool value) +{ + if(value) + { + _output_stream->writeAttribute(attribute, "true"); } - else { - _output_stream->writeAttribute(attribute,"false"); + else + { + _output_stream->writeAttribute(attribute, "false"); } - } -void Xpip::writeFilterParameters(const AutomaticFilterParameters & filters) { - qDebug() << "Xpip::writeFilterParameters begin"; - _output_stream->writeStartElement("filter_params"); - writeDoubleAttribute("pep_evalue",filters.getFilterPeptideEvalue()); - writeDoubleAttribute("prot_evalue",filters.getFilterProteinEvalue()); - _output_stream->writeAttribute("pep_number",QString("%1").arg(filters.getFilterMinimumPeptidePerMatch())); - writeBooleanAttribute("cross_sample",filters.getFilterCrossSamplePeptideNumber()); - _output_stream->writeEndElement(); - qDebug() << "Xpip::writeFilterParameters end"; +void +Xpip::writeFilterParameters(const AutomaticFilterParameters &filters) +{ + qDebug() << "Xpip::writeFilterParameters begin"; + _output_stream->writeStartElement("filter_params"); + writeDoubleAttribute("pep_evalue", filters.getFilterPeptideEvalue()); + writeDoubleAttribute("prot_evalue", filters.getFilterProteinEvalue()); + _output_stream->writeAttribute( + "pep_number", QString("%1").arg(filters.getFilterMinimumPeptidePerMatch())); + writeBooleanAttribute("cross_sample", + filters.getFilterCrossSamplePeptideNumber()); + _output_stream->writeEndElement(); + qDebug() << "Xpip::writeFilterParameters end"; } -void Xpip::writeDescription() { +void +Xpip::writeDescription() +{ - _output_stream->writeStartElement("description"); - _output_stream->writeAttribute("version",XTPCPP_VERSION); - _output_stream->writeAttribute("grouping","peptidemass"); - if (_sp_project.get()->getProjectMode() == ProjectMode::combined) { - writeBooleanAttribute("combine",true); + _output_stream->writeStartElement("description"); + _output_stream->writeAttribute("version", XTPCPP_VERSION); + _output_stream->writeAttribute("grouping", "peptidemass"); + if(_sp_project.get()->getProjectMode() == ProjectMode::combined) + { + writeBooleanAttribute("combine", true); } - else { - writeBooleanAttribute("combine",false); + else + { + writeBooleanAttribute("combine", false); } - _output_stream->writeAttribute("date",QDateTime::currentDateTime().toString( Qt::ISODate)); - _output_stream->writeEndElement(); + _output_stream->writeAttribute( + "date", QDateTime::currentDateTime().toString(Qt::ISODate)); + _output_stream->writeEndElement(); } -void Xpip::writeCounts() { +void +Xpip::writeCounts() +{ - _output_stream->writeStartElement("counts"); - _output_stream->writeAttribute("proteins",QString("%1").arg(_sp_project.get()->getProteinStore().size())); - _output_stream->writeAttribute("peptides",QString("%1").arg(_sp_project.get()->getPeptideStore().size())); + _output_stream->writeStartElement("counts"); + _output_stream->writeAttribute( + "proteins", QString("%1").arg(_sp_project.get()->getProteinStore().size())); + _output_stream->writeAttribute( + "peptides", QString("%1").arg(_sp_project.get()->getPeptideStore().size())); - std::size_t count_peptide_evidences=0; - std::size_t count_protein_matches=0; - for (const IdentificationGroup * p_group : _sp_project.get()->getIdentificationGroupList()) { - for (const IdentificationDataSource * p_id_source : p_group->getIdentificationDataSourceList()) { - count_peptide_evidences += p_id_source->getPeptideEvidenceStore().size(); + std::size_t count_peptide_evidences = 0; + std::size_t count_protein_matches = 0; + for(const IdentificationGroup *p_group : + _sp_project.get()->getIdentificationGroupList()) + { + for(const IdentificationDataSource *p_id_source : + p_group->getIdentificationDataSourceList()) + { + count_peptide_evidences += + p_id_source->getPeptideEvidenceStore().size(); } - count_protein_matches += p_group->getProteinMatchList().size(); + count_protein_matches += p_group->getProteinMatchList().size(); } - _output_stream->writeAttribute("peptide_evidences",QString("%1").arg(count_peptide_evidences)); - _output_stream->writeAttribute("protein_matches",QString("%1").arg(count_protein_matches)); - _output_stream->writeEndElement(); + _output_stream->writeAttribute("peptide_evidences", + QString("%1").arg(count_peptide_evidences)); + _output_stream->writeAttribute("protein_matches", + QString("%1").arg(count_protein_matches)); + _output_stream->writeEndElement(); } -void Xpip::writeIdentificationDataSourceList(const IdentificationDataSourceStore & ident_store) { - - _output_stream->writeStartElement("identification_source_list"); - for (const IdentificationDataSourceSp ident_source_sp : ident_store.getIdentificationDataSourceList()) { - _output_stream->writeStartElement("identification_source"); - _output_stream->writeAttribute("id",ident_source_sp.get()->getXmlId()); - _output_stream->writeAttribute("msrun_id",ident_source_sp.get()->getMsRunSp().get()->getXmlId()); - //_output_stream->writeAttribute("format",QString("%1").arg(static_cast<std::int8_t>(ident_source_sp.get()->getIdentFormat()))); - _output_stream->writeAttribute("path",ident_source_sp.get()->getResourceName()); - - _output_stream->writeAttribute("engine",QString("%1").arg(static_cast<std::int8_t>(ident_source_sp.get()->getIdentificationEngine()))); - _output_stream->writeAttribute("version",ident_source_sp.get()->getIdentificationEngineVersion()); +void +Xpip::writeIdentificationDataSourceList( + const IdentificationDataSourceStore &ident_store) +{ - QStringList fasta_file_id; - for (FastaFileSp fasta_file :ident_source_sp.get()->getFastaFileList()) { - fasta_file_id << fasta_file.get()->getXmlId(); + _output_stream->writeStartElement("identification_source_list"); + for(const IdentificationDataSourceSp ident_source_sp : + ident_store.getIdentificationDataSourceList()) + { + _output_stream->writeStartElement("identification_source"); + _output_stream->writeAttribute("id", ident_source_sp.get()->getXmlId()); + _output_stream->writeAttribute( + "msrun_id", ident_source_sp.get()->getMsRunSp().get()->getXmlId()); + //_output_stream->writeAttribute("format",QString("%1").arg(static_cast<std::int8_t>(ident_source_sp.get()->getIdentFormat()))); + _output_stream->writeAttribute("path", + ident_source_sp.get()->getResourceName()); + + _output_stream->writeAttribute( + "engine", QString("%1").arg(static_cast<std::int8_t>( + ident_source_sp.get()->getIdentificationEngine()))); + _output_stream->writeAttribute( + "version", ident_source_sp.get()->getIdentificationEngineVersion()); + + QStringList fasta_file_id; + for(FastaFileSp fasta_file : ident_source_sp.get()->getFastaFileList()) + { + fasta_file_id << fasta_file.get()->getXmlId(); } - _output_stream->writeAttribute("fasta_ids",fasta_file_id.join(" ")); - - const std::map<IdentificationEngineParam, QVariant> params = ident_source_sp.get()->getIdentificationEngineParamMap(); - if (params.size() > 0) { - _output_stream->writeStartElement("params"); - for (const std::pair<IdentificationEngineParam, QVariant> stat_pair: params) { - _output_stream->writeStartElement("param"); - _output_stream->writeAttribute("key",QString("%1").arg(static_cast<std::int8_t>(stat_pair.first))); - _output_stream->writeAttribute("value",stat_pair.second.toString()); - _output_stream->writeEndElement(); + _output_stream->writeAttribute("fasta_ids", fasta_file_id.join(" ")); + + const std::map<IdentificationEngineParam, QVariant> params = + ident_source_sp.get()->getIdentificationEngineParamMap(); + if(params.size() > 0) + { + _output_stream->writeStartElement("params"); + for(const std::pair<IdentificationEngineParam, QVariant> stat_pair : + params) + { + _output_stream->writeStartElement("param"); + _output_stream->writeAttribute( + "key", + QString("%1").arg(static_cast<std::int8_t>(stat_pair.first))); + _output_stream->writeAttribute("value", + stat_pair.second.toString()); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } - const std::map<IdentificationEngineStatistics, QVariant> stats = ident_source_sp.get()->getIdentificationEngineStatisticsMap(); - if (stats.size() > 0) { - _output_stream->writeStartElement("stats"); - for (const std::pair<IdentificationEngineStatistics, QVariant> stat_pair: stats) { - _output_stream->writeStartElement("stat"); - _output_stream->writeAttribute("key",QString("%1").arg(static_cast<std::int8_t>(stat_pair.first))); - _output_stream->writeAttribute("value",stat_pair.second.toString()); - _output_stream->writeEndElement(); + const std::map<IdentificationEngineStatistics, QVariant> stats = + ident_source_sp.get()->getIdentificationEngineStatisticsMap(); + if(stats.size() > 0) + { + _output_stream->writeStartElement("stats"); + for(const std::pair<IdentificationEngineStatistics, QVariant> + stat_pair : stats) + { + _output_stream->writeStartElement("stat"); + _output_stream->writeAttribute( + "key", + QString("%1").arg(static_cast<std::int8_t>(stat_pair.first))); + _output_stream->writeAttribute("value", + stat_pair.second.toString()); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); - + _output_stream->writeEndElement(); } -void Xpip::writeMsrunList(const MsRunStore & msrun_store) { - - _output_stream->writeStartElement("msrun_list"); - for (const MsRunSp msrun_sp : msrun_store.getMsRunList()) { - _output_stream->writeStartElement("msrun"); - _output_stream->writeAttribute("id",msrun_sp.get()->getXmlId()); - _output_stream->writeAttribute("name",msrun_sp.get()->getSampleName()); - _output_stream->writeAttribute("format",QString("%1").arg(static_cast<std::int8_t>(msrun_sp.get()->getMzFormat()))); - QFileInfo mz_info(msrun_sp.get()->getFilename()); - if (mz_info.exists()) { - _output_stream->writeAttribute("path",msrun_sp.get()->getFilename()); +void +Xpip::writeMsrunList(const MsRunStore &msrun_store) +{ + + _output_stream->writeStartElement("msrun_list"); + for(const MsRunSp msrun_sp : msrun_store.getMsRunList()) + { + _output_stream->writeStartElement("msrun"); + _output_stream->writeAttribute("id", msrun_sp.get()->getXmlId()); + _output_stream->writeAttribute("name", msrun_sp.get()->getSampleName()); + _output_stream->writeAttribute( + "format", QString("%1").arg( + static_cast<std::int8_t>(msrun_sp.get()->getMzFormat()))); + QFileInfo mz_info(msrun_sp.get()->getFilename()); + if(mz_info.exists()) + { + _output_stream->writeAttribute("path", msrun_sp.get()->getFilename()); } - else { - _output_stream->writeAttribute("path",mz_info.completeBaseName()); + else + { + _output_stream->writeAttribute("path", mz_info.completeBaseName()); } - const std::map<MsRunStatistics, QVariant> stats = msrun_sp.get()->getMsRunStatisticsMap(); - if (stats.size() > 0) { - _output_stream->writeStartElement("stats"); - for (const std::pair<MsRunStatistics, QVariant> stat_pair: stats) { - _output_stream->writeStartElement("stat"); - _output_stream->writeAttribute("key",QString("%1").arg(static_cast<std::int8_t>(stat_pair.first))); - _output_stream->writeAttribute("value",stat_pair.second.toString()); - _output_stream->writeEndElement(); + const std::map<MsRunStatistics, QVariant> stats = + msrun_sp.get()->getMsRunStatisticsMap(); + if(stats.size() > 0) + { + _output_stream->writeStartElement("stats"); + for(const std::pair<MsRunStatistics, QVariant> stat_pair : stats) + { + _output_stream->writeStartElement("stat"); + _output_stream->writeAttribute( + "key", + QString("%1").arg(static_cast<std::int8_t>(stat_pair.first))); + _output_stream->writeAttribute("value", + stat_pair.second.toString()); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } -void Xpip::writeFastaFileList(const FastaFileStore & fasta_store) { - qDebug() << "Xpip::writeFastaFileList begin"; - _output_stream->writeStartElement("fasta_file_list"); - for (FastaFileSp fasta_file_sp : fasta_store.getFastaFileList()) { - _output_stream->writeStartElement("fasta_file"); - _output_stream->writeAttribute("id",fasta_file_sp.get()->getXmlId()); - _output_stream->writeAttribute("path",fasta_file_sp.get()->getAbsoluteFilePath()); +void +Xpip::writeFastaFileList(const FastaFileStore &fasta_store) +{ + qDebug() << "Xpip::writeFastaFileList begin"; + _output_stream->writeStartElement("fasta_file_list"); + for(FastaFileSp fasta_file_sp : fasta_store.getFastaFileList()) + { + _output_stream->writeStartElement("fasta_file"); + _output_stream->writeAttribute("id", fasta_file_sp.get()->getXmlId()); + _output_stream->writeAttribute( + "path", fasta_file_sp.get()->getAbsoluteFilePath()); - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); - qDebug() << "Xpip::writeFastaFileList end"; + _output_stream->writeEndElement(); + qDebug() << "Xpip::writeFastaFileList end"; } -void Xpip::writeProteinList() { - qDebug() << "Xpip::writeProteinList begin"; - _output_stream->writeStartElement("protein_list"); - const ProteinStore & protein_store = _sp_project.get()->getProteinStore(); - for (std::pair<QString, ProteinXtpSp> protein_pair : protein_store.getProteinMap()) { - const ProteinXtp * p_protein = protein_pair.second.get(); - _output_stream->writeStartElement("protein"); - if (p_protein->getFastaFileP() == nullptr) { - throw pappso::PappsoException(QObject::tr("Error writing XPIP file :\n FastaFile pointer is null for protein accession %1").arg(p_protein->getAccession())); +void +Xpip::writeProteinList() +{ + qDebug() << "Xpip::writeProteinList begin"; + _output_stream->writeStartElement("protein_list"); + const ProteinStore &protein_store = _sp_project.get()->getProteinStore(); + for(std::pair<QString, ProteinXtpSp> protein_pair : + protein_store.getProteinMap()) + { + const ProteinXtp *p_protein = protein_pair.second.get(); + _output_stream->writeStartElement("protein"); + if(p_protein->getFastaFileP() == nullptr) + { + throw pappso::PappsoException( + QObject::tr("Error writing XPIP file :\n FastaFile pointer is null " + "for protein accession %1") + .arg(p_protein->getAccession())); } - _output_stream->writeAttribute("fasta_id",p_protein->getFastaFileP()->getXmlId()); - _output_stream->writeAttribute("acc",p_protein->getAccession()); - _output_stream->writeAttribute("description",p_protein->getDescription()); - - if (p_protein->isDecoy()) { - _output_stream->writeAttribute("is_decoy","true"); + _output_stream->writeAttribute("fasta_id", + p_protein->getFastaFileP()->getXmlId()); + _output_stream->writeAttribute("acc", p_protein->getAccession()); + _output_stream->writeAttribute("description", + p_protein->getDescription()); + + if(p_protein->isDecoy()) + { + _output_stream->writeAttribute("is_decoy", "true"); } - else { - _output_stream->writeAttribute("is_decoy","false"); + else + { + _output_stream->writeAttribute("is_decoy", "false"); } - if (p_protein->isContaminant()) { - _output_stream->writeAttribute("is_contaminant","true"); + if(p_protein->isContaminant()) + { + _output_stream->writeAttribute("is_contaminant", "true"); } - else { - _output_stream->writeAttribute("is_contaminant","false"); + else + { + _output_stream->writeAttribute("is_contaminant", "false"); } - _output_stream->writeStartElement("sequence"); - _output_stream->writeCharacters(p_protein->getSequence()); - _output_stream->writeEndElement(); - - for (DbXref db_xref : p_protein->getDbxrefList()) { - _output_stream->writeStartElement("dbxref"); - _output_stream->writeAttribute("acc",db_xref.accession); - _output_stream->writeAttribute("database",QString("%1").arg(static_cast<std::int8_t>(db_xref.database))); - _output_stream->writeEndElement(); + _output_stream->writeStartElement("sequence"); + _output_stream->writeCharacters(p_protein->getSequence()); + _output_stream->writeEndElement(); + + for(DbXref db_xref : p_protein->getDbxrefList()) + { + _output_stream->writeStartElement("dbxref"); + _output_stream->writeAttribute("acc", db_xref.accession); + _output_stream->writeAttribute( + "database", + QString("%1").arg(static_cast<std::int8_t>(db_xref.database))); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); + _output_stream->writeEndElement(); } - _output_stream->writeEndElement(); - qDebug() << "Xpip::writeProteinList end"; + _output_stream->writeEndElement(); + qDebug() << "Xpip::writeProteinList end"; } -QString Xpip::getPeptideId(std::size_t crc_peptide) const { - return QString("p%1").arg(pappso::Utils::getLexicalOrderedString(crc_peptide)); +QString +Xpip::getPeptideId(std::size_t crc_peptide) const +{ + return QString("p%1").arg( + pappso::Utils::getLexicalOrderedString(crc_peptide)); } -void Xpip::writeLabelingMethod() { - qDebug() << "Xpip::writeLabelingMethod begin"; - - LabelingMethod * p_labeling_method = _sp_project.get()->getLabelingMethodSp().get(); - if (p_labeling_method == nullptr) return; - _output_stream->writeStartElement("label_method"); - _output_stream->writeAttribute("id",p_labeling_method->getXmlId()); - - _output_stream->writeStartElement("label_list"); - for (const Label * p_label : p_labeling_method->getLabelList()) { - _output_stream->writeStartElement("label"); - _output_stream->writeAttribute("id", p_label->getXmlId()); - for (const LabelModification label_modification : p_label->getLabelModifictionList()) { - _output_stream->writeStartElement("label_modification"); - _output_stream->writeAttribute("at", label_modification.at); - _output_stream->writeAttribute("mod", label_modification.modification->getAccession()); - _output_stream->writeEndElement();// label_modification +void +Xpip::writeLabelingMethod() +{ + qDebug() << "Xpip::writeLabelingMethod begin"; + + LabelingMethod *p_labeling_method = + _sp_project.get()->getLabelingMethodSp().get(); + if(p_labeling_method == nullptr) + return; + _output_stream->writeStartElement("label_method"); + _output_stream->writeAttribute("id", p_labeling_method->getXmlId()); + + _output_stream->writeStartElement("label_list"); + for(const Label *p_label : p_labeling_method->getLabelList()) + { + _output_stream->writeStartElement("label"); + _output_stream->writeAttribute("id", p_label->getXmlId()); + for(const LabelModification label_modification : + p_label->getLabelModifictionList()) + { + _output_stream->writeStartElement("label_modification"); + _output_stream->writeAttribute("at", label_modification.at); + _output_stream->writeAttribute( + "mod", label_modification.modification->getAccession()); + _output_stream->writeEndElement(); // label_modification } - _output_stream->writeEndElement();// label + _output_stream->writeEndElement(); // label } - _output_stream->writeEndElement();// label_list + _output_stream->writeEndElement(); // label_list - _output_stream->writeEndElement();// label_method - qDebug() << "Xpip::writeLabelingMethod end"; + _output_stream->writeEndElement(); // label_method + qDebug() << "Xpip::writeLabelingMethod end"; } -void Xpip::writePeptideList() { - qDebug() << "Xpip::writePeptideList begin"; - _output_stream->writeStartElement("peptide_list"); - - writeLabelingMethod(); - - const PeptideStore & peptide_store = _sp_project.get()->getPeptideStore(); - _output_stream->writeStartElement("modification_list"); - for (pappso::AaModificationP mod_p : peptide_store.getModificationCollection()) { - QString id = QString("mod%1").arg(pappso::Utils::getLexicalOrderedString(_map_modifications.size()+1)); - _map_modifications.insert(std::pair<pappso::AaModificationP, QString>(mod_p, id)); - _output_stream->writeStartElement("modification"); - _output_stream->writeAttribute("id", id); - _output_stream->writeAttribute("mod", mod_p->getAccession()); - _output_stream->writeEndElement();// modification +void +Xpip::writePeptideList() +{ + qDebug() << "Xpip::writePeptideList begin"; + _output_stream->writeStartElement("peptide_list"); + + writeLabelingMethod(); + + const PeptideStore &peptide_store = _sp_project.get()->getPeptideStore(); + _output_stream->writeStartElement("modification_list"); + for(pappso::AaModificationP mod_p : peptide_store.getModificationCollection()) + { + QString id = QString("mod%1").arg( + pappso::Utils::getLexicalOrderedString(_map_modifications.size() + 1)); + _map_modifications.insert( + std::pair<pappso::AaModificationP, QString>(mod_p, id)); + _output_stream->writeStartElement("modification"); + _output_stream->writeAttribute("id", id); + _output_stream->writeAttribute("mod", mod_p->getAccession()); + _output_stream->writeEndElement(); // modification } - _output_stream->writeEndElement();// modification_list - - for (std::pair<std::size_t, PeptideXtpSp> peptide_pair : peptide_store.getPeptideMap()) { - const PeptideXtp * p_peptide = peptide_pair.second.get(); - _output_stream->writeStartElement("peptide"); - QString idp = QString("p%1").arg(pappso::Utils::getLexicalOrderedString(_map_peptides.size()+1)); - _map_peptides.insert(std::pair<const PeptideXtp *, QString>(p_peptide, idp)); - _output_stream->writeAttribute("id",idp); - _output_stream->writeAttribute("seq",p_peptide->getSequence()); - - const Label * p_label = p_peptide->getLabel(); - if (p_label != nullptr) { - _output_stream->writeAttribute("label_id",p_label->getXmlId()); + _output_stream->writeEndElement(); // modification_list + + for(std::pair<std::size_t, PeptideXtpSp> peptide_pair : + peptide_store.getPeptideMap()) + { + const PeptideXtp *p_peptide = peptide_pair.second.get(); + _output_stream->writeStartElement("peptide"); + QString idp = QString("p%1").arg( + pappso::Utils::getLexicalOrderedString(_map_peptides.size() + 1)); + _map_peptides.insert( + std::pair<const PeptideXtp *, QString>(p_peptide, idp)); + _output_stream->writeAttribute("id", idp); + _output_stream->writeAttribute("seq", p_peptide->getSequence()); + + const Label *p_label = p_peptide->getLabel(); + if(p_label != nullptr) + { + _output_stream->writeAttribute("label_id", p_label->getXmlId()); } - unsigned int i=0; - for (const pappso::Aa & amino_acid: *p_peptide) { + unsigned int i = 0; + for(const pappso::Aa &amino_acid : *p_peptide) + { - std::list<pappso::AaModificationP> aa_modif_list = amino_acid.getModificationList(); + std::list<pappso::AaModificationP> aa_modif_list = + amino_acid.getModificationList(); - for (auto && aa_modif : aa_modif_list) { - if (!aa_modif->isInternal()) { - _output_stream->writeStartElement("mod"); - _output_stream->writeAttribute("ref", _map_modifications.at(aa_modif)); - _output_stream->writeAttribute("position", QString ("%1").arg(i)); - _output_stream->writeAttribute("aa", QString(amino_acid.getLetter())); - _output_stream->writeEndElement();// mod + for(auto &&aa_modif : aa_modif_list) + { + if(!aa_modif->isInternal()) + { + _output_stream->writeStartElement("mod"); + _output_stream->writeAttribute( + "ref", _map_modifications.at(aa_modif)); + _output_stream->writeAttribute("position", + QString("%1").arg(i)); + _output_stream->writeAttribute( + "aa", QString(amino_acid.getLetter())); + _output_stream->writeEndElement(); // mod } } - i++; + i++; } - _output_stream->writeEndElement();// peptide + _output_stream->writeEndElement(); // peptide } - _output_stream->writeEndElement(); //peptide_list - qDebug() << "Xpip::writePeptideList end"; + _output_stream->writeEndElement(); // peptide_list + qDebug() << "Xpip::writePeptideList end"; } -void Xpip::writeIdentificationGroupList() { - qDebug() << "Xpip::writeIdentificationGroupList begin"; - _output_stream->writeStartElement("identification_group_list"); - for (const IdentificationGroup * p_identification_group : _sp_project.get()->getIdentificationGroupList()) { - //std::vector<ProteinMatch *> & getProteinMatchList() - writeIdentificationGroup(p_identification_group); +void +Xpip::writeIdentificationGroupList() +{ + qDebug() << "Xpip::writeIdentificationGroupList begin"; + _output_stream->writeStartElement("identification_group_list"); + for(const IdentificationGroup *p_identification_group : + _sp_project.get()->getIdentificationGroupList()) + { + // std::vector<ProteinMatch *> & getProteinMatchList() + writeIdentificationGroup(p_identification_group); } - _output_stream->writeEndElement(); //identification_group_list - qDebug() << "Xpip::writeIdentificationGroupList end"; + _output_stream->writeEndElement(); // identification_group_list + qDebug() << "Xpip::writeIdentificationGroupList end"; } -void Xpip::writePeptideEvidence(const PeptideEvidence * p_peptide_evidence) { - qDebug() << "Xpip::writePeptideEvidence begin"; +void +Xpip::writePeptideEvidence(const PeptideEvidence *p_peptide_evidence) +{ + qDebug() << "Xpip::writePeptideEvidence begin"; - _output_stream->writeStartElement("peptide_evidence"); - QString idp = QString("pe%1").arg(pappso::Utils::getLexicalOrderedString(_map_peptide_evidences.size()+1)); - _map_peptide_evidences.insert(std::pair<const PeptideEvidence *, QString>(p_peptide_evidence, idp)); - _output_stream->writeAttribute("id",idp); + _output_stream->writeStartElement("peptide_evidence"); + QString idp = QString("pe%1").arg( + pappso::Utils::getLexicalOrderedString(_map_peptide_evidences.size() + 1)); + _map_peptide_evidences.insert( + std::pair<const PeptideEvidence *, QString>(p_peptide_evidence, idp)); + _output_stream->writeAttribute("id", idp); - //_output_stream->writeAttribute("ms_id",p_peptide_match->getMsRunP()->getXmlId()); - try { - _output_stream->writeAttribute("peptide_id",_map_peptides.at( p_peptide_evidence->getPeptideXtpSp().get())); + //_output_stream->writeAttribute("ms_id",p_peptide_match->getMsRunP()->getXmlId()); + try + { + _output_stream->writeAttribute( + "peptide_id", + _map_peptides.at(p_peptide_evidence->getPeptideXtpSp().get())); } - catch (out_of_range exception_std) { - throw pappso::PappsoException(QObject::tr("ERROR in Xpip::writePeptideEvidence peptide %1 not found in map :\n%2").arg(p_peptide_evidence->getPeptideXtpSp().get()->toAbsoluteString()).arg(exception_std.what())); + catch(out_of_range exception_std) + { + throw pappso::PappsoException( + QObject::tr("ERROR in Xpip::writePeptideEvidence peptide %1 not found " + "in map :\n%2") + .arg(p_peptide_evidence->getPeptideXtpSp().get()->toAbsoluteString()) + .arg(exception_std.what())); } - qDebug() << "Xpip::writePeptideEvidence scan"; - _output_stream->writeAttribute("scan",QString("%1").arg(p_peptide_evidence->getScan())); - writeDoubleAttribute("rt",p_peptide_evidence->getRetentionTime()); - _output_stream->writeAttribute("eng",QString("%1").arg((unsigned int) p_peptide_evidence->getIdentificationEngine())); - writeDoubleAttribute("evalue",p_peptide_evidence->getEvalue()); - writeDoubleAttribute("exp_mass",p_peptide_evidence->getExperimentalMass()); - _output_stream->writeAttribute("charge",QString("%1").arg(p_peptide_evidence->getCharge())); - - if (p_peptide_evidence->isChecked()) { - _output_stream->writeAttribute("checked","true"); + qDebug() << "Xpip::writePeptideEvidence scan"; + _output_stream->writeAttribute( + "scan", QString("%1").arg(p_peptide_evidence->getScan())); + writeDoubleAttribute("rt", p_peptide_evidence->getRetentionTime()); + _output_stream->writeAttribute( + "eng", QString("%1").arg( + (unsigned int)p_peptide_evidence->getIdentificationEngine())); + writeDoubleAttribute("evalue", p_peptide_evidence->getEvalue()); + writeDoubleAttribute("exp_mass", p_peptide_evidence->getExperimentalMass()); + _output_stream->writeAttribute( + "charge", QString("%1").arg(p_peptide_evidence->getCharge())); + + if(p_peptide_evidence->isChecked()) + { + _output_stream->writeAttribute("checked", "true"); } - else { - _output_stream->writeAttribute("checked","false"); + else + { + _output_stream->writeAttribute("checked", "false"); } - qDebug() << "Xpip::writePeptideEvidence getParamList"; - const std::map<PeptideEvidenceParam, QVariant> & params = p_peptide_evidence->getParamList(); + qDebug() << "Xpip::writePeptideEvidence getParamList"; + const std::map<PeptideEvidenceParam, QVariant> ¶ms = + p_peptide_evidence->getParamList(); - //if (params.size() > 0) { - // _output_stream->writeStartElement("stats"); - for (const std::pair<PeptideEvidenceParam, QVariant> param_pair: params) { - _output_stream->writeStartElement("param"); - _output_stream->writeAttribute("key",QString("%1").arg(static_cast<std::int8_t>(param_pair.first))); - _output_stream->writeAttribute("value",param_pair.second.toString()); - _output_stream->writeEndElement(); + // if (params.size() > 0) { + // _output_stream->writeStartElement("stats"); + for(const std::pair<PeptideEvidenceParam, QVariant> param_pair : params) + { + _output_stream->writeStartElement("param"); + _output_stream->writeAttribute( + "key", QString("%1").arg(static_cast<std::int8_t>(param_pair.first))); + _output_stream->writeAttribute("value", param_pair.second.toString()); + _output_stream->writeEndElement(); } - // _output_stream->writeEndElement(); - _output_stream->writeEndElement(); //peptide_evidence - qDebug() << "Xpip::writePeptideEvidence end"; + // _output_stream->writeEndElement(); + _output_stream->writeEndElement(); // peptide_evidence + qDebug() << "Xpip::writePeptideEvidence end"; } -void Xpip::writePeptideEvidenceList(const IdentificationDataSource * p_ident_data_source) { - qDebug() << "Xpip::writePeptideEvidenceList begin"; +void +Xpip::writePeptideEvidenceList( + const IdentificationDataSource *p_ident_data_source) +{ + qDebug() << "Xpip::writePeptideEvidenceList begin"; - _output_stream->writeStartElement("peptide_evidence_list"); - _output_stream->writeAttribute("ident_source_id",p_ident_data_source->getXmlId()); + _output_stream->writeStartElement("peptide_evidence_list"); + _output_stream->writeAttribute("ident_source_id", + p_ident_data_source->getXmlId()); - for (const PeptideEvidenceSp & sp_peptide_evidence:p_ident_data_source->getPeptideEvidenceStore().getPeptideEvidenceList()) { - writePeptideEvidence(sp_peptide_evidence.get()); + for(const PeptideEvidenceSp &sp_peptide_evidence : + p_ident_data_source->getPeptideEvidenceStore().getPeptideEvidenceList()) + { + writePeptideEvidence(sp_peptide_evidence.get()); } - _output_stream->writeEndElement(); //peptide_evidence_list - qDebug() << "Xpip::writePeptideEvidenceList end"; + _output_stream->writeEndElement(); // peptide_evidence_list + qDebug() << "Xpip::writePeptideEvidenceList end"; } -void Xpip::writeIdentificationGroup(const IdentificationGroup * p_identification_group) { - qDebug() << "Xpip::writeIdentificationGroup begin"; - _output_stream->writeStartElement("identification_group"); - //QStringList id_list; - for ( const IdentificationDataSource * ident_data_source : p_identification_group->getIdentificationDataSourceList()) { - //id_list << ident_data_source->getXmlId(); - writePeptideEvidenceList(ident_data_source); +void +Xpip::writeIdentificationGroup( + const IdentificationGroup *p_identification_group) +{ + qDebug() << "Xpip::writeIdentificationGroup begin"; + _output_stream->writeStartElement("identification_group"); + // QStringList id_list; + for(const IdentificationDataSource *ident_data_source : + p_identification_group->getIdentificationDataSourceList()) + { + // id_list << ident_data_source->getXmlId(); + writePeptideEvidenceList(ident_data_source); } - _output_stream->writeStartElement("protein_match_list"); - for (const ProteinMatch * p_protein_match : p_identification_group->getProteinMatchList()) { - //std::vector<ProteinMatch *> & getProteinMatchList() - _output_stream->writeStartElement("protein_match"); - _output_stream->writeAttribute("acc", p_protein_match->getProteinXtpSp().get()->getAccession()); - if (p_protein_match->isChecked()) { - _output_stream->writeAttribute("checked","true"); + _output_stream->writeStartElement("protein_match_list"); + for(const ProteinMatch *p_protein_match : + p_identification_group->getProteinMatchList()) + { + // std::vector<ProteinMatch *> & getProteinMatchList() + _output_stream->writeStartElement("protein_match"); + _output_stream->writeAttribute( + "acc", p_protein_match->getProteinXtpSp().get()->getAccession()); + if(p_protein_match->isChecked()) + { + _output_stream->writeAttribute("checked", "true"); } - else { - _output_stream->writeAttribute("checked","false"); + else + { + _output_stream->writeAttribute("checked", "false"); } - for (const PeptideMatch & peptide_match : p_protein_match->getPeptideMatchList()) { - writePeptideMatch(peptide_match); + for(const PeptideMatch &peptide_match : + p_protein_match->getPeptideMatchList()) + { + writePeptideMatch(peptide_match); } - _output_stream->writeEndElement();// protein_match + _output_stream->writeEndElement(); // protein_match } - _output_stream->writeEndElement(); //protein_match_list - _output_stream->writeEndElement(); //identification_group - qDebug() << "Xpip::writeIdentificationGroup end"; + _output_stream->writeEndElement(); // protein_match_list + _output_stream->writeEndElement(); // identification_group + qDebug() << "Xpip::writeIdentificationGroup end"; } -void Xpip::writePeptideMatch(const PeptideMatch & peptide_match) { - qDebug() << "Xpip::writePeptideMatch begin"; - _output_stream->writeStartElement("peptide_match"); - _output_stream->writeAttribute("peptide_evidence_id",_map_peptide_evidences.at( peptide_match.getPeptideEvidence())); - _output_stream->writeAttribute("start",QString("%1").arg(peptide_match.getStart())); - - _output_stream->writeEndElement(); //protein_match_list - qDebug() << "Xpip::writePeptideMatch end"; +void +Xpip::writePeptideMatch(const PeptideMatch &peptide_match) +{ + qDebug() << "Xpip::writePeptideMatch begin"; + _output_stream->writeStartElement("peptide_match"); + _output_stream->writeAttribute( + "peptide_evidence_id", + _map_peptide_evidences.at(peptide_match.getPeptideEvidence())); + _output_stream->writeAttribute("start", + QString("%1").arg(peptide_match.getStart())); + + _output_stream->writeEndElement(); // protein_match_list + qDebug() << "Xpip::writePeptideMatch end"; } diff --git a/src/output/xpip.h b/src/output/xpip.h index f378379e5e91f52f1d4fe1b4bca80021d2e1601c..e44d9afa7cc12789dc5bca695dedfeb04ebf2a33 100644 --- a/src/output/xpip.h +++ b/src/output/xpip.h @@ -6,26 +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 + ******************************************************************************/ #ifndef XPIP_H #define XPIP_H @@ -37,44 +38,47 @@ class Xpip { -public: - Xpip(const QString & out_filename); - ~Xpip(); + public: + Xpip(const QString &out_filename); + ~Xpip(); - void write(ProjectSp sp_project); - void close(); + void write(ProjectSp sp_project); + void close(); -private : - void writeFilterParameters(const AutomaticFilterParameters & filters); - void writeDescription(); - void writeCounts(); + private: + void writeFilterParameters(const AutomaticFilterParameters &filters); + void writeDescription(); + void writeCounts(); - void writeMsrunList(const MsRunStore & msrun_store); - void writeIdentificationDataSourceList(const IdentificationDataSourceStore & ident_store); - void writeFastaFileList(const FastaFileStore & fasta_store); - void writeDoubleAttribute(const QString & attribute, pappso::pappso_double value); - void writeBooleanAttribute(const QString & attribute, bool value); - - void writeProteinList(); - void writePeptideList(); - void writeLabelingMethod(); - void writeIdentificationGroupList(); - void writeIdentificationGroup(const IdentificationGroup * p_identification_group); - void writePeptideEvidenceList(const IdentificationDataSource * p_ident_data_source); - void writePeptideMatch(const PeptideMatch & peptide_match); - void writePeptideEvidence(const PeptideEvidence * p_peptide_evidence); + void writeMsrunList(const MsRunStore &msrun_store); + void writeIdentificationDataSourceList( + const IdentificationDataSourceStore &ident_store); + void writeFastaFileList(const FastaFileStore &fasta_store); + void writeDoubleAttribute(const QString &attribute, + pappso::pappso_double value); + void writeBooleanAttribute(const QString &attribute, bool value); - QString getPeptideId(std::size_t crc_peptide) const; + void writeProteinList(); + void writePeptideList(); + void writeLabelingMethod(); + void writeIdentificationGroupList(); + void + writeIdentificationGroup(const IdentificationGroup *p_identification_group); + void + writePeptideEvidenceList(const IdentificationDataSource *p_ident_data_source); + void writePeptideMatch(const PeptideMatch &peptide_match); + void writePeptideEvidence(const PeptideEvidence *p_peptide_evidence); -private : - QFile * _output_file; - QXmlStreamWriter * _output_stream; - ProjectSp _sp_project; - - std::map<pappso::AaModificationP, QString> _map_modifications; - std::map<const PeptideXtp *, QString> _map_peptides; - std::map<const PeptideEvidence *, QString> _map_peptide_evidences; + QString getPeptideId(std::size_t crc_peptide) const; + private: + QFile *_output_file; + QXmlStreamWriter *_output_stream; + ProjectSp _sp_project; + + std::map<pappso::AaModificationP, QString> _map_modifications; + std::map<const PeptideXtp *, QString> _map_peptides; + std::map<const PeptideEvidence *, QString> _map_peptide_evidences; }; #endif // XPIP_H diff --git a/src/utils/fastafilestore.cpp b/src/utils/fastafilestore.cpp index 617b2998300ea89c0fc0c5ba81278f714ac9cbbb..040024de05ac0eb518a939815fe4b7e84d649bf8 100644 --- a/src/utils/fastafilestore.cpp +++ b/src/utils/fastafilestore.cpp @@ -7,64 +7,74 @@ /******************************************************************************* -* 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 "fastafilestore.h" #include <pappsomspp/utils.h> #include <QDebug> FastaFileStore::FastaFileStore() { - } FastaFileStore::~FastaFileStore() { - } -FastaFileSp FastaFileStore::getInstance(const FastaFile & location) { - qDebug() << "FastaFileStore::getInstance() begin "; - qDebug() << "FastaFileStore::getInstance() begin "<< location.getAbsoluteFilePath(); - std::vector<FastaFileSp>::iterator it = _map_fastafile.begin(); - std::vector<FastaFileSp>::iterator itend = _map_fastafile.end(); - while (it != itend) { - if (it->get()->getFilename() == location.getFilename()) { +FastaFileSp +FastaFileStore::getInstance(const FastaFile &location) +{ + qDebug() << "FastaFileStore::getInstance() begin "; + qDebug() << "FastaFileStore::getInstance() begin " + << location.getAbsoluteFilePath(); + std::vector<FastaFileSp>::iterator it = _map_fastafile.begin(); + std::vector<FastaFileSp>::iterator itend = _map_fastafile.end(); + while(it != itend) + { + if(it->get()->getFilename() == location.getFilename()) + { - qDebug() << "FastaFileStore::getInstance() end b "<< it->get()->getFilename(); - return *it; + qDebug() << "FastaFileStore::getInstance() end b " + << it->get()->getFilename(); + return *it; } - it++; + it++; } - FastaFileSp fastafile_sp = std::make_shared<FastaFile>(location); + FastaFileSp fastafile_sp = std::make_shared<FastaFile>(location); - fastafile_sp.get()->setXmlId(QString("fasta%1").arg(pappso::Utils::getLexicalOrderedString(_map_fastafile.size()))); - _map_fastafile.push_back(fastafile_sp); - qDebug() << "FastaFileStore::getFastaFileList() end a " << _map_fastafile.size(); - return fastafile_sp; + fastafile_sp.get()->setXmlId(QString("fasta%1").arg( + pappso::Utils::getLexicalOrderedString(_map_fastafile.size()))); + _map_fastafile.push_back(fastafile_sp); + qDebug() << "FastaFileStore::getFastaFileList() end a " + << _map_fastafile.size(); + return fastafile_sp; } -const std::vector<FastaFileSp> & FastaFileStore::getFastaFileList() const { - qDebug() << "FastaFileStore::getFastaFileList() begin" ; - qDebug() << "FastaFileStore::getFastaFileList() begin" << _map_fastafile.size(); - return _map_fastafile; +const std::vector<FastaFileSp> & +FastaFileStore::getFastaFileList() const +{ + qDebug() << "FastaFileStore::getFastaFileList() begin"; + qDebug() << "FastaFileStore::getFastaFileList() begin" + << _map_fastafile.size(); + return _map_fastafile; } diff --git a/src/utils/fastafilestore.h b/src/utils/fastafilestore.h index af3e877b3d5b9c1ed3be2d13722969a66be30d06..1a6e2387dbeac56221d2378406e8805d6150fd22 100644 --- a/src/utils/fastafilestore.h +++ b/src/utils/fastafilestore.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef FASTAFILESTORE_H #define FASTAFILESTORE_H @@ -36,15 +37,16 @@ class FastaFileStore { -public: - FastaFileStore(); - ~FastaFileStore(); - - FastaFileSp getInstance(const FastaFile & fastafile); - - const std::vector<FastaFileSp> & getFastaFileList() const; -private: - std::vector<FastaFileSp> _map_fastafile; + public: + FastaFileStore(); + ~FastaFileStore(); + + FastaFileSp getInstance(const FastaFile &fastafile); + + const std::vector<FastaFileSp> &getFastaFileList() const; + + private: + std::vector<FastaFileSp> _map_fastafile; }; diff --git a/src/utils/groupstore.cpp b/src/utils/groupstore.cpp index 6371c5fc29486d0a68a67fe4c3663dc7e2b90d32..e16ab3b3ebc577d9c83ae807890b35d44bd014be 100644 --- a/src/utils/groupstore.cpp +++ b/src/utils/groupstore.cpp @@ -7,73 +7,87 @@ /******************************************************************************* -* 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 "groupstore.h" GroupStore::GroupStore() { - } GroupStore::~GroupStore() { - } -void GroupStore::clear() { - _map_group.clear(); +void +GroupStore::clear() +{ + _map_group.clear(); } -std::size_t GroupStore::countGroup() const { - return _map_group.size(); +std::size_t +GroupStore::countGroup() const +{ + return _map_group.size(); } -std::size_t GroupStore::countSubGroup() const { - - unsigned int count = 0; - for (auto && pair_group :_map_group) { +std::size_t +GroupStore::countSubGroup() const +{ + + unsigned int count = 0; + for(auto &&pair_group : _map_group) + { count += pair_group.second->getNumberOfSubgroups(); } - return count; + return count; } - const std::map<unsigned int, GroupingGroupSp> & GroupStore::getGroupMap() const { - return _map_group; - } +const std::map<unsigned int, GroupingGroupSp> & +GroupStore::getGroupMap() const +{ + return _map_group; +} -GroupingGroupSp GroupStore::getInstance(unsigned int group_number) { +GroupingGroupSp +GroupStore::getInstance(unsigned int group_number) +{ - GroupingGroupSp sp_group; - if (group_number > 0) { - std::map< unsigned int, GroupingGroupSp>::iterator it = _map_group.find(group_number); - if (it != _map_group.end()) { - sp_group = it->second; + GroupingGroupSp sp_group; + if(group_number > 0) + { + std::map<unsigned int, GroupingGroupSp>::iterator it = + _map_group.find(group_number); + if(it != _map_group.end()) + { + sp_group = it->second; } - else { - sp_group = std::make_shared<GroupingGroup>(); - _map_group.insert(std::pair<unsigned int, GroupingGroupSp>(group_number,sp_group)); + else + { + sp_group = std::make_shared<GroupingGroup>(); + _map_group.insert( + std::pair<unsigned int, GroupingGroupSp>(group_number, sp_group)); } } - return (sp_group); - + return (sp_group); } diff --git a/src/utils/groupstore.h b/src/utils/groupstore.h index 98db1ce5408f9f7c607098d7e18e25664234a5ef..7132ac4e5f2dbf8411bea80080ee4f06bfc1d2e4 100644 --- a/src/utils/groupstore.h +++ b/src/utils/groupstore.h @@ -7,26 +7,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 "../grouping/groupinggroup.h" @@ -37,17 +38,18 @@ class GroupStore { -public: - GroupStore(); - ~GroupStore(); - GroupingGroupSp getInstance(unsigned int group_number); - const std::map<unsigned int, GroupingGroupSp> & getGroupMap() const; - - void clear(); - std::size_t countGroup() const; - std::size_t countSubGroup() const; -private : - std::map<unsigned int, GroupingGroupSp> _map_group; + public: + GroupStore(); + ~GroupStore(); + GroupingGroupSp getInstance(unsigned int group_number); + const std::map<unsigned int, GroupingGroupSp> &getGroupMap() const; + + void clear(); + std::size_t countGroup() const; + std::size_t countSubGroup() const; + + private: + std::map<unsigned int, GroupingGroupSp> _map_group; }; #endif // GROUPSTORE_H diff --git a/src/utils/identificationdatasourcestore.cpp b/src/utils/identificationdatasourcestore.cpp index 51705b31c08445d7f19c84cce6131124e5674c3e..1f7df966988b33650162ed22313df5d36f2212d6 100644 --- a/src/utils/identificationdatasourcestore.cpp +++ b/src/utils/identificationdatasourcestore.cpp @@ -2,31 +2,33 @@ * \file utils/identificationdatasourcestore.cpp * \date 5/4/2017 * \author Olivier Langella - * \brief store unique version of identification data sources (output files from identification engines) + * \brief store unique version of identification data sources (output files from + * identification engines) */ /******************************************************************************* -* 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 "identificationdatasourcestore.h" #include "../core/identification_sources/identificationxtandemfile.h" @@ -38,97 +40,153 @@ IdentificationDataSourceStore::IdentificationDataSourceStore() { - } IdentificationDataSourceStore::~IdentificationDataSourceStore() { - } -IdentificationDataSourceSp IdentificationDataSourceStore::getInstance(const QString & location, IdentificationEngine engine) { - qDebug() << "IdentificationDataSourceStore::getInstance begin " << location; - std::map< QString, IdentificationDataSourceSp >::iterator it = _map_identification_data_sources.find(location); - if (it != _map_identification_data_sources.end()) { - qDebug() << "IdentificationDataSourceStore::getInstance found " << location; - return it->second; +IdentificationDataSourceSp +IdentificationDataSourceStore::getInstance(const QString &location, + IdentificationEngine engine) +{ + qDebug() << "IdentificationDataSourceStore::getInstance begin " << location; + std::map<QString, IdentificationDataSourceSp>::iterator it = + _map_identification_data_sources.find(location); + if(it != _map_identification_data_sources.end()) + { + qDebug() << "IdentificationDataSourceStore::getInstance found " + << location; + return it->second; } - else { - QFileInfo location_file(location); - QString ext = location_file.suffix(); - qDebug() << "IdentificationDataSourceStore::getInstance coucou 1 "; - //QString sample_name = location_file.baseName(); - IdentificationDataSourceSp p_identfile = nullptr; - if (ext.toLower() == "xml") { - //X!Tandem result file - p_identfile = std::make_shared<IdentificationXtandemFile>(location_file); - } else if (ext.toLower() == "pep") { - //pep xml file - p_identfile = std::make_shared<IdentificationPwizFile>(location_file); - } else { - p_identfile = std::make_shared<IdentificationPwizFile>(location_file); + else + { + QFileInfo location_file(location); + QString ext = location_file.suffix(); + qDebug() << "IdentificationDataSourceStore::getInstance coucou 1 "; + // QString sample_name = location_file.baseName(); + IdentificationDataSourceSp p_identfile = nullptr; + if(ext.toLower() == "xml") + { + // X!Tandem result file + p_identfile = + std::make_shared<IdentificationXtandemFile>(location_file); } - if (p_identfile == nullptr) { - throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized (null pointer)").arg(location)); + else if(ext.toLower() == "pep") + { + // pep xml file + p_identfile = std::make_shared<IdentificationPwizFile>(location_file); } - qDebug() << "IdentificationDataSourceStore::getInstance coucou 2 "; - p_identfile.get()->setXmlId(QString("ident%1").arg(pappso::Utils::getLexicalOrderedString(_map_identification_data_sources.size()))); - p_identfile.get()->setIdentificationEngine(engine); - _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSourceSp >(location, p_identfile)); - _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSourceSp >(location_file.absoluteFilePath(), p_identfile)); - qDebug() << "IdentificationDataSourceStore::getInstance inserted " << location; - return p_identfile; + else + { + p_identfile = std::make_shared<IdentificationPwizFile>(location_file); + } + if(p_identfile == nullptr) + { + throw pappso::PappsoException( + QObject::tr( + "Identification resource %1 not recognized (null pointer)") + .arg(location)); + } + qDebug() << "IdentificationDataSourceStore::getInstance coucou 2 "; + p_identfile.get()->setXmlId( + QString("ident%1").arg(pappso::Utils::getLexicalOrderedString( + _map_identification_data_sources.size()))); + p_identfile.get()->setIdentificationEngine(engine); + _map_identification_data_sources.insert( + std::pair<QString, IdentificationDataSourceSp>(location, p_identfile)); + _map_identification_data_sources.insert( + std::pair<QString, IdentificationDataSourceSp>( + location_file.absoluteFilePath(), p_identfile)); + qDebug() << "IdentificationDataSourceStore::getInstance inserted " + << location; + return p_identfile; } - throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized").arg(location)); + throw pappso::PappsoException( + QObject::tr("Identification resource %1 not recognized").arg(location)); } -IdentificationDataSourceSp IdentificationDataSourceStore::getInstance(const QString & location) { - qDebug() << "IdentificationDataSourceStore::getInstance begin " << location; - qDebug() << " " << _map_identification_data_sources.size(); - std::map< QString, IdentificationDataSourceSp >::iterator it = _map_identification_data_sources.find(location); - if (it != _map_identification_data_sources.end()) { - return it->second; +IdentificationDataSourceSp +IdentificationDataSourceStore::getInstance(const QString &location) +{ + qDebug() << "IdentificationDataSourceStore::getInstance begin " << location; + qDebug() << " " << _map_identification_data_sources.size(); + std::map<QString, IdentificationDataSourceSp>::iterator it = + _map_identification_data_sources.find(location); + if(it != _map_identification_data_sources.end()) + { + return it->second; } - else { - QFileInfo location_file(location); - QString ext = location_file.completeSuffix(); - //QString sample_name = location_file.baseName(); - IdentificationDataSourceSp p_identfile = nullptr; - if (ext.toLower() == "xml") { - //X!Tandem result file - p_identfile = std::make_shared<IdentificationXtandemFile>(location_file); - } else if (ext.toLower() == "pep") { - //pep xml file - p_identfile = std::make_shared<IdentificationPepXmlFile>(location_file); - } else if (ext.toLower() == "pep.xml") { - //pep xml file - p_identfile = std::make_shared<IdentificationPepXmlFile>(location_file); - } else if (ext.toLower() == "pepxml") { - //pep xml file - p_identfile = std::make_shared<IdentificationPepXmlFile>(location_file); - } else if (ext.toLower() == "dat") { - //MASCOT dat file - p_identfile = std::make_shared<IdentificationMascotDatFile>(location_file); - } else { - p_identfile = std::make_shared<IdentificationPwizFile>(location_file); + else + { + QFileInfo location_file(location); + QString ext = location_file.completeSuffix(); + // QString sample_name = location_file.baseName(); + IdentificationDataSourceSp p_identfile = nullptr; + if(ext.toLower() == "xml") + { + // X!Tandem result file + p_identfile = + std::make_shared<IdentificationXtandemFile>(location_file); } - if (p_identfile == nullptr) { - throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized (null pointer)").arg(location)); + else if(ext.toLower() == "pep") + { + // pep xml file + p_identfile = + std::make_shared<IdentificationPepXmlFile>(location_file); } - p_identfile.get()->setXmlId(QString("ident%1").arg(pappso::Utils::getLexicalOrderedString(_map_identification_data_sources.size()))); + else if(ext.toLower() == "pep.xml") + { + // pep xml file + p_identfile = + std::make_shared<IdentificationPepXmlFile>(location_file); + } + else if(ext.toLower() == "pepxml") + { + // pep xml file + p_identfile = + std::make_shared<IdentificationPepXmlFile>(location_file); + } + else if(ext.toLower() == "dat") + { + // MASCOT dat file + p_identfile = + std::make_shared<IdentificationMascotDatFile>(location_file); + } + else + { + p_identfile = std::make_shared<IdentificationPwizFile>(location_file); + } + if(p_identfile == nullptr) + { + throw pappso::PappsoException( + QObject::tr( + "Identification resource %1 not recognized (null pointer)") + .arg(location)); + } + p_identfile.get()->setXmlId( + QString("ident%1").arg(pappso::Utils::getLexicalOrderedString( + _map_identification_data_sources.size()))); - _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSourceSp >(location, p_identfile)); - _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSourceSp >(location_file.absoluteFilePath(), p_identfile)); - return p_identfile; + _map_identification_data_sources.insert( + std::pair<QString, IdentificationDataSourceSp>(location, p_identfile)); + _map_identification_data_sources.insert( + std::pair<QString, IdentificationDataSourceSp>( + location_file.absoluteFilePath(), p_identfile)); + return p_identfile; } - throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized").arg(location)); + throw pappso::PappsoException( + QObject::tr("Identification resource %1 not recognized").arg(location)); } -std::vector<IdentificationDataSourceSp> IdentificationDataSourceStore::getIdentificationDataSourceList() const { - std::vector<IdentificationDataSourceSp> idsource_list; - for (auto & msrun_pair :_map_identification_data_sources) { - idsource_list.push_back(msrun_pair.second); +std::vector<IdentificationDataSourceSp> +IdentificationDataSourceStore::getIdentificationDataSourceList() const +{ + std::vector<IdentificationDataSourceSp> idsource_list; + for(auto &msrun_pair : _map_identification_data_sources) + { + idsource_list.push_back(msrun_pair.second); } - return idsource_list; + return idsource_list; } diff --git a/src/utils/identificationdatasourcestore.h b/src/utils/identificationdatasourcestore.h index a84b06a83c997fa73e55b29e5c190817f3db78b7..b59e667ae4a57ce83e6772fcbd770382c7940b2d 100644 --- a/src/utils/identificationdatasourcestore.h +++ b/src/utils/identificationdatasourcestore.h @@ -2,31 +2,33 @@ * \file utils/identificationdatasourcestore.h * \date 5/4/2017 * \author Olivier Langella - * \brief store unique version of identification data sources (output files from identification engines) + * \brief store unique version of identification data sources (output files from + * identification engines) */ /******************************************************************************* -* 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 IDENTIFICATIONDATASOURCESTORE_H #define IDENTIFICATIONDATASOURCESTORE_H @@ -38,15 +40,19 @@ class IdentificationDataSourceStore { -public: - IdentificationDataSourceStore(); - ~IdentificationDataSourceStore(); - IdentificationDataSourceSp getInstance(const QString & location); - IdentificationDataSourceSp getInstance(const QString & location, IdentificationEngine engine); - - std::vector<IdentificationDataSourceSp> getIdentificationDataSourceList() const; -private : - std::map<QString, IdentificationDataSourceSp> _map_identification_data_sources; + public: + IdentificationDataSourceStore(); + ~IdentificationDataSourceStore(); + IdentificationDataSourceSp getInstance(const QString &location); + IdentificationDataSourceSp getInstance(const QString &location, + IdentificationEngine engine); + + std::vector<IdentificationDataSourceSp> + getIdentificationDataSourceList() const; + + private: + std::map<QString, IdentificationDataSourceSp> + _map_identification_data_sources; }; #endif // IDENTIFICATIONDATASOURCESTORE_H diff --git a/src/utils/msrunstatisticshandler.cpp b/src/utils/msrunstatisticshandler.cpp index a73714ccf99753db25a9adff946fe9fe17ee1ceb..cd1c3d0d8373689872bb198c2bdbaa634436f9f3 100644 --- a/src/utils/msrunstatisticshandler.cpp +++ b/src/utils/msrunstatisticshandler.cpp @@ -78,7 +78,8 @@ MsRunStatisticsHandler::getMsLevelTic(unsigned int ms_level) const return 0; if(ms_level > _tic_ms_level_spectrum.size()) return 0; - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << _tic_ms_level_spectrum[ms_level - 1]; + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ + << _tic_ms_level_spectrum[ms_level - 1]; return (_tic_ms_level_spectrum[ms_level - 1]); } diff --git a/src/utils/msrunstatisticshandler.h b/src/utils/msrunstatisticshandler.h index ae57c462c4203ad4a76c46acbdccf27c9c920a2d..c0a645ef67d06e47d595783e7fbd8852b8ecc8a7 100644 --- a/src/utils/msrunstatisticshandler.h +++ b/src/utils/msrunstatisticshandler.h @@ -2,28 +2,29 @@ * \file utils/msrunstatisticshandler.h * \date 12/08/2018 * \author Olivier Langella - * \brief handler on MZ data file to read all spectrums and make basic statistics + * \brief handler on MZ data file to read all spectrums and make basic + * statistics */ /******************************************************************************* -* Copyright (c) 2018 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/>. -******************************************************************************/ + * Copyright (c) 2018 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/>. + ******************************************************************************/ #pragma once diff --git a/src/utils/msrunstore.h b/src/utils/msrunstore.h index 48391de8c890b8e26df4b6aa47a20bacc7900526..e0853179a944d34dab9ff0e289cfb4976386ad08 100644 --- a/src/utils/msrunstore.h +++ b/src/utils/msrunstore.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef MSRUNSTORE_H #define MSRUNSTORE_H @@ -38,16 +39,17 @@ class MsRunStore { -public: - MsRunStore(); - ~MsRunStore(); - - MsRunSp getInstance(const QString & location); - MsRunSp getInstance(const MsRun * p_msrun); - - const std::vector<MsRunSp> & getMsRunList() const; -private: - std::vector<MsRunSp> _map_msrun; + public: + MsRunStore(); + ~MsRunStore(); + + MsRunSp getInstance(const QString &location); + MsRunSp getInstance(const MsRun *p_msrun); + + const std::vector<MsRunSp> &getMsRunList() const; + + private: + std::vector<MsRunSp> _map_msrun; }; #endif // MSRUNSTORE_H diff --git a/src/utils/peptideevidencestore.cpp b/src/utils/peptideevidencestore.cpp index e2ebd231eeb952b92a583fd0c155efe0b17e06d2..a99100907b1a2bb2535c079b58b4673194b294d4 100644 --- a/src/utils/peptideevidencestore.cpp +++ b/src/utils/peptideevidencestore.cpp @@ -6,101 +6,139 @@ */ - /******************************************************************************* -* 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 "peptideevidencestore.h" #include <QDebug> #include <pappsomspp/pappsoexception.h> #include "../core/peptideevidence.h" -std::shared_ptr<PeptideEvidence> & PeptideEvidenceStore::recordInstance(const PeptideEvidence * p_peptide_evidence) { - _peptide_evidence_list.push_back(p_peptide_evidence->makePeptideEvidenceSp()); - - //qDebug() << "PeptideEvidenceStore::getInstance end " << find_it->second.get()->getScan() << " size=" << _multimap_scan_evidence.size(); - return _peptide_evidence_list.back(); +std::shared_ptr<PeptideEvidence> & +PeptideEvidenceStore::recordInstance(const PeptideEvidence *p_peptide_evidence) +{ + _peptide_evidence_list.push_back(p_peptide_evidence->makePeptideEvidenceSp()); + + // qDebug() << "PeptideEvidenceStore::getInstance end " << + // find_it->second.get()->getScan() << " size=" << + // _multimap_scan_evidence.size(); + return _peptide_evidence_list.back(); } -std::shared_ptr<PeptideEvidence> & PeptideEvidenceStore::getInstance(const PeptideEvidence * p_peptide_evidence) { - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " scan=" << p_peptide_evidence->getScan(); - //qDebug() << "PeptideEvidenceStore::getInstance begin" ; - std::multimap<unsigned int ,PeptideEvidenceSp>::iterator it = _multimap_scan_evidence.find(p_peptide_evidence->getScan()); - std::multimap<unsigned int ,PeptideEvidenceSp>::iterator find_it = _multimap_scan_evidence.end(); - - - while ((find_it == _multimap_scan_evidence.end()) && (it->first == p_peptide_evidence->getScan()) && (it != find_it)) { - if (it->second.get()->getPeptideXtpSp().get() == p_peptide_evidence->getPeptideXtpSp().get()) { - //it is the same peptide - find_it = it; +std::shared_ptr<PeptideEvidence> & +PeptideEvidenceStore::getInstance(const PeptideEvidence *p_peptide_evidence) +{ + // qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__ << " scan=" + // << p_peptide_evidence->getScan(); qDebug() << + // "PeptideEvidenceStore::getInstance begin" ; + std::multimap<unsigned int, PeptideEvidenceSp>::iterator it = + _multimap_scan_evidence.find(p_peptide_evidence->getScan()); + std::multimap<unsigned int, PeptideEvidenceSp>::iterator find_it = + _multimap_scan_evidence.end(); + + + while((find_it == _multimap_scan_evidence.end()) && + (it->first == p_peptide_evidence->getScan()) && (it != find_it)) + { + if(it->second.get()->getPeptideXtpSp().get() == + p_peptide_evidence->getPeptideXtpSp().get()) + { + // it is the same peptide + find_it = it; } - else { - //throw pappso::PappsoException(QObject::tr("PeptideEvidenceStore::getInstance multiple peptide for scan %1").arg(p_peptide_evidence->getScan())); + else + { + // throw + // pappso::PappsoException(QObject::tr("PeptideEvidenceStore::getInstance + // multiple peptide for scan %1").arg(p_peptide_evidence->getScan())); } - it++; + it++; } - if (find_it == _multimap_scan_evidence.end()) { - // insert it - find_it = _multimap_scan_evidence.insert(std::pair<unsigned int , PeptideEvidenceSp>(p_peptide_evidence->getScan(), p_peptide_evidence->makePeptideEvidenceSp())); - _peptide_evidence_list.push_back(find_it->second); + if(find_it == _multimap_scan_evidence.end()) + { + // insert it + find_it = _multimap_scan_evidence.insert( + std::pair<unsigned int, PeptideEvidenceSp>( + p_peptide_evidence->getScan(), + p_peptide_evidence->makePeptideEvidenceSp())); + _peptide_evidence_list.push_back(find_it->second); } - //qDebug() << "PeptideEvidenceStore::getInstance end " << find_it->second.get()->getScan() << " size=" << _multimap_scan_evidence.size(); - //qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__; - return find_it->second; - + // qDebug() << "PeptideEvidenceStore::getInstance end " << + // find_it->second.get()->getScan() << " size=" << + // _multimap_scan_evidence.size(); qDebug() << __FILE__ << " " << + // __FUNCTION__<< " " << __LINE__; + return find_it->second; } -std::size_t PeptideEvidenceStore::size() const { - return _peptide_evidence_list.size(); +std::size_t +PeptideEvidenceStore::size() const +{ + return _peptide_evidence_list.size(); } -void PeptideEvidenceStore::clearMap() { - qDebug() << "PeptideEvidenceStore::clearMap begin" ; - _multimap_scan_evidence.clear(); - qDebug() << "PeptideEvidenceStore::clearMap end" ; - +void +PeptideEvidenceStore::clearMap() +{ + qDebug() << "PeptideEvidenceStore::clearMap begin"; + _multimap_scan_evidence.clear(); + qDebug() << "PeptideEvidenceStore::clearMap end"; } -void PeptideEvidenceStore::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { - qDebug() << "PeptideEvidenceStore::updateAutomaticFilters begin" ; - for (PeptideEvidenceSp & peptide_evidence_sp:_peptide_evidence_list) { - peptide_evidence_sp.get()->updateAutomaticFilters(automatic_filter_parameters); +void +PeptideEvidenceStore::updateAutomaticFilters( + const AutomaticFilterParameters &automatic_filter_parameters) +{ + qDebug() << "PeptideEvidenceStore::updateAutomaticFilters begin"; + for(PeptideEvidenceSp &peptide_evidence_sp : _peptide_evidence_list) + { + peptide_evidence_sp.get()->updateAutomaticFilters( + automatic_filter_parameters); } - qDebug() << "PeptideEvidenceStore::updateAutomaticFilters end" ; - + qDebug() << "PeptideEvidenceStore::updateAutomaticFilters end"; } -const std::vector<std::shared_ptr<PeptideEvidence>> & PeptideEvidenceStore::getPeptideEvidenceList() const { - return _peptide_evidence_list; +const std::vector<std::shared_ptr<PeptideEvidence>> & +PeptideEvidenceStore::getPeptideEvidenceList() const +{ + return _peptide_evidence_list; } -void PeptideEvidenceStore::getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const { - for (const PeptideEvidenceSp & peptide_evidence_sp:_peptide_evidence_list) { - if (p_msrun != peptide_evidence_sp.get()->getMsRunP()) continue; - else if (p_peptide != peptide_evidence_sp.get()->getPeptideXtpSp().get()) continue; - else if (charge != peptide_evidence_sp.get()->getCharge()) continue; - peptide_evidence_list.push_back(peptide_evidence_sp.get()); +void +PeptideEvidenceStore::getSameXicPeptideEvidenceList( + std::vector<const PeptideEvidence *> &peptide_evidence_list, + const MsRun *p_msrun, const PeptideXtp *p_peptide, unsigned int charge) const +{ + for(const PeptideEvidenceSp &peptide_evidence_sp : _peptide_evidence_list) + { + if(p_msrun != peptide_evidence_sp.get()->getMsRunP()) + continue; + else if(p_peptide != peptide_evidence_sp.get()->getPeptideXtpSp().get()) + continue; + else if(charge != peptide_evidence_sp.get()->getCharge()) + continue; + peptide_evidence_list.push_back(peptide_evidence_sp.get()); } } diff --git a/src/utils/peptideevidencestore.h b/src/utils/peptideevidencestore.h index 1ae1889c3778f7f611744407a651d9d9d6854a7d..515cc660572c66a501881799e863a5ca19134e5b 100644 --- a/src/utils/peptideevidencestore.h +++ b/src/utils/peptideevidencestore.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef PEPTIDEEVIDENCESTORE_H #define PEPTIDEEVIDENCESTORE_H @@ -42,33 +43,41 @@ class PeptideEvidence; class PeptideEvidenceStore { -public: - /** @brief directly register an instance of peptide evidence : no duplication check - */ - std::shared_ptr<PeptideEvidence> & recordInstance(const PeptideEvidence * p_peptide_evidence); - /** @brief register an instance of peptide evidence : duplication check - */ - std::shared_ptr<PeptideEvidence> & getInstance(const PeptideEvidence * p_peptide_evidence); - void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); - - const std::vector<std::shared_ptr<PeptideEvidence>> & getPeptideEvidenceList() const; - std::size_t size() const; - void clearMap(); - - - - /** @brief look for a peptide in the same XIC - * @param peptide_evidence_list the peptide evidence list to build - * @param p_msrun MSrun to look for - * @param p_peptide peptide to look for - * @param charge charge to look for - */ - void getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const; + public: + /** @brief directly register an instance of peptide evidence : no duplication + * check + */ + std::shared_ptr<PeptideEvidence> & + recordInstance(const PeptideEvidence *p_peptide_evidence); + /** @brief register an instance of peptide evidence : duplication check + */ + std::shared_ptr<PeptideEvidence> & + getInstance(const PeptideEvidence *p_peptide_evidence); + void updateAutomaticFilters( + const AutomaticFilterParameters &automatic_filter_parameters); -private: - std::vector<std::shared_ptr<PeptideEvidence>> _peptide_evidence_list; - - std::multimap<unsigned int ,std::shared_ptr<PeptideEvidence>> _multimap_scan_evidence; + const std::vector<std::shared_ptr<PeptideEvidence>> & + getPeptideEvidenceList() const; + std::size_t size() const; + void clearMap(); + + + /** @brief look for a peptide in the same XIC + * @param peptide_evidence_list the peptide evidence list to build + * @param p_msrun MSrun to look for + * @param p_peptide peptide to look for + * @param charge charge to look for + */ + void getSameXicPeptideEvidenceList( + std::vector<const PeptideEvidence *> &peptide_evidence_list, + const MsRun *p_msrun, const PeptideXtp *p_peptide, + unsigned int charge) const; + + private: + std::vector<std::shared_ptr<PeptideEvidence>> _peptide_evidence_list; + + std::multimap<unsigned int, std::shared_ptr<PeptideEvidence>> + _multimap_scan_evidence; }; #endif // PEPTIDEEVIDENCESTORE_H diff --git a/src/utils/peptidestore.cpp b/src/utils/peptidestore.cpp index 9156c44f4897df6ace4eaecefd68c995e9e5a5e6..f22a1e6c6bfac334a15cb051cbd786d426ad65f9 100644 --- a/src/utils/peptidestore.cpp +++ b/src/utils/peptidestore.cpp @@ -24,7 +24,8 @@ * along with peptider. If not, see <http://www.gnu.org/licenses/>. * * Contributors: - * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation + * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and + *implementation ******************************************************************************/ #include "peptidestore.h" @@ -33,81 +34,113 @@ PeptideStore::PeptideStore() { - } PeptideStore::~PeptideStore() { - } -PeptideXtpSp & PeptideStore::getInstance(PeptideXtpSp & peptide_in) { - std::size_t sequence_crc = _hash_fn ( peptide_in.get()->toAbsoluteString().toStdString()); - - //QByteArray source = peptide_in.get()->getLiAbsoluteString().toUtf8(); - //quint16 sequence_li_crc = qChecksum(source.data(), source.length()); - - std::pair<std::unordered_map< std::size_t, PeptideXtpSp>::iterator,bool> ret = _map_crc_peptide_list.insert(std::pair<std::size_t, PeptideXtpSp>(sequence_crc,peptide_in)); - if (ret.second) { - //if new peptide in store - - for (auto && aa : *(ret.first->second.get())) { - std::list<pappso::AaModificationP> mod_list = aa.getModificationList(); - _modification_collection.insert(mod_list.begin(), mod_list.end()); +PeptideXtpSp & +PeptideStore::getInstance(PeptideXtpSp &peptide_in) +{ + std::size_t sequence_crc = + _hash_fn(peptide_in.get()->toAbsoluteString().toStdString()); + + // QByteArray source = peptide_in.get()->getLiAbsoluteString().toUtf8(); + // quint16 sequence_li_crc = qChecksum(source.data(), source.length()); + + std::pair<std::unordered_map<std::size_t, PeptideXtpSp>::iterator, bool> ret = + _map_crc_peptide_list.insert( + std::pair<std::size_t, PeptideXtpSp>(sequence_crc, peptide_in)); + if(ret.second) + { + // if new peptide in store + + for(auto &&aa : *(ret.first->second.get())) + { + std::list<pappso::AaModificationP> mod_list = + aa.getModificationList(); + _modification_collection.insert(mod_list.begin(), mod_list.end()); } } - return ret.first->second; - + return ret.first->second; } -std::size_t PeptideStore::size() const { - return _map_crc_peptide_list.size(); +std::size_t +PeptideStore::size() const +{ + return _map_crc_peptide_list.size(); } -bool PeptideStore::replaceModification(pappso::AaModificationP oldmod, pappso::AaModificationP newmod) { - for (std::pair<std::size_t, PeptideXtpSp> pair_peptide:_map_crc_peptide_list) { - PeptideXtpSp peptide_xtp = pair_peptide.second; - peptide_xtp.get()->replaceAaModification(oldmod, newmod); +bool +PeptideStore::replaceModification(pappso::AaModificationP oldmod, + pappso::AaModificationP newmod) +{ + for(std::pair<std::size_t, PeptideXtpSp> pair_peptide : _map_crc_peptide_list) + { + PeptideXtpSp peptide_xtp = pair_peptide.second; + peptide_xtp.get()->replaceAaModification(oldmod, newmod); } - _modification_collection.erase(oldmod); - _modification_collection.insert(newmod); - + _modification_collection.erase(oldmod); + _modification_collection.insert(newmod); } -void PeptideStore::clearLabelingMethod() { - for (std::pair<std::size_t, PeptideXtpSp> pair_peptide:_map_crc_peptide_list) { - PeptideXtpSp peptide_xtp = pair_peptide.second; - peptide_xtp.get()->clearLabel(); +void +PeptideStore::clearLabelingMethod() +{ + for(std::pair<std::size_t, PeptideXtpSp> pair_peptide : _map_crc_peptide_list) + { + PeptideXtpSp peptide_xtp = pair_peptide.second; + peptide_xtp.get()->clearLabel(); } } -const std::set<pappso::AaModificationP> & PeptideStore::getModificationCollection() const { - return _modification_collection; +const std::set<pappso::AaModificationP> & +PeptideStore::getModificationCollection() const +{ + return _modification_collection; } -bool PeptideStore::checkPsimodCompliance() const { - for (pappso::AaModificationP modification :_modification_collection) { - if (modification->isInternal()) { +bool +PeptideStore::checkPsimodCompliance() const +{ + for(pappso::AaModificationP modification : _modification_collection) + { + if(modification->isInternal()) + { } - else { - if (modification->getAccession().startsWith("MOD:")) { + else + { + if(modification->getAccession().startsWith("MOD:")) + { } - else { - throw pappso::PappsoException(QObject::tr("Modification %1 is not a PSIMOD accession. Please go into the edit=>modifications menu to replace modifications masses by PSIMOD accessions").arg(modification->getAccession())); + else + { + throw pappso::PappsoException( + QObject::tr("Modification %1 is not a PSIMOD accession. Please " + "go into the edit=>modifications menu to replace " + "modifications masses by PSIMOD accessions") + .arg(modification->getAccession())); } } } - return true; + return true; } -void PeptideStore::setLabelingMethodSp(LabelingMethodSp labeling_method_sp) { - if (_labeling_method_sp != nullptr) { - clearLabelingMethod(); +void +PeptideStore::setLabelingMethodSp(LabelingMethodSp labeling_method_sp) +{ + if(_labeling_method_sp != nullptr) + { + clearLabelingMethod(); } - _labeling_method_sp = labeling_method_sp; - for (std::pair<std::size_t, PeptideXtpSp> pair_peptide:_map_crc_peptide_list) { - PeptideXtpSp peptide_xtp = pair_peptide.second; - peptide_xtp.get()->applyLabelingMethod(labeling_method_sp); + _labeling_method_sp = labeling_method_sp; + for(std::pair<std::size_t, PeptideXtpSp> pair_peptide : _map_crc_peptide_list) + { + PeptideXtpSp peptide_xtp = pair_peptide.second; + peptide_xtp.get()->applyLabelingMethod(labeling_method_sp); } } -const std::unordered_map<std::size_t, PeptideXtpSp> & PeptideStore::getPeptideMap() const { - return _map_crc_peptide_list; +const std::unordered_map<std::size_t, PeptideXtpSp> & +PeptideStore::getPeptideMap() const +{ + return _map_crc_peptide_list; } diff --git a/src/utils/peptidestore.h b/src/utils/peptidestore.h index 53862e9f7e65ab6521b4aafb4d6347c0f1b2c590..55faba9da51d7122ecbf31859996f2d8d407cd2e 100644 --- a/src/utils/peptidestore.h +++ b/src/utils/peptidestore.h @@ -24,7 +24,8 @@ * along with peptider. If not, see <http://www.gnu.org/licenses/>. * * Contributors: - * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation + * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and + *implementation ******************************************************************************/ #ifndef PEPTIDESTORE_H @@ -37,39 +38,40 @@ class PeptideStore { -public: - PeptideStore(); - ~PeptideStore(); - - PeptideXtpSp & getInstance(PeptideXtpSp & peptide_in); + public: + PeptideStore(); + ~PeptideStore(); - /** @brief check that modifications are coded with PSI MOD accessions - */ - bool checkPsimodCompliance() const; + PeptideXtpSp &getInstance(PeptideXtpSp &peptide_in); - const std::set<pappso::AaModificationP> & getModificationCollection() const; + /** @brief check that modifications are coded with PSI MOD accessions + */ + bool checkPsimodCompliance() const; - /** @brief replaces all occurences of a given modification by another one - */ - bool replaceModification(pappso::AaModificationP oldmod, pappso::AaModificationP newmod); + const std::set<pappso::AaModificationP> &getModificationCollection() const; - /** @brief apply labeling method to all peptide match - * */ - void setLabelingMethodSp(LabelingMethodSp labeling_method_sp); - - const std::unordered_map<std::size_t, PeptideXtpSp> & getPeptideMap() const; - std::size_t size() const; -private: - /** @brief reset labeling method - * */ - void clearLabelingMethod(); + /** @brief replaces all occurences of a given modification by another one + */ + bool replaceModification(pappso::AaModificationP oldmod, + pappso::AaModificationP newmod); -private : + /** @brief apply labeling method to all peptide match + * */ + void setLabelingMethodSp(LabelingMethodSp labeling_method_sp); - LabelingMethodSp _labeling_method_sp; - std::hash<std::string> _hash_fn; - std::unordered_map<std::size_t, PeptideXtpSp> _map_crc_peptide_list; - std::set<pappso::AaModificationP> _modification_collection; + const std::unordered_map<std::size_t, PeptideXtpSp> &getPeptideMap() const; + std::size_t size() const; + + private: + /** @brief reset labeling method + * */ + void clearLabelingMethod(); + + private: + LabelingMethodSp _labeling_method_sp; + std::hash<std::string> _hash_fn; + std::unordered_map<std::size_t, PeptideXtpSp> _map_crc_peptide_list; + std::set<pappso::AaModificationP> _modification_collection; }; #endif // PEPTIDESTORE_H diff --git a/src/utils/proteinstore.cpp b/src/utils/proteinstore.cpp index 98195342ea2c701c162c278cd2f36fda17c74785..9d4a3b8222877059fd4d866c2c1445fd8282aa62 100644 --- a/src/utils/proteinstore.cpp +++ b/src/utils/proteinstore.cpp @@ -6,26 +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 "proteinstore.h" #include "../files/fastafile.h" @@ -35,120 +36,172 @@ ProteinStore::ProteinStore() { - QSettings settings; - - _regexp_contaminant.setPattern(settings.value("automatic_filter/contaminant_regexp","^conta\\|").toString()); - _regexp_decoy.setPattern(settings.value("automatic_filter/decoy_regexp",".*\\|reversed$").toString()); - + QSettings settings; + _regexp_contaminant.setPattern( + settings.value("automatic_filter/contaminant_regexp", "^conta\\|") + .toString()); + _regexp_decoy.setPattern( + settings.value("automatic_filter/decoy_regexp", ".*\\|reversed$") + .toString()); } ProteinStore::~ProteinStore() { - } -std::size_t ProteinStore::size() const { - return _map_accession_protein_list.size(); +std::size_t +ProteinStore::size() const +{ + return _map_accession_protein_list.size(); } -const std::vector<const FastaFile *> & ProteinStore::getContaminantFastaFileList() const { - return _fasta_contaminant_list; +const std::vector<const FastaFile *> & +ProteinStore::getContaminantFastaFileList() const +{ + return _fasta_contaminant_list; } -const std::vector<const FastaFile *> & ProteinStore::getDecoyFastaFileList() const { - return _fasta_decoy_list; +const std::vector<const FastaFile *> & +ProteinStore::getDecoyFastaFileList() const +{ + return _fasta_decoy_list; } -QRegExp ProteinStore::getRegexpContaminant() const { - return (_regexp_contaminant); +QRegExp +ProteinStore::getRegexpContaminant() const +{ + return (_regexp_contaminant); } -void ProteinStore::setRegexpContaminantPattern(const QString & pattern) { - _regexp_contaminant.setPattern(pattern); +void +ProteinStore::setRegexpContaminantPattern(const QString &pattern) +{ + _regexp_contaminant.setPattern(pattern); - for (std::pair<const QString, ProteinXtpSp> & acc_protein :_map_accession_protein_list) { - setProteinInformations(acc_protein.second); + for(std::pair<const QString, ProteinXtpSp> &acc_protein : + _map_accession_protein_list) + { + setProteinInformations(acc_protein.second); } - QSettings settings; - settings.setValue("automatic_filter/contaminant_regexp", pattern); + QSettings settings; + settings.setValue("automatic_filter/contaminant_regexp", pattern); } -QRegExp ProteinStore::getRegexpDecoy() const { - return (_regexp_decoy); +QRegExp +ProteinStore::getRegexpDecoy() const +{ + return (_regexp_decoy); } -const std::map<QString, ProteinXtpSp> & ProteinStore::getProteinMap() const { - return _map_accession_protein_list; +const std::map<QString, ProteinXtpSp> & +ProteinStore::getProteinMap() const +{ + return _map_accession_protein_list; } -void ProteinStore::setRegexpDecoyPattern(const QString & pattern) { - _regexp_decoy.setPattern(pattern); +void +ProteinStore::setRegexpDecoyPattern(const QString &pattern) +{ + _regexp_decoy.setPattern(pattern); - for (std::pair<const QString, ProteinXtpSp> & acc_protein :_map_accession_protein_list) { - setProteinInformations(acc_protein.second); + for(std::pair<const QString, ProteinXtpSp> &acc_protein : + _map_accession_protein_list) + { + setProteinInformations(acc_protein.second); } - QSettings settings; - settings.setValue("automatic_filter/decoy_regexp", pattern); - + QSettings settings; + settings.setValue("automatic_filter/decoy_regexp", pattern); } -void ProteinStore::clearDecoys() { - _fasta_decoy_list.clear(); - for (std::pair<const QString, ProteinXtpSp> & acc_protein :_map_accession_protein_list) { - acc_protein.second.get()->setIsDecoy(false); +void +ProteinStore::clearDecoys() +{ + _fasta_decoy_list.clear(); + for(std::pair<const QString, ProteinXtpSp> &acc_protein : + _map_accession_protein_list) + { + acc_protein.second.get()->setIsDecoy(false); } } -void ProteinStore::clearContaminants() { - _fasta_contaminant_list.clear(); - for (std::pair<const QString, ProteinXtpSp> & acc_protein :_map_accession_protein_list) { - acc_protein.second.get()->setIsContaminant(false); +void +ProteinStore::clearContaminants() +{ + _fasta_contaminant_list.clear(); + for(std::pair<const QString, ProteinXtpSp> &acc_protein : + _map_accession_protein_list) + { + acc_protein.second.get()->setIsContaminant(false); } } -void ProteinStore::addContaminantFastaFile(const FastaFile * p_fasta_file) { - _fasta_contaminant_list.push_back(p_fasta_file); +void +ProteinStore::addContaminantFastaFile(const FastaFile *p_fasta_file) +{ + _fasta_contaminant_list.push_back(p_fasta_file); } -void ProteinStore::addDecoyFastaFile(const FastaFile * p_fasta_file) { - _fasta_decoy_list.push_back(p_fasta_file); +void +ProteinStore::addDecoyFastaFile(const FastaFile *p_fasta_file) +{ + _fasta_decoy_list.push_back(p_fasta_file); } -void ProteinStore::setDecoyAccession(QString accession) { - std::map<QString, ProteinXtpSp>::iterator it = _map_accession_protein_list.find(accession); - if (it != _map_accession_protein_list.end()) { - it->second.get()->setIsDecoy(true); +void +ProteinStore::setDecoyAccession(QString accession) +{ + std::map<QString, ProteinXtpSp>::iterator it = + _map_accession_protein_list.find(accession); + if(it != _map_accession_protein_list.end()) + { + it->second.get()->setIsDecoy(true); } } -void ProteinStore::setContaminantAccession(QString accession) { - std::map<QString, ProteinXtpSp>::iterator it = _map_accession_protein_list.find(accession); - if (it != _map_accession_protein_list.end()) { - it->second.get()->setIsContaminant(true); +void +ProteinStore::setContaminantAccession(QString accession) +{ + std::map<QString, ProteinXtpSp>::iterator it = + _map_accession_protein_list.find(accession); + if(it != _map_accession_protein_list.end()) + { + it->second.get()->setIsContaminant(true); } } -ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & protein_in) { +ProteinXtpSp & +ProteinStore::getInstance(ProteinXtpSp &protein_in) +{ - std::pair<std::map< QString, ProteinXtpSp>::iterator,bool> ret = _map_accession_protein_list.insert(std::pair<QString, ProteinXtpSp>(protein_in.get()->getAccession(),protein_in)); + std::pair<std::map<QString, ProteinXtpSp>::iterator, bool> ret = + _map_accession_protein_list.insert(std::pair<QString, ProteinXtpSp>( + protein_in.get()->getAccession(), protein_in)); - if (ret.second) { - //the protein is new in the store, update content - setProteinInformations(ret.first->second); + if(ret.second) + { + // the protein is new in the store, update content + setProteinInformations(ret.first->second); - if (ret.first->second.get()->getDbxrefList().size() == 0) { - ret.first->second.get()->parseAccession2dbxref(); + if(ret.first->second.get()->getDbxrefList().size() == 0) + { + ret.first->second.get()->parseAccession2dbxref(); } } - return (ret.first->second); - + return (ret.first->second); } -void ProteinStore::setProteinInformations(ProteinXtpSp & protein_in) { - //qDebug() << "ProteinStore::setProteinInformations begin" << peptide_in.get()->getSequence(); - protein_in.get()->setIsContaminant(false); - protein_in.get()->setIsDecoy(false); - QString accession = protein_in.get()->getAccession(); - - if ((!_regexp_contaminant.isEmpty()) && (_regexp_contaminant.indexIn(accession, 0)>-1)) { - //qDebug() << "ProteinStore::setProteinInformations is contaminant " << accession; - protein_in.get()->setIsContaminant(true); +void +ProteinStore::setProteinInformations(ProteinXtpSp &protein_in) +{ + // qDebug() << "ProteinStore::setProteinInformations begin" << + // peptide_in.get()->getSequence(); + protein_in.get()->setIsContaminant(false); + protein_in.get()->setIsDecoy(false); + QString accession = protein_in.get()->getAccession(); + + if((!_regexp_contaminant.isEmpty()) && + (_regexp_contaminant.indexIn(accession, 0) > -1)) + { + // qDebug() << "ProteinStore::setProteinInformations is contaminant " << + // accession; + protein_in.get()->setIsContaminant(true); } - if ((!_regexp_decoy.isEmpty()) && (_regexp_decoy.indexIn(accession, 0)>-1) ) { - protein_in.get()->setIsDecoy(true); + if((!_regexp_decoy.isEmpty()) && (_regexp_decoy.indexIn(accession, 0) > -1)) + { + protein_in.get()->setIsDecoy(true); } - //qDebug() << "ProteinStore::setProteinInformations end"; + // qDebug() << "ProteinStore::setProteinInformations end"; } diff --git a/src/utils/proteinstore.h b/src/utils/proteinstore.h index 9a6e1541896144a71131147fcfb89ba93a212328..4d84a4c41cfb717976c2afdfacda93f1910882ae 100644 --- a/src/utils/proteinstore.h +++ b/src/utils/proteinstore.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef PROTEINSTORE_H @@ -43,52 +44,51 @@ class FastaFile; class ProteinStore { -public: - ProteinStore(); - ~ProteinStore(); - - ProteinXtpSp & getInstance(ProteinXtpSp & protein_in); - - void setRegexpDecoyPattern(const QString & pattern); - - QRegExp getRegexpDecoy() const; - - void setRegexpContaminantPattern(const QString & pattern); - - QRegExp getRegexpContaminant() const; - - void addContaminantFastaFile(const FastaFile * p_fasta_file); - void addDecoyFastaFile(const FastaFile * p_fasta_file); - - const std::vector<const FastaFile *> & getContaminantFastaFileList() const; - const std::vector<const FastaFile *> & getDecoyFastaFileList() const; - - - void clearContaminants(); - void clearDecoys(); - - void setContaminantAccession(QString accession); - void setDecoyAccession(QString accession); - std::size_t size() const; - - const std::map<QString, ProteinXtpSp> & getProteinMap() const; - -private : - void setProteinInformations(ProteinXtpSp & protein_in); -private : - - std::map<QString, ProteinXtpSp> _map_accession_protein_list; - - /** \brief decoy Fasta file liste */ - std::vector<const FastaFile *> _fasta_decoy_list; - /** \brief contaminant Fasta file liste */ - std::vector<const FastaFile *> _fasta_contaminant_list; - - /** \brief recognize decoy accession */ - QRegExp _regexp_decoy; - /** \brief recognize contaminant accession */ - QRegExp _regexp_contaminant; + public: + ProteinStore(); + ~ProteinStore(); + ProteinXtpSp &getInstance(ProteinXtpSp &protein_in); + + void setRegexpDecoyPattern(const QString &pattern); + + QRegExp getRegexpDecoy() const; + + void setRegexpContaminantPattern(const QString &pattern); + + QRegExp getRegexpContaminant() const; + + void addContaminantFastaFile(const FastaFile *p_fasta_file); + void addDecoyFastaFile(const FastaFile *p_fasta_file); + + const std::vector<const FastaFile *> &getContaminantFastaFileList() const; + const std::vector<const FastaFile *> &getDecoyFastaFileList() const; + + + void clearContaminants(); + void clearDecoys(); + + void setContaminantAccession(QString accession); + void setDecoyAccession(QString accession); + std::size_t size() const; + + const std::map<QString, ProteinXtpSp> &getProteinMap() const; + + private: + void setProteinInformations(ProteinXtpSp &protein_in); + + private: + std::map<QString, ProteinXtpSp> _map_accession_protein_list; + + /** \brief decoy Fasta file liste */ + std::vector<const FastaFile *> _fasta_decoy_list; + /** \brief contaminant Fasta file liste */ + std::vector<const FastaFile *> _fasta_contaminant_list; + + /** \brief recognize decoy accession */ + QRegExp _regexp_decoy; + /** \brief recognize contaminant accession */ + QRegExp _regexp_contaminant; }; #endif // PROTEINSTORE_H diff --git a/src/utils/types.h b/src/utils/types.h index c80ad03ccc3679b4368284fdef4e1973eeaec38f..91f06ca306b7d68dd635afc5021ce5ac49796bce 100644 --- a/src/utils/types.h +++ b/src/utils/types.h @@ -73,20 +73,22 @@ enum class PeptideEvidenceParam : std::int8_t 3, ///< PSI-MS MS:1001172 mascot:expectation value 2.42102904673618e-006 peptide_prophet_probability = 4, ///< no PSI MS description peptide_inter_prophet_probability = 5, ///< no PSI MS description - omssa_evalue = 6, ///< MS:1001328 "OMSSA E-value." [PSI:PI] - omssa_pvalue = 7, ///< MS:1001329 "OMSSA p-value." [PSI:PI] - msgfplus_raw = 8, ///< MS:1002049 "MS-GF raw score." [PSI:PI] - msgfplus_denovo = 9, ///< MS:1002050 "MS-GF de novo score." [PSI:PI] - msgfplus_energy = 10, ///< MS:1002051 "MS-GF energy score." [PSI:PI] + omssa_evalue = 6, ///< MS:1001328 "OMSSA E-value." [PSI:PI] + omssa_pvalue = 7, ///< MS:1001329 "OMSSA p-value." [PSI:PI] + msgfplus_raw = 8, ///< MS:1002049 "MS-GF raw score." [PSI:PI] + msgfplus_denovo = 9, ///< MS:1002050 "MS-GF de novo score." [PSI:PI] + msgfplus_energy = 10, ///< MS:1002051 "MS-GF energy score." [PSI:PI] msgfplus_SpecEValue = 11, ///< MS:1002052 "MS-GF spectral E-value." [PSI:PI] - msgfplus_EValue = 12, ///< MS:1002053 "MS-GF E-value." [PSI:PI] + msgfplus_EValue = 12, ///< MS:1002053 "MS-GF E-value." [PSI:PI] msgfplus_isotope_error = 13, ///< MS-GF isotope error - comet_xcorr = 14, ///< MS:1002252 "The Comet result 'XCorr'." [PSI:PI] + comet_xcorr = 14, ///< MS:1002252 "The Comet result 'XCorr'." [PSI:PI] comet_deltacn = 15, ///< MS:1002253 "The Comet result 'DeltaCn'." [PSI:PI] - comet_deltacnstar = 16, ///< MS:1002254 "The Comet result 'DeltaCnStar'." [PSI:PI] + comet_deltacnstar = + 16, ///< MS:1002254 "The Comet result 'DeltaCnStar'." [PSI:PI] comet_spscore = 17, ///< MS:1002255 "The Comet result 'SpScore'." [PSI:PI] - comet_sprank = 18, ///< MS:1002256 "The Comet result 'SpRank'." [PSI:PI] - comet_expectation_value = 19, ///< MS:1002257 "The Comet result 'Expectation value'." [PSI:PI] + comet_sprank = 18, ///< MS:1002256 "The Comet result 'SpRank'." [PSI:PI] + comet_expectation_value = + 19, ///< MS:1002257 "The Comet result 'Expectation value'." [PSI:PI] }; @@ -124,9 +126,9 @@ enum class MsRunStatistics : std::int8_t total_spectra_ms1 = 2, ///< total number of MS1 spectra total_spectra_ms2 = 3, ///< total number of MS2 spectra total_spectra_ms3 = 4, ///< total number of MS3 spectra - tic_spectra_ms1 = 5, ///< total ion current in MS1 spectra - tic_spectra_ms2 = 6, ///< total ion current in MS2 spectra - tic_spectra_ms3 = 7, ///< total ion current in MS3 spectra + tic_spectra_ms1 = 5, ///< total ion current in MS1 spectra + tic_spectra_ms2 = 6, ///< total ion current in MS2 spectra + tic_spectra_ms3 = 7, ///< total ion current in MS3 spectra }; diff --git a/src/utils/workmonitor.cpp b/src/utils/workmonitor.cpp index e1294423fc6874952f7669b2d6c003234d9829ef..c80a0a2e647a552f8fd84e1b7bfab05770fdd8c3 100644 --- a/src/utils/workmonitor.cpp +++ b/src/utils/workmonitor.cpp @@ -7,64 +7,81 @@ /******************************************************************************* -* 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 "workmonitor.h" #include <QDebug> -WorkMonitor::WorkMonitor() { - _max_value = 100; - _timer_duration = 200; - _time.restart(); +WorkMonitor::WorkMonitor() +{ + _max_value = 100; + _timer_duration = 200; + _time.restart(); } -void WorkMonitor::finished(const QString & message) { - emit workerJobFinished(message); +void +WorkMonitor::finished(const QString &message) +{ + emit workerJobFinished(message); } -void WorkMonitor::message(const QString & message) { - if (_time.elapsed() > _timer_duration) { - _time.currentTime(); - emit workerMessage(message); +void +WorkMonitor::message(const QString &message) +{ + if(_time.elapsed() > _timer_duration) + { + _time.currentTime(); + emit workerMessage(message); } } -void WorkMonitor::message(const QString & message, int value) { - qDebug() << "WorkMonitor::message " << value << " " << _max_value << " " << (value/_max_value)*100; - if (_time.elapsed() > _timer_duration) { - int percent = ((float)value/(float)_max_value)*(float)100; +void +WorkMonitor::message(const QString &message, int value) +{ + qDebug() << "WorkMonitor::message " << value << " " << _max_value << " " + << (value / _max_value) * 100; + if(_time.elapsed() > _timer_duration) + { + int percent = ((float)value / (float)_max_value) * (float)100; - _time.restart(); - emit workerMessagePercent(message,percent); + _time.restart(); + emit workerMessagePercent(message, percent); } } -void WorkMonitor::setProgressMaximumValue(int max_value) { - //qDebug() << "WorkMonitor::setProgressMaximumValue " << max_value; - _max_value = max_value; +void +WorkMonitor::setProgressMaximumValue(int max_value) +{ + // qDebug() << "WorkMonitor::setProgressMaximumValue " << max_value; + _max_value = max_value; } -void WorkMonitor::appendText(char * p_char) { - //qDebug() << "WorkMonitor::setProgressMaximumValue " << max_value; - emit workerAppendText(p_char); +void +WorkMonitor::appendText(char *p_char) +{ + // qDebug() << "WorkMonitor::setProgressMaximumValue " << max_value; + emit workerAppendText(p_char); } -void WorkMonitor::setText(const QString text) { - emit workerSetText(text); +void +WorkMonitor::setText(const QString text) +{ + emit workerSetText(text); } diff --git a/src/utils/workmonitor.h b/src/utils/workmonitor.h index 4c45540e5a384dbd156b7134927becf011587573..73818ac8b13ec67759b619409c23920a22efaa5d 100644 --- a/src/utils/workmonitor.h +++ b/src/utils/workmonitor.h @@ -7,26 +7,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 + ******************************************************************************/ #ifndef WORKMONITOR_H #define WORKMONITOR_H @@ -36,38 +37,38 @@ class WorkMonitorInterface { -public: - virtual void finished(const QString & message) = 0; - virtual void message(const QString & message) = 0; - virtual void message(const QString & message, int value) = 0; - virtual void setProgressMaximumValue(int max_value) = 0; - virtual void appendText(char * p_char) =0; - virtual void setText(const QString text)=0; + public: + virtual void finished(const QString &message) = 0; + virtual void message(const QString &message) = 0; + virtual void message(const QString &message, int value) = 0; + virtual void setProgressMaximumValue(int max_value) = 0; + virtual void appendText(char *p_char) = 0; + virtual void setText(const QString text) = 0; }; -class WorkMonitor: public QObject, public WorkMonitorInterface +class WorkMonitor : public QObject, public WorkMonitorInterface { - Q_OBJECT -public: - WorkMonitor(); - void finished(const QString & message) override; - void message(const QString & message) override; - void message(const QString & message, int value) override; - void setProgressMaximumValue(int max_value) override; - void appendText(char * p_char) override; - void setText(const QString text) override; + Q_OBJECT + public: + WorkMonitor(); + void finished(const QString &message) override; + void message(const QString &message) override; + void message(const QString &message, int value) override; + void setProgressMaximumValue(int max_value) override; + void appendText(char *p_char) override; + void setText(const QString text) override; -signals: - void workerJobFinished(QString message); - void workerMessage(QString message); - void workerMessagePercent(QString message, int value); - void workerAppendText(char * p_char); - void workerSetText(QString text); + signals: + void workerJobFinished(QString message); + void workerMessage(QString message); + void workerMessagePercent(QString message, int value); + void workerAppendText(char *p_char); + void workerSetText(QString text); -private : - QTime _time; - int _max_value; - int _timer_duration; + private: + QTime _time; + int _max_value; + int _timer_duration; }; #endif // WORKMONITOR_H