libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
precursorparser.cpp
Go to the documentation of this file.
1
2/**
3 * \file pappsomspp/masschroq/input/precursorparser.h
4 * \date 25/09/2024
5 * \author Olivier Langella
6 * \brief read presurcors in ms run files for MassChroqLight
7 */
8
9/*******************************************************************************
10 * Copyright (c) 2024 Olivier Langella
11 *<Olivier.Langella@universite-paris-saclay.fr>.
12 *
13 * This file is part of MassChroQ.
14 *
15 * MassChroQ is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * MassChroQ is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with MassChroQ. If not, see <http://www.gnu.org/licenses/>.
27 *
28 ******************************************************************************/
29
30#include "precursorparser.h"
33
34
39
40
44
45bool
47{
48 return false;
49}
50void
52 const pappso::QualifiedMassSpectrum &qspectrum)
53{
54
55 if(qspectrum.getMsLevel() > 1)
56 {
57
58 pappso::masschroq::PrecursorSp precursor = std::make_shared<pappso::masschroq::Precursor>(
59 qspectrum.getPrecursorSpectrumIndex(),
60 qspectrum.getPrecursorMz(),
61 qspectrum.getPrecursorIntensity(),
62 msp_msrunReader.get()->newXicCoordSPtrFromQualifiedMassSpectrum(
64
65
66 qDebug() << " native_id=" << qspectrum.getMassSpectrumId().getNativeId()
67 << " scan idx=" << qspectrum.getMassSpectrumId().getSpectrumIndex()
68 << " precursor_idx=" << qspectrum.getPrecursorSpectrumIndex()
69 << " precursor.get()->getXicCoordSPtr().get()->toString="
70 << precursor.get()->getXicCoordSPtr().get()->toString();
71 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
72 {
73 throw pappso::PappsoException(QObject::tr("precursor.get()->getXicCoordSPtr().get() == "
74 "nullptr\nindex=%1 %2 %3 %4")
75 .arg(qspectrum.getMassSpectrumId().getNativeId())
76 .arg(__FILE__)
77 .arg(__FUNCTION__)
78 .arg(__LINE__));
79 }
80 /// adding this new precursor to the msrun's hash map of scan_num ->
81 /// precursor
82 qDebug();
83 if(qspectrum.getMassSpectrumId().getNativeId().contains("scan="))
84 {
85 qDebug();
87 qspectrum.getMassSpectrumId().getNativeId()),
88 precursor);
90 qDebug();
91 }
92 else
93 {
94 qDebug();
96
98 qDebug();
99 }
100 qDebug();
101 }
102}
103
104bool
106{
107 return true;
108}
109
110void
113{
114
115 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
116 {
118 QObject::tr("precursor.get()->getXicCoordSPtr().get() == nullptr scan_num=%1\n")
119 .arg(scan_num));
120 }
121 m_scanNumber2PrecursorMap[scan_num] = precursor;
122}
123
124void
126 std::size_t spectrum_index, pappso::masschroq::PrecursorSp precursor)
127{
128
129 qDebug() << " spectrum_index=" << spectrum_index;
130
131 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
132 {
134 QObject::tr("precursor.get()->getXicCoordSPtr().get() == nullptr \n")
135 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId())
136 .arg(spectrum_index));
137 }
138 m_spectrumIndex2PrecursorMap[spectrum_index] = precursor;
139 qDebug() << " spectrum_index=" << spectrum_index;
140}
141
144 std::size_t spectrum_index) const
145{
146 auto it = m_spectrumIndex2PrecursorMap.find(spectrum_index);
147 if(it != m_spectrumIndex2PrecursorMap.end())
148 {
149 }
150 else
151 {
152 throw pappso::PappsoException(QObject::tr("spectrum index %1 not found in %2")
153 .arg(spectrum_index)
154 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
155 }
156 return it->second;
157}
158
161{
162 auto it = m_scanNumber2PrecursorMap.find(spectrum_index);
163 if(it != m_scanNumber2PrecursorMap.end())
164 {
165 }
166 else
167 {
168 throw pappso::PappsoException(QObject::tr("scan number %1 not found in %2")
169 .arg(spectrum_index)
170 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
171 }
172 return it->second;
173}
std::size_t getSpectrumIndex() const
const QString & getNativeId() const
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
Class representing a fully specified mass spectrum.
uint getMsLevel() const
Get the mass spectrum level.
pappso_double getPrecursorIntensity(bool *ok=nullptr) const
get precursor intensity
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
std::size_t getPrecursorSpectrumIndex() const
Get the scan number of the precursor ion.
static std::size_t extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id)
Definition utils.cpp:285
const PrecursorSp & getPrecursorSPtrBySpectrumIndex(std::size_t spectrum_index) const
void mapSpectrumIndexToPrecursor(std::size_t spectrum_index, PrecursorSp precursor)
map spectrum index to precursor new modern method to replace obsolete scan number
std::map< std::size_t, PrecursorSp > m_scanNumber2PrecursorMap
virtual bool needPeakList() const override
tells if we need the peak list (if we want the binary data) for each spectrum
void mapScanNumberPrecursor(std::size_t scan_num, PrecursorSp precursor)
map precursor to its scan number as parsed in the xml file of this msrun
std::map< std::size_t, PrecursorSp > m_spectrumIndex2PrecursorMap
virtual void setQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &qspectrum) override
virtual bool isReadAhead() const override
tells if we want to read ahead spectrum
const PrecursorSp & getPrecursorSPtrByScanNumber(std::size_t spectrum_index) const
PrecursorParser(pappso::MsRunReaderCstSPtr msrun_reader)
pappso::MsRunReaderCstSPtr msp_msrunReader
const pappso::XicCoordSPtr & getXicCoordSPtr() const
Definition precursor.cpp:71
std::shared_ptr< Precursor > PrecursorSp
Definition precursor.h:39
std::shared_ptr< const MsRunReader > MsRunReaderCstSPtr
Definition msrunreader.h:58