Skip to content
Snippets Groups Projects
Commit eecb11af authored by Olivier Langella's avatar Olivier Langella
Browse files

new identification data source store OK

parent 8f67e6de
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
}
......
......@@ -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;
};
......
......@@ -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;
}
......
......@@ -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
......@@ -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;
}
......
/**
* \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));
}
/**
* \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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment