libpappsomspp
Library for mass spectrometry
precision.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/mass_range.h
3 * \date 4/3/2015
4 * \author Olivier Langella
5 * \brief object to handle a mass range (an mz value + or - some delta)
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and
28 *implementation
29 ******************************************************************************/
30
31#pragma once
32
33#include <map>
34
35#include <QString>
36
37#include "exportinmportconfig.h"
38#include "types.h"
39
40namespace pappso
41{
42
44{
45 protected:
47
48 PrecisionBase(pappso_double nominal) : m_nominal(nominal)
49 {
50 }
51
52 public:
53 virtual PrecisionUnit unit() const = 0;
54 virtual pappso_double getNominal() const final;
55 virtual pappso_double delta(pappso_double value) const = 0;
56 virtual QString toString() const = 0;
57};
58
59
60/** \def specific type for a dalton precision
61 *
62 */
64{
65 friend class PrecisionFactory;
66
67 protected:
69
70 public:
71 virtual ~DaltonPrecision();
72
73 virtual PrecisionUnit unit() const override;
74
75 virtual pappso_double delta(pappso_double value) const override;
76
77 virtual QString toString() const override;
78};
79
80/** \def specific type for a ppm precision
81 *
82 */
84{
85 friend class PrecisionFactory;
86
87 protected:
89
90 public:
91 virtual ~PpmPrecision();
92
93 virtual PrecisionUnit unit() const override;
94
95 virtual pappso_double delta(pappso_double value) const override;
96
97 virtual QString toString() const override;
98};
99
100
101/** \def specific type for a res precision
102 *
103 */
105{
106 friend class PrecisionFactory;
107
108 protected:
110
111 public:
112 virtual ~ResPrecision();
113
114 virtual PrecisionUnit unit() const override;
115
116 virtual pappso_double delta(pappso_double value) const override;
117
118 virtual QString toString() const override;
119};
120
121
123
124
125// was class Precision
127{
128 using MapDaltonPrecision = std::map<pappso_double, DaltonPrecision *>;
129 using MapPpmPrecision = std::map<pappso_double, PpmPrecision *>;
130 using MapResPrecision = std::map<pappso_double, ResPrecision *>;
131
132 private:
136
137 public:
138 /** @brief get a precision pointer from a string
139 * @param str is of the form : "nominal_value unit", example : "0.02 dalton"
140 */
141 static PrecisionPtr fromString(const QString &str);
142
143
144 /** @brief get a Dalton precision pointer
145 * @param value the precision value in dalton
146 */
147 static PrecisionPtr getDaltonInstance(pappso_double value);
148
149
150 /** @brief get a ppm precision pointer
151 * @param value the precision value in ppm
152 */
153 static PrecisionPtr getPpmInstance(pappso_double value);
154
155 /** @brief get a resolution precision pointer
156 * @param value the precision value in resolution
157 */
158 static PrecisionPtr getResInstance(pappso_double value);
159
160
161 /** @brief get the fraction of an existing precision pointer
162 * @param origin the original precision pointer
163 * @param fraction the fraction to apply on the original precision
164 */
165 static PrecisionPtr getPrecisionPtrFractionInstance(PrecisionPtr origin,
166 double fraction);
167
168 /** @brief get a precision pointer instance
169 * @param unit the precision unit
170 * @param value the precision value
171 */
172 static PrecisionPtr getPrecisionPtrInstance(PrecisionUnit unit, double value);
173};
174
175} // namespace pappso
const pappso_double m_nominal
Definition: precision.h:46
PrecisionBase(pappso_double nominal)
Definition: precision.h:48
virtual PrecisionUnit unit() const =0
static MapResPrecision m_mapRes
Definition: precision.h:135
static MapPpmPrecision m_mapPpm
Definition: precision.h:134
std::map< pappso_double, PpmPrecision * > MapPpmPrecision
Definition: precision.h:129
std::map< pappso_double, DaltonPrecision * > MapDaltonPrecision
Definition: precision.h:128
static MapDaltonPrecision m_mapDalton
Definition: precision.h:133
std::map< pappso_double, ResPrecision * > MapResPrecision
Definition: precision.h:130
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
PrecisionUnit
Definition: types.h:63
double pappso_double
A type definition for doubles.
Definition: types.h:48
const PrecisionBase * PrecisionPtr
Definition: precision.h:122
This header contains all the type re-definitions and all the global variables definitions used in the...