xtandempresetreader.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/processing/tandemwrapper/xtandempresetreader.cpp
* \date 06/02/2020
* \author Olivier Langella
* \brief read tandem preset file to get centroid parameters and number of
* threads
*/
/*******************************************************************************
* Copyright (c) 2020 Olivier Langella <Olivier.Langella@u-psud.fr>.
*
* This file is part of PAPPSOms-tools.
*
* PAPPSOms-tools is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms-tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "xtandempresetreader.h"
#include "../../pappsoexception.h"
#include "../../precision.h"
namespace pappso
{
XtandemPresetReader::XtandemPresetReader()
{
}
XtandemPresetReader::~XtandemPresetReader()
{
}
void
XtandemPresetReader::read_note()
{
// <note type="input"
// label="output,path">/gorgone/pappso/jouy/users/Celine/2019_Lumos/20191222_107_Juste_APD/metapappso_condor/test_run/20191222_18_EF1_third_step_test_condor_22janv.xml</note>
if(m_qxmlStreamReader.name() != "note")
{
m_qxmlStreamReader.skipCurrentElement();
return;
}
Q_ASSERT(m_qxmlStreamReader.name() == "note");
QString label;
m_countNote++;
if((m_qxmlStreamReader.attributes().hasAttribute("type")) &&
(m_qxmlStreamReader.attributes().value("type").toString() == "input"))
{
if(m_qxmlStreamReader.attributes().hasAttribute("label"))
{
label = m_qxmlStreamReader.attributes().value("label").toString();
}
}
if(label.isEmpty())
{
}
else
{
if(label == "spectrum, timstof MS2 filters")
{
}
else if(label == "spectrum, threads")
{
m_threads = m_qxmlStreamReader.readElementText().toInt();
return;
}
else if(label == "spectrum, fragment monoisotopic mass error units")
{
m_ms2precisionUnit = PrecisionUnit::dalton;
if(m_qxmlStreamReader.readElementText().trimmed().toLower() == "ppm")
{
m_ms2precisionUnit = PrecisionUnit::ppm;
}
return;
}
else if(label == "spectrum, fragment monoisotopic mass error")
{
m_ms2precisionValue = m_qxmlStreamReader.readElementText().toDouble();
return;
}
}
m_qxmlStreamReader.skipCurrentElement();
// qDebug() << "end ";
//
}
int
XtandemPresetReader::getNumberOfThreads() const
{
return m_threads;
}
const QString
XtandemPresetReader::getMs2FiltersOptions() const
{
QString filter_suite;
PrecisionPtr precision = PrecisionFactory::getPrecisionPtrInstance(
m_ms2precisionUnit, m_ms2precisionValue);
QString charge_decon_filter = QString("chargeDeconvolution|%1")
.arg(precision->toString().replace(" ", ""));
PrecisionPtr precision_exclu = PrecisionFactory::getPrecisionPtrInstance(
m_ms2precisionUnit, m_ms2precisionValue / 2);
QString mz_exclusion_filter =
QString("mzExclusion|%1").arg(precision_exclu->toString().replace(" ", ""));
filter_suite = charge_decon_filter + " " + mz_exclusion_filter;
return filter_suite;
}
void
XtandemPresetReader::readStream()
{
qDebug();
m_countNote = 0;
m_threads = -1;
m_ms2precisionUnit = PrecisionUnit::dalton;
m_ms2precisionValue = -1;
if(m_qxmlStreamReader.readNextStartElement())
{
if(m_qxmlStreamReader.name() == "bioml")
{
qDebug();
while(m_qxmlStreamReader.readNextStartElement())
{
// qDebug() << m_qxmlStreamReader.name();
read_note();
}
}
else
{
m_qxmlStreamReader.raiseError(
QObject::tr("Not an X!Tandem preset file"));
m_qxmlStreamReader.skipCurrentElement();
}
}
if(m_threads == -1)
{
qDebug();
m_qxmlStreamReader.raiseError(QObject::tr("Not an X!Tandem preset file"));
}
qDebug();
}
int
XtandemPresetReader::getCountNote() const
{
return m_countNote;
}
} // namespace pappso
pappso::PrecisionBase
Definition: precision.h:44
pappso::PrecisionBase::toString
virtual QString toString() const =0
pappso::PrecisionFactory::getPrecisionPtrInstance
static PrecisionPtr getPrecisionPtrInstance(PrecisionUnit unit, double value)
get a precision pointer instance
Definition: precision.cpp:213
pappso::XmlStreamReaderInterface::m_qxmlStreamReader
QXmlStreamReader m_qxmlStreamReader
Definition: xmlstreamreaderinterface.h:71
pappso::XtandemPresetReader::m_threads
int m_threads
Definition: xtandempresetreader.h:64
pappso::XtandemPresetReader::m_countNote
int m_countNote
Definition: xtandempresetreader.h:63
pappso::XtandemPresetReader::~XtandemPresetReader
virtual ~XtandemPresetReader()
Definition: xtandempresetreader.cpp:39
pappso::XtandemPresetReader::getMs2FiltersOptions
const QString getMs2FiltersOptions() const
Definition: xtandempresetreader.cpp:110
pappso::XtandemPresetReader::m_ms2precisionValue
double m_ms2precisionValue
Definition: xtandempresetreader.h:67
pappso::XtandemPresetReader::getCountNote
int getCountNote() const
Definition: xtandempresetreader.cpp:162
pappso::XtandemPresetReader::getNumberOfThreads
int getNumberOfThreads() const
Definition: xtandempresetreader.cpp:103
pappso::XtandemPresetReader::readStream
virtual void readStream() override
Definition: xtandempresetreader.cpp:128
pappso::XtandemPresetReader::XtandemPresetReader
XtandemPresetReader()
Definition: xtandempresetreader.cpp:35
pappso::XtandemPresetReader::read_note
void read_note()
Definition: xtandempresetreader.cpp:45
pappso::XtandemPresetReader::m_ms2precisionUnit
PrecisionUnit m_ms2precisionUnit
Definition: xtandempresetreader.h:66
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
pappso::PrecisionUnit::ppm
@ ppm
pappso::PrecisionUnit::dalton
@ dalton
xtandempresetreader.h
read tandem preset file to get centroid parameters and number of threads