libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
wraptandeminput.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/tandemwrapper/wraptandeminput.cpp
3 * \date 13/11/2021
4 * \author Olivier Langella
5 * \brief rewrites tandem xml input file with temporary files
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2021 Olivier Langella <Olivier.Langella@u-psud.fr>.
10 *
11 * This file is part of PAPPSOms-tools.
12 *
13 * PAPPSOms-tools is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms-tools is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
28
29#include "wraptandeminput.h"
30#include <QFileInfo>
32
33
34namespace pappso
35{
36WrapTandemInput::WrapTandemInput(const QString &destinationMzXmlFile,
37 const QString &destinationTandemInputFile,
38 const QString &destinationTandemOutputFile)
39 : m_destinationTandemInputFile(destinationTandemInputFile)
40{
41 m_destinationMzXmlFileName = destinationMzXmlFile;
42 m_destinationTandemOutputFileName = destinationTandemOutputFile;
43 m_destinationTandemInputFileName = QFileInfo(destinationTandemInputFile).absoluteFilePath();
44
45 if(destinationTandemInputFile.isEmpty())
46 {
47 throw pappso::PappsoException(QObject::tr("ERROR: X!Tandem input file path is empty"));
48 }
49
50 if(!m_destinationTandemInputFile.open(QIODevice::WriteOnly))
51 {
53 QObject::tr("ERROR: unable to open %1 tandem output file for write")
54 .arg(destinationTandemInputFile));
55 }
56
58 m_writerXmlTandemInput.setAutoFormatting(true);
59 m_writerXmlTandemInput.writeStartDocument("1.0");
60}
61
66
67
68void
70{
71 qDebug();
72 if(m_qxmlStreamReader.readNextStartElement())
73 {
74 if(m_qxmlStreamReader.name().toString() == "bioml")
75 {
77 qDebug();
78 while(m_qxmlStreamReader.readNextStartElement())
79 {
80 // qDebug() << m_qxmlStreamReader.name();
81 // read_note();
83
84 QString type = m_qxmlStreamReader.attributes().value("type").toString();
85 QString label = m_qxmlStreamReader.attributes().value("label").toString();
86
87 if((type == "input") && (label == "spectrum, path"))
88 {
89 //<note type="input" label="spectrum, path">
90
93 // m_qxmlStreamReader.skipCurrentElement();
94 }
95 else if((type == "input") && (label == "output, path"))
96 {
97 //<note type="input" label="output, path">
100 // m_qxmlStreamReader.skipCurrentElement();
101 }
102 // list path, default parameters
103 else if((type == "input") && (label == "list path, default parameters"))
104 {
105 //<note type="input" label="list path, default
106 // parameters">/gorgone/pappso/tmp/xtpcpp.AjyZGg/Lumos_trypsin_rev_camC_oxM_10ppm_HCDOT_12102017CH.xml</note>
107
110 }
111 else
112 {
113 m_writerXmlTandemInput.writeCharacters(m_qxmlStreamReader.readElementText());
114 }
115 m_writerXmlTandemInput.writeEndElement();
116 }
117 }
118 else
119 {
120 m_qxmlStreamReader.raiseError(QObject::tr("Not an X!Tandem input file"));
121 m_qxmlStreamReader.skipCurrentElement();
122 }
123 }
124 m_writerXmlTandemInput.writeEndDocument();
126 qDebug();
127}
128
129
130const QString &
135
136const QString &
141
142const QString &
147} // namespace pappso
QXmlStreamWriter m_writerXmlTandemInput
virtual void readStream() override
WrapTandemInput(const QString &destinationMzXmlFile, const QString &destinationTandemInputFile, const QString &destinationTandemOutputFile)
const QString & getOriginalTandemOutputFileName() const
QString m_destinationTandemOutputFileName
const QString & getOriginalTandemPresetFileName() const
const QString & getOriginalMsDataFileName() const
void cloneStartElement(QXmlStreamWriter &output) const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39