diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 88bd6083345d7c12e5b442119ebe69150e869631..2be9885af9288d4ccbd49068ffd6d724f77a834f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,8 +29,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 #sudo apt-get install libpappsomspp-dev #FIND_PACKAGE( Pappsomspp REQUIRED ) - SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") -# SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") +# SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") + SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so") @@ -69,6 +69,7 @@ SET(CPP_FILES grouping/groupingpeptidemass.cpp gui/peptide_detail_view/spectrum_widget/spectrumpainter.cpp input/xpipsaxhandler.cpp + utils/identificationdatasourcestore.cpp utils/groupstore.cpp utils/peptidestore.cpp utils/proteinstore.cpp diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp index dfaa29727dd18da29867a2854d6d69564b086933..6341285c15b97ea46f0a671244211bb6d3538cac 100644 --- a/src/core/identification_sources/identificationdatasource.cpp +++ b/src/core/identification_sources/identificationdatasource.cpp @@ -26,14 +26,6 @@ #include <QFileInfo> #include "../../utils/readspectrum.h" - -IdentificationDataSource::MapIdentificationDataSources IdentificationDataSource::_map_identification_data_sources = [] -{ - MapIdentificationDataSources ret; - - return ret; -}(); - IdentificationDataSource::IdentificationDataSource(const QString resource_name) { _resource_name = resource_name; @@ -55,31 +47,6 @@ bool IdentificationDataSource::operator==(const IdentificationDataSource& other) } -void IdentificationDataSource::clear() { - _map_identification_data_sources.clear(); -} - -IdentificationDataSource * IdentificationDataSource::getInstance(const QString & location) { - - std::map< QString, IdentificationDataSource* >::iterator it = IdentificationDataSource::_map_identification_data_sources.find(location); - if (it != IdentificationDataSource::_map_identification_data_sources.end()) { - return it->second; - } - else { - QFileInfo location_file(location); - QString ext = location_file.suffix(); - //QString sample_name = location_file.baseName(); - if (ext.toLower() == "xml") { - //X!Tandem result file - IdentificationXtandemFile * p_xtfile = new IdentificationXtandemFile(location_file); - _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location, p_xtfile)); - _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location_file.absoluteFilePath(), p_xtfile)); - return p_xtfile; - } - } - throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized").arg(location)); -} - const QString & IdentificationDataSource::getResourceName () const { return _resource_name; } diff --git a/src/core/identification_sources/identificationdatasource.h b/src/core/identification_sources/identificationdatasource.h index 4205c18d35bb7e61ad942e52283b15a64a533a62..eafcb169ea4892786b084b2c6516f6837dba30f7 100644 --- a/src/core/identification_sources/identificationdatasource.h +++ b/src/core/identification_sources/identificationdatasource.h @@ -26,17 +26,16 @@ #include <pappsomspp/msrun/msrunid.h> #include <pappsomspp/spectrum/spectrum.h> -#include <map> +#include <memory> +class IdentificationDataSource; +typedef std::shared_ptr<IdentificationDataSource> IdentificationDataSourceSp; + class IdentificationDataSource { public: - using MapIdentificationDataSources = std::map<QString, IdentificationDataSource *>; - static void clear(); - static IdentificationDataSource * getInstance(const QString & location); - IdentificationDataSource(const QString resource_name); IdentificationDataSource(const IdentificationDataSource& other); ~IdentificationDataSource(); @@ -53,7 +52,6 @@ public: protected : QString _resource_name; private : - static MapIdentificationDataSources _map_identification_data_sources; //static std::map<QString, pappso::MsRunIdSp> _map_msrunidsp; pappso::MsRunIdSp _ms_run_sp = nullptr; }; diff --git a/src/core/project.cpp b/src/core/project.cpp index 6139b6d20d64075dfb72a1f8a90b7d06d0919328..5b41ef2d9dee01253d0fb17f570f17278287da4c 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -42,7 +42,7 @@ std::vector<IdentificationGroup *> Project::getIdentificationGroupList() { return _identification_goup_list; } const GroupingType Project::getGroupingType() const { - return _grouping_type; + return _grouping_type; } PeptideStore & Project::getPeptideStore() { return _peptide_store; @@ -51,6 +51,10 @@ PeptideStore & Project::getPeptideStore() { ProteinStore & Project::getProteinStore() { return _protein_store; } + +IdentificationDataSourceStore & Project::getIdentificationDataSourceStore() { + return _identification_data_source_store; +} const AutomaticFilterParameters & Project::getAutomaticFilterParameters() const { return _automatic_filter_parameters; } @@ -101,7 +105,7 @@ void Project::readXpipFile(QFileInfo xpip_fileinfo) { } IdentificationGroup* Project::getCurrentIdentificationGroupP() const { - + qDebug() << "Project::getCurrentIdentificationGroupP begin " << _p_current_identification_group; return _p_current_identification_group; } diff --git a/src/core/project.h b/src/core/project.h index 880ac3e383bb019b09aea894b0b364d79f726d95..9fcb09358473e6fdc8292d9971c8ed6569e7c65e 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -29,6 +29,7 @@ #include "../utils/types.h" #include "../utils/peptidestore.h" #include "../utils/proteinstore.h" +#include "../utils/identificationdatasourcestore.h" class Project; typedef std::shared_ptr<Project> ProjectSp; @@ -45,6 +46,7 @@ public: ProjectSp makeProjectSp() const; ProteinStore & getProteinStore(); PeptideStore & getPeptideStore(); + IdentificationDataSourceStore & getIdentificationDataSourceStore(); void readXpipFile(QFileInfo xpip_source); IdentificationGroup* newIdentificationGroup(); IdentificationGroup* getCurrentIdentificationGroupP() const; @@ -69,6 +71,7 @@ private : ProteinStore _protein_store; PeptideStore _peptide_store; + IdentificationDataSourceStore _identification_data_source_store; }; #endif // PROJECT_H diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 6033fe6f5058681a1b058740ce95599593ed4a74..09c5e24807928e0654efb41a96ec1f2e7b9ec836 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -248,7 +248,7 @@ bool XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) { _p_peptide_match->setCharge(attributes.value("charge").simplified().toUInt()); - IdentificationDataSource* p_identification_data_source = IdentificationDataSource::getInstance(attributes.value("sample_file").simplified()); + IdentificationDataSource* p_identification_data_source = _p_project->getIdentificationDataSourceStore().getInstance(attributes.value("sample_file").simplified()).get(); _p_peptide_match->setIdentificationDataSource( p_identification_data_source); if (p_identification_data_source->getMsRunSp().get() == nullptr) { p_identification_data_source->setMsRunSp(ms_run_id); @@ -340,7 +340,6 @@ bool XpipSaxHandler::endDocument() { } bool XpipSaxHandler::startDocument() { - IdentificationDataSource::clear(); return true; } diff --git a/src/utils/identificationdatasourcestore.cpp b/src/utils/identificationdatasourcestore.cpp new file mode 100644 index 0000000000000000000000000000000000000000..04e37584f6c21368d278f256613b7b3f83768dd3 --- /dev/null +++ b/src/utils/identificationdatasourcestore.cpp @@ -0,0 +1,64 @@ +/** + * \file utils/identificationdatasourcestore.cpp + * \date 5/4/2017 + * \author Olivier Langella + * \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 +******************************************************************************/ + +#include "identificationdatasourcestore.h" +#include "../core/identification_sources/identificationxtandemfile.h" +#include <pappsomspp/pappsoexception.h> + +IdentificationDataSourceStore::IdentificationDataSourceStore() +{ + +} + +IdentificationDataSourceStore::~IdentificationDataSourceStore() +{ + +} + +IdentificationDataSourceSp IdentificationDataSourceStore::getInstance(const QString & location) { + + 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.suffix(); + //QString sample_name = location_file.baseName(); + if (ext.toLower() == "xml") { + //X!Tandem result file + IdentificationDataSourceSp p_xtfile = std::make_shared<IdentificationXtandemFile>(location_file); + _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSourceSp >(location, p_xtfile)); + _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSourceSp >(location_file.absoluteFilePath(), p_xtfile)); + return p_xtfile; + } + } + throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized").arg(location)); +} diff --git a/src/utils/identificationdatasourcestore.h b/src/utils/identificationdatasourcestore.h new file mode 100644 index 0000000000000000000000000000000000000000..60b2a6c22238ba1a141effbb94f40eea671e8749 --- /dev/null +++ b/src/utils/identificationdatasourcestore.h @@ -0,0 +1,48 @@ +/** + * \file utils/identificationdatasourcestore.h + * \date 5/4/2017 + * \author Olivier Langella + * \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 +******************************************************************************/ + +#ifndef IDENTIFICATIONDATASOURCESTORE_H +#define IDENTIFICATIONDATASOURCESTORE_H + +#include <map> +#include "../core/identification_sources/identificationdatasource.h" + +class IdentificationDataSourceStore +{ +public: + IdentificationDataSourceStore(); + ~IdentificationDataSourceStore(); + IdentificationDataSourceSp getInstance(const QString & location); + void clear(); +private : + std::map<QString, IdentificationDataSourceSp> _map_identification_data_sources; +}; + +#endif // IDENTIFICATIONDATASOURCESTORE_H