diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b186818603e05ae6d2410a1a55deb7466c03fd02..885ed02d186d614ff43e131d213a1fda6a1b50f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,6 +72,7 @@ SET(CPP_FILES output/masschroqml.cpp output/ods/odsexport.cpp output/ods/simplesheet.cpp + utils/fastafilestore.cpp utils/identificationdatasourcestore.cpp utils/groupstore.cpp utils/msrunstore.cpp @@ -109,7 +110,7 @@ SET(XTPCPP_SRCS ) SET (GUI_UIS - ./gui/choose_modification_dialog/choose_modification_dialog.uicpp + ./gui/choose_modification_dialog/choose_modification_dialog.ui ./gui/edit_label_methods/edit_label_methods.ui ./gui/edit_modifications/edit_modifications.ui ./gui/export_spreadsheet_dialog/export_spreadsheet_dialog.ui diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp index dd06ce03a8d9120d3f14e03036cf5bb471681f96..4e377f01d0e138e7a1650043dc6d50153b7647ce 100644 --- a/src/core/identification_sources/identificationdatasource.cpp +++ b/src/core/identification_sources/identificationdatasource.cpp @@ -26,6 +26,8 @@ #include <QFileInfo> #include "../../utils/readspectrum.h" +FastaFileStore IdentificationDataSource::_fasta_file_store; + IdentificationDataSource::IdentificationDataSource(const QString resource_name) { _resource_name = resource_name; @@ -82,5 +84,9 @@ pappso::SpectrumSp IdentificationDataSource::getSpectrumSp(unsigned int scan_num } void IdentificationDataSource::addFastaFile (FastaFile file) { - _fastafile_list.push_back(file); + _fastafile_list.push_back(IdentificationDataSource::_fasta_file_store.getInstance(file)); +} +const std::vector<FastaFileSp> & IdentificationDataSource::getFastaFileList() const { + qDebug()<< "IdentificationDataSource::getFastaFileList begin" << _fastafile_list.size(); + return _fastafile_list; } diff --git a/src/core/identification_sources/identificationdatasource.h b/src/core/identification_sources/identificationdatasource.h index 3d4b51f2b5b0fc17d461a3d2b08f3a9b6fc9e106..f5a7d0e8877d5ebfd500f209ee363fcfc19dce5b 100644 --- a/src/core/identification_sources/identificationdatasource.h +++ b/src/core/identification_sources/identificationdatasource.h @@ -27,7 +27,7 @@ #include <pappsomspp/spectrum/spectrum.h> #include <memory> #include "../msrun.h" -#include "../../files/fastafile.h" +#include "../../utils/fastafilestore.h" class Project; @@ -74,16 +74,19 @@ public: /** \brief add Fastafile used by the identification engine */ void addFastaFile (FastaFile file); + + const std::vector<FastaFileSp> & getFastaFileList() const; protected : QString _resource_name; IdentificationEngine _engine = IdentificationEngine::unknown; private : //static std::map<QString, pappso::MsRunIdSp> _map_msrunidsp; + static FastaFileStore _fasta_file_store; QString _version; MsRunSp _ms_run_sp = nullptr; std::map<IdentificationEngineParam, QString> _params; - std::vector<FastaFile> _fastafile_list; + std::vector<FastaFileSp> _fastafile_list; }; #endif // IDENTIFICATIONDATASOURCE_H diff --git a/src/core/project.h b/src/core/project.h index 544de7dc9934dc398de76e86d851a238f6db64f2..5f454f4047d61f0a6eed792099bd640eccd5fbb4 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -83,6 +83,7 @@ private : PeptideStore _peptide_store; IdentificationDataSourceStore _identification_data_source_store; MsRunStore _msrun_store; + }; #endif // PROJECT_H diff --git a/src/files/fastafile.cpp b/src/files/fastafile.cpp index 26d4c8358d68c426f2d9a38427f2b1cd2a069823..aa6694508907623c516fddf37525d528472d3bba 100644 --- a/src/files/fastafile.cpp +++ b/src/files/fastafile.cpp @@ -26,11 +26,6 @@ FastaFile::FastaFile(const QString & fasta_source) : _fasta_source(fasta_source) { -} - -FastaFile::FastaFile(const QUrl & fasta_source) : _fasta_source(fasta_source) -{ - } FastaFile::FastaFile(const QFileInfo & fasta_source): _fasta_source(fasta_source.absoluteFilePath()) { @@ -43,3 +38,16 @@ FastaFile::~FastaFile() { } + +bool FastaFile::operator<( const FastaFile& other ) const +{ + return (_fasta_source.absoluteFilePath() < other._fasta_source.absoluteFilePath()); +} +bool FastaFile::operator==( const FastaFile& other ) const +{ + return (_fasta_source == other._fasta_source); +} + +const QString FastaFile::getFilename() const { + return _fasta_source.fileName(); +} diff --git a/src/files/fastafile.h b/src/files/fastafile.h index 3e3c90a390bedf164b6d92b0817b969d0e9a329f..263bf587d8fd8fb25016865962da371e271ebe1d 100644 --- a/src/files/fastafile.h +++ b/src/files/fastafile.h @@ -24,19 +24,26 @@ #ifndef FASTAFILE_H #define FASTAFILE_H -#include <QUrl> #include <QFileInfo> +#include <memory> + +class FastaFile; +typedef std::shared_ptr<FastaFile> FastaFileSp; + class FastaFile { public: FastaFile(const QString & fasta_source); - FastaFile(const QUrl & fasta_source); FastaFile(const QFileInfo & fasta_source); FastaFile(const FastaFile & other); ~FastaFile(); + bool operator<( const FastaFile& other ) const; + bool operator==( const FastaFile& other ) const; + + const QString getFilename() const; private : - const QUrl _fasta_source; + const QFileInfo _fasta_source; }; diff --git a/src/gui/choose_modification_dialog/choosemodificationdialog.cpp b/src/gui/choose_modification_dialog/choosemodificationdialog.cpp index fc0c9bc5a54791818e19f530c177195aff79b2e3..e8a889206b5c58bb0cbeba3ee26b81f56a2974b7 100644 --- a/src/gui/choose_modification_dialog/choosemodificationdialog.cpp +++ b/src/gui/choose_modification_dialog/choosemodificationdialog.cpp @@ -44,7 +44,7 @@ ChooseModificationDialog::ChooseModificationDialog(QWidget * parent): _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 /* @@ -68,27 +68,27 @@ ChooseModificationDialog::~ChooseModificationDialog() } void ChooseModificationDialog::setMassRange(const pappso::MassRange & massrange) { - - qDebug() << "ChooseModificationDialog::setMassRange " << massrange.toString(); - _selected_modification = nullptr; + + 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); - } + 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); + } } @@ -108,6 +108,6 @@ void ChooseModificationDialog::ItemClicked (QModelIndex index ) _selected_modification = modification; } - pappso::AaModificationP ChooseModificationDialog::getSelectedModification()const { - return _selected_modification; - } +pappso::AaModificationP ChooseModificationDialog::getSelectedModification()const { + return _selected_modification; +} diff --git a/src/gui/project_view/project_view.ui b/src/gui/project_view/project_view.ui index bcff87cae093fc912e8936e7c7adb37cb86bd67f..f45e0bde2451651437545c2180993d9429b147f1 100644 --- a/src/gui/project_view/project_view.ui +++ b/src/gui/project_view/project_view.ui @@ -20,8 +20,11 @@ <property name="enabled"> <bool>true</bool> </property> + <property name="toolTip"> + <string/> + </property> <property name="currentIndex"> - <number>0</number> + <number>2</number> </property> <widget class="QWidget" name="identifications"> <attribute name="title"> @@ -64,6 +67,9 @@ </layout> </widget> <widget class="QWidget" name="fdr"> + <property name="toolTip"> + <string/> + </property> <attribute name="title"> <string>FDR</string> </attribute> @@ -72,6 +78,9 @@ <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QGroupBox" name="groupBox_3"> + <property name="toolTip"> + <string/> + </property> <property name="title"> <string>FDR</string> </property> @@ -85,6 +94,9 @@ </item> <item row="0" column="1"> <widget class="QLabel" name="peptide_fdr_label"> + <property name="toolTip"> + <string>FDR is computed using peptides tagged as "decoy" on all valid peptides (check filter parameters)</string> + </property> <property name="text"> <string>0 %</string> </property> @@ -99,6 +111,9 @@ </item> <item row="1" column="1"> <widget class="QLabel" name="protein_fdr_label"> + <property name="toolTip"> + <string>FDR is computed using proteins tagged as "decoy" on all valid proteins (check filter parameters)</string> + </property> <property name="text"> <string>0 %</string> </property> @@ -114,7 +129,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_3"> <item> - <widget class="QListWidget" name="decoy_database_list_widget"/> + <widget class="QListView" name="decoy_database_listview"/> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout"> @@ -188,6 +203,9 @@ </layout> </widget> <widget class="QWidget" name="mass_precision"> + <property name="toolTip"> + <string/> + </property> <attribute name="title"> <string>Mass precision</string> </attribute> @@ -250,6 +268,9 @@ </item> <item row="3" column="1"> <widget class="QLabel" name="mass_precision_sd_label"> + <property name="toolTip"> + <string>Mass deviation is computed on all valid and checked proteins but not decoy</string> + </property> <property name="text"> <string>0</string> </property> diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 92fc2c5368696b9404827bc4329a5a780a8ca6d7..48254de5cbcb055edb12c6af56826589706fddb6 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -43,6 +43,9 @@ ProjectWindow::ProjectWindow(MainWindow *parent): main_window = parent; ui->setupUi(this); + _p_fasta_str_li = new QStandardItemModel(); + ui->decoy_database_listview->setModel(_p_fasta_str_li); + _p_automatic_filter_widget = new AutomaticFilterWidget(this); ui->filter_parameter_layout->addWidget(_p_automatic_filter_widget); @@ -206,7 +209,7 @@ void ProjectWindow::refresh() { computeFdr(ValidationState::valid); computeMassPrecision(ValidationState::validAndChecked); qDebug() << "ProjectWindow::refresh end "; - + } void ProjectWindow::doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters) { qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged begin "; @@ -341,7 +344,20 @@ void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_grou } void ProjectWindow::setProjectSp(ProjectSp project_sp) { + + _fastafile_list = _project_sp.get()->getIdentificationDataSourceStore().getFastaFileList(); + + /* + for (FastaFileSp fasta_file : _fastafile_list ) { + QStandardItem *item; + item = new QStandardItem(QString("%1").arg(fasta_file.get()->getFilename())); + item->setEditable(false); + _p_fasta_str_li->appendRow(item); + item->setData(QVariant(QString("%1").arg(fasta_file.get()->getFilename())),Qt::UserRole); + } + */ + for (auto && p_window :_peptide_list_window_collection) { delete p_window; } @@ -402,9 +418,8 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { ui->decoy_protein_regexp_line_edit->setText(_project_sp.get()->getProteinStore().getRegexpDecoy().pattern()); ui->contaminant_protein_regexp_line_edit->setText(_project_sp.get()->getProteinStore().getRegexpContaminant().pattern()); - computeFdr(ValidationState::grouped); - - computeMassPrecision(ValidationState::validAndChecked); + + refresh(); this->setEnabled(true); } diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h index a2c680802c737c5a1fa335a55e66f9420b4208a5..02144ec1dc7467b28190109ec23c506c781de0d9 100644 --- a/src/gui/project_view/projectwindow.h +++ b/src/gui/project_view/projectwindow.h @@ -25,6 +25,7 @@ #define PROJECTWINDOW_H #include <QMainWindow> +#include <set> #include "../../core/project.h" #include "../edit_label_methods/editlabelmethods.h" #include "../edit_modifications/editmodifications.h" @@ -102,6 +103,9 @@ private: EditLabelMethods * _p_edit_label_methods = nullptr; ProjectSp _project_sp; + + QStandardItemModel * _p_fasta_str_li; + std::set<FastaFileSp> _fastafile_list; }; diff --git a/src/utils/fastafilestore.cpp b/src/utils/fastafilestore.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d07b8ba6bf9eeddf9cf961c9d571b1e497bf790c --- /dev/null +++ b/src/utils/fastafilestore.cpp @@ -0,0 +1,63 @@ +/** + * \file utils/fastafiletore.cpp + * \date 22/4/2017 + * \author Olivier Langella + * \brief store unique version of fastafile + */ + + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public 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" +FastaFileStore::FastaFileStore() +{ + +} + +FastaFileStore::~FastaFileStore() +{ + +} + +FastaFileSp FastaFileStore::getInstance(const FastaFile & location) { + + std::map< FastaFile, FastaFileSp >::iterator it = _map_fastafile.find(location); + if (it != _map_fastafile.end()) { + return it->second; + } + else { + FastaFileSp p_xtfile = std::make_shared<FastaFile>(location); + _map_fastafile.insert(std::pair< FastaFile, FastaFileSp >(location, p_xtfile)); + return p_xtfile; + + } +} + + +std::vector<FastaFileSp> FastaFileStore::getFastaFileList() const { + std::vector<FastaFileSp> msrun_list; + for (auto & msrun_pair :_map_fastafile) { + msrun_list.push_back(msrun_pair.second); + } + return msrun_list; +} diff --git a/src/utils/fastafilestore.h b/src/utils/fastafilestore.h new file mode 100644 index 0000000000000000000000000000000000000000..a5cca3cc0e6fa2486646b8c2b8cc8e4d5abff664 --- /dev/null +++ b/src/utils/fastafilestore.h @@ -0,0 +1,52 @@ +/** + * \file utils/fastafiletore.h + * \date 22/4/2017 + * \author Olivier Langella + * \brief store unique version of fastafile + */ + + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public 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 + +#include <map> +#include <vector> +#include "../files/fastafile.h" + +class FastaFileStore +{ +public: + FastaFileStore(); + ~FastaFileStore(); + + FastaFileSp getInstance(const FastaFile & fastafile); + + std::vector<FastaFileSp> getFastaFileList() const; +private: + std::map<FastaFile, FastaFileSp> _map_fastafile; +}; + + +#endif // FASTAFILESTORE_H diff --git a/src/utils/identificationdatasourcestore.cpp b/src/utils/identificationdatasourcestore.cpp index 04e37584f6c21368d278f256613b7b3f83768dd3..003800f7859d6218cda17fc81e9ba47829b2b4ab 100644 --- a/src/utils/identificationdatasourcestore.cpp +++ b/src/utils/identificationdatasourcestore.cpp @@ -43,7 +43,8 @@ IdentificationDataSourceStore::~IdentificationDataSourceStore() } 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; @@ -62,3 +63,17 @@ IdentificationDataSourceSp IdentificationDataSourceStore::getInstance(const QStr } throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized").arg(location)); } + +std::set<FastaFileSp> IdentificationDataSourceStore::getFastaFileList() const { + qDebug()<< "IdentificationDataSourceStore::getFastaFileList begin "; + std::set<FastaFileSp> list_fasta_set; + /* + for (auto pair_ident:_map_identification_data_sources) { + qDebug()<< "IdentificationDataSourceStore::getFastaFileList 1"; + std::vector<FastaFileSp> idfastalist = pair_ident.second.get()->getFastaFileList(); + list_fasta_set.insert(idfastalist.begin(), idfastalist.end()); + } + */ + qDebug()<< "IdentificationDataSourceStore::getFastaFileList end"; + return list_fasta_set; +} diff --git a/src/utils/identificationdatasourcestore.h b/src/utils/identificationdatasourcestore.h index cfef38ee8f7e425a7582d0ad0600d5034c508474..3262a49eb40e9794cb09c4a6a8c30a040abb0bbc 100644 --- a/src/utils/identificationdatasourcestore.h +++ b/src/utils/identificationdatasourcestore.h @@ -32,7 +32,9 @@ #define IDENTIFICATIONDATASOURCESTORE_H #include <map> +#include <set> #include "../core/identification_sources/identificationdatasource.h" +#include "../files/fastafile.h" class IdentificationDataSourceStore { @@ -40,6 +42,8 @@ public: IdentificationDataSourceStore(); ~IdentificationDataSourceStore(); IdentificationDataSourceSp getInstance(const QString & location); + + std::set<FastaFileSp> getFastaFileList() const; private : std::map<QString, IdentificationDataSourceSp> _map_identification_data_sources; };