diff --git a/src/core/project.cpp b/src/core/project.cpp index 834e30e3065e093cfe6c2c3df75726d25ca4ce8c..4a37001748911d82272449d69d4e7b443606f254 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -70,6 +70,10 @@ const GroupingType Project::getGroupingType() const { FastaFileStore & Project::getFastaFileStore() { return _fasta_file_store; } + +const FastaFileStore & Project::getFastaFileStore() const { + return _fasta_file_store; +} MsRunStore & Project::getMsRunStore() { return _msrun_store; } diff --git a/src/core/project.h b/src/core/project.h index 78c0067a54819d78eb1ec88ecda3a8d723b3c271..b7cbebe58387400d762579821513045cfcf8a046 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -53,6 +53,7 @@ public: MsRunStore & getMsRunStore(); const MsRunStore & getMsRunStore() const; FastaFileStore & getFastaFileStore(); + const FastaFileStore & getFastaFileStore() const; IdentificationDataSourceStore & getIdentificationDataSourceStore(); const IdentificationDataSourceStore & getIdentificationDataSourceStore() const; void readXpipFile(WorkMonitorInterface * p_monitor, QFileInfo xpip_source); diff --git a/src/files/fastafile.cpp b/src/files/fastafile.cpp index e075c7ab076e4aa092fa084c9881d4304bbebab5..a4bbdef091656aa6522f037332f043c26406ce95 100644 --- a/src/files/fastafile.cpp +++ b/src/files/fastafile.cpp @@ -76,6 +76,12 @@ FastaFile::~FastaFile() } +void FastaFile::setXmlId(const QString xmlid) { + _xml_id = xmlid; +} +const QString & FastaFile::getXmlId() const { + return _xml_id; +} const QString FastaFile::getFilename() const { return _fasta_source.fileName(); } @@ -84,7 +90,7 @@ const QString FastaFile::getAbsoluteFilePath() const { return _fasta_source.absoluteFilePath(); } void FastaFile::setContaminants(ProteinStore & protein_store) const { - + protein_store.addContaminantFastaFile(this); if (_fasta_source.exists()) { AccessionContaminantReader accession_reader(protein_store); pappso::FastaReader reader(accession_reader); @@ -92,7 +98,6 @@ void FastaFile::setContaminants(ProteinStore & protein_store) const { if (fasta_file.open(QIODevice::ReadOnly)) { reader.parse(&fasta_file); fasta_file.close(); - protein_store.addContaminantFastaFile(*this); } else { qDebug() << "FastaFile::setContaminants "<< _fasta_source.absoluteFilePath() << " not open"; @@ -106,7 +111,7 @@ void FastaFile::setContaminants(ProteinStore & protein_store) const { } void FastaFile::setDecoys(ProteinStore & protein_store) const { - + protein_store.addDecoyFastaFile(this); if (_fasta_source.exists()) { AccessionDecoyReader accession_reader(protein_store); pappso::FastaReader reader(accession_reader); @@ -114,7 +119,6 @@ void FastaFile::setDecoys(ProteinStore & protein_store) const { if (fasta_file.open(QIODevice::ReadOnly)) { reader.parse(&fasta_file); fasta_file.close(); - protein_store.addDecoyFastaFile(*this); } else { qDebug() << "FastaFile::setDecoys "<< _fasta_source.absoluteFilePath() << " not open"; diff --git a/src/files/fastafile.h b/src/files/fastafile.h index 243f9dcb505ddfec63fb16ee108a4683c412795f..59213a2f5b7a3e23960bfd6ba568d5c9256bda87 100644 --- a/src/files/fastafile.h +++ b/src/files/fastafile.h @@ -50,9 +50,14 @@ public: /** @brief read fasta file and set accessions as decoys * */ void setDecoys(ProteinStore & protein_store) const; + + + void setXmlId(const QString xmlid); + const QString & getXmlId() const; private : const QFileInfo _fasta_source; + QString _xml_id; }; diff --git a/src/output/ods/infosheet.cpp b/src/output/ods/infosheet.cpp index ce22bd2c2ce44ea0548d8b937a395175dd6b8bff..ff5761fa80ccbd0ee7fd0d0237105750d8b7f7fb 100644 --- a/src/output/ods/infosheet.cpp +++ b/src/output/ods/infosheet.cpp @@ -72,30 +72,31 @@ InfoSheet::InfoSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, p_writer->writeLine(); p_writer->writeLine(); - std::vector<FastaFile> conta_file_list = p_project->getProteinStore().getContaminantFastaFileList(); + std::vector<const FastaFile *> conta_file_list = p_project->getProteinStore().getContaminantFastaFileList(); if (conta_file_list.size() == 0) { p_writer->writeCell("contaminant pattern"); p_writer->writeCell(p_project->getProteinStore().getRegexpContaminant().pattern()); } else { p_writer->writeCell("contaminant fasta files"); - for (FastaFile & fasta_file : conta_file_list) { - p_writer->writeCell(fasta_file.getAbsoluteFilePath()); + for (const FastaFile * fasta_file : conta_file_list) { + p_writer->writeCell(fasta_file->getAbsoluteFilePath()); } - } - std::vector<FastaFile> decoy_file_list = p_project->getProteinStore().getDecoyFastaFileList(); + p_writer->writeLine(); + + std::vector<const FastaFile *> decoy_file_list = p_project->getProteinStore().getDecoyFastaFileList(); if (conta_file_list.size() == 0) { p_writer->writeCell("decoy pattern"); p_writer->writeCell(p_project->getProteinStore().getRegexpDecoy().pattern()); } else { p_writer->writeCell("decoy fasta files"); - for (FastaFile & fasta_file : decoy_file_list) { - p_writer->writeCell(fasta_file.getAbsoluteFilePath()); + for (const FastaFile * fasta_file : decoy_file_list) { + p_writer->writeCell(fasta_file->getAbsoluteFilePath()); } - } + p_writer->writeLine(); } diff --git a/src/output/xpip.cpp b/src/output/xpip.cpp index 733b65567033ccd560bcb5d762dcdeb7eeb804d6..16a9e64d7f0d9d61ae3360993e5a1d137f1b91d2 100644 --- a/src/output/xpip.cpp +++ b/src/output/xpip.cpp @@ -189,7 +189,7 @@ void Xpip::writeMsrunList(const MsRunStore & msrun_store) { _output_stream->writeStartElement("fasta_file_list"); for (FastaFileSp fasta_file_sp : fasta_store.getFastaFileList()) { _output_stream->writeStartElement("fasta_file"); - //_output_stream->writeAttribute("id",fasta_file_sp.get()->getXmlId()); + _output_stream->writeAttribute("id",fasta_file_sp.get()->getXmlId()); _output_stream->writeAttribute("path",fasta_file_sp.get()->getAbsoluteFilePath()); _output_stream->writeEndElement(); diff --git a/src/utils/fastafilestore.cpp b/src/utils/fastafilestore.cpp index ddafcd3cc7682de6dccd966a4b7dc90d18fc8f81..617b2998300ea89c0fc0c5ba81278f714ac9cbbb 100644 --- a/src/utils/fastafilestore.cpp +++ b/src/utils/fastafilestore.cpp @@ -29,6 +29,7 @@ ******************************************************************************/ #include "fastafilestore.h" +#include <pappsomspp/utils.h> #include <QDebug> FastaFileStore::FastaFileStore() { @@ -41,19 +42,21 @@ FastaFileStore::~FastaFileStore() } FastaFileSp FastaFileStore::getInstance(const FastaFile & location) { -qDebug() << "FastaFileStore::getInstance() begin "; -qDebug() << "FastaFileStore::getInstance() begin "<< location.getAbsoluteFilePath(); + 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()->getFilename() == location.getFilename()) { - -qDebug() << "FastaFileStore::getInstance() end b "<< it->get()->getFilename(); + + qDebug() << "FastaFileStore::getInstance() end b "<< it->get()->getFilename(); return *it; } it++; } FastaFileSp fastafile_sp = std::make_shared<FastaFile>(location); + + fastafile_sp.get()->setXmlId(QString("fasta%1").arg(pappso::Utils::getLexicalOrderedString(_map_fastafile.size()))); _map_fastafile.push_back(fastafile_sp); qDebug() << "FastaFileStore::getFastaFileList() end a " << _map_fastafile.size(); return fastafile_sp; diff --git a/src/utils/proteinstore.cpp b/src/utils/proteinstore.cpp index 733835e0c9fa9835abaa23c53f3975d3b3edb674..7a86409776226d96fe7d5ec848ab1b39592decb0 100644 --- a/src/utils/proteinstore.cpp +++ b/src/utils/proteinstore.cpp @@ -48,12 +48,12 @@ ProteinStore::~ProteinStore() } - const std::vector<FastaFile> & ProteinStore::getContaminantFastaFileList() const { - return _fasta_contaminant_list; - } - const std::vector<FastaFile> & ProteinStore::getDecoyFastaFileList() const { - return _fasta_decoy_list; - } +const std::vector<const FastaFile *> & ProteinStore::getContaminantFastaFileList() const { + return _fasta_contaminant_list; +} +const std::vector<const FastaFile *> & ProteinStore::getDecoyFastaFileList() const { + return _fasta_decoy_list; +} QRegExp ProteinStore::getRegexpContaminant() const { return (_regexp_contaminant); } @@ -93,11 +93,11 @@ void ProteinStore::clearContaminants() { } } -void ProteinStore::addContaminantFastaFile(const FastaFile & fasta_file) { - _fasta_contaminant_list.push_back(fasta_file); +void ProteinStore::addContaminantFastaFile(const FastaFile * p_fasta_file) { + _fasta_contaminant_list.push_back(p_fasta_file); } -void ProteinStore::addDecoyFastaFile(const FastaFile & fasta_file) { - _fasta_decoy_list.push_back(fasta_file); +void ProteinStore::addDecoyFastaFile(const FastaFile * p_fasta_file) { + _fasta_decoy_list.push_back(p_fasta_file); } diff --git a/src/utils/proteinstore.h b/src/utils/proteinstore.h index 454904b4ee4597277d970a049c185876396391f8..fa06e1304bda2ee61eab255bb1f45fe70899fe63 100644 --- a/src/utils/proteinstore.h +++ b/src/utils/proteinstore.h @@ -57,11 +57,11 @@ public: QRegExp getRegexpContaminant() const; - void addContaminantFastaFile(const FastaFile & fasta_file); - void addDecoyFastaFile(const FastaFile & fasta_file); + void addContaminantFastaFile(const FastaFile * p_fasta_file); + void addDecoyFastaFile(const FastaFile * p_fasta_file); - const std::vector<FastaFile> & getContaminantFastaFileList() const; - const std::vector<FastaFile> & getDecoyFastaFileList() const; + const std::vector<const FastaFile *> & getContaminantFastaFileList() const; + const std::vector<const FastaFile *> & getDecoyFastaFileList() const; void clearContaminants(); @@ -77,9 +77,9 @@ private : std::map<QString, ProteinXtpSp> _map_accession_protein_list; /** \brief decoy Fasta file liste */ - std::vector<FastaFile> _fasta_decoy_list; + std::vector<const FastaFile *> _fasta_decoy_list; /** \brief contaminant Fasta file liste */ - std::vector<FastaFile> _fasta_contaminant_list; + std::vector<const FastaFile *> _fasta_contaminant_list; /** \brief recognize decoy accession */ QRegExp _regexp_decoy;