libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
massspectrumid.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
3 *
4 * This file is part of the PAPPSOms++ library.
5 *
6 * PAPPSOms++ is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * PAPPSOms++ is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Contributors:
20 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
21 *implementation
22 ******************************************************************************/
23
24
25#include <QRegularExpressionMatch>
26#include <limits>
27#include "massspectrumid.h"
28
29namespace pappso
30{
31
32
36
37
41
42
43MassSpectrumId::MassSpectrumId(const MsRunIdCstSPtr &msRunId, std::size_t spectrum_index)
44 : mcsp_msRunId(msRunId), m_nativeId(""), m_spectrumIndex(spectrum_index)
45{
46}
47
48
55
56
60
61
64{
65 if(&other == this)
66 return *this;
67
70 m_nativeId = other.m_nativeId;
71
72 return *this;
73}
74
75
76void
82
83
84const MsRunIdCstSPtr &
89
90
91void
92MassSpectrumId::setNativeId(const QString &native_id)
93{
94 m_nativeId = native_id;
95}
96
97
98const QString &
100{
101 return m_nativeId;
102}
103
104
105void
107{
108 m_spectrumIndex = index;
109}
110
111
112std::size_t
117
118
119bool
121{
122 return (mcsp_msRunId == other.mcsp_msRunId && m_spectrumIndex == other.m_spectrumIndex);
123}
124
125bool
127{
128 return mcsp_msRunId->isValid() && m_spectrumIndex != std::numeric_limits<std::size_t>::max();
129}
130
131
132QString
134{
135 return QString(
136 "ms run id: %1 \n"
137 "native id: %2 \n"
138 "m_spectrumIndex: %3\n")
139 .arg(mcsp_msRunId != nullptr ? mcsp_msRunId->toString() : "nullptr")
140 .arg(m_nativeId)
141 .arg(m_spectrumIndex);
142}
143
144std::size_t
146{
147 *is_ok = false;
148
149 QRegularExpression regexp_scan("scan=([0-9]+)");
150 QRegularExpressionMatch match = regexp_scan.match(m_nativeId);
151 if(match.hasMatch())
152 {
153 return match.captured(0).toInt(is_ok);
154 }
155 return 0;
156}
157} // namespace pappso
void setNativeId(const QString &native_id)
void setMsRunId(MsRunIdCstSPtr other)
MassSpectrumId & operator=(const MassSpectrumId &other)
std::size_t getSpectrumIndex() const
void setSpectrumIndex(std::size_t index)
const QString & getNativeId() const
std::size_t extractScanNumberFromNativeId(bool *is_ok) const
try to find scan id in the native id string
bool operator==(const MassSpectrumId &other) const
MsRunIdCstSPtr mcsp_msRunId
const MsRunIdCstSPtr & getMsRunIdCstSPtr() const
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