Commit cc249141 authored by Olivier Langella's avatar Olivier Langella
Browse files

MassChroqML writer implemented

parent 81a45156
......@@ -151,34 +151,55 @@ void
MasschroqWriter::printAlignmentResults(const Msrun * msrun)
{
_output_stream->writeStartElement("alignment_result");
// get the time values for this msrun and encode them
std::vector<mcq_double> v_time = msrun->getVectorOfTimeValues();
QByteArray enc_time_array = DecodeBinary::base64_encode_doubles(v_time);
const QString enc_time = QString::fromAscii(enc_time_array.constData());
_output_stream->writeAttribute("precision", _enc_precision);
_output_stream->writeAttribute("little_endian", _enc_little_endian);
_output_stream->writeCharacters(enc_time);
_output_stream->writeEndElement(); // </alignment_result>
qDebug() << "MasschroqWriter::printAlignmentResults begin";
//check this was not already written
bool already_written = (find(_written_align_results.begin(), _written_align_results.end(), msrun) != _written_align_results.end());
if (already_written) {
}
else {
_output_stream->writeStartElement("alignment_result");
// get the time values for this msrun and encode them
std::vector<mcq_double> v_time = msrun->getVectorOfTimeValues();
QByteArray enc_time_array = DecodeBinary::base64_encode_doubles(v_time);
const QString enc_time = QString::fromAscii(enc_time_array.constData());
_output_stream->writeAttribute("precision", _enc_precision);
_output_stream->writeAttribute("little_endian", _enc_little_endian);
_output_stream->writeCharacters(enc_time);
_output_stream->writeEndElement(); // </alignment_result>
_written_align_results.push_back(msrun);
}
qDebug() << "MasschroqWriter::printAlignmentResults end";
}
void
MasschroqWriter::writeQuantifyBegin(const Quantificator * p_quantificator)
{
qDebug() << "MasschroqWriter::writeQuantifyBegin begin";
_p_quantificator = p_quantificator;
_current_group_id = p_quantificator->getMsRunGroup()->getXmlId();
_current_quantify_id = _p_quantificator->getXmlId();
_output_stream->writeStartElement("result");
_output_stream->writeAttribute("quantify_id", _p_quantificator->getXmlId());
qDebug() << "MasschroqWriter::writeQuantifyBegin end";
}
void
MasschroqWriter::writeQuantifyEnd()
{
qDebug() << "MasschroqWriter::writeQuantifyEnd begin";
_current_group_id.clear();
if (_p_msrun != nullptr) {
setEndCurrentMsrun();
}
_output_stream->writeEndElement(); // </result>
_written_align_results.clear();
qDebug() << "MasschroqWriter::writeQuantifyEnd end";
}
......@@ -204,10 +225,12 @@ void
MasschroqWriter::setEndCurrentMsrun()
{
_output_stream->writeEndElement(); // </data>
_p_msrun = nullptr;
}
void MasschroqWriter::privWriteMatchedPeak(const Msrun * p_msrun, const QuantiItemBase * p_quanti_item, const AlignedXicPeak * peak) {
qDebug() << "MasschroqWriter::privWriteMatchedPeak begin";
setCurrentMsrun(p_msrun);
_output_stream->writeStartElement("quanti_item");
......@@ -231,34 +254,37 @@ void MasschroqWriter::privWriteMatchedPeak(const Msrun * p_msrun, const QuantiIt
unsigned int currentZ;
_output_stream->writeStartElement("quantification_data");
if (peak != nullptr) {
_output_stream->writeStartElement("quantification_data");
_output_stream->writeAttribute("mz", currentMz);
_output_stream->writeAttribute("rt", peak->getMaxXicElement().rt);
_output_stream->writeAttribute("max_intensity", peak->getMaxXicElement().intensity);
_output_stream->writeAttribute("area", peak->getArea());
_output_stream->writeAttribute("rt_begin", peak->getLeftBoundary().rt);
_output_stream->writeAttribute("rt_end", peak->getRightBoundary().rt);
_output_stream->writeAttribute("mz", currentMz);
_output_stream->writeAttribute("rt", peak->getMaxXicElement().rt);
_output_stream->writeAttribute("max_intensity", peak->getMaxXicElement().intensity);
_output_stream->writeAttribute("area", peak->getArea());
_output_stream->writeAttribute("rt_begin", peak->getLeftBoundary().rt);
_output_stream->writeAttribute("rt_end", peak->getRightBoundary().rt);
if (current_peptide != 0)
{
pepId = current_peptide->getXmlId();
_output_stream->writeAttribute("peptide", pepId);
if (current_peptide->getIsotopeLabel() != 0)
if (current_peptide != 0)
{
isotopeLabel = current_peptide->getIsotopeLabel()->getXmlId();
_output_stream->writeAttribute("isotope", isotopeLabel);
}
pepId = current_peptide->getXmlId();
_output_stream->writeAttribute("peptide", pepId);
currentZ = *p_quanti_item->getZ();
_output_stream->writeAttribute("z", currentZ);
}
_output_stream->writeEndElement(); // "</quantification_data>"
if (current_peptide->getIsotopeLabel() != 0)
{
isotopeLabel = current_peptide->getIsotopeLabel()->getXmlId();
_output_stream->writeAttribute("isotope", isotopeLabel);
}
currentZ = *p_quanti_item->getZ();
_output_stream->writeAttribute("z", currentZ);
}
_output_stream->writeEndElement(); // "</quantification_data>"
}
_output_stream->writeEndElement(); // </quanti_item>
qDebug() << "MasschroqWriter::privWriteMatchedPeak end";
}
......@@ -270,6 +296,9 @@ MasschroqWriter::debriefing()
{
// write protein results
qDebug() << "MasschroqWriter::debriefing begin";
_output_stream->writeEndElement(); // </results>
_output_stream->writeStartElement("summary");
QString mcq_version(MASSCHROQ_VERSION);
_output_stream->writeAttribute("masschroq_version", mcq_version);
......@@ -296,4 +325,5 @@ MasschroqWriter::debriefing()
_output_stream->writeEndElement(); // </summary>
_output_stream->writeEndDocument();
_output_file->close();
qDebug() << "MasschroqWriter::debriefing end";
}
......@@ -93,6 +93,7 @@ private :
const QString _enc_little_endian;
const Quantificator* _p_quantificator=nullptr;
const Msrun* _p_msrun =nullptr;
std::vector<const Msrun *> _written_align_results;
};
......
......@@ -860,10 +860,13 @@
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element ref="quantification_result"
maxOccurs="unbounded" minOccurs="1"/>
<xs:element ref="compar_result"
maxOccurs="unbounded" minOccurs="0"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="quantification_result"></xs:element>
<xs:element ref="compar_result"></xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment