diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp index 4e377f01d0e138e7a1650043dc6d50153b7647ce..0e0780733634433651614375d9f05531a12daee3 100644 --- a/src/core/identification_sources/identificationdatasource.cpp +++ b/src/core/identification_sources/identificationdatasource.cpp @@ -26,7 +26,6 @@ #include <QFileInfo> #include "../../utils/readspectrum.h" -FastaFileStore IdentificationDataSource::_fasta_file_store; IdentificationDataSource::IdentificationDataSource(const QString resource_name) { @@ -83,8 +82,8 @@ pappso::SpectrumSp IdentificationDataSource::getSpectrumSp(unsigned int scan_num return spectrum_sp; } -void IdentificationDataSource::addFastaFile (FastaFile file) { - _fastafile_list.push_back(IdentificationDataSource::_fasta_file_store.getInstance(file)); +void IdentificationDataSource::addFastaFile (FastaFileSp file) { + _fastafile_list.push_back(file); } const std::vector<FastaFileSp> & IdentificationDataSource::getFastaFileList() const { qDebug()<< "IdentificationDataSource::getFastaFileList begin" << _fastafile_list.size(); diff --git a/src/core/identification_sources/identificationdatasource.h b/src/core/identification_sources/identificationdatasource.h index f5a7d0e8877d5ebfd500f209ee363fcfc19dce5b..efb09f341c4cd3360d2bdd02d8c118aa957b3243 100644 --- a/src/core/identification_sources/identificationdatasource.h +++ b/src/core/identification_sources/identificationdatasource.h @@ -73,7 +73,7 @@ public: /** \brief add Fastafile used by the identification engine */ - void addFastaFile (FastaFile file); + void addFastaFile (FastaFileSp file); const std::vector<FastaFileSp> & getFastaFileList() const; @@ -82,7 +82,6 @@ protected : 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; diff --git a/src/core/project.cpp b/src/core/project.cpp index be9f6dde316963b6294ce662ced493cbb7e31c43..e4d78b800e90e701d8f85174c4f9ab9b30d80859 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -65,6 +65,9 @@ const GroupingType Project::getGroupingType() const { return _grouping_type; } +FastaFileStore & Project::getFastaFileStore() { + return _fasta_file_store; +} MsRunStore & Project::getMsRunStore() { return _msrun_store; } diff --git a/src/core/project.h b/src/core/project.h index 5f454f4047d61f0a6eed792099bd640eccd5fbb4..73a8b06b8f6b486842672ab22a3e43a4d35de5d0 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -48,6 +48,7 @@ public: ProteinStore & getProteinStore(); PeptideStore & getPeptideStore(); MsRunStore & getMsRunStore(); + FastaFileStore & getFastaFileStore(); IdentificationDataSourceStore & getIdentificationDataSourceStore(); void readXpipFile(QFileInfo xpip_source); IdentificationGroup* newIdentificationGroup(); @@ -83,6 +84,7 @@ private : PeptideStore _peptide_store; IdentificationDataSourceStore _identification_data_source_store; MsRunStore _msrun_store; + FastaFileStore _fasta_file_store; }; diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index 9265c6292e14a4a5f6494e9249fe818301c97d89..d44f1fe72868028860c843dcb1b262773609fcec 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -62,7 +62,7 @@ bool ProteinMatch::contains(PeptideMatch * peptide_match) const { } void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) { - qDebug() <<"ProteinMatch::updateAutomaticFilters begin " ; + //qDebug() <<"ProteinMatch::updateAutomaticFilters begin " ; _proxy_valid = false; unsigned int number_of_valid_peptides =0; bool cross_sample = automatic_filter_parameters.getFilterCrossSamplePeptideNumber(); @@ -102,7 +102,7 @@ void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & auto } } } - qDebug() <<"ProteinMatch::updateAutomaticFilters end " << number_of_valid_peptides ; + //qDebug() <<"ProteinMatch::updateAutomaticFilters end " << number_of_valid_peptides ; } const ProteinXtpSp & ProteinMatch::getProteinXtpSp() const { @@ -213,7 +213,7 @@ unsigned int ProteinMatch::countSequenceLi(ValidationState state, const MsRun * } } } - qDebug() <<"ProteinMatch::countValidAndCheckedPeptide end " << sequence_list.size(); + //qDebug() <<"ProteinMatch::countValidAndCheckedPeptide end " << sequence_list.size(); return sequence_list.size(); } diff --git a/src/files/fastafile.cpp b/src/files/fastafile.cpp index aa6694508907623c516fddf37525d528472d3bba..2ac6b0dac093c8d5b24963d7c12a3949c4938b7c 100644 --- a/src/files/fastafile.cpp +++ b/src/files/fastafile.cpp @@ -27,7 +27,7 @@ FastaFile::FastaFile(const QString & fasta_source) : _fasta_source(fasta_source) { } -FastaFile::FastaFile(const QFileInfo & fasta_source): _fasta_source(fasta_source.absoluteFilePath()) +FastaFile::FastaFile(const QFileInfo & fasta_source): _fasta_source(fasta_source) { } FastaFile::FastaFile(const FastaFile & other) : _fasta_source(other._fasta_source) @@ -39,15 +39,10 @@ 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(); } + +const QString FastaFile::getAbsoluteFilePath() const { + return _fasta_source.absoluteFilePath(); +} diff --git a/src/files/fastafile.h b/src/files/fastafile.h index 263bf587d8fd8fb25016865962da371e271ebe1d..1ba9082722017218d2059dbd6df7d04e06be5fce 100644 --- a/src/files/fastafile.h +++ b/src/files/fastafile.h @@ -38,10 +38,10 @@ public: FastaFile(const FastaFile & other); ~FastaFile(); - bool operator<( const FastaFile& other ) const; - bool operator==( const FastaFile& other ) const; const QString getFilename() const; + const QString getAbsoluteFilePath() const; + private : const QFileInfo _fasta_source; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index b6b27e37844bad5e3d058212fe4c1b9f680b420f..496fb71d913fa7049770f899198ede409d67b27b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -219,7 +219,10 @@ void MainWindow::doProjectReady(ProjectSp project_sp) { qDebug() << "MainWindow::doProjectReady begin"; try { + 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() ; doDisplayLoadingMessage(tr("grouping proteins")); project_sp.get()->startGrouping(); doDisplayLoadingMessage(tr("grouping proteins finished")); diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 7e6294f1b82d8e1ac13366339c124c632cfea86c..780eaa948f8675af91794363fb6dadc998630835 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -346,8 +346,12 @@ void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_grou } void ProjectWindow::setProjectSp(ProjectSp project_sp) { + qDebug() << "ProjectWindow::setProjectSp begin" ; - _fastafile_list = _project_sp.get()->getIdentificationDataSourceStore().getFastaFileList(); + _project_sp = project_sp; + + qDebug() << "ProjectWindow::setProjectSp begin " << _project_sp.get()->getFastaFileStore().getFastaFileList().size() ; + _fastafile_list = _project_sp.get()->getFastaFileStore().getFastaFileList(); for (FastaFileSp fasta_file : _fastafile_list ) { @@ -384,8 +388,6 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { _peptide_detail_window_collection.clear(); _p_current_peptide_detail_window = nullptr; - _project_sp = project_sp; - if (_p_identification_widget != nullptr) { delete _p_identification_widget; } diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h index 5d3882f18efba7bd0890874bd8068bf29d9e9f49..daae90f48023610da4ebe699b5285649e8d96d8f 100644 --- a/src/gui/project_view/projectwindow.h +++ b/src/gui/project_view/projectwindow.h @@ -105,7 +105,7 @@ private: ProjectSp _project_sp; QStandardItemModel * _p_fasta_str_li; - std::set<FastaFileSp> _fastafile_list; + std::vector<FastaFileSp> _fastafile_list; }; diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index e925bd943f1db5c6175329465a05860d5ba85ac9..a8f9b20c5037140f55181994e44833d469f7ac06 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -215,6 +215,7 @@ bool XpipSaxHandler::startElement_protein(QXmlAttributes attributes) { </protein> */ _current_protein.setCompleteDescription(attributes.value("description")); + _current_fasta_file_sp = _p_project->getFastaFileStore().getInstance(FastaFile(attributes.value("URL"))); qDebug() << "startElement_protein end" ; return true; } @@ -247,6 +248,7 @@ bool XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) { 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()")); } + p_identification_data_source->addFastaFile(_current_fasta_file_sp); _p_peptide_match->setChecked(false); if (attributes.value("validate").simplified().toLower() == "true") { _p_peptide_match->setChecked(true); diff --git a/src/input/xpipsaxhandler.h b/src/input/xpipsaxhandler.h index dc172caa0c7ccb084577dd1e510e8830bcaab77a..f7f3feeb8f2a565ee080e94137e13a89b723976d 100644 --- a/src/input/xpipsaxhandler.h +++ b/src/input/xpipsaxhandler.h @@ -85,6 +85,7 @@ private: ProteinXtp _current_protein; PeptideXtpSp _current_peptide_sp; IdentificationGroup * _current_identification_group_p; + FastaFileSp _current_fasta_file_sp; QMap<QString, pappso::AaModificationP> _map_massstr_aamod; }; diff --git a/src/input/xtandemsaxhandler.cpp b/src/input/xtandemsaxhandler.cpp index e1649cf2f907850332f23cf7fe632ec602a49f54..58c59468c29aee9aaa7deeb16de7acc95160a335 100644 --- a/src/input/xtandemsaxhandler.cpp +++ b/src/input/xtandemsaxhandler.cpp @@ -449,8 +449,8 @@ bool XtandemSaxHandler::endElement_note() { //<note label="list path, sequence source #1">/gorgone/pappso/formation/TD/Database/Genome_Z_mays_5a.fasta</note> //<note label="list path, sequence source #2">/gorgone/pappso/formation/TD/Database/contaminants_standarts.fasta</note> - if (_current_note_label.startsWith("list path, sequence source")) { - _p_identification_data_source->addFastaFile(FastaFile(_current_text)); + if (_current_note_label.startsWith("list path, sequence source #")) { + _p_identification_data_source->addFastaFile(_p_project->getFastaFileStore().getInstance( FastaFile(_current_text))); } /* diff --git a/src/utils/fastafilestore.cpp b/src/utils/fastafilestore.cpp index d07b8ba6bf9eeddf9cf961c9d571b1e497bf790c..ab5a58b4a468c10f18cf74e94955cedb1d31fd22 100644 --- a/src/utils/fastafilestore.cpp +++ b/src/utils/fastafilestore.cpp @@ -29,6 +29,7 @@ ******************************************************************************/ #include "fastafilestore.h" +#include <QDebug> FastaFileStore::FastaFileStore() { @@ -40,24 +41,27 @@ 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; - +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()->getAbsoluteFilePath() == location.getAbsoluteFilePath()) { + +qDebug() << "FastaFileStore::getInstance() end b "<< it->get()->getAbsoluteFilePath(); + return *it; + } + it++; } + FastaFileSp fastafile_sp = std::make_shared<FastaFile>(location); + _map_fastafile.push_back(fastafile_sp); + qDebug() << "FastaFileStore::getFastaFileList() end a " << _map_fastafile.size(); + return fastafile_sp; } -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; +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 a5cca3cc0e6fa2486646b8c2b8cc8e4d5abff664..af3e877b3d5b9c1ed3be2d13722969a66be30d06 100644 --- a/src/utils/fastafilestore.h +++ b/src/utils/fastafilestore.h @@ -31,7 +31,6 @@ #ifndef FASTAFILESTORE_H #define FASTAFILESTORE_H -#include <map> #include <vector> #include "../files/fastafile.h" @@ -43,9 +42,9 @@ public: FastaFileSp getInstance(const FastaFile & fastafile); - std::vector<FastaFileSp> getFastaFileList() const; + const std::vector<FastaFileSp> & getFastaFileList() const; private: - std::map<FastaFile, FastaFileSp> _map_fastafile; + std::vector<FastaFileSp> _map_fastafile; }; diff --git a/src/utils/identificationdatasourcestore.cpp b/src/utils/identificationdatasourcestore.cpp index 003800f7859d6218cda17fc81e9ba47829b2b4ab..012e65c8c76a30f3cc4b1321fe31c15c14eae0a5 100644 --- a/src/utils/identificationdatasourcestore.cpp +++ b/src/utils/identificationdatasourcestore.cpp @@ -63,17 +63,3 @@ qDebug() << " " << _map_identification_data_sources.size(); } 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 3262a49eb40e9794cb09c4a6a8c30a040abb0bbc..e634800fb964e3c4ffe9e30a7ef340ecf101583c 100644 --- a/src/utils/identificationdatasourcestore.h +++ b/src/utils/identificationdatasourcestore.h @@ -42,8 +42,6 @@ public: IdentificationDataSourceStore(); ~IdentificationDataSourceStore(); IdentificationDataSourceSp getInstance(const QString & location); - - std::set<FastaFileSp> getFastaFileList() const; private : std::map<QString, IdentificationDataSourceSp> _map_identification_data_sources; };