Skip to content
Snippets Groups Projects
Commit b8ed528b authored by Olivier Langella's avatar Olivier Langella
Browse files

WIP : writing MassChroqML

parent 73cf8585
No related branches found
No related tags found
No related merge requests found
......@@ -67,8 +67,12 @@ PeptideXtpSp PeptideXtp::makePeptideXtpSp() const {
pappso::mz PeptideXtp::getGroupingMass() const {
return getNativePeptideP()->getMass();
}
const pappso::Peptide * PeptideXtp::getNativePeptideP() const {
if (_sp_native_peptide.get() == nullptr) {
return getMass();
return this;
}
return _sp_native_peptide.get()->getMass();
return _sp_native_peptide.get();
}
......@@ -40,12 +40,15 @@ public:
~PeptideXtp();
PeptideXtpSp makePeptideXtpSp() const;
/** \brief get the tehoretical mass to use for grouping
* This mass might be different than the true peptide mass to recognize that a tagged
* peptide with taget modification is a light, inter or heavy version of the same peptide
*/
pappso::mz getGroupingMass() const;
const pappso::Peptide * getNativePeptideP() const;
/** \brief human readable string that contains modifications
* */
const QString getModifString() const;
......
......@@ -32,6 +32,15 @@
#include <pappsomspp/utils.h>
#include <pappsomspp/grouping/grpprotein.h>
struct McqPeptide {
QString id;
pappso::pappso_double mh;
QStringList mods;
QStringList prot_ids;
QString seq;
};
MassChroQml::MassChroQml(const QString & out_filename)
{
//_p_digestion_pipeline = p_digestion_pipeline;
......@@ -116,29 +125,58 @@ void MassChroQml::write(ProjectSp sp_project) {
void MassChroQml::writePeptideList() {
//<peptide_list>
_output_stream->writeStartElement("peptide_list");
QStringList empty;
for (const GroupingGroupSp & group:_group_list) {
std::map<const PeptideMatch *, QStringList> peptide_sg_map;
unsigned int group_number = group.get()->getGroupNumber();
for (auto && pair_peptide_match :group.get()->getPairSgNumberPeptideMatchList()) {
unsigned int sg_number = pair_peptide_match.first;
const PeptideMatch * p_peptide_match = pair_peptide_match.second;
if (!p_peptide_match->isGrouped()) continue;
std::pair<std::map< const PeptideMatch *, QStringList>::iterator,bool> ret = peptide_sg_map.insert(std::pair<const PeptideMatch *, QStringList>(p_peptide_match, empty));
QString sg_str = QString("%1.%2.a1").arg(pappso::Utils::getLexicalOrderedString(group_number)).arg(pappso::Utils::getLexicalOrderedString(sg_number));
if (!ret.first->second.contains(sg_str)) {
ret.first->second << sg_str;
std::vector<McqPeptide> mcq_peptide_list;
for (ProteinMatch * p_protein_match :_p_identification_group->getProteinMatchList()) {
if (!p_protein_match->isGrouped()) continue;
for (PeptideMatch * peptide_match :p_protein_match->getPeptideMatchList()) {
if (!peptide_match->isGrouped()) continue;
McqPeptide mcq_peptide;
mcq_peptide.id = peptide_match->getGrpPeptideSp().get()->getGroupingId();
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_list.push_back(mcq_peptide);
}
}
//sort list
std::sort(mcq_peptide_list.begin(),mcq_peptide_list.end(),[](const McqPeptide & first, const McqPeptide & second) {
return (first.id < second.id) ;
});
std::vector<McqPeptide> cumul_mcq_peptide_list;
if (mcq_peptide_list.size() > 0) {
McqPeptide cumul = mcq_peptide_list[0];
for (McqPeptide & mcq_peptide : mcq_peptide_list) {
if (cumul.id == mcq_peptide.id) {
if (!cumul.prot_ids.contains(mcq_peptide.prot_ids[0])) {
cumul.prot_ids << mcq_peptide.prot_ids[0];
}
if (!cumul.mods.contains(mcq_peptide.mods[0])) {
cumul.mods << mcq_peptide.mods[0];
}
}
else {
cumul_mcq_peptide_list.push_back(cumul);
cumul = mcq_peptide;
}
}
cumul_mcq_peptide_list.push_back(cumul);
}
for (auto && pair_peptide_sgid : peptide_sg_map) {
for (McqPeptide mcq_peptide : cumul_mcq_peptide_list) {
//<peptide id="pep0" mh="1463.626" mods="114.08" prot_ids="P1.1"
// seq="TCVADESHAGCEK">
_output_stream->writeStartElement("peptide");
_output_stream->writeAttribute("id",pair_peptide_sgid.first->getGrpPeptideSp().get()->getGroupingId());
_output_stream->writeAttribute("prot_ids",pair_peptide_sgid.second.join(" "));
_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("seq",mcq_peptide.seq);
/*
<modifications><!-- this tag is optional but gives an exact mass computation -->
<psimod at="2" acc="MOD:00397"></psimod>
......@@ -148,7 +186,6 @@ void MassChroQml::writePeptideList() {
<observed_in data="samp1" scan="798" z="2" />*/
//</peptide>
_output_stream->writeEndElement();
}
}
//</peptide_list>
_output_stream->writeEndElement();
......@@ -187,7 +224,6 @@ void MassChroQml::writeProteinList() {
if (!p_protein_match->isGrouped()) continue;
//<protein desc="conta|P02769|ALBU_BOVIN SERUM ALBUMIN PRECURSOR."
// id="P1.1" />
_group_list.insert(p_protein_match->getGroupingGroupSp());
pappso::GrpProteinSp grp_protein = p_protein_match->getGrpProteinSp();
if (grp_protein.get()->getRank() == 1) {
_output_stream->writeStartElement("protein");
......
......@@ -53,7 +53,6 @@ private :
QXmlStreamWriter * _output_stream;
ProjectSp _sp_project;
IdentificationGroup * _p_identification_group;
std::set<GroupingGroupSp> _group_list;
};
#endif // MASSCHROQML_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment