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="
68 << qspectrum.getMassSpectrumId().getSpectrumIndex()
69 << " precursor_idx=" << qspectrum.getPrecursorSpectrumIndex()
70 << " precursor.get()->getXicCoordSPtr().get()->toString="
71 << precursor.get()->getXicCoordSPtr().get()->toString();
72 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
73 {
75 QObject::tr("precursor.get()->getXicCoordSPtr().get() == "
76 "nullptr\nindex=%1 %2 %3 %4")
77 .arg(qspectrum.getMassSpectrumId().getNativeId())
78 .arg(__FILE__)
79 .arg(__FUNCTION__)
80 .arg(__LINE__));
81 }
82 /// adding this new precursor to the msrun's hash map of scan_num ->
83 /// precursor
84 qDebug();
85 if(qspectrum.getMassSpectrumId().getNativeId().contains("scan="))
86 {
87 qDebug();
90 qspectrum.getMassSpectrumId().getNativeId()),
91 precursor);
93 qspectrum.getMassSpectrumId().getSpectrumIndex(), precursor);
94 qDebug();
95 }
96 else
97 {
98 qDebug();
100 qspectrum.getMassSpectrumId().getSpectrumIndex(), precursor);
101
103 qspectrum.getMassSpectrumId().getSpectrumIndex(), precursor);
104 qDebug();
105 }
106 qDebug();
107 }
108}
109
110bool
112{
113 return true;
114}
115
116void
119{
120
121 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
122 {
124 QObject::tr(
125 "precursor.get()->getXicCoordSPtr().get() == nullptr scan_num=%1\n")
126 .arg(scan_num));
127 }
128 m_scanNumber2PrecursorMap[scan_num] = precursor;
129}
130
131void
134{
135
136 qDebug() << " spectrum_index=" << spectrum_index;
137
138 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
139 {
141 QObject::tr("precursor.get()->getXicCoordSPtr().get() == nullptr \n")
142 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId())
143 .arg(spectrum_index));
144 }
145 m_spectrumIndex2PrecursorMap[spectrum_index] = precursor;
146 qDebug() << " spectrum_index=" << spectrum_index;
147}
148
151 std::size_t spectrum_index) const
152{
153 auto it = m_spectrumIndex2PrecursorMap.find(spectrum_index);
154 if(it != m_spectrumIndex2PrecursorMap.end())
155 {
156 }
157 else
158 {
160 QObject::tr("spectrum index %1 not found in %2")
161 .arg(spectrum_index)
162 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
163 }
164 return it->second;
165}
166
169 std::size_t spectrum_index) const
170{
171 auto it = m_scanNumber2PrecursorMap.find(spectrum_index);
172 if(it != m_scanNumber2PrecursorMap.end())
173 {
174 }
175 else
176 {
178 QObject::tr("scan number %1 not found in %2")
179 .arg(spectrum_index)
180 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
181 }
182 return it->second;
183}
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:258
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:72
std::shared_ptr< Precursor > PrecursorSp
Definition precursor.h:39
std::shared_ptr< const MsRunReader > MsRunReaderCstSPtr
Definition msrunreader.h:58