libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pwizmsrunreader.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/msrun/private/pwizmsrunreader.cpp
3 * \date 29/05/2018
4 * \author Olivier Langella
5 * \brief MSrun file reader base on proteowizard library
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2018 Olivier Langella <Olivier.Langella@u-psud.fr>.
10 *
11 * This file is part of the PAPPSOms++ library.
12 *
13 * PAPPSOms++ 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++ 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++. If not, see <http://www.gnu.org/licenses/>.
25 *
26 * Contributors:
27 * Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and
28 *implementation
29 ******************************************************************************/
30
31
32#include <QDebug>
33
34#include "pwizmsrunreader.h"
35
36#include <pwiz/data/msdata/DefaultReaderList.hpp>
37#include "../../obo/obopsims.h"
39
40
45#include "pappsomspp/config.h"
46
47// int pwizMsRunReaderMetaTypeId =
48// qRegisterMetaType<pappso::PwizMsRunReader>("pappso::PwizMsRunReader");
49
50
51namespace pappso
52{
53
55
57{
58 // The initialization needs to be done immediately so that we get the pwiz
59 // MsDataPtr corresponding to the right ms_run_id in the parameter. That
60 // pointer will be set to msp_msData.
61
62 initialize();
63}
64
65
66void
68{
69 std::string file_name_std = Utils::toUtf8StandardString(mcsp_msRunId->getFileName());
70
71
72 // Now actually search the useful MSDataPtr to the member variable.
73
74 pwiz::msdata::DefaultReaderList defaultReaderList;
75
76 std::vector<pwiz::msdata::MSDataPtr> msDataPtrVector;
77
78 try
79 {
80 defaultReaderList.read(file_name_std, msDataPtrVector);
81 }
82 catch(std::exception &error)
83 {
84 qDebug() << QString("Failed to read the data from file %1")
85 .arg(QString::fromStdString(file_name_std));
86
87 throw(PappsoException(QString("Error reading file %1 in PwizMsRunReader, for msrun %2:\n%3")
88 .arg(mcsp_msRunId->getFileName())
89 .arg(mcsp_msRunId.get()->toString())
90 .arg(error.what())));
91 }
92
93 qDebug() << "The number of runs is:" << msDataPtrVector.size()
94 << "The number of spectra in first run is:"
95 << msDataPtrVector.at(0)->run.spectrumListPtr->size();
96
97 // Single-run file handling here.
98
99 // Specific case of the MGF data format: we do not have a run id for that
100 // kind of data. In this case there must be a single run!
101
102 if(mcsp_msRunId->getRunId().isEmpty())
103 {
104 if(msDataPtrVector.size() != 1)
105 throw(
106 ExceptionNotPossible("For the kind of file at hand there can only be "
107 "one run in the file."));
108
109 // At this point we know the single msDataPtr is the one we are looking
110 // for.
111
112 msp_msData = msDataPtrVector.front();
113 }
114 else
115 {
116 // Multi-run file handling here.
117 for(const pwiz::msdata::MSDataPtr &msDataPtr : msDataPtrVector)
118 {
119 qDebug() << "msDataPtr->run.id=" << msDataPtr->run.id.c_str();
120 qDebug() << "mcsp_msRunId->getRunId()=" << mcsp_msRunId->getRunId();
121 qDebug() << "mcsp_msRunId->getXmlId()=" << mcsp_msRunId->getXmlId();
122 qDebug() << "mcsp_msRunId->getSampleName()=" << mcsp_msRunId->getSampleName();
123
124 if(msDataPtr->run.id == mcsp_msRunId->getRunId().toStdString())
125 {
126 msp_msData = msDataPtr;
127
128 qDebug() << "Found the right MSDataPtr for run id.";
129
130 break;
131 }
132 }
133 }
134
135 if(msp_msData == nullptr)
136 {
137 throw(ExceptionNotPossible(QString("Could not find a pwiz MSDataPtr "
138 "matching the requested run id : %1")
139 .arg(mcsp_msRunId.get()->toString())));
140 }
141
142
143 // check if this MS run can be used with scan numbers
144 // MS:1000490 Agilent instrument model
145 pwiz::cv::CVID native_id_format = pwiz::msdata::id::getDefaultNativeIDFormat(*msp_msData.get());
146
147 // msp_msData.get()->getDefaultNativeIDFormat();
148
149 if(native_id_format == pwiz::cv::CVID::MS_Thermo_nativeID_format)
150 {
151 m_hasScanNumbers = true;
152 }
153 else
154 {
155 m_hasScanNumbers = false;
156 }
157
158 if(mcsp_msRunId.get()->getMsDataFormat() == Enums::MsDataFormat::mzXML)
159 {
160 m_hasScanNumbers = true;
161 }
162}
163
167
168const pwiz::msdata::MSDataPtr
169
171{
172 return msp_msData;
173}
174
175const OboPsiModTerm
177{
178
179 OboPsiModTerm term;
180
181 term.setAccession("MS:1000824");
182 term.m_name = "no nativeID format";
183 term.m_definition =
184 "No nativeID format indicates that the file tagged with this term does "
185 "not "
186 "contain spectra that can have a nativeID format.";
187
188
189 pwiz::cv::CVID cvid = pwiz::msdata::id::getDefaultNativeIDFormat(*(msp_msData.get()));
190
191 switch(cvid)
192 {
193 case pwiz::cv::MS_Thermo_nativeID_format:
194 term.setAccession("MS:1000768");
195 term.m_name = "Thermo nativeID format";
196 term.m_definition =
197 "Native format defined by controllerType=xsd:nonNegativeInteger "
198 "controllerNumber=xsd:positiveInteger scan=xsd:positiveInteger.";
199 break;
200 default:
201 break;
202 }
203 return term;
204}
205
206pwiz::msdata::SpectrumPtr
207PwizMsRunReader::getPwizSpectrumPtr(pwiz::msdata::SpectrumList *p_spectrum_list,
208 std::size_t spectrum_index,
209 bool want_binary_data) const
210{
211 pwiz::msdata::SpectrumPtr native_pwiz_spectrum_sp;
212
213 try
214 {
215 native_pwiz_spectrum_sp = p_spectrum_list->spectrum(spectrum_index, want_binary_data);
216 }
217 catch(std::runtime_error &error)
218 {
219 qDebug() << "getPwizSpectrumPtr error " << error.what() << " " << typeid(error).name();
220
221 throw ExceptionNotFound(QObject::tr("Pwiz spectrum index %1 not found in "
222 "MS file std::runtime_error :\n%2")
223 .arg(spectrum_index)
224 .arg(error.what()));
225 }
226 catch(std::exception &error)
227 {
228 qDebug() << "getPwizSpectrumPtr error " << error.what() << typeid(error).name();
229
230 throw ExceptionNotFound(QObject::tr("Pwiz spectrum index %1 not found in MS file :\n%2")
231 .arg(spectrum_index)
232 .arg(error.what()));
233 }
234
235 if(native_pwiz_spectrum_sp.get() == nullptr)
236 {
237 throw ExceptionNotFound(
238 QObject::tr("Pwiz spectrum index %1 not found in MS file : null pointer")
239 .arg(spectrum_index));
240 }
241
242 return native_pwiz_spectrum_sp;
243}
244
245
246bool
247PwizMsRunReader::processRetentionTime(pwiz::msdata::Spectrum *spectrum_p,
248 QualifiedMassSpectrum &qualified_mass_spectrum) const
249{
250
251 // We now have to set the retention time at which this mass spectrum
252 // was acquired. This is the scan start time.
253
254 if(!spectrum_p->scanList.scans[0].hasCVParam(pwiz::msdata::MS_scan_start_time))
255 {
256 if(mcsp_msRunId.get()->getMsDataFormat() == Enums::MsDataFormat::MGF)
257 { // MGF could not have scan start time
258 qualified_mass_spectrum.setRtInSeconds(-1);
259 }
260 else
261 {
262 throw(ExceptionNotPossible("The spectrum has no scan start time value set."));
263 }
264 }
265 else
266 {
267 pwiz::data::CVParam retention_time_cv_param =
268 spectrum_p->scanList.scans[0].cvParam(pwiz::msdata::MS_scan_start_time);
269
270 // Try to get the units of the retention time value.
271
272 std::string unit_name = retention_time_cv_param.unitsName();
273 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
274 //<< "Unit name for the retention time:"
275 //<< QString::fromStdString(unit_name);
276
277 if(unit_name == "second")
278 {
279 qualified_mass_spectrum.setRtInSeconds(retention_time_cv_param.valueAs<double>());
280 }
281 else if(unit_name == "minute")
282 {
283 qualified_mass_spectrum.setRtInSeconds(retention_time_cv_param.valueAs<double>() * 60);
284 }
285 else
286 throw(
287 ExceptionNotPossible("Could not determine the unit for the "
288 "scan start time value."));
289 }
290
291 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
292 //<< "Retention time for spectrum is:"
293 //<< qualified_mass_spectrum.getRtInSeconds();
294
295 // Old version not checking unit (by default unit is minutes for RT,
296 // not seconds)
297 //
298 // pappso_double retentionTime =
299 // QString(spectrum_p->scanList.scans[0]
300 //.cvParam(pwiz::msdata::MS_scan_start_time)
301 //.value.c_str())
302 //.toDouble();
303 // qualified_mass_spectrum.setRtInSeconds(retentionTime);
304
305 return true;
306}
307
308
309bool
310PwizMsRunReader::processDriftTime(pwiz::msdata::Spectrum *spectrum_p,
311 QualifiedMassSpectrum &qualified_mass_spectrum) const
312{
313 // Not all the acquisitions have ion mobility data. We need to test
314 // that:
315
316 if(spectrum_p->scanList.scans[0].hasCVParam(pwiz::msdata::MS_ion_mobility_drift_time))
317 {
318
319 // qDebug() << "as strings:"
320 //<< QString::fromStdString(
321 // spectrum_p->scanList.scans[0]
322 //.cvParam(pwiz::msdata::MS_ion_mobility_drift_time)
323 //.valueAs<std::string>());
324
325 pappso_double driftTime = spectrum_p->scanList.scans[0]
326 .cvParam(pwiz::msdata::MS_ion_mobility_drift_time)
327 .valueAs<double>();
328
329 // qDebug() << "driftTime:" << driftTime;
330
331 // Old version requiring use of QString.
332 // pappso_double driftTime =
333 // QString(spectrum_p->scanList.scans[0]
334 //.cvParam(pwiz::msdata::MS_ion_mobility_drift_time)
335 //.value.c_str())
336 //.toDouble();
337
338 // Now make positively sure that the obtained value is correct.
339 // Note that I suffered a lot with Waters Synapt data that
340 // contained apparently correct drift time XML element that in
341 // fact contained either NaN or inf. When such mass spectra were
342 // encountered, the mz,i data were bogus and crashed the data
343 // loading functions. We just want to skip this kind of bogus mass
344 // spectrum by letting the caller know that the drift time was
345 // bogus ("I" is Filippo Rusconi).
346
347 if(std::isnan(driftTime) || std::isinf(driftTime))
348 {
349 // qDebug() << "detected as nan or inf.";
350
351 return false;
352 }
353 else
354 {
355 // The mzML standard stipulates that drift times are in
356 // milliseconds.
357 qualified_mass_spectrum.setDtInMilliSeconds(driftTime);
358 }
359 }
360 // End of
361 // if(spectrum_p->scanList.scans[0].hasCVParam(
362 // pwiz::msdata::MS_ion_mobility_drift_time))
363 else
364 {
365 // Not a bogus mass spectrum but also not a drift spectrum, set -1
366 // as the drift time value.
367 qualified_mass_spectrum.setDtInMilliSeconds(-1);
368 }
369
370 return true;
371}
372
373
376 pwiz::msdata::Spectrum *spectrum_p,
377 bool want_binary_data,
378 bool &ok) const
379{
380 // qDebug();
381
382 if(spectrum_p == nullptr)
383 qFatal("Spectrum pointer cannot be nullptr.");
384
385 std::string backup_env = setGlobalLocaleToEnglish();
386
387 QualifiedMassSpectrum qualified_mass_spectrum(massSpectrumId);
388
389 try
390 {
391
392 // We want to store the ms level for this spectrum
393
394 int msLevel = (spectrum_p->cvParam(pwiz::msdata::MS_ms_level).valueAs<int>());
395
396 qualified_mass_spectrum.setMsLevel(msLevel);
397
398 if(!spectrum_p->scanList.scans[0].hasCVParam(pwiz::msdata::MS_peak_list_scans))
399 {
400
401 // qDebug() << spectrum_p->cvParam(pwiz::msdata::MS_peak_list_scans)
402 // .valueAs<double>();
403 qualified_mass_spectrum.setParameterValue(
405 spectrum_p->cvParam(pwiz::msdata::MS_peak_list_scans).valueAs<double>());
406 }
407 // We want to know if this spectrum is a fragmentation spectrum obtained
408 // from a selected precursor ion.
409
410 std::size_t precursor_list_size = spectrum_p->precursors.size();
411
412 // qDebug() << "For spectrum at index:" <<
413 // massSpectrumId.getSpectrumIndex()
414 //<< "msLevel:" << msLevel
415 //<< "with number of precursors:" << precursor_list_size;
416
417 if(precursor_list_size > 0)
418 {
419
420 // Sanity check
421 if(msLevel < 2)
422 {
423 qDebug() << "Going to throw: msLevel cannot be less than two for "
424 "a spectrum that has items in its Precursor list.";
425
426 throw(
427 ExceptionNotPossible("msLevel cannot be less than two for "
428 "a spectrum that has items in its Precursor list."));
429 }
430
431 // See what is the first precursor in the list.
432
433 for(auto &precursor : spectrum_p->precursors)
434 {
435
436 // Set this variable ready as we need that default value in
437 // certain circumstances.
438
439 std::size_t precursor_spectrum_index = std::numeric_limits<std::size_t>::max();
440
441 // The spectrum ID of the precursor might be empty.
442
443 if(precursor.spectrumID.empty())
444 {
445 // qDebug() << "The precursor's spectrum ID is empty.";
446
447 if(mcsp_msRunId.get()->getMsDataFormat() == Enums::MsDataFormat::MGF)
448 {
449 // qDebug()
450 //<< "Format is MGF, precursor's spectrum ID can be
451 // empty.";
452 }
453 else
454 {
455 // When performing Lumos Fusion fragmentation
456 // experiments in Tune mode and with recording, the
457 // first spectrum of the list is a fragmentation
458 // spectrum (ms level 2) that has no identity for the
459 // precursor spectrum because there is no full scan
460 // accquisition.
461 }
462 }
463 // End of
464 // if(precursor.spectrumID.empty())
465 else
466 {
467 // We could get a native precursor spectrum id, so convert
468 // that native id to a spectrum index.
469
470 qualified_mass_spectrum.setPrecursorNativeId(
471 QString::fromStdString(precursor.spectrumID));
472
473 if(qualified_mass_spectrum.getPrecursorNativeId().isEmpty())
474 {
475 // qDebug() << "The native id of the precursor spectrum
476 // is empty.";
477 }
478
479 // Get the spectrum index of the spectrum that contained
480 // the precursor ion.
481
482 precursor_spectrum_index =
483 msp_msData->run.spectrumListPtr->find(precursor.spectrumID);
484
485 // Note that the Mascot MGF format has a peculiar handling
486 // of the precursor ion stuff so we cannot throw.
487 if(precursor_spectrum_index == msp_msData->run.spectrumListPtr->size())
488 {
489 if(mcsp_msRunId.get()->getMsDataFormat() != Enums::MsDataFormat::MGF)
490 {
491 throw(
492 ExceptionNotPossible("Failed to find the index of the "
493 "precursor ion's spectrum."));
494 }
495 }
496
497 qualified_mass_spectrum.setPrecursorSpectrumIndex(precursor_spectrum_index);
498
499 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__
500 // <<
501 // "()"
502 //<< "Set the precursor spectrum index to:"
503 //<< qualified_mass_spectrum.getPrecursorSpectrumIndex()
504 //<< "for qualified mass spectrum:"
505 //<< &qualified_mass_spectrum;
506 }
507
508 if(!precursor.selectedIons.size())
509 {
510 qDebug() << "Going to throw The spectrum has msLevel > 1 but the "
511 "precursor ions's selected ions list is empty..";
512
513 throw(
514 ExceptionNotPossible("The spectrum has msLevel > 1 but the "
515 "precursor ions's selected ions "
516 "list is empty."));
517 }
518
519 pwiz::msdata::SelectedIon &ion = *(precursor.selectedIons.begin());
520
521 // selected ion m/z
522
523 pappso_double selected_ion_mz =
524 QString(ion.cvParam(pwiz::cv::MS_selected_ion_m_z).value.c_str()).toDouble();
525
526 // selected ion peak intensity
527 //<cvParam cvRef="MS" accession="MS:1000042"
528 // value="910663.949707031" name="peak intensity"
529 // unitAccession="MS:1000131" unitName="number of detector
530 // counts" unitCvRef="MS" />
531
532 pappso_double selected_ion_peak_intensity =
533 QString(ion.cvParam(pwiz::cv::MS_peak_intensity).value.c_str()).toDouble();
534
535 // charge state
536
537 unsigned int selected_ion_charge_state =
538 QString(ion.cvParam(pwiz::cv::MS_charge_state).value.c_str()).toUInt();
539
540 // At this point we can craft a new PrecursorIonData instance
541 // and push it back to the vector.
542
543 PrecursorIonData precursor_ion_data(
544 selected_ion_mz, selected_ion_charge_state, selected_ion_peak_intensity);
545
546 qualified_mass_spectrum.appendPrecursorIonData(precursor_ion_data);
547
548 // General sum-up
549
550 // qDebug()
551 //<< "Appended new PrecursorIonData:"
552 //<< "mz:"
553 //<< qualified_mass_spectrum.getPrecursorIonData().back().mz
554 //<< "charge:"
555 //<< qualified_mass_spectrum.getPrecursorIonData().back().charge
556 //<< "intensity:"
557 //<< qualified_mass_spectrum.getPrecursorIonData()
558 //.back()
559 //.intensity;
560 }
561 // End of
562 // for(auto &precursor : spectrum_p->precursors)
563 }
564 // End of
565 // if(precursor_list_size > 0)
566 else
567 {
568 // Sanity check
569
570 // Unfortunately, logic here is defeated by some vendors that have
571 // files with MS2 spectra without <precursorList>. Thus we have
572 // spectrum_p->precursors.size() == 0 and msLevel > 1.
573
574 // if(msLevel != 1)
575 //{
576 // throw(
577 // ExceptionNotPossible("msLevel cannot be different than 1 if "
578 //"there is not a single precursor ion."));
579 //}
580 }
581
582 // Sanity check.
583
584 if(precursor_list_size != qualified_mass_spectrum.getPrecursorIonData().size())
585 {
586 qDebug() << "Going to throw The number of precursors in the file is "
587 "different from the number of precursors in memory.";
588
590 QObject::tr("The number of precursors in the file is different "
591 "from the number of precursors in memory."));
592 }
593
594 // if(precursor_list_size == 1)
595 //{
596 // qDebug() << "Trying to get the mz value of the unique precursor ion:"
597 //<< qualified_mass_spectrum.getPrecursorMz();
598 //}
599
600 processRetentionTime(spectrum_p, qualified_mass_spectrum);
601
602 processDriftTime(spectrum_p, qualified_mass_spectrum);
603
604 // for(pwiz::data::CVParam cv_param : ion.cvParams)
605 //{
606 // pwiz::msdata::CVID param_id = cv_param.cvid;
607 // qDebug() << param_id;
608 // qDebug() << cv_param.cvid.c_str();
609 // qDebug() << cv_param.name().c_str();
610 // qDebug() << cv_param.value.c_str();
611 //}
612
613 if(want_binary_data)
614 {
615
616 // Fill-in MZIntensityPair vector for convenient access to binary
617 // data
618
619 std::vector<pwiz::msdata::MZIntensityPair> pairs;
620 spectrum_p->getMZIntensityPairs(pairs);
621
622 MassSpectrum spectrum;
623 double tic = 0;
624 // std::size_t iterCount = 0;
625
626 // Iterate through the m/z-intensity pairs
627 for(std::vector<pwiz::msdata::MZIntensityPair>::const_iterator it = pairs.begin(),
628 end = pairs.end();
629 it != end;
630 ++it)
631 {
632 //++iterCount;
633
634 // qDebug() << "it->mz " << it->mz << " it->intensity" <<
635 // it->intensity;
636 if(it->intensity)
637 {
638 spectrum.push_back(DataPoint(it->mz, it->intensity));
639 tic += it->intensity;
640 }
641 }
642
643 if(mcsp_msRunId.get()->getMsDataFormat() == Enums::MsDataFormat::MGF)
644 {
645 // Sort peaks by mz
646 spectrum.sortMz();
647 }
648
649 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()
650 // "<< spectrum.size();
651 MassSpectrumSPtr spectrum_sp = spectrum.makeMassSpectrumSPtr();
652 qualified_mass_spectrum.setMassSpectrumSPtr(spectrum_sp);
653
654 // double sumY =
655 // qualified_mass_spectrum.getMassSpectrumSPtr()->sumY(); qDebug()
656 // <<
657 // __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
658 //<< "iterCount:" << iterCount << "Spectrum size "
659 //<< spectrum.size() << "with tic:" << tic
660 //<< "and sumY:" << sumY;
661 }
662 else
663 qualified_mass_spectrum.setMassSpectrumSPtr(nullptr);
664 }
665 catch(PappsoException &errorp)
666 {
667 qDebug() << "Going to throw";
668
670 QObject::tr("Error reading data using the proteowizard library: %1").arg(errorp.qwhat()));
671 }
672 catch(std::exception &error)
673 {
674 qDebug() << "Going to throw";
675
677 QObject::tr("Error reading data using the proteowizard library: %1").arg(error.what()));
678 }
679
680 ok = true;
681
682 // qDebug() << "QualifiedMassSpectrum: " <<
683 // qualified_mass_spectrum.toString();
684 return qualified_mass_spectrum;
685}
686
687
690 bool want_binary_data,
691 bool &ok) const
692{
693
694 std::string backup_env = setGlobalLocaleToEnglish();
695
696 MassSpectrumId massSpectrumId(mcsp_msRunId);
697
698 if(msp_msData == nullptr)
699 {
700 setGlobalLocaleToCurrentOs(backup_env);
701 return (QualifiedMassSpectrum(massSpectrumId));
702 }
703
704 // const bool want_binary_data = true;
705
706 pwiz::msdata::SpectrumListPtr spectrum_list_p = msp_msData->run.spectrumListPtr;
707
708 if(spectrum_index == spectrum_list_p.get()->size())
709 {
710 setGlobalLocaleToCurrentOs(backup_env);
711 throw ExceptionNotFound(
712 QObject::tr("The spectrum index cannot be equal to the size of the "
713 "spectrum list."));
714 }
715
716 // At this point we know the spectrum index might be sane, so store it in
717 // the mass spec id object.
718 massSpectrumId.setSpectrumIndex(spectrum_index);
719
720 pwiz::msdata::SpectrumPtr native_pwiz_spectrum_sp =
721 getPwizSpectrumPtr(spectrum_list_p.get(), spectrum_index, want_binary_data);
722
723 setGlobalLocaleToCurrentOs(backup_env);
724
725 massSpectrumId.setNativeId(QString::fromStdString(native_pwiz_spectrum_sp->id));
726
728 massSpectrumId, native_pwiz_spectrum_sp.get(), want_binary_data, ok);
729}
730
731
732bool
733PwizMsRunReader::accept(const QString &file_name) const
734{
735 // We want to know if we can handle the file_name.
736 pwiz::msdata::ReaderList reader_list;
737
738 std::string reader_type = reader_list.identify(file_name.toStdString());
739
740 if(!reader_type.empty())
741 return true;
742
743 return false;
744}
745
746
748PwizMsRunReader::massSpectrumSPtr(std::size_t spectrum_index)
749{
750 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
751 return qualifiedMassSpectrum(spectrum_index, true).getMassSpectrumSPtr();
752}
753
755PwizMsRunReader::massSpectrumCstSPtr(std::size_t spectrum_index)
756{
757 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
758 return qualifiedMassSpectrum(spectrum_index, true).getMassSpectrumCstSPtr();
759}
760
762PwizMsRunReader::qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data) const
763{
764
765 QualifiedMassSpectrum spectrum;
766 bool ok = false;
767
768 spectrum = qualifiedMassSpectrumFromPwizMSData(spectrum_index, want_binary_data, ok);
769
770 if(mcsp_msRunId->getMsDataFormat() == Enums::MsDataFormat::MGF)
771 {
772 if(spectrum.getRtInSeconds() == 0)
773 {
774 // spectrum = qualifiedMassSpectrumFromPwizMSData(scan_num - 1);
775 }
776 }
777
778 // if(!ok)
779 // qDebug() << "Encountered a mass spectrum for which the status is bad.";
780
781 return spectrum;
782}
783
784
785void
787{
788 try
789 {
791 }
792 catch(std::exception &error)
793 {
794 qDebug() << "Going to throw";
795
797 QObject::tr("Error reading data (spectrum collection) using the "
798 "proteowizard library: %1")
799 .arg(error.what()));
800 }
801}
802
803void
806{
807 qDebug();
808 try
809 {
811 }
812 catch(std::exception &error)
813 {
814 qDebug() << "Going to throw";
815
817 QObject::tr("Error reading data (spectrum collection2) using the "
818 "proteowizard library: %1")
819 .arg(error.what()));
820 }
821}
822
823void
825 unsigned int ms_level)
826{
827
829 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
830
831 // We want to iterate in the pwiz-spectrum-list and for each pwiz-spectrum
832 // create a pappso-spectrum (QualifiedMassSpectrum). Once the pappso mass
833 // spectrum has been fully qualified (that is, the member data have been
834 // set), it is transferred to the handler passed as parameter to this
835 // function for the consumer to do what it wants with it.
836
837 // Does the handler consuming the mass spectra read from file want these
838 // mass spectra to hold the binary data arrays (mz/i vectors)?
839
840 const bool want_binary_data = handler.needPeakList();
841
842 std::string backup_env = setGlobalLocaleToEnglish();
843
844 // We access the pwiz-mass-spectra via the spectrumListPtr that sits in the
845 // run member of msp_msData.
846
847 pwiz::msdata::SpectrumListPtr spectrum_list_p = msp_msData->run.spectrumListPtr;
848
849 // We'll need it to perform the looping in the spectrum list.
850 std::size_t spectrum_list_size = spectrum_list_p.get()->size();
851
852 // qDebug() << "The spectrum list has size:" << spectrum_list_size;
853
854 // Inform the handler of the spectrum list so that it can handle feedback to
855 // the user.
856 handler.spectrumListHasSize(spectrum_list_size);
857
858 // Iterate in the full list of spectra.
859
860 for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
861 {
862
863 // If the user of this reader instance wants to stop reading the
864 // spectra, then break this loop.
865 if(handler.shouldStop())
866 {
867 qDebug() << "The operation was cancelled. Breaking the loop.";
868 break;
869 }
870
871 // Get the native pwiz-spectrum from the spectrum list.
872 // Note that this pointer is a shared pointer from pwiz.
873
874 pwiz::msdata::SpectrumPtr native_pwiz_spectrum_sp =
875 getPwizSpectrumPtr(spectrum_list_p.get(), iter, want_binary_data);
876 /*
877 * we want to load metadata of the spectrum even if it does not contain
878 peaks
879
880 * if(!native_pwiz_spectrum_sp->hasBinaryData())
881 {
882 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ <<
883 "
884 ()"
885 //<< "native pwiz spectrum is empty, continuing.";
886 continue;
887 }
888 */
889
890 // Instantiate the mass spectrum id that will hold critical information
891 // like the the native id string and the spectrum index.
892
893 MassSpectrumId massSpectrumId(mcsp_msRunId, iter /* spectrum index*/);
894
895 // Get the spectrum native id as a QString to store it in the mass
896 // spectrum id class. This is will allow later to refer to the same
897 // spectrum starting back from the file.
898
899 QString native_id = QString::fromStdString(native_pwiz_spectrum_sp->id);
900 massSpectrumId.setNativeId(native_id);
901
902 // Finally, instantiate the qualified mass spectrum with its id. This
903 // function will continue performing pappso-spectrum detailed
904 // qualification.
905
906 bool ok = false;
907
909 massSpectrumId, native_pwiz_spectrum_sp.get(), want_binary_data, ok);
910
911 if(!ok)
912 {
913 // qDebug() << "Encountered a mass spectrum for which the returned "
914 //"status is bad.";
915 continue;
916 }
917
918 // Before handing the mass spectrum out to the handler, see if the
919 // native mass spectrum was empty or not.
920
921 // if(!native_pwiz_spectrum_sp->defaultArrayLength)
922 // qDebug() << "The mass spectrum has not defaultArrayLength";
923
924 qualified_mass_spectrum.setEmptyMassSpectrum(!native_pwiz_spectrum_sp->defaultArrayLength);
925
926 // The handler will receive the index of the mass spectrum in the
927 // current run via the mass spectrum id member datum.
928 if(ms_level == 0)
929 {
930 handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
931 }
932 else
933 {
934 if(qualified_mass_spectrum.getMsLevel() == ms_level)
935 {
936 handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
937 }
938 }
939 }
940
941 setGlobalLocaleToCurrentOs(backup_env);
942 // End of
943 // for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
944
945 // Now let the loading handler know that the loading of the data has ended.
946 // The handler might need this "signal" to perform additional tasks or to
947 // cleanup cruft.
948
949 // qDebug() << "Loading ended";
950 handler.loadingEnded();
951}
952
953void
956{
958 // qDebug();
959
960 // We want to iterate in the pwiz-spectrum-list and for each pwiz-spectrum
961 // create a pappso-spectrum (QualifiedMassSpectrum). Once the pappso mass
962 // spectrum has been fully qualified (that is, the member data have been
963 // set), it is transferred to the handler passed as parameter to this
964 // function for the consumer to do what it wants with it.
965
966 // Does the handler consuming the mass spectra read from file want these
967 // mass spectra to hold the binary data arrays (mz/i vectors)?
968
969 const bool want_binary_data = config.needPeakList();
970
971
972 std::string backup_env = setGlobalLocaleToEnglish();
973
974 // qDebug();
975 // We access the pwiz-mass-spectra via the spectrumListPtr that sits in the
976 // run member of msp_msData.
977
978 pwiz::msdata::SpectrumListPtr spectrum_list_p = msp_msData->run.spectrumListPtr;
979
980 // We'll need it to perform the looping in the spectrum list.
981 std::size_t spectrum_list_size = spectrum_list_p.get()->size();
982
983 // qDebug() << "The spectrum list has size:" << spectrum_list_size;
984
985 // Inform the handler of the spectrum list so that it can handle feedback to
986 // the user.
987 handler.spectrumListHasSize(spectrum_list_size);
988
989 // Iterate in the full list of spectra.
990
991 qDebug();
992 for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
993 {
994
995
996 // If the user of this reader instance wants to stop reading the
997 // spectra, then break this loop.
998 if(handler.shouldStop())
999 {
1000 qDebug() << "The operation was cancelled. Breaking the loop.";
1001 break;
1002 }
1003
1004 // qDebug();
1005 // Get the native pwiz-spectrum from the spectrum list.
1006 // Note that this pointer is a shared pointer from pwiz.
1007
1008 pwiz::msdata::SpectrumPtr native_pwiz_spectrum_sp =
1009 getPwizSpectrumPtr(spectrum_list_p.get(), iter, want_binary_data);
1010 // qDebug();
1011 /*
1012 * we want to load metadata of the spectrum even if it does not contain
1013 peaks
1014
1015 * if(!native_pwiz_spectrum_sp->hasBinaryData())
1016 {
1017 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ <<
1018 "
1019 ()"
1020 //<< "native pwiz spectrum is empty, continuing.";
1021 continue;
1022 }
1023 */
1024
1025 // Instantiate the mass spectrum id that will hold critical information
1026 // like the the native id string and the spectrum index.
1027
1028 MassSpectrumId massSpectrumId(mcsp_msRunId, iter /* spectrum index*/);
1029
1030 // qDebug();
1031 // Get the spectrum native id as a QString to store it in the mass
1032 // spectrum id class. This is will allow later to refer to the same
1033 // spectrum starting back from the file.
1034
1035 QString native_id = QString::fromStdString(native_pwiz_spectrum_sp->id);
1036 massSpectrumId.setNativeId(native_id);
1037
1038 // Finally, instantiate the qualified mass spectrum with its id. This
1039 // function will continue performing pappso-spectrum detailed
1040 // qualification.
1041
1042 bool ok = false;
1043
1045 massSpectrumId, native_pwiz_spectrum_sp.get(), want_binary_data, ok);
1046
1047 if(!ok)
1048 {
1049 // qDebug() << "Encountered a mass spectrum for which the returned "
1050 //"status is bad.";
1051 continue;
1052 }
1053
1054 // qDebug();
1055 // Before handing the mass spectrum out to the handler, see if the
1056 // native mass spectrum was empty or not.
1057
1058 // if(!native_pwiz_spectrum_sp->defaultArrayLength)
1059 // qDebug() << "The mass spectrum has not defaultArrayLength";
1060
1061 qualified_mass_spectrum.setEmptyMassSpectrum(!native_pwiz_spectrum_sp->defaultArrayLength);
1062
1063 // The handler will receive the index of the mass spectrum in the
1064 // current run via the mass spectrum id member datum.
1065
1066 // qDebug();
1067 if(config.acceptMsLevel(qualified_mass_spectrum.getMsLevel()))
1068 {
1069 if(config.acceptRetentionTimeInSeconds(qualified_mass_spectrum.getRtInSeconds()))
1070 {
1071 handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
1072 }
1073 }
1074 }
1075
1076
1077 qDebug();
1078 setGlobalLocaleToCurrentOs(backup_env);
1079 // End of
1080 // for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
1081
1082 // Now let the loading handler know that the loading of the data has ended.
1083 // The handler might need this "signal" to perform additional tasks or to
1084 // cleanup cruft.
1085
1086 qDebug() << "Loading ended";
1087 handler.loadingEnded();
1088}
1089
1090std::size_t
1092{
1093 return msp_msData->run.spectrumListPtr.get()->size();
1094}
1095
1096bool
1098{
1099 return m_hasScanNumbers;
1100}
1101
1102bool
1104{
1105 msp_msData = nullptr;
1106 return true;
1107}
1108
1109bool
1111{
1112 if(msp_msData == nullptr)
1113 {
1114 initialize();
1115 }
1116 return true;
1117}
1118
1119
1122 pappso::PrecisionPtr precision) const
1123{
1124
1125 QualifiedMassSpectrum mass_spectrum = qualifiedMassSpectrum(spectrum_index, false);
1126
1127 return newXicCoordSPtrFromQualifiedMassSpectrum(mass_spectrum, precision);
1128}
1129
1132 const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const
1133{
1134 XicCoordSPtr xic_coord = std::make_shared<XicCoord>();
1135
1136 xic_coord.get()->rtTarget = mass_spectrum.getRtInSeconds();
1137
1138 xic_coord.get()->mzRange = MzRange(mass_spectrum.getPrecursorMz(), precision);
1139
1140 return xic_coord;
1141}
1142std::string
1144{
1145 std::string env_backup;
1146 try
1147 {
1148#ifdef MXE
1149 // std::locale::global(std::locale("C")); // set locale to default
1150 // locale
1151
1152 std::string env_backup = std::setlocale(LC_ALL, nullptr);
1153 std::setlocale(LC_ALL, "C");
1154#else
1155 std::locale::global(std::locale("C")); // set locale to default locale
1156#endif
1157 }
1158 catch(std::exception &error)
1159 {
1161 QObject::tr("Error trying to set local to C : %1").arg(error.what()));
1162 }
1163 return env_backup;
1164}
1165
1166void
1167PwizMsRunReader::setGlobalLocaleToCurrentOs(const std::string &environment_locale)
1168{
1169 try
1170 {
1171#ifdef MXE
1172 // std::locale::global(std::locale("C")); // set locale to default
1173 // locale
1174 std::setlocale(LC_ALL, environment_locale.c_str());
1175#else
1176 std::locale::global(std::locale("")); // sets locale according to OS environment
1177#endif
1178 }
1179 catch(std::exception &error)
1180 {
1182 QObject::tr("Error trying to set local to original system one %1 : %2")
1183 .arg(environment_locale.c_str())
1184 .arg(error.what()));
1185 }
1186}
1187
1188std::size_t
1190{
1191 acquireDevice();
1192 std::size_t spectrum_id =
1193 msp_msData->run.spectrumListPtr->find(spectrum_identifier.toStdString());
1194 if(spectrum_id == msp_msData->run.spectrumListPtr->size())
1195 {
1197 QObject::tr("Spectrum identifier %1 not found").arg(spectrum_identifier));
1198 }
1199 return spectrum_id;
1200}
1201
1202} // namespace pappso
1203
1204
1207{
1208
1209
1211
1212 if(getOboPsiModTermNativeIDFormat().getAccession() == "MS:1000768")
1213 {
1214
1216
1217 pappso::OboPsiMs psims_file(psims_map);
1218 // it should be a Thermo instrument
1219 /*
1220 * [Term]
1221 id: MS:1000494
1222 name: Thermo Scientific instrument model
1223 def: "Thermo Scientific instrument model." [PSI:MS]
1224 is_a: MS:1000483 ! Thermo Fisher Scientific instrument model
1225
1226 */
1227 term = psims_map.getOboPsiModTermWithAccession("MS:1000494");
1228
1229 for(auto &param_group : msp_msData.get()->paramGroupPtrs)
1230 {
1231 for (const auto &cv_param : param_group.get()->cvParams) {
1232 if(cv_param.cvid == pwiz::cv::CVID::MS_Q_Exactive)
1233 {
1234 term = psims_map.getOboPsiModTermWithAccession("MS:1001911");
1235 }
1236 else if(cv_param.cvid == pwiz::cv::CVID::MS_Velos_Plus)
1237 {
1238 /// Velos Plus: Thermo Scientific second generation Velos.
1239 term = psims_map.getOboPsiModTermWithAccession("MS:1001909");
1240 }
1241 else if(cv_param.cvid == pwiz::cv::CVID::MS_LTQ_Orbitrap_Elite)
1242 {
1243 /// LTQ Orbitrap Elite: Thermo Scientific LTQ Orbitrap Elite, often just referred
1244 /// to as the Orbitrap Elite.
1245
1246 term = psims_map.getOboPsiModTermWithAccession("MS:1001910");
1247 }
1248
1249 /// Orbitrap Fusion: Thermo Scientific Orbitrap Fusion.
1250 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Fusion)
1251 {
1252 /// LTQ Orbitrap Elite: Thermo Scientific LTQ Orbitrap Elite, often just referred
1253 /// to as the Orbitrap Elite.
1254
1255 term = psims_map.getOboPsiModTermWithAccession("MS:1002416");
1256 }
1257 /// Q Exactive HF: Thermo Scientific Q Exactive.
1258 // MS_Q_Exactive_HF = 1002523,
1259 else if(cv_param.cvid == pwiz::cv::CVID::MS_Q_Exactive_HF)
1260 {
1261 /// LTQ Orbitrap Elite: Thermo Scientific LTQ Orbitrap Elite, often just referred
1262 /// to as the Orbitrap Elite.
1263
1264 term = psims_map.getOboPsiModTermWithAccession("MS:1002523");
1265 }
1266 //
1267 /// Exactive Plus: Thermo Scientific Exactive Plus MS.
1268 else if(cv_param.cvid == pwiz::cv::CVID::MS_Exactive_Plus)
1269 {
1270 term = psims_map.getOboPsiModTermWithAccession("MS:1002526");
1271 }
1272 /// Q Exactive Plus: Thermo Scientific Q Exactive Plus.
1273 else if(cv_param.cvid == pwiz::cv::CVID::MS_Q_Exactive_Plus)
1274 {
1275 term = psims_map.getOboPsiModTermWithAccession("MS:1002634");
1276 }
1277 /// Orbitrap Fusion Lumos: Thermo Scientific Orbitrap Fusion Lumos mass spectrometer
1278 /// with Tribrid architecture consisting of quadrupole mass filter, linear ion trap
1279 /// and Orbitrap mass analyzers.
1280 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Fusion_Lumos)
1281 {
1282 term = psims_map.getOboPsiModTermWithAccession("MS:1002732");
1283 }
1284 /// Q Exactive HF-X: Thermo Scientific Q Exactive HF-X Hybrid Quadrupole Orbitrap MS.
1285 else if(cv_param.cvid == pwiz::cv::CVID::MS_Q_Exactive_HF_X)
1286 {
1287 term = psims_map.getOboPsiModTermWithAccession("MS:1002877");
1288 }
1289 /// Orbitrap Exploris 480: Thermo Scientific Orbitrap Exploris 480 Quadrupole Orbitrap
1290 /// MS.
1291
1292 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Exploris_480)
1293 {
1294 term = psims_map.getOboPsiModTermWithAccession("MS:1003028");
1295 }
1296 /// Orbitrap Eclipse: Thermo Scientific Orbitrap Eclipse mass spectrometer with
1297 /// Tribrid architecture consisting of quadrupole mass filter, linear ion trap and
1298 /// Orbitrap mass analyzers.
1299 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Eclipse)
1300 {
1301 term = psims_map.getOboPsiModTermWithAccession("MS:1003029");
1302 }
1303 /// Orbitrap Exploris 240: Thermo Scientific Orbitrap Exploris 240 Quadrupole Orbitrap
1304 /// MS.
1305
1306 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Exploris_240)
1307 {
1308 term = psims_map.getOboPsiModTermWithAccession("MS:1003094");
1309 }
1310 /// Orbitrap Exploris 120: Thermo Scientific Orbitrap Exploris 120 Quadrupole Orbitrap
1311 /// MS.
1312
1313 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Exploris_120)
1314 {
1315 term = psims_map.getOboPsiModTermWithAccession("MS:1003095");
1316 }
1317 /// LTQ Orbitrap Velos Pro: Thermo Scientific LTQ Orbitrap Velos Pro, often just
1318 /// referred to as the Orbitrap Velos Pro.
1319 else if(cv_param.cvid == pwiz::cv::CVID::MS_LTQ_Orbitrap_Velos_Pro)
1320 {
1321 term = psims_map.getOboPsiModTermWithAccession("MS:1003096");
1322 }
1323 /// Q Exactive UHMR: Thermo Scientific Q Exactive UHMR (Ultra High Mass Range) Hybrid
1324 /// Quadrupole Orbitrap MS.
1325 else if(cv_param.cvid == pwiz::cv::CVID::MS_Q_Exactive_UHMR)
1326 {
1327 term = psims_map.getOboPsiModTermWithAccession("MS:1003245");
1328 }
1329 /// TSQ Altis Plus: Thermo Scientific TSQ Altis Plus Triple Quadrupole MS.
1330 else if(cv_param.cvid == pwiz::cv::CVID::MS_TSQ_Altis_Plus)
1331 {
1332 term = psims_map.getOboPsiModTermWithAccession("MS:1003292");
1333 }
1334 /// Orbitrap Ascend: Thermo Scientific Orbitrap Ascend mass spectrometer with Tribrid
1335 /// architecture consisting of quadrupole mass filter, linear ion trap and Orbitrap
1336 /// mass analyzers.
1337 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Ascend)
1338 {
1339 term = psims_map.getOboPsiModTermWithAccession("MS:1003356");
1340 }
1341 /// Orbitrap Astral: Thermo Scientific Orbitrap Astral mass spectrometer contains
1342 /// three mass analyzers: a quadrupole analyzer, an Orbitrap analyzer, and the Astral
1343 /// analyzer.
1344 else if(cv_param.cvid == pwiz::cv::CVID::MS_Orbitrap_Astral)
1345 {
1346 term = psims_map.getOboPsiModTermWithAccession("MS:1003378");
1347 }
1348 }
1349 }
1350 }
1351 else
1352 {
1353
1354 throw ExceptionNotFound(QObject::tr("instrument model name not found in %1")
1355 .arg(mcsp_msRunId.get()->getFileName()));
1356 }
1357
1358 return term;
1359}
const OboPsiModTerm & getOboPsiModTermWithAccession(const QString &accession) const
void setNativeId(const QString &native_id)
void setSpectrumIndex(std::size_t index)
Class to represent a mass spectrum.
void sortMz()
Sort the DataPoint instances of this spectrum.
MassSpectrumSPtr makeMassSpectrumSPtr() const
bool acceptMsLevel(std::size_t ms_level) const
bool acceptRetentionTimeInSeconds(double retention_time_in_seconds) const
MsRunIdCstSPtr mcsp_msRunId
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
void setAccession(const QString &accession)
virtual const QString & qwhat() const
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum index
pwiz::msdata::MSDataPtr msp_msData
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler, unsigned int ms_level) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
static std::string setGlobalLocaleToEnglish()
virtual void readSpectrumCollectionWithMsrunReadConfig(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)
bool processDriftTime(pwiz::msdata::Spectrum *spectrum_p, QualifiedMassSpectrum &qualified_mass_spectrum) const
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
const pwiz::msdata::MSDataPtr getMsDataPtr() const
QualifiedMassSpectrum qualifiedMassSpectrumFromPwizMSData(std::size_t spectrum_index, bool want_binary_data, bool &ok) const
PwizMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
static void setGlobalLocaleToCurrentOs(const std::string &environment_locale)
QualifiedMassSpectrum qualifiedMassSpectrumFromPwizSpectrumPtr(const MassSpectrumId &massSpectrumId, pwiz::msdata::Spectrum *spectrum_p, bool want_binary_data, bool &ok) const
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual std::size_t spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) override
if possible, get the spectrum index given a string identifier throw a not found exception if spectrum...
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
virtual bool hasScanNumbers() const override
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
bool processRetentionTime(pwiz::msdata::Spectrum *spectrum_p, QualifiedMassSpectrum &qualified_mass_spectrum) const
virtual bool acquireDevice() override
acquire data back end device
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
virtual void initialize() override
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual bool accept(const QString &file_name) const override
tells if the reader is able to handle this file must be implemented by private MS run reader,...
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
pwiz::msdata::SpectrumPtr getPwizSpectrumPtr(pwiz::msdata::SpectrumList *p_spectrum_list, std::size_t spectrum_index, bool want_binary_data) const
virtual bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum
const OboPsiModTerm getOboPsiModTermNativeIDFormat() const
get OboPsiModTerm corresponding to the nativeID format format of mz data
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
Class representing a fully specified mass spectrum.
uint getMsLevel() const
Get the mass spectrum level.
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
void setPrecursorNativeId(const QString &native_id)
Set the scan native id of the precursor ion.
const std::vector< PrecursorIonData > & getPrecursorIonData() const
void setDtInMilliSeconds(pappso_double rt)
Set the drift time in milliseconds.
const QString & getPrecursorNativeId() const
void appendPrecursorIonData(const PrecursorIonData &precursor_ion_data)
void setMsLevel(uint ms_level)
Set the mass spectrum level.
void setPrecursorSpectrumIndex(std::size_t precursor_scan_num)
Set the scan number of the precursor ion.
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
MassSpectrumSPtr getMassSpectrumSPtr() const
Get the MassSpectrumSPtr.
void setParameterValue(QualifiedMassSpectrumParameter parameter, const QVariant &value)
void setMassSpectrumSPtr(MassSpectrumSPtr massSpectrum)
Set the MassSpectrumSPtr.
void setRtInSeconds(pappso_double rt)
Set the retention time in seconds.
pappso_double getRtInSeconds() const
Get the retention time in seconds.
void setEmptyMassSpectrum(bool is_empty_mass_spectrum)
interface to collect spectrums from the MsRunReader class
virtual bool needPeakList() const =0
tells if we need the peak list (if we want the binary data) for each spectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum)=0
static std::string toUtf8StandardString(const QString &text)
Definition utils.cpp:166
@ MGF
Mascot format.
Definition types.h:152
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
double pappso_double
A type definition for doubles.
Definition types.h:60
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44