From d93aff0a1eb456ca29529b2611a9b3c55a314148 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Fri, 7 Apr 2017 16:07:30 +0200
Subject: [PATCH] WIP : writing MassChroqML quantification methods

---
 src/input/xpipsaxhandler.cpp |   1 -
 src/output/masschroqml.cpp   | 111 +++++++++++++++++++++++++++++++++++
 src/output/masschroqml.h     |   2 +
 3 files changed, 113 insertions(+), 1 deletion(-)

diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp
index bd719e39..c3ead743 100644
--- a/src/input/xpipsaxhandler.cpp
+++ b/src/input/xpipsaxhandler.cpp
@@ -182,7 +182,6 @@ bool XpipSaxHandler::startElement_sample(QXmlAttributes attributes) {
     qDebug() << "startElement_sample ";
     
     MsRunSp ms_run =  _p_project->getMsRunStore().getInstance(attributes.value("value").simplified());
-    ms_run.get()->setXmlId(attributes.value("value").simplified());
     ms_run.get()->setFilename(attributes.value("value").simplified());
     _current_identification_group_p->addMsRunSp(ms_run);
     qDebug() << "startElement_sample end" ;
diff --git a/src/output/masschroqml.cpp b/src/output/masschroqml.cpp
index 1399e04c..9ad538a6 100644
--- a/src/output/masschroqml.cpp
+++ b/src/output/masschroqml.cpp
@@ -131,9 +131,120 @@ void MassChroQml::write(ProjectSp sp_project) {
     writeProteinList();
     writePeptideList();
     writeIsotopeLabelList();
+    writeAlignments();
+    writeQuantificationMethods();
 }
 
 
+void MassChroQml::writeQuantificationMethods() {
+    //<quantification_methods>
+    _output_stream->writeStartElement("quantification_methods");
+    //<quantification_method id="my_qzivy">
+    _output_stream->writeStartElement("quantification_method");
+    _output_stream->writeAttribute("id","quant1");
+    //<xic_extraction xic_type="sum">
+    _output_stream->writeStartElement("xic_extraction");
+    _output_stream->writeAttribute("xic_type","max");
+    _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->writeStartElement("ppm_range");
+    _output_stream->writeAttribute("min","10");
+    _output_stream->writeAttribute("max","10");
+    _output_stream->writeComment("For XIC extraction on Da use: mz_range");
+    _output_stream->writeEndElement();
+    //</xic_extraction>
+    _output_stream->writeEndElement();
+    //<xic_filters>
+    _output_stream->writeStartElement("xic_filters");
+    //<anti_spike half="5"/>
+    _output_stream->writeStartElement("anti_spike");
+    _output_stream->writeAttribute("half","5");
+    _output_stream->writeEndElement();
+    //<background half_mediane="5" half_min_max="20"/>
+    _output_stream->writeComment("<background half_mediane=\"5\" half_min_max=\"20\"/>");
+    //</xic_filters>
+    _output_stream->writeEndElement();
+    //<peak_detection>
+
+    _output_stream->writeStartElement("peak_detection");
+    //<detection_zivy>
+    _output_stream->writeStartElement("detection_zivy");
+    //<mean_filter_half_edge>1</mean_filter_half_edge>
+    _output_stream->writeStartElement("mean_filter_half_edge");
+    _output_stream->writeCharacters("1");
+    _output_stream->writeEndElement();
+    //<minmax_half_edge>3</minmax_half_edge>
+    _output_stream->writeStartElement("minmax_half_edge");
+    _output_stream->writeCharacters("3");
+    _output_stream->writeEndElement();
+    //<maxmin_half_edge>2</maxmin_half_edge>
+    _output_stream->writeStartElement("maxmin_half_edge");
+    _output_stream->writeCharacters("2");
+    _output_stream->writeEndElement();
+    //<detection_threshold_on_max>5000</detection_threshold_on_max>
+    _output_stream->writeStartElement("detection_threshold_on_max");
+    _output_stream->writeCharacters("5000");
+    _output_stream->writeEndElement();
+    //<detection_threshold_on_min>3000</detection_threshold_on_min>
+    _output_stream->writeStartElement("detection_threshold_on_min");
+    _output_stream->writeCharacters("3000");
+    _output_stream->writeEndElement();
+    //</detection_zivy>
+    _output_stream->writeEndElement();
+    //</peak_detection>
+
+    _output_stream->writeEndElement();
+    //</quantification_method>
+    _output_stream->writeEndElement();
+    //</quantification_methods>
+    _output_stream->writeEndElement();
+}
+void MassChroQml::writeAlignments() {
+    //<alignments>
+    _output_stream->writeStartElement("alignments");
+    //<alignment_methods>
+    _output_stream->writeStartElement("alignment_methods");
+    //<alignment_method id="my_ms2">
+    _output_stream->writeStartElement("alignment_method");
+    _output_stream->writeAttribute("id","my_ms2");
+
+    //<ms2><!-- write_time_values_output_dir="directory" to write retention time corrections -->
+
+    _output_stream->writeStartElement("ms2");
+    _output_stream->writeComment("write_time_values_output_dir=\"directory\" to write retention time corrections");
+    //<ms2_tendency_halfwindow>10</ms2_tendency_halfwindow>
+    _output_stream->writeStartElement("ms2_tendency_halfwindow");
+    _output_stream->writeCharacters("10");
+    _output_stream->writeEndElement();
+    //<ms2_smoothing_halfwindow>5</ms2_smoothing_halfwindow>
+
+    _output_stream->writeStartElement("ms2_smoothing_halfwindow");
+    _output_stream->writeCharacters("15");
+    _output_stream->writeEndElement();
+    //<ms1_smoothing_halfwindow>3</ms1_smoothing_halfwindow>
+
+    _output_stream->writeStartElement("ms1_smoothing_halfwindow");
+    _output_stream->writeCharacters("0");
+    _output_stream->writeEndElement();
+    //</ms2>
+    _output_stream->writeEndElement();
+    //</alignment_method>
+    _output_stream->writeEndElement();
+    _output_stream->writeComment("<alignment_method id=\"my_obiwarp\">          \n<obiwarp>\n					<lmat_precision>1</lmat_precision>\n					<mz_start>500</mz_start>\n					<mz_stop>1200</mz_stop>\n				</obiwarp>\n			</alignment_method>");
+    //</alignment_methods>
+    _output_stream->writeEndElement();
+    //<align group_id="G1" method_id="my_ms2" reference_data_id="samp0" />
+    //<align group_id="G2" method_id="my_obiwarp" reference_data_id="samp2" />
+    _output_stream->writeStartElement("align");
+    _output_stream->writeAttribute("group_id","fractiona1");
+    _output_stream->writeAttribute("method_id","my_ms2");
+    _output_stream->writeAttribute("reference_data_id","sampa1");
+    _output_stream->writeEndElement();
+    //</alignments>
+    _output_stream->writeEndElement();
+}
+
 void MassChroQml::writeIsotopeLabelList() {
     //<isotope_label_list>
     _output_stream->writeStartElement("isotope_label_list");
diff --git a/src/output/masschroqml.h b/src/output/masschroqml.h
index d52c8736..0e975795 100644
--- a/src/output/masschroqml.h
+++ b/src/output/masschroqml.h
@@ -49,6 +49,8 @@ private:
     void writeProteinList();
     void writePeptideList();
     void writeIsotopeLabelList();
+    void writeAlignments();
+    void writeQuantificationMethods();
 private :
     QFile * _output_file;
     QXmlStreamWriter * _output_stream;
-- 
GitLab