libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::cbor::mzcbor::QcborSpectrum Class Reference

#include <qcborspectrum.h>

Inheritance diagram for pappso::cbor::mzcbor::QcborSpectrum:

Public Member Functions

 QcborSpectrum ()
 QcborSpectrum (const QcborSpectrum &other)
QString getId () const
void setId (const QString &id)
std::size_t getIndex () const
void setIndex (std::size_t index)
std::size_t getDefaultArrayLength () const
int getMsLevel () const
std::vector< QcborSpectrumPrecursor > getPrecursorList () const
void setPrecursorList (std::vector< QcborSpectrumPrecursor > &precursor_list)
double getRetentionTimeInSeconds () const
void decodeTrace (pappso::Trace &trace) const

Detailed Description

Todo
write docs

Definition at line 47 of file qcborspectrum.h.

Constructor & Destructor Documentation

◆ QcborSpectrum() [1/2]

pappso::cbor::mzcbor::QcborSpectrum::QcborSpectrum ( )

Definition at line 50 of file qcborspectrum.cpp.

50 : QCborMap()
51{
52}

Referenced by QcborSpectrum().

◆ QcborSpectrum() [2/2]

pappso::cbor::mzcbor::QcborSpectrum::QcborSpectrum ( const QcborSpectrum & other)

Definition at line 53 of file qcborspectrum.cpp.

53 : QCborMap(other)
54{
55}

References QcborSpectrum().

Member Function Documentation

◆ decodeTrace()

void pappso::cbor::mzcbor::QcborSpectrum::decodeTrace ( pappso::Trace & trace) const

Definition at line 280 of file qcborspectrum.cpp.

281{
282 qDebug();
283 std::vector<pappso_double> xVector;
284 std::vector<pappso_double> yVector;
285 std::size_t length = getDefaultArrayLength();
286
287
288 auto it = constFind(QCborValue("binaryDataArray"));
289 if(it != end())
290 {
291 for(auto it_binarr = it->toArray().cbegin(); it_binarr != it->toArray().cend(); it_binarr++)
292 {
293 BinaryDataArray binary_array;
294 binary_array.fromQCborMap(it_binarr->toMap());
295 qDebug();
296 if(binary_array.isIntensity())
297 {
298 qDebug();
299 binary_array.decodeVector(length, yVector);
300 }
301 else if(binary_array.isMz())
302 {
303 qDebug();
304 binary_array.decodeVector(length, xVector);
305 }
306 else
307 {
308
309 throw pappso::ExceptionNotFound(
310 QObject::tr("error in QcborSpectrum::decodeTrace binary vector "
311 "type not found"));
312 }
313 qDebug();
314 }
315 }
316 else
317 {
318 throw pappso::PappsoException(
319 QObject::tr("ERROR: no binaryDataArray in QcborSpectrum %1").arg(getId()));
320 }
321 qDebug();
322 trace.initialize(xVector, yVector);
323 qDebug();
324}
size_t initialize(const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
Definition trace.cpp:597

References pappso::cbor::mzcbor::BinaryDataArray::decodeVector(), pappso::cbor::mzcbor::BinaryDataArray::fromQCborMap(), getDefaultArrayLength(), getId(), pappso::Trace::initialize(), pappso::cbor::mzcbor::BinaryDataArray::isIntensity(), and pappso::cbor::mzcbor::BinaryDataArray::isMz().

Referenced by pappso::cbor::mzcbor::MzcborPrecursorFinder::findPotentialPrecursorIonData().

◆ getDefaultArrayLength()

std::size_t pappso::cbor::mzcbor::QcborSpectrum::getDefaultArrayLength ( ) const

Definition at line 179 of file qcborspectrum.cpp.

180{
181 QCborValue id("defaultArrayLength");
182 auto it = constFind(id);
183 if(it != end())
184 {
185 qDebug() << *it;
186 return it.value().toInteger();
187 }
188 else
189 {
190 throw pappso::PappsoException(
191 QObject::tr("ERROR: no defaultArrayLength in QcborSpectrum %1").arg(getId()));
192 }
193}

References getId().

Referenced by decodeTrace().

◆ getId()

QString pappso::cbor::mzcbor::QcborSpectrum::getId ( ) const

Definition at line 159 of file qcborspectrum.cpp.

160{
161 // <spectrum
162 // id="controllerType=0 controllerNumber=1 scan=1"
163 // index="0"
164 // defaultArrayLength="1552"
165 // >
166 QCborValue id("id");
167 auto it = constFind(id);
168 if(it != end())
169 {
170 qDebug() << *it;
171 return it.value().toString();
172 }
173 else
174 {
175 throw pappso::PappsoException(QObject::tr("ERROR: no id in QcborSpectrum"));
176 }
177}

Referenced by decodeTrace(), pappso::cbor::mzcbor::MzcborPrecursorFinder::findPotentialPrecursorIonData(), getDefaultArrayLength(), getMsLevel(), pappso::cbor::mzcbor::MzcborCopyReplaceBase::processQcborSpectrum(), pappso::cbor::mzcbor::MzcborPrecursorFinder::processQcborSpectrum(), and pappso::cbor::mzcbor::SpectrumTube::push_back().

◆ getIndex()

std::size_t pappso::cbor::mzcbor::QcborSpectrum::getIndex ( ) const

Definition at line 215 of file qcborspectrum.cpp.

216{
217 QCborValue id("index");
218 auto it = constFind(id);
219 if(it != end())
220 {
221 qDebug() << *it;
222 return (std::size_t)it.value().toInteger();
223 }
224 else
225 {
226 throw pappso::PappsoException(QObject::tr("ERROR: no index in QcborSpectrum"));
227 }
228}

◆ getMsLevel()

int pappso::cbor::mzcbor::QcborSpectrum::getMsLevel ( ) const

Definition at line 251 of file qcborspectrum.cpp.

252{
253 //"cvParam":[{"cvRef":"MS","accession":"MS:1000511","name":"ms level","value":1}
254
255 QCborValue cv_param("cvParam");
256 auto it = constFind(cv_param);
257 if(it != end())
258 {
259 for(auto it_cv = it->toArray().cbegin(); it_cv != it->toArray().cend(); it_cv++)
260 {
261 auto it_accession = it_cv->toMap().constFind(QCborValue("accession"));
262 if(it_accession->toString() == "MS:1000511")
263 {
264 auto it_value = it_cv->toMap().find(QCborValue("value"));
265 return (it_value.value().toInteger());
266 }
267 }
268
269 throw pappso::ExceptionNotFound(
270 QObject::tr("ERROR: MS level not found in QcborSpectrum %1").arg(getId()));
271 }
272 else
273 {
274 throw pappso::PappsoException(
275 QObject::tr("ERROR: no cvparam in QcborSpectrum %1").arg(getId()));
276 }
277}

References getId().

Referenced by pappso::cbor::mzcbor::MzcborCopyReplaceBase::processQcborSpectrum(), and pappso::cbor::mzcbor::MzcborPrecursorFinder::processQcborSpectrum().

◆ getPrecursorList()

std::vector< QcborSpectrumPrecursor > pappso::cbor::mzcbor::QcborSpectrum::getPrecursorList ( ) const

Definition at line 57 of file qcborspectrum.cpp.

58{
59 std::vector<QcborSpectrumPrecursor> precursor_list;
60 qDebug();
61 auto itout = constFind(QCborValue("precursorList"));
62 if(itout != end())
63 {
64 auto it = itout.value().toMap().constFind(QCborValue("precursor"));
65 if(it != end())
66 {
67 for(auto it_cv = it->toArray().cbegin(); it_cv != it->toArray().cend(); it_cv++)
68 {
69 qDebug();
70 QcborSpectrumPrecursor precursor(it_cv->toMap());
71 precursor_list.push_back(precursor);
72 }
73 return precursor_list;
74 }
75 else
76 {
77 throw pappso::PappsoException(QObject::tr("ERROR: no precursor array in QcborSpectrum"));
78 }
79 }
80 else
81 {
82 throw pappso::PappsoException(QObject::tr("ERROR: no precursorList in QcborSpectrum"));
83 }
84}

Referenced by pappso::cbor::mzcbor::MzcborPrecursorFinder::processQcborSpectrum().

◆ getRetentionTimeInSeconds()

double pappso::cbor::mzcbor::QcborSpectrum::getRetentionTimeInSeconds ( ) const

Definition at line 87 of file qcborspectrum.cpp.

88{
89 auto itout = constFind(QCborValue("scanList"));
90 if(itout != end())
91 {
92 auto it = itout.value().toMap().constFind(QCborValue("scan"));
93 if(it != end())
94 {
95 for(auto it_cv = it->toArray().cbegin(); it_cv != it->toArray().cend(); it_cv++)
96 {
97 qDebug();
98 Scan scan;
99 scan.fromQCborMap(it_cv->toMap());
100 return scan.getRtInSeconds();
101 }
102 }
103 else
104 {
105 throw pappso::PappsoException(QObject::tr("ERROR: no scan array in QcborSpectrum"));
106 }
107 }
108 else
109 {
110 throw pappso::PappsoException(QObject::tr("ERROR: no scanList in QcborSpectrum"));
111 }
112 return 0.0;
113}

References pappso::cbor::mzcbor::Scan::fromQCborMap(), and pappso::cbor::mzcbor::Scan::getRtInSeconds().

Referenced by pappso::cbor::mzcbor::MzcborPrecursorFinder::processQcborSpectrum().

◆ setId()

void pappso::cbor::mzcbor::QcborSpectrum::setId ( const QString & id)

Definition at line 195 of file qcborspectrum.cpp.

196{
197 // <spectrum
198 // id="controllerType=0 controllerNumber=1 scan=1"
199 // index="0"
200 // defaultArrayLength="1552"
201 // >
202 QCborValue native_id("id");
203 auto it = find(native_id);
204 if(it != end())
205 {
206 qDebug() << *it;
207 it.value() = QCborValue(id);
208 }
209 else
210 {
211 throw pappso::PappsoException(QObject::tr("ERROR: no id in QcborSpectrum"));
212 }
213}

Referenced by pappso::cbor::mzcbor::MzcborCopyReplaceBase::processQcborSpectrum(), and pappso::cbor::mzcbor::SpectrumTube::push_back().

◆ setIndex()

void pappso::cbor::mzcbor::QcborSpectrum::setIndex ( std::size_t index)

Definition at line 230 of file qcborspectrum.cpp.

231{
232 // <spectrum
233 // id="controllerType=0 controllerNumber=1 scan=1"
234 // index="0"
235 // defaultArrayLength="1552"
236 // >
237 QCborValue id("index");
238 auto it = find(id);
239 if(it != end())
240 {
241 qDebug() << *it;
242 it.value() = QCborValue((qint64)index);
243 }
244 else
245 {
246 throw pappso::PappsoException(QObject::tr("ERROR: no index in QcborSpectrum"));
247 }
248}

Referenced by pappso::cbor::mzcbor::SpectrumTube::push_back().

◆ setPrecursorList()

void pappso::cbor::mzcbor::QcborSpectrum::setPrecursorList ( std::vector< QcborSpectrumPrecursor > & precursor_list)

Definition at line 115 of file qcborspectrum.cpp.

116{
117 QCborMap cbor_precursor_list;
118 // auto itout = find(QCborValue("precursorList"));
119 // qDebug();
120 // if(itout != end())
121 // {
122 qDebug();
123 cbor_precursor_list.insert(QCborValue("count"), (qint64)precursor_list.size());
124 qDebug();
125
126 QCborArray cbor_arr;
127 for(auto &it_prec : precursor_list)
128 {
129 cbor_arr.push_back(it_prec);
130 }
131 cbor_precursor_list.insert(QCborValue("precursor"), cbor_arr);
132
133 insert(QCborValue("precursorList"), cbor_precursor_list);
134 // auto it2 = itout.value().toMap().find(QCborValue("precursor"));
135 // if(it2 != end())
136 // {
137 // QCborArray cbor_arr;
138 // for(auto &it_prec : precursor_list)
139 // {
140 // cbor_arr.push_back(it_prec);
141 // }
142 // qDebug() << cbor_arr.size();
143 // // it2. = QCborValue(cbor_arr);
144 // itout.value().toMap().insert(QCborValue("precursor"), cbor_arr);
145 // }
146 // else
147 // {
148 // throw pappso::PappsoException(
149 // QObject::tr("ERROR: no precursor in precursorList QcborSpectrum"));
150 // }
151 // qDebug();
152 // }
153 // else
154 // {
155 // throw pappso::PappsoException(QObject::tr("ERROR: no precursorList in QcborSpectrum"));
156 // }
157}

Referenced by pappso::cbor::mzcbor::MzcborPrecursorFinder::findPotentialPrecursorIonData(), and pappso::cbor::mzcbor::MzcborPrecursorFinder::processQcborSpectrum().


The documentation for this class was generated from the following files: