diff --git a/src/output/masschroqml.cpp b/src/output/masschroqml.cpp index be34dc01a7c27b5a25b6ada00e8aca796c32d4d1..1399e04c9e9aa639b6b97970a5cfbee4403bd78c 100644 --- a/src/output/masschroqml.cpp +++ b/src/output/masschroqml.cpp @@ -31,14 +31,23 @@ #include <pappsomspp/pappsoexception.h> #include <pappsomspp/utils.h> #include <pappsomspp/grouping/grpprotein.h> +#include <pappsomspp/amino_acid/Aa.h> struct McqPeptide { QString id; - pappso::pappso_double mh; QStringList mods; QStringList prot_ids; QString seq; + const pappso::Peptide * native_peptide; + std::vector<QString> data; + std::vector<unsigned int> scan; + std::vector<unsigned int> charge; +}; + +struct McqPsimod { + unsigned int at; + QString accession; }; MassChroQml::MassChroQml(const QString & out_filename) @@ -121,7 +130,26 @@ void MassChroQml::write(ProjectSp sp_project) { writeGroups(); writeProteinList(); writePeptideList(); + writeIsotopeLabelList(); +} + + +void MassChroQml::writeIsotopeLabelList() { + //<isotope_label_list> + _output_stream->writeStartElement("isotope_label_list"); + /* + <isotope_label id="iso1"> + <mod at="Nter" value="28.0" acc="MOD:00429"/> + <mod at="K" value="28.0" acc="MOD:00429"/> + </isotope_label> + <isotope_label id="iso2"> + <mod at="Nter" value="32.0" /> + <mod at="K" value="32.0" /> + </isotope_label>*/ + //</isotope_label_list> + _output_stream->writeEndElement(); } + void MassChroQml::writePeptideList() { //<peptide_list> _output_stream->writeStartElement("peptide_list"); @@ -136,7 +164,10 @@ void MassChroQml::writePeptideList() { mcq_peptide.mods << peptide_match->getPeptideXtpSp().get()->getModifString(); mcq_peptide.prot_ids << p_protein_match->getGrpProteinSp().get()->getGroupingId(); mcq_peptide.seq = peptide_match->getPeptideXtpSp().get()->getSequence(); - mcq_peptide.mh = peptide_match->getPeptideXtpSp().get()->getNativePeptideP()->getMz(1); + mcq_peptide.native_peptide = peptide_match->getPeptideXtpSp().get()->getNativePeptideP(); + mcq_peptide.data.push_back(peptide_match->getMsRunP()->getXmlId()); + mcq_peptide.scan.push_back(peptide_match->getScan()); + mcq_peptide.charge.push_back(peptide_match->getCharge()); mcq_peptide_list.push_back(mcq_peptide); } @@ -152,6 +183,23 @@ void MassChroQml::writePeptideList() { McqPeptide cumul = mcq_peptide_list[0]; for (McqPeptide & mcq_peptide : mcq_peptide_list) { if (cumul.id == mcq_peptide.id) { + unsigned int charge = mcq_peptide.charge[0]; + QString data = mcq_peptide.data[0]; + unsigned int scan = mcq_peptide.scan[0]; + + bool not_found= true; + for (unsigned int i=0; i < cumul.scan.size(); i++) { + if ((cumul.charge[i] == charge)&&(cumul.data[i] == data)&&(cumul.scan[i] == scan)) { + not_found= false; + break; + } + } + + if (not_found) { + cumul.charge.push_back(mcq_peptide.charge[0]); + cumul.data.push_back(mcq_peptide.data[0]); + cumul.scan.push_back(mcq_peptide.scan[0]); + } if (!cumul.prot_ids.contains(mcq_peptide.prot_ids[0])) { cumul.prot_ids << mcq_peptide.prot_ids[0]; } @@ -175,15 +223,47 @@ void MassChroQml::writePeptideList() { _output_stream->writeAttribute("id",mcq_peptide.id); _output_stream->writeAttribute("mods",mcq_peptide.mods.join("|")); _output_stream->writeAttribute("prot_ids",mcq_peptide.prot_ids.join(" ")); - _output_stream->writeAttribute("mh",QString::number(mcq_peptide.mh, 'f', 10)); + _output_stream->writeAttribute("mh",QString::number(mcq_peptide.native_peptide->getMz(1), 'f', 10)); _output_stream->writeAttribute("seq",mcq_peptide.seq); - /* - <modifications><!-- this tag is optional but gives an exact mass computation --> - <psimod at="2" acc="MOD:00397"></psimod> - <psimod at="11" acc="MOD:00397"></psimod> - </modifications> - <observed_in data="samp0" scan="655" z="2" /> - <observed_in data="samp1" scan="798" z="2" />*/ + + //<modifications><!-- this tag is optional but gives an exact mass computation --> + std::vector<McqPsimod> mod_list; + unsigned int pos=1; + for (const pappso::Aa & aa: *(mcq_peptide.native_peptide)) { + const std::list<pappso::AaModificationP> aa_mod_list = aa.getModificationList(); + for (pappso::AaModificationP mod : aa_mod_list) { + if (!mod->isInternal()) { + McqPsimod psimod; + psimod.accession = mod->getAccession(); + psimod.at = pos; + mod_list.push_back(psimod); + } + } + pos++; + } + if (mod_list.size() > 0) { + _output_stream->writeStartElement("modifications"); + for (McqPsimod & psimod :mod_list) { + //<psimod at="2" acc="MOD:00397"></psimod> + _output_stream->writeStartElement("psimod"); + _output_stream->writeAttribute("at",QString("%1").arg(psimod.at)); + _output_stream->writeAttribute("acc",psimod.accession); + //<psimod at="11" acc="MOD:00397"></psimod> + _output_stream->writeEndElement(); + } + //</modifications> + _output_stream->writeEndElement(); + } + + //<observed_in data="samp0" scan="655" z="2" /> + for (unsigned int i=0; i < mcq_peptide.scan.size(); i++) { + _output_stream->writeStartElement("observed_in"); + _output_stream->writeAttribute("data",mcq_peptide.data[i]); + _output_stream->writeAttribute("scan",QString("%1").arg(mcq_peptide.scan[i])); + _output_stream->writeAttribute("z",QString("%1").arg(mcq_peptide.charge[i])); + _output_stream->writeEndElement(); + } + //<observed_in data="samp1" scan="798" z="2" />*/ //</peptide> _output_stream->writeEndElement(); } diff --git a/src/output/masschroqml.h b/src/output/masschroqml.h index c9cb8583476292eaf4ff9bef7c46e1f6ed2053da..d52c87363645491d163e627539327af71332eb4a 100644 --- a/src/output/masschroqml.h +++ b/src/output/masschroqml.h @@ -48,6 +48,7 @@ private: void writeGroups(); void writeProteinList(); void writePeptideList(); + void writeIsotopeLabelList(); private : QFile * _output_file; QXmlStreamWriter * _output_stream;