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

better assign pointer first...

parent 0f5f0ccf
No related branches found
No related tags found
No related merge requests found
Showing
with 54 additions and 61 deletions
......@@ -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();
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
};
......
......@@ -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();
}
......
......@@ -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();
}
......@@ -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;
......
......@@ -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"));
......
......@@ -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;
}
......
......@@ -105,7 +105,7 @@ private:
ProjectSp _project_sp;
QStandardItemModel * _p_fasta_str_li;
std::set<FastaFileSp> _fastafile_list;
std::vector<FastaFileSp> _fastafile_list;
};
......
......@@ -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);
......
......@@ -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;
};
......
......@@ -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)));
}
/*
......
......@@ -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;
}
......@@ -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;
};
......
......@@ -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;
}
......@@ -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;
};
......
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