From cc4bc995c96807ec192106bebbd6e13e2a41fa8c Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Wed, 17 May 2017 16:47:51 +0200 Subject: [PATCH] WIP : proticdbml writer, test xpip --- .../identificationxtandemfile.cpp | 2 +- src/core/identificationgroup.cpp | 8 ++++ src/core/identificationgroup.h | 6 ++- src/input/xpipsaxhandler.cpp | 3 +- src/output/proticdbml.cpp | 39 ++++++++++--------- src/output/proticdbml.h | 1 + 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/core/identification_sources/identificationxtandemfile.cpp b/src/core/identification_sources/identificationxtandemfile.cpp index dd394f345..1555984d0 100644 --- a/src/core/identification_sources/identificationxtandemfile.cpp +++ b/src/core/identification_sources/identificationxtandemfile.cpp @@ -80,7 +80,7 @@ void IdentificationXtandemFile::parseTo(Project* p_project) { } } - identification_group_p->addMsRunSp(msrun_sp); + identification_group_p->addIdentificationDataSourceP(this); XtandemSaxHandler * parser = new XtandemSaxHandler(p_project, identification_group_p, this); QXmlSimpleReader simplereader; diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 944f41fa5..78e09767a 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -149,6 +149,14 @@ bool IdentificationGroup::contains (const MsRun * p_msrun) const { } return false; } + + void IdentificationGroup::addIdentificationDataSourceP(IdentificationDataSource * p_identification_source) { + addMsRunSp(p_identification_source->getMsRunSp()); + auto it = std::find (_id_source_list.begin() ,_id_source_list.end(),p_identification_source); + if (it == _id_source_list.end()) { + _id_source_list.push_back(p_identification_source); + } + } void IdentificationGroup::addMsRunSp(MsRunSp ms_run_sp) { auto it = std::find (_ms_run_list.begin() ,_ms_run_list.end(),ms_run_sp); if (it == _ms_run_list.end()) { diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index 53c1f6949..0d5de141e 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.h @@ -48,7 +48,7 @@ public: const GroupStore & getGroupStore() const; void addProteinMatch(ProteinMatch * protein_match); std::vector<ProteinMatch *> & getProteinMatchList(); - void addMsRunSp(MsRunSp ms_run_sp); + void addIdentificationDataSourceP(IdentificationDataSource * p_identification_source); /** @brief count groups * */ @@ -102,6 +102,9 @@ public: void collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const; private : + + void addMsRunSp(MsRunSp ms_run_sp); +private : GroupingExperiment * _p_grp_experiment= nullptr; Project * _p_project; @@ -111,6 +114,7 @@ private : std::vector<ProteinMatch *> _protein_match_list; std::vector<MsRunSp> _ms_run_list; + std::vector<IdentificationDataSource *> _id_source_list; std::map<QString, ProteinMatch *> _cache_accession_protein_match; }; diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 411c8227f..739fc8ac2 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -189,7 +189,7 @@ bool XpipSaxHandler::startElement_sample(QXmlAttributes attributes) { MsRunSp ms_run = _p_project->getMsRunStore().getInstance(attributes.value("value").simplified()); ms_run.get()->setFilename(attributes.value("value").simplified()); - _current_identification_group_p->addMsRunSp(ms_run); + //_current_identification_group_p->addMsRunSp(ms_run); qDebug() << "startElement_sample end" ; return true; } @@ -255,6 +255,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()")); } + _current_identification_group_p->addIdentificationDataSourceP(p_identification_data_source); p_identification_data_source->addFastaFile(_current_fasta_file_sp); _p_peptide_match->setChecked(false); if (attributes.value("validate").simplified().toLower() == "true") { diff --git a/src/output/proticdbml.cpp b/src/output/proticdbml.cpp index cf80947e1..06ba2c163 100644 --- a/src/output/proticdbml.cpp +++ b/src/output/proticdbml.cpp @@ -270,12 +270,12 @@ void ProticdbMl::writeMsRuns() { } -void ProticdbMl::writeIdentificationRun(Identification identification) { - writer.writeAttribute("ident_method_id", "m1"); - writer.writeAttribute("customdb_id", "customdb0"); +void ProticdbMl::writeIdentificationRun(IdentificationGroup * p_identification) { + _output_stream->writeAttribute("ident_method_id", "m1"); + _output_stream->writeAttribute("customdb_id", "customdb0"); - writer.writeStartElement("description"); - writer.writeStartElement("admin"); + _output_stream->writeStartElement("description"); + _output_stream->writeStartElement("admin"); // writer.writeStartElement("contact"); // writer.writeStartElement("email"); // writer.writeCharacters("valot@moulon.inra.fr"); @@ -285,24 +285,25 @@ void ProticdbMl::writeIdentificationRun(Identification identification) { // writer.writeCharacters("Valot Benoit"); // writer.writeEndElement();// name // writer.writeEndElement();// contact + /* this.xpipFile = XtandemPipelineSession.getInstance() .getCurrentXpipFile(); - writer.writeStartElement("sourceFile"); - writer.writeStartElement("nameOfFile"); + _output_stream->writeStartElement("sourceFile"); + _output_stream->writeStartElement("nameOfFile"); // TODO // get the loaded xpip file name - writer.writeCharacters(this.xpipFile.getName()); - writer.writeEndElement();// nameOfFile - writer.writeStartElement("pathToFile"); - writer.writeCharacters(this.xpipFile.getAbsolutePath()); - writer.writeEndElement();// pathToFile - writer.writeStartElement("fileType"); - writer.writeCharacters("XPIP file"); - writer.writeEndElement();// fileType - writer.writeEndElement();// sourceFile - - writer.writeEndElement();// admin + _output_stream->writeCharacters(this.xpipFile.getName()); + _output_stream->writeEndElement();// nameOfFile + _output_stream->writeStartElement("pathToFile"); + _output_stream->writeCharacters(this.xpipFile.getAbsolutePath()); + _output_stream->writeEndElement();// pathToFile + _output_stream->writeStartElement("fileType"); + _output_stream->writeCharacters("XPIP file"); + _output_stream->writeEndElement();// fileType + _output_stream->writeEndElement();// sourceFile +*/ + _output_stream->writeEndElement();// admin // if we can retrieve original informations in xml xtandem results HashSet<IdentificationXtandemFile> xtSourceFiles = Utils @@ -345,7 +346,7 @@ void ProticdbMl::writeIdentificationRun(Identification identification) { writer.writeStartElement("processingMethod"); // cvParams - this.writeCvParam("PROTICdbO:0000323", "" + writeCvParam("PROTICdbO:0000323", "" + XtandemPipelineSession.getInstance().getConfig() .get_protein_evalue(), "X!TandemPipeline filter on protein evalue (log)"); diff --git a/src/output/proticdbml.h b/src/output/proticdbml.h index f2b6837ef..b3364df62 100644 --- a/src/output/proticdbml.h +++ b/src/output/proticdbml.h @@ -55,6 +55,7 @@ private : void writeIdentMethod(); void writeSamples(); void writeMsRuns(); + void writeIdentificationRun(IdentificationGroup * p_identification); private : QFile * _output_file; -- GitLab