From 22d2e76e14bc21ba6b5068ddcbe20232392e8a99 Mon Sep 17 00:00:00 2001 From: Olivier Langella <olivier.langella@u-psud.fr> Date: Thu, 16 Nov 2017 21:54:50 +0100 Subject: [PATCH] xpip output almost done --- src/core/peptidematch.cpp | 3 +++ src/core/peptidematch.h | 2 ++ src/output/xpip.cpp | 56 +++++++++++++++++++++++++++++++++++++-- src/output/xpip.h | 1 + src/utils/types.h | 4 +-- 5 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp index ab3a9377b..4e51d36a7 100644 --- a/src/core/peptidematch.cpp +++ b/src/core/peptidematch.cpp @@ -76,6 +76,9 @@ const QVariant PeptideMatch::getParam(PeptideMatchParam param) const { return QVariant(); } } +const std::map<PeptideMatchParam, QVariant> & PeptideMatch::getParamList() const { + return _params; +} std::size_t PeptideMatch::getHashPeptideMassSample() const { return PeptideMatch::_hash_fn (QString("%1 %2").arg(_peptide_sp.get()->toAbsoluteString()).arg(_msrunid_sp->getXmlId()).toStdString()); diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h index 0c5ccf6a0..1da789cd2 100644 --- a/src/core/peptidematch.h +++ b/src/core/peptidematch.h @@ -66,6 +66,8 @@ public : /** \brief get specific parameter value */ virtual const QVariant getParam(PeptideMatchParam param) const; + + const std::map<PeptideMatchParam, QVariant> & getParamList() const; /** @brief set start position of this peptide inside the protein sequence diff --git a/src/output/xpip.cpp b/src/output/xpip.cpp index 20f9077c2..0e7df072d 100644 --- a/src/output/xpip.cpp +++ b/src/output/xpip.cpp @@ -233,14 +233,20 @@ void Xpip::writeProteinList() { _output_stream->writeStartElement("protein"); _output_stream->writeAttribute("acc",p_protein->getAccession()); _output_stream->writeAttribute("description",p_protein->getDescription()); - _output_stream->writeAttribute("is_decoy","false"); + if (p_protein->isDecoy()) { _output_stream->writeAttribute("is_decoy","true"); } - _output_stream->writeAttribute("is_contaminant","false"); + else { + _output_stream->writeAttribute("is_decoy","false"); + } + if (p_protein->isContaminant()) { _output_stream->writeAttribute("is_contaminant","true"); } + else { + _output_stream->writeAttribute("is_contaminant","false"); + } _output_stream->writeStartElement("sequence"); _output_stream->writeCharacters(p_protein->getSequence()); @@ -362,8 +368,54 @@ void Xpip::writeIdentificationGroup(const IdentificationGroup * p_identification //std::vector<ProteinMatch *> & getProteinMatchList() _output_stream->writeStartElement("protein_match"); _output_stream->writeAttribute("acc", p_protein_match->getProteinXtpSp().get()->getAccession()); + if (p_protein_match->isChecked()) { + _output_stream->writeAttribute("checked","true"); + } + else { + _output_stream->writeAttribute("checked","false"); + } + for (const PeptideMatch * p_peptide_match : p_protein_match->getPeptideMatchList()) { + writePeptideMatch(p_peptide_match); + } _output_stream->writeEndElement();// protein_match } _output_stream->writeEndElement(); //protein_match_list qDebug() << "Xpip::writeIdentificationGroup end"; } + +void Xpip::writePeptideMatch(const PeptideMatch * p_peptide_match) { + qDebug() << "Xpip::writePeptideMatch begin"; + _output_stream->writeStartElement("peptide_match"); + _output_stream->writeAttribute("source_id",p_peptide_match->getIdentificationDataSource()->getXmlId()); + //_output_stream->writeAttribute("ms_id",p_peptide_match->getMsRunP()->getXmlId()); + _output_stream->writeAttribute("peptide_id",_map_peptides.at( p_peptide_match->getPeptideXtpSp().get())); + _output_stream->writeAttribute("scan",QString("%1").arg(p_peptide_match->getScan())); + writeDoubleAttribute("rt",p_peptide_match->getRetentionTime()); + writeDoubleAttribute("evalue",p_peptide_match->getEvalue()); + writeDoubleAttribute("exp_mass",p_peptide_match->getExperimentalMass()); + _output_stream->writeAttribute("start",QString("%1").arg(p_peptide_match->getStart())); + _output_stream->writeAttribute("charge",QString("%1").arg(p_peptide_match->getCharge())); + + if (p_peptide_match->isChecked()) { + _output_stream->writeAttribute("checked","true"); + } + else { + _output_stream->writeAttribute("checked","false"); + } + + const std::map<PeptideMatchParam, QVariant> & params = p_peptide_match->getParamList(); + + //if (params.size() > 0) { + // _output_stream->writeStartElement("stats"); + for (const std::pair<PeptideMatchParam, QVariant> param_pair: params) { + _output_stream->writeStartElement("param"); + _output_stream->writeAttribute("key",QString("%1").arg(static_cast<std::int8_t>(param_pair.first))); + _output_stream->writeAttribute("value",param_pair.second.toString()); + _output_stream->writeEndElement(); + } + // _output_stream->writeEndElement(); + //} + + _output_stream->writeEndElement(); //protein_match_list + qDebug() << "Xpip::writePeptideMatch end"; +} diff --git a/src/output/xpip.h b/src/output/xpip.h index 2775fb89b..ec52fb03f 100644 --- a/src/output/xpip.h +++ b/src/output/xpip.h @@ -59,6 +59,7 @@ private : void writeLabelingMethod(); void writeIdentificationGroupList(); void writeIdentificationGroup(const IdentificationGroup * p_identification_group); + void writePeptideMatch(const PeptideMatch * p_peptide_match); QString getPeptideId(std::size_t crc_peptide) const; diff --git a/src/utils/types.h b/src/utils/types.h index 68c5507b7..116c3b0f2 100644 --- a/src/utils/types.h +++ b/src/utils/types.h @@ -53,8 +53,8 @@ enum class IdentificationEngine: std::int8_t { /** \def PeptideMatchParam peptide match specific parameters * */ -enum class PeptideMatchParam { - tandem_hyperscore ///< X!Tandem hyperscore +enum class PeptideMatchParam: std::int8_t { + tandem_hyperscore=0 ///< X!Tandem hyperscore }; /** \def IdentificationEngineParam identification engine parameters -- GitLab