From 62ead64094b80b2e3b4c3ef2e756daf6e9fdda17 Mon Sep 17 00:00:00 2001 From: Olivier Langella <olivier.langella@u-psud.fr> Date: Tue, 30 Apr 2019 08:34:48 +0200 Subject: [PATCH] WIP: adapting xtpcpp to new PAPPSOms++ library --- src/core/msrun.cpp | 50 ++++++++++++++++++++---- src/input/mascot/mascotdatparser.cpp | 57 ++++++++++++++++------------ src/input/pepxmlsaxhandler.cpp | 42 +++++++++++--------- src/input/xpipsaxhandler.cpp | 2 +- src/input/xtandemsaxhandler.cpp | 2 +- src/input/xtpxpipsaxhandler.cpp | 2 +- src/utils/msrunstore.cpp | 13 ++++--- 7 files changed, 110 insertions(+), 58 deletions(-) diff --git a/src/core/msrun.cpp b/src/core/msrun.cpp index b4ca0879c..ec29da3d8 100644 --- a/src/core/msrun.cpp +++ b/src/core/msrun.cpp @@ -164,10 +164,27 @@ MsRun::findMsRunFile() { if(_msrun_reader_sp == nullptr) { - _msrun_reader_sp = - pappso::MsRunReaderFactory::getInstance() - .buildPwizMsRunReaderSp(*this); + pappso::MsFileAccessor accessor(getFilename(), 0); + qDebug() + << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"; + auto msrunid_list = accessor.getMsRunIds(); + if(msrunid_list.size() == 1) + { + _msrun_reader_sp = + accessor.msRunReaderSp(msrunid_list.front()); + } + else + { + throw(pappso::ExceptionNotImplemented( + QObject::tr("multiple msruns inside mz data file " + "not yet implemented"))); + } + /* + _msrun_reader_sp = + pappso::MsRunReaderFactory::getInstance() + .buildPwizMsRunReaderSp(*this); + */ return true; } } @@ -182,13 +199,30 @@ MsRun::findMsRunFile() { try { - this->setFilename(file.absoluteFilePath()); + this->setFileName(file.absoluteFilePath()); if(_msrun_reader_sp == nullptr) { - _msrun_reader_sp = - pappso::MsRunReaderFactory::getInstance() - .buildPwizMsRunReaderSp(*this); + + pappso::MsFileAccessor accessor(getFilename(), 0); + qDebug() + << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"; + auto msrunid_list = accessor.getMsRunIds(); + if(msrunid_list.size() == 1) + { + _msrun_reader_sp = + accessor.msRunReaderSp(msrunid_list.front()); + } + else + { + throw(pappso::ExceptionNotImplemented( + QObject::tr("multiple msruns inside mz data file " + "not yet implemented"))); + } + /* + _msrun_reader_sp = + pappso::MsRunReaderFactory::getInstance() + .buildPwizMsRunReaderSp(*this);*/ return true; } } @@ -199,7 +233,7 @@ MsRun::findMsRunFile() } } } - this->setFilename(file_original.absoluteFilePath()); + this->setFileName(file_original.absoluteFilePath()); _msrun_reader_sp = nullptr; return false; } diff --git a/src/input/mascot/mascotdatparser.cpp b/src/input/mascot/mascotdatparser.cpp index e0ea73b2a..306d71a2e 100644 --- a/src/input/mascot/mascotdatparser.cpp +++ b/src/input/mascot/mascotdatparser.cpp @@ -38,7 +38,8 @@ #include "../../core/peptideevidence.h" MascotDatParser::MascotDatParser( - Project *p_project, IdentificationGroup *p_identification_group, + Project *p_project, + IdentificationGroup *p_identification_group, IdentificationDataSource *p_identification_data_source) { _p_project = p_project; @@ -418,7 +419,7 @@ INTERNALS=0.0,700.0 { // FILE=F:\MSData\Batch4 Qex+TOUL Injection2\QEKAC160601_02.raw.mgf - _p_identification_data_source->getMsRunSp().get()->setFilename( + _p_identification_data_source->getMsRunSp().get()->setFileName( header_list[2]); QFileInfo fileinfo(header_list[2]); @@ -550,8 +551,9 @@ MascotDatParser::parsePeptidesLine(const QString &peptide_line) catch(pappso::PappsoException exception_pappso) { - _error_str = QObject::tr("ERROR in MascotDatParser::parsePeptidesLine " - "%1, PAPPSO exception:\n%2 near q%3_p%4") + _error_str = QObject::tr( + "ERROR in MascotDatParser::parsePeptidesLine " + "%1, PAPPSO exception:\n%2 near q%3_p%4") .arg(peptide_line) .arg(exception_pappso.qwhat()) .arg(_current_peptide.query_index) @@ -561,13 +563,13 @@ MascotDatParser::parsePeptidesLine(const QString &peptide_line) } catch(std::exception exception_std) { - _error_str = - QObject::tr("ERROR in MascotDatParser::parsePeptidesLine %1, std " - "exception:\n%2 near q%3_p%4") - .arg(peptide_line) - .arg(exception_std.what()) - .arg(_current_peptide.query_index) - .arg(_current_peptide.peptide_index); + _error_str = QObject::tr( + "ERROR in MascotDatParser::parsePeptidesLine %1, std " + "exception:\n%2 near q%3_p%4") + .arg(peptide_line) + .arg(exception_std.what()) + .arg(_current_peptide.query_index) + .arg(_current_peptide.peptide_index); qDebug() << _error_str; throw pappso::PappsoException(_error_str); } @@ -637,11 +639,11 @@ MascotDatParser::parseQueryLine(const QString &query_line) catch(pappso::PappsoException exception_pappso) { - _error_str = - QObject::tr("ERROR in MascotDatParser::parseQueryLine %1, PAPPSO " - "exception:\n%2") - .arg(query_line) - .arg(exception_pappso.qwhat()); + _error_str = QObject::tr( + "ERROR in MascotDatParser::parseQueryLine %1, PAPPSO " + "exception:\n%2") + .arg(query_line) + .arg(exception_pappso.qwhat()); qDebug() << _error_str; throw pappso::PappsoException(_error_str); } @@ -846,13 +848,15 @@ MascotDatParser::savePeptideList(std::vector<PeptideLine> &peptide_list, { peptide_evidence.setEvalue(getEvalue( ion_score, - _decoy_summary_list.at(_current_query.query_index - 1), 0.05)); + _decoy_summary_list.at(_current_query.query_index - 1), + 0.05)); } else { - peptide_evidence.setEvalue(getEvalue( - ion_score, _summary_list.at(_current_query.query_index - 1), - 0.05)); + peptide_evidence.setEvalue( + getEvalue(ion_score, + _summary_list.at(_current_query.query_index - 1), + 0.05)); } peptide_evidence.setParam( @@ -984,16 +988,18 @@ MascotDatParser::savePeptideList(std::vector<PeptideLine> &peptide_list, catch(pappso::PappsoException exception_pappso) { - _error_str = QObject::tr("ERROR in MascotDatParser::savePeptideList " - " PAPPSO exception:\n%2") + _error_str = QObject::tr( + "ERROR in MascotDatParser::savePeptideList " + " PAPPSO exception:\n%2") .arg(exception_pappso.qwhat()); qDebug() << _error_str; throw pappso::PappsoException(_error_str); } catch(std::exception exception_std) { - _error_str = QObject::tr("ERROR in MascotDatParser::savePeptideList std " - "exception:\n%2") + _error_str = QObject::tr( + "ERROR in MascotDatParser::savePeptideList std " + "exception:\n%2") .arg(exception_std.what()); qDebug() << _error_str; throw pappso::PappsoException(_error_str); @@ -1019,7 +1025,8 @@ MascotDatParser::getEvalue(pappso::pappso_double ion_score, pappso::pappso_double MascotDatParser::getEvalueExperimental( - pappso::pappso_double ion_score, SummaryLine &summary_line, + pappso::pappso_double ion_score, + SummaryLine &summary_line, pappso::pappso_double confidence_interval) const { // Evalue experimental Homology threshold (QPlughole value from .dat file). diff --git a/src/input/pepxmlsaxhandler.cpp b/src/input/pepxmlsaxhandler.cpp index af6b1be03..bdc252be1 100644 --- a/src/input/pepxmlsaxhandler.cpp +++ b/src/input/pepxmlsaxhandler.cpp @@ -38,7 +38,8 @@ PepXmlSaxHandler::PepXmlSaxHandler( - Project *p_project, IdentificationGroup *p_identification_group, + Project *p_project, + IdentificationGroup *p_identification_group, IdentificationDataSource *p_identification_data_source) : _p_project(p_project) { @@ -55,7 +56,8 @@ PepXmlSaxHandler::~PepXmlSaxHandler() bool PepXmlSaxHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, + const QString &localName, + const QString &qName, const QXmlAttributes &attributes) { // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; @@ -128,8 +130,9 @@ PepXmlSaxHandler::startElement(const QString &namespaceURI, } catch(pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in PepXmlSaxHandler::startElement tag " - "%1, PAPPSO exception:\n%2") + _errorStr = QObject::tr( + "ERROR in PepXmlSaxHandler::startElement tag " + "%1, PAPPSO exception:\n%2") .arg(qName) .arg(exception_pappso.qwhat()); return false; @@ -148,7 +151,8 @@ PepXmlSaxHandler::startElement(const QString &namespaceURI, bool PepXmlSaxHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) + const QString &localName, + const QString &qName) { // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; @@ -171,8 +175,9 @@ PepXmlSaxHandler::endElement(const QString &namespaceURI, } catch(pappso::PappsoException exception_pappso) { - _errorStr = QObject::tr("ERROR in PepXmlSaxHandler::endElement tag %1, " - "PAPPSO exception:\n%2") + _errorStr = QObject::tr( + "ERROR in PepXmlSaxHandler::endElement tag %1, " + "PAPPSO exception:\n%2") .arg(qName) .arg(exception_pappso.qwhat()); return false; @@ -234,7 +239,7 @@ PepXmlSaxHandler::startElement_msms_run_summary(QXmlAttributes attributes) .arg(old_file) .arg(_current_complete_msrun_file_path)); } - _sp_msrun.get()->setFilename(attributes.value("base_name")); + _sp_msrun.get()->setFileName(attributes.value("base_name")); _sp_msrun.get()->setSampleName( QFileInfo(_current_complete_msrun_file_path).baseName()); return is_ok; @@ -285,7 +290,7 @@ PepXmlSaxHandler::startElement_spectrum_query(QXmlAttributes attributes) QString spectrum_ref = attributes.value("spectrum"); if(_current_complete_msrun_file_path.isEmpty()) { - _sp_msrun.get()->setFilename(QFileInfo(spectrum_ref).baseName()); + _sp_msrun.get()->setFileName(QFileInfo(spectrum_ref).baseName()); } unsigned int start_scan = attributes.value("start_scan").toUInt(); unsigned int end_scan = attributes.value("end_scan").toUInt(); @@ -304,9 +309,10 @@ PepXmlSaxHandler::startElement_spectrum_query(QXmlAttributes attributes) if(attributes.value("retention_time_sec").isEmpty()) { QString message = - QObject::tr("ERROR reading pepxml file :\n" - "unable to read search results from '%1' as retention time " - "is not given in spectrum_query elements") + QObject::tr( + "ERROR reading pepxml file :\n" + "unable to read search results from '%1' as retention time " + "is not given in spectrum_query elements") .arg(_current_search_engine); qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " << message; @@ -326,7 +332,7 @@ PepXmlSaxHandler::startElement_spectrum_query(QXmlAttributes attributes) //<alternative_protein protein="sp|P46784|RS10B_YEAST" protein_descr="40S // ribosomal protein S10-B OS=Saccharomyces cerevisiae (strain ATCC 204508 -// \ +// \ //S288c) GN=RPS10B PE=1 SV=1" num_tol_term="2" peptide_prev_aa="K" // peptide_next_aa="N"/> bool @@ -690,8 +696,9 @@ PepXmlSaxHandler::endElement_modification_info() bool PepXmlSaxHandler::error(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3") + _errorStr = QObject::tr( + "Parse error at line %1, column %2 :\n" + "%3") .arg(exception.lineNumber()) .arg(exception.columnNumber()) .arg(exception.message()); @@ -703,8 +710,9 @@ PepXmlSaxHandler::error(const QXmlParseException &exception) bool PepXmlSaxHandler::fatalError(const QXmlParseException &exception) { - _errorStr = QObject::tr("Parse error at line %1, column %2 :\n" - "%3") + _errorStr = QObject::tr( + "Parse error at line %1, column %2 :\n" + "%3") .arg(exception.lineNumber()) .arg(exception.columnNumber()) .arg(exception.message()); diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 7f869c494..60b5f0238 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -282,7 +282,7 @@ XpipSaxHandler::startElement_sample(QXmlAttributes attributes) MsRunSp ms_run = _p_project->getMsRunStore().getInstance( attributes.value("value").simplified()); - ms_run.get()->setFilename(attributes.value("value").simplified()); + ms_run.get()->setFileName(attributes.value("value").simplified()); //_current_identification_group_p->addMsRunSp(ms_run); // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; return true; diff --git a/src/input/xtandemsaxhandler.cpp b/src/input/xtandemsaxhandler.cpp index dfb409b71..7fbee73cd 100644 --- a/src/input/xtandemsaxhandler.cpp +++ b/src/input/xtandemsaxhandler.cpp @@ -607,7 +607,7 @@ XtandemSaxHandler::endElement_note() if(_current_note_label == "spectrum, path") { - _sp_msrun.get()->setFilename(_current_text); + _sp_msrun.get()->setFileName(_current_text); } /* diff --git a/src/input/xtpxpipsaxhandler.cpp b/src/input/xtpxpipsaxhandler.cpp index b40d362ab..97d3c303a 100644 --- a/src/input/xtpxpipsaxhandler.cpp +++ b/src/input/xtpxpipsaxhandler.cpp @@ -556,7 +556,7 @@ XtpXpipSaxHandler::startElement_msrun(QXmlAttributes attributes) _sp_msrun = _p_project->getMsRunStore().getInstance( attributes.value("path").simplified()); - _sp_msrun.get()->setFilename(attributes.value("path").simplified()); + _sp_msrun.get()->setFileName(attributes.value("path").simplified()); _sp_msrun.get()->setSampleName(attributes.value("name").simplified()); _sp_msrun.get()->setXmlId(attributes.value("id").simplified()); _map_msruns.insert( diff --git a/src/utils/msrunstore.cpp b/src/utils/msrunstore.cpp index f867fb0b9..2a3719c49 100644 --- a/src/utils/msrunstore.cpp +++ b/src/utils/msrunstore.cpp @@ -46,8 +46,9 @@ MsRunSp MsRunStore::getInstance(const MsRun *p_msrun) { auto it = std::find_if( - _map_msrun.begin(), _map_msrun.end(), - [p_msrun](const MsRunSp &msrun_sp) { return msrun_sp.get() == p_msrun; }); + _map_msrun.begin(), _map_msrun.end(), [p_msrun](const MsRunSp &msrun_sp) { + return msrun_sp.get() == p_msrun; + }); if(it != _map_msrun.end()) { return (*it); @@ -65,7 +66,8 @@ MsRunStore::getInstance(const QString &location) if(file_ondisk.baseName() == location) { // look only for the same sample name - it = std::find_if(_map_msrun.begin(), _map_msrun.end(), + it = std::find_if(_map_msrun.begin(), + _map_msrun.end(), [location](const MsRunSp &msrun_sp) { return msrun_sp.get()->getSampleName() == location; }); @@ -73,7 +75,8 @@ MsRunStore::getInstance(const QString &location) else { // look for an absolute file path - it = std::find_if(_map_msrun.begin(), _map_msrun.end(), + it = std::find_if(_map_msrun.begin(), + _map_msrun.end(), [location](const MsRunSp &msrun_sp) { if(msrun_sp.get()->getSampleName() == msrun_sp.get()->getFilename()) @@ -93,7 +96,7 @@ MsRunStore::getInstance(const QString &location) MsRunSp p_xtfile = std::make_shared<MsRun>(location); p_xtfile.get()->setXmlId(QString("msrun%1").arg( pappso::Utils::getLexicalOrderedString(_map_msrun.size() + 1))); - p_xtfile.get()->setFilename(location); + p_xtfile.get()->setFileName(location); _map_msrun.push_back(p_xtfile); return p_xtfile; } -- GitLab