libpappsomspp
Library for mass spectrometry
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>
31 #include "../../pappsoexception.h"
32 
33 
34 namespace pappso
35 {
36 WrapTandemInput::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;
44  QFileInfo(destinationTandemInputFile).absoluteFilePath();
45 
46  if(destinationTandemInputFile.isEmpty())
47  {
49  QObject::tr("ERROR: X!Tandem input file path is empty"));
50  }
51 
52  if(!m_destinationTandemInputFile.open(QIODevice::WriteOnly))
53  {
55  QObject::tr("ERROR: unable to open %1 tandem output file for write")
56  .arg(destinationTandemInputFile));
57  }
58 
60  m_writerXmlTandemInput.setAutoFormatting(true);
61  m_writerXmlTandemInput.writeStartDocument("1.0");
62 }
63 
65 {
67 }
68 
69 
70 void
72 {
73  qDebug();
74  if(m_qxmlStreamReader.readNextStartElement())
75  {
76  if(m_qxmlStreamReader.name().toString() == "bioml")
77  {
79  qDebug();
80  while(m_qxmlStreamReader.readNextStartElement())
81  {
82  // qDebug() << m_qxmlStreamReader.name();
83  // read_note();
85 
86  QString type =
87  m_qxmlStreamReader.attributes().value("type").toString();
88  QString label =
89  m_qxmlStreamReader.attributes().value("label").toString();
90 
91  if((type == "input") && (label == "spectrum, path"))
92  {
93  //<note type="input" label="spectrum, path">
94 
95  m_originMzDataFileName = m_qxmlStreamReader.readElementText();
96  m_writerXmlTandemInput.writeCharacters(
98  // m_qxmlStreamReader.skipCurrentElement();
99  }
100  else if((type == "input") && (label == "output, path"))
101  {
102  //<note type="input" label="output, path">
104  m_qxmlStreamReader.readElementText();
105  m_writerXmlTandemInput.writeCharacters(
107  // m_qxmlStreamReader.skipCurrentElement();
108  }
109  // list path, default parameters
110  else if((type == "input") &&
111  (label == "list path, default parameters"))
112  {
113  //<note type="input" label="list path, default
114  // parameters">/gorgone/pappso/tmp/xtpcpp.AjyZGg/Lumos_trypsin_rev_camC_oxM_10ppm_HCDOT_12102017CH.xml</note>
115 
117  m_qxmlStreamReader.readElementText();
118  m_writerXmlTandemInput.writeCharacters(
120  }
121  else
122  {
123  m_writerXmlTandemInput.writeCharacters(
124  m_qxmlStreamReader.readElementText());
125  }
126  m_writerXmlTandemInput.writeEndElement();
127  }
128  }
129  else
130  {
131  m_qxmlStreamReader.raiseError(
132  QObject::tr("Not an X!Tandem input file"));
133  m_qxmlStreamReader.skipCurrentElement();
134  }
135  }
136  m_writerXmlTandemInput.writeEndDocument();
138  qDebug();
139 }
140 
141 
142 const QString &
144 {
145  return m_originMzDataFileName;
146 }
147 
148 const QString &
150 {
152 }
153 
154 const QString &
156 {
158 }
159 } // 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_destinationTandemInputFileName
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
rewrites tandem xml input file with temporary files