libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
xiccoordtims.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/msrun/xiccoord/xiccoordtims.cpp
3 * \date 22/04/2021
4 * \author Olivier Langella
5 * \brief XIC coordinate in a Tims MSrun
6 */
7
8
9/*******************************************************************************
10 * Copyright (c) 2021 Olivier Langella
11 *<Olivier.Langella@universite-paris-saclay.fr>.
12 *
13 * This file is part of the PAPPSOms++ library.
14 *
15 * PAPPSOms++ 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 * PAPPSOms++ 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 PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
27 *
28 ******************************************************************************/
29
30
31#include <QObject>
32#include <QVariant>
33
34#include "xiccoordtims.h"
36
37
38namespace pappso
39{
40
42{
44 scanNumEnd = other.scanNumEnd;
45}
46
47
51
52
55{
56
57 XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
58
59 xic_coord_sp.get()->xicSptr = std::make_shared<Xic>();
60
61 return xic_coord_sp;
62}
63
64
67{
68 XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
69
70 XicCoordTims *toadd = dynamic_cast<XicCoordTims *>(to_add.get());
71
72 if(toadd == nullptr)
73 {
74 throw ExceptionNotPossible(QObject::tr("XicCoord to add is of a different type"));
75 }
76
77 // xic_coord_sp.get()->xicSptr = xic_coord_sp.get()->xicSptr;
78
79 xic_coord_sp.get()->mzRange += to_add.get()->mzRange;
80 xic_coord_sp.get()->rtTarget += to_add.get()->rtTarget;
81 xic_coord_sp.get()->scanNumBegin += toadd->scanNumBegin;
82 xic_coord_sp.get()->scanNumEnd += toadd->scanNumEnd;
83
84 qDebug() << "xic_coord_sp.get()->scanNumBegin=" << xic_coord_sp.get()->scanNumBegin;
85 qDebug() << "xic_coord_sp.get()->scanNumEnd=" << xic_coord_sp.get()->scanNumEnd;
86 return xic_coord_sp;
87}
88
89
91XicCoordTims::multiplyBy(double number) const
92{
93 XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
94
95 // xic_coord_sp.get()->xicSptr = nullptr;
96
97 xic_coord_sp.get()->rtTarget *= number;
98 xic_coord_sp.get()->mzRange *= number;
99
100 xic_coord_sp.get()->scanNumBegin *= number;
101 xic_coord_sp.get()->scanNumEnd *= number;
102
103 return xic_coord_sp;
104}
105
107XicCoordTims::divideBy(double number) const
108{
109
110 XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
111
112 // xic_coord_sp.get()->xicSptr = nullptr;
113
114 xic_coord_sp.get()->rtTarget /= number;
115 xic_coord_sp.get()->mzRange *= (double)((double)1 / number);
116
117 xic_coord_sp.get()->scanNumBegin /= number;
118 xic_coord_sp.get()->scanNumEnd /= number;
119
120 qDebug() << "xic_coord_sp.get()->scanNumBegin=" << xic_coord_sp.get()->scanNumBegin;
121 qDebug() << "xic_coord_sp.get()->scanNumEnd=" << xic_coord_sp.get()->scanNumEnd;
122 return xic_coord_sp;
123}
124
125
126void
128{
129
130 xicSptr = nullptr;
131
132 rtTarget = 0;
133 mzRange = MzRange(0.0, 0.0);
134 scanNumBegin = 0;
135 scanNumEnd = 0;
136}
137
138QString
140{
141 return QString("%1 begin=%2 end=%3").arg(XicCoord::toString()).arg(scanNumBegin).arg(scanNumEnd);
142}
143
144
145const QVariant
147{
148 switch(param)
149 {
151 return QVariant((quint64)scanNumBegin);
152 break;
154 return QVariant((quint64)scanNumEnd);
155 break;
156 default:
157 return QVariant();
158 }
159}
160void
161XicCoordTims::scanNumBeginRangeCorrection(long start_dev, long stop_dev)
162{
163 long begin = scanNumBegin + start_dev;
164 long end = scanNumEnd + stop_dev;
165 if(begin < 0)
166 scanNumBegin = 0;
167 else
168 scanNumBegin = begin;
169 if(end < 0)
170 scanNumEnd = 0;
171 else
172 scanNumEnd = end;
173}
174} // namespace pappso
175
176
177void
178pappso::XicCoordTims::writeCborStream(QCborStreamWriter &cbor_writer) const
179{
180 cbor_writer.append(QLatin1String("xic_coord"));
181 cbor_writer.startMap(3);
182 cbor_writer.append(QLatin1String("mz_range"));
183 cbor_writer.startArray(2);
184 cbor_writer.append(mzRange.lower());
185 cbor_writer.append(mzRange.upper());
186 cbor_writer.endArray();
187
188 cbor_writer.append(QLatin1String("rt"));
189 cbor_writer.append(rtTarget);
190
191 cbor_writer.append(QLatin1String("tim_im_range"));
192 cbor_writer.startArray(2);
193 cbor_writer.append((quint64)scanNumBegin);
194 cbor_writer.append((quint64)scanNumEnd);
195 cbor_writer.endArray();
196 cbor_writer.endMap();
197}
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
XicCoordParam
Definition xiccoord.h:51
@ TimsTofIonMobilityScanNumberStart
Definition xiccoord.h:52
std::shared_ptr< XicCoordTims > XicCoordTimsSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44
void scanNumBeginRangeCorrection(long start_dev, long stop_dev)
apply scan num correction on xic coordinate
virtual XicCoordSPtr initializeAndClone() const override
intialize the XIC and make a deep copy of object
virtual XicCoordSPtr addition(const XicCoordSPtr &to_add) const override
compute a new XIC coord as the sum of the given one
std::size_t scanNumEnd
mobility index end
std::size_t scanNumBegin
mobility index begin
virtual QString toString() const override
get a description of the XIC coordinate in a string
virtual const QVariant getParam(XicCoordParam param) const override
get a specific XIC coordinate parameter
virtual void reset() override
reset to zero
virtual XicCoordSPtr divideBy(double number) const override
compute a new xic coord as a division by
virtual void writeCborStream(QCborStreamWriter &cbor_writer) const override
writes xic coordinates in a cbor stream
virtual XicCoordSPtr multiplyBy(double number) const override
compute a new xic coord as a product by
XicSPtr xicSptr
extracted xic
Definition xiccoord.h:135
double rtTarget
the targeted retention time to extract around intended in seconds, and related to one msrun....
Definition xiccoord.h:131
MzRange mzRange
the mass to extract
Definition xiccoord.h:125
virtual QString toString() const
get a description of the XIC coordinate in a string
Definition xiccoord.cpp:114