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

labeling method and masschroqml tested ok

parent de117191
No related branches found
Tags xtpcpp_0.1.11-1
No related merge requests found
......@@ -28,6 +28,7 @@
******************************************************************************/
#include "label.h"
#include "../../utils/utils.h"
#include <pappsomspp/amino_acid/aamodification.h>
#include <pappsomspp/pappsoexception.h>
#include <QDebug>
......@@ -79,3 +80,27 @@ pappso::PeptideSp Label::getLabeledPeptideSp(const pappso::Peptide * p_peptide)
}
return (peptide.makePeptideSp());
}
const QString & Label::getXmlId() const {
return _xml_id;
}
void Label::writeMassChroqMl(QXmlStreamWriter* output_stream) const {
//<isotope_label id="iso1">
output_stream->writeStartElement("isotope_label");
output_stream->writeAttribute("id",_xml_id);
// <mod at="Nter" value="28.0" acc="MOD:00429"/>
// <mod at="K" value="28.0" acc="MOD:00429"/>
for (const LabelModification label_modification: _modification_list) {
output_stream->writeStartElement("mod");
output_stream->writeAttribute("at",label_modification.at);
output_stream->writeAttribute("value",Utils::getXmlDouble(label_modification.modification->getMass()));
output_stream->writeAttribute("acc",label_modification.modification->getAccession());
output_stream->writeEndElement();
output_stream->writeComment(label_modification.modification->getName());
}
// </isotope_label>
output_stream->writeEndElement();
}
......@@ -34,6 +34,7 @@
#include <QDomNode>
#include <pappsomspp/amino_acid/aamodification.h>
#include <pappsomspp/peptide/peptide.h>
#include <QXmlStreamWriter>
struct LabelModification {
......@@ -49,6 +50,8 @@ public:
Label( const Label & other);
bool containsAaModificationP(const std::list<pappso::AaModificationP> & modification_set) const;
pappso::PeptideSp getLabeledPeptideSp(const pappso::Peptide * p_peptide) const;
void writeMassChroqMl(QXmlStreamWriter* output_stream) const;
const QString & getXmlId() const;
private:
QString _xml_id;
std::vector<LabelModification> _modification_list;
......
......@@ -71,6 +71,9 @@ Label * LabelingMethod::getLabel(const std::list<pappso::AaModificationP> & modi
return nullptr;
}
const QString & LabelingMethod::getXmlId() const {
return _xml_id;
}
LabelingMethod::LabelingMethod( const LabelingMethod & other):_xml_id(other._xml_id) {
for (Label * p_label: other._label_list) {
_label_list.push_back( new Label(*p_label));
......@@ -94,3 +97,27 @@ void LabelingMethod::parseMethod(QDomNode & method_node) {
child = child.nextSibling();
}
}
void LabelingMethod::writeMassChroqMl(QXmlStreamWriter* output_stream) const {
//<isotope_label_list>
output_stream->writeStartElement("isotope_label_list");
output_stream->writeComment(getXmlId());
/*
<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>*/
for (Label * p_label: _label_list) {
p_label->writeMassChroqMl(output_stream);
}
//</isotope_label_list>
output_stream->writeEndElement();
}
const std::vector<Label *> & LabelingMethod::getLabelList() const {
return _label_list;
}
......@@ -33,6 +33,7 @@
#include <QDomNode>
#include <vector>
#include <memory>
#include <QXmlStreamWriter>
#include "label.h"
class LabelingMethod;
......@@ -46,6 +47,9 @@ public:
~LabelingMethod();
LabelingMethodSp makeLabelingMethodSp() const;
Label * getLabel(const std::list<pappso::AaModificationP> & modification_set) const;
const QString & getXmlId() const;
void writeMassChroqMl(QXmlStreamWriter* output_stream) const;
const std::vector<Label *> & getLabelList() const;
private :
void parseMethod(QDomNode & method_node);
void parseLabel(QDomNode & method_node);
......
......@@ -85,7 +85,7 @@ ProteinStore & Project::getProteinStore() {
IdentificationDataSourceStore & Project::getIdentificationDataSourceStore() {
return _identification_data_source_store;
}
const IdentificationDataSourceStore & Project::getIdentificationDataSourceStore() const{
const IdentificationDataSourceStore & Project::getIdentificationDataSourceStore() const {
return _identification_data_source_store;
}
const AutomaticFilterParameters & Project::getAutomaticFilterParameters() const {
......@@ -147,3 +147,7 @@ void Project::setLabelingMethodSp(LabelingMethodSp labeling_method_sp) {
_labeling_method_sp = labeling_method_sp;
_peptide_store.setLabelingMethodSp(labeling_method_sp);
}
LabelingMethodSp Project::getLabelingMethodSp() const {
return _labeling_method_sp;
}
......@@ -78,6 +78,10 @@ public:
* */
void setLabelingMethodSp(LabelingMethodSp labeling_method_sp);
/** @brief get labeling method shared pointer
* */
LabelingMethodSp getLabelingMethodSp() const;
private :
LabelingMethodSp _labeling_method_sp;
bool _is_combine_mode =true;
......
......@@ -32,6 +32,7 @@
#include <pappsomspp/utils.h>
#include <pappsomspp/grouping/grpprotein.h>
#include <pappsomspp/amino_acid/Aa.h>
#include <QStringList>
struct McqObserved {
......@@ -144,8 +145,8 @@ void MassChroQml::write(ProjectSp sp_project) {
writeQuantificationTraces();
writeQuantify();
_output_stream->writeEndElement();
_output_stream->writeEndDocument();
}
......@@ -210,6 +211,13 @@ void MassChroQml::writeQuantify() {
_output_stream->writeStartElement("peptides_in_peptide_list");
_output_stream->writeAttribute("mode","post_matching");
_output_stream->writeAttribute("ni_min_abundance","0.8");
if (_sp_project.get()->getLabelingMethodSp().get() != nullptr) {
QStringList isotope_label_ref;
for (const Label * p_label :_sp_project.get()->getLabelingMethodSp().get()->getLabelList()) {
isotope_label_ref << p_label->getXmlId();
}
_output_stream->writeAttribute("isotope_label_refs",isotope_label_ref.join(" "));
}
_output_stream->writeEndElement();
_output_stream->writeComment("<mz_list>732.317 449.754 552.234 464.251 381.577 569.771 575.256</mz_list>");
......@@ -231,7 +239,7 @@ void MassChroQml::writeQuantificationMethods() {
_output_stream->writeComment("max : XIC on BasePeak; sum : XIC on TIC");
//<ppm_range min="10" max="10"/><!--For XIC extraction on Da use: mz_range-->
_output_stream->writeComment("For XIC extraction on Da use: mz_range");
_output_stream->writeStartElement("ppm_range");
_output_stream->writeAttribute("min","10");
......@@ -330,53 +338,45 @@ void MassChroQml::writeAlignments() {
}
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();
LabelingMethod * p_labeling_method = _sp_project.get()->getLabelingMethodSp().get();
if (p_labeling_method != nullptr) {
//<isotope_label_list>
p_labeling_method->writeMassChroqMl(_output_stream);
}
}
void MassChroQml::writePeptideList() {
//<peptide_list>
_output_stream->writeStartElement("peptide_list");
const std::map<unsigned int, GroupingGroupSp> & group_store = _p_identification_group->getGroupStore().getGroupMap();
for (auto & group_pair :group_store) {
writePeptideListInGroup(group_pair.second.get());
}
//</peptide_list>
_output_stream->writeEndElement();
}
}
void MassChroQml::writePeptideListInGroup(const GroupingGroup * p_group) {
const std::vector<std::pair<unsigned int, const PeptideMatch *>> & sg_peptide_match_list = p_group->getPairSgNumberPeptideMatchList();
std::vector<McqPeptide> mcq_peptide_list;
for (auto & sg_peptide_pair :sg_peptide_match_list) {
unsigned int sg_number = sg_peptide_pair.first;
const PeptideMatch * peptide_match = sg_peptide_pair.second;
McqPeptide mcq_peptide;
mcq_peptide.id = peptide_match->getGrpPeptideSp().get()->getGroupingId();
mcq_peptide.mods << peptide_match->getPeptideXtpSp().get()->getModifString();
mcq_peptide.prot_ids << p_group->getProteinGroupingIdOfSubgroup(sg_number);
mcq_peptide.seq = peptide_match->getPeptideXtpSp().get()->getSequence();
mcq_peptide.native_peptide = peptide_match->getPeptideXtpSp().get()->getNativePeptideP();
McqObserved observed = {peptide_match->getMsRunP(),peptide_match->getScan(),peptide_match->getCharge() };
mcq_peptide.observed_in.push_back(observed);
mcq_peptide_list.push_back(mcq_peptide);
McqPeptide mcq_peptide;
mcq_peptide.id = peptide_match->getGrpPeptideSp().get()->getGroupingId();
mcq_peptide.mods << peptide_match->getPeptideXtpSp().get()->getModifString();
mcq_peptide.prot_ids << p_group->getProteinGroupingIdOfSubgroup(sg_number);
mcq_peptide.seq = peptide_match->getPeptideXtpSp().get()->getSequence();
mcq_peptide.native_peptide = peptide_match->getPeptideXtpSp().get()->getNativePeptideP();
McqObserved observed = {peptide_match->getMsRunP(),peptide_match->getScan(),peptide_match->getCharge() };
mcq_peptide.observed_in.push_back(observed);
mcq_peptide_list.push_back(mcq_peptide);
}
......@@ -390,9 +390,9 @@ void MassChroQml::writePeptideListInGroup(const GroupingGroup * p_group) {
McqPeptide cumul = mcq_peptide_list[0];
for (McqPeptide & mcq_peptide : mcq_peptide_list) {
if (cumul.id == mcq_peptide.id) {
cumul.observed_in.push_back(mcq_peptide.observed_in[0]);
if (!cumul.prot_ids.contains(mcq_peptide.prot_ids[0])) {
cumul.prot_ids << mcq_peptide.prot_ids[0];
}
......@@ -450,11 +450,11 @@ void MassChroQml::writePeptideListInGroup(const GroupingGroup * p_group) {
//<observed_in data="samp0" scan="655" z="2" />
std::sort(mcq_peptide.observed_in.begin(), mcq_peptide.observed_in.end(),[](const McqObserved & first, const McqObserved & second) {
return std::tie(first.charge, first.scan, first.msrun) < std::tie(second.charge, second.scan, second.msrun);
});
return std::tie(first.charge, first.scan, first.msrun) < std::tie(second.charge, second.scan, second.msrun);
});
auto last = std::unique(mcq_peptide.observed_in.begin(), mcq_peptide.observed_in.end());
mcq_peptide.observed_in.erase(last, mcq_peptide.observed_in.end());
mcq_peptide.observed_in.erase(last, mcq_peptide.observed_in.end());
for (McqObserved observed_in : mcq_peptide.observed_in) {
_output_stream->writeStartElement("observed_in");
_output_stream->writeAttribute("data",observed_in.msrun->getXmlId());
......
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