1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1
// --------------------------------------------------------------------------
2
// OpenMS -- Open-Source Mass Spectrometry
3
// --------------------------------------------------------------------------
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
7
// This software is released under a three-clause BSD license:
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright
11
// notice, this list of conditions and the following disclaimer in the
12
// documentation and/or other materials provided with the distribution.
13
// * Neither the name of any author or any participating institution
14
// may be used to endorse or promote products derived from this software
15
// without specific prior written permission.
16
// For a full list of authors, refer to the file AUTHORS.
17
// --------------------------------------------------------------------------
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Andreas Bertsch $
37
MetaInfoRegistry::MetaInfoRegistry(): next_index_(1024), name_to_index_(), index_to_name_(), index_to_description_(), index_to_unit_()
39
name_to_index_["isotopic_range"] = 1;
40
index_to_name_[1] = "isotopic_range";
41
index_to_description_[1] = "consecutive numbering of the peaks in an isotope pattern. 0 is the monoisotopic peak";
42
index_to_unit_[1] = "";
44
name_to_index_["cluster_id"] = 2;
45
index_to_name_[2] = "cluster_id";
46
index_to_description_[2] = "consecutive numbering of isotope clusters in a spectrum";
47
index_to_unit_[2] = "";
49
name_to_index_["label"] = 3;
50
index_to_name_[3] = "label";
51
index_to_description_[3] = "label e.g. shown in visialization";
52
index_to_unit_[3] = "";
54
name_to_index_["icon"] = 4;
55
index_to_name_[4] = "icon";
56
index_to_description_[4] = "icon shown in visialization";
57
index_to_unit_[4] = "";
59
name_to_index_["color"] = 5;
60
index_to_name_[5] = "color";
61
index_to_description_[5] = "color used for visialization e.g. #FF00FF for purple";
62
index_to_unit_[5] = "";
64
name_to_index_["RT"] = 6;
65
index_to_name_[6] = "RT";
66
index_to_description_[6] = "the retention time of an identification";
67
index_to_unit_[6] = "";
69
name_to_index_["MZ"] = 7;
70
index_to_name_[7] = "MZ";
71
index_to_description_[7] = "the MZ of an identification";
72
index_to_unit_[7] = "";
74
name_to_index_["predicted_RT"] = 8;
75
index_to_name_[8] = "predicted_RT";
76
index_to_description_[8] = "the predicted retention time of a peptide hit";
77
index_to_unit_[8] = "";
79
name_to_index_["predicted_RT_p_value"] = 9;
80
index_to_name_[9] = "predicted_RT_p_value";
81
index_to_description_[9] = "the predicted RT p-value of a peptide hit";
82
index_to_unit_[9] = "";
84
name_to_index_["spectrum_reference"] = 10;
85
index_to_name_[10] = "spectrum_reference";
86
index_to_description_[10] = "Refenference to a spectrum or feature number";
87
index_to_unit_[10] = "";
89
name_to_index_["ID"] = 11;
90
index_to_name_[11] = "ID";
91
index_to_description_[11] = "Some type of identifier";
92
index_to_unit_[11] = "";
94
name_to_index_["low_quality"] = 12;
95
index_to_name_[12] = "low_quality";
96
index_to_description_[12] = "Flag which indicatest that some entity has a low quality (e.g. a feature pair)";
97
index_to_unit_[12] = "";
99
name_to_index_["charge"] = 13;
100
index_to_name_[13] = "charge";
101
index_to_description_[13] = "Charge of a feature or peak";
102
index_to_unit_[13] = "";
106
MetaInfoRegistry::MetaInfoRegistry(const MetaInfoRegistry& rhs)
111
MetaInfoRegistry::~MetaInfoRegistry()
116
MetaInfoRegistry& MetaInfoRegistry::operator = (const MetaInfoRegistry& rhs)
118
if (this==&rhs) return *this;
119
#pragma omp critical (MetaInfoRegistry)
44
MetaInfoRegistry::MetaInfoRegistry() :
45
next_index_(1024), name_to_index_(), index_to_name_(), index_to_description_(), index_to_unit_()
47
name_to_index_["isotopic_range"] = 1;
48
index_to_name_[1] = "isotopic_range";
49
index_to_description_[1] = "consecutive numbering of the peaks in an isotope pattern. 0 is the monoisotopic peak";
50
index_to_unit_[1] = "";
52
name_to_index_["cluster_id"] = 2;
53
index_to_name_[2] = "cluster_id";
54
index_to_description_[2] = "consecutive numbering of isotope clusters in a spectrum";
55
index_to_unit_[2] = "";
57
name_to_index_["label"] = 3;
58
index_to_name_[3] = "label";
59
index_to_description_[3] = "label e.g. shown in visialization";
60
index_to_unit_[3] = "";
62
name_to_index_["icon"] = 4;
63
index_to_name_[4] = "icon";
64
index_to_description_[4] = "icon shown in visialization";
65
index_to_unit_[4] = "";
67
name_to_index_["color"] = 5;
68
index_to_name_[5] = "color";
69
index_to_description_[5] = "color used for visialization e.g. #FF00FF for purple";
70
index_to_unit_[5] = "";
72
name_to_index_["RT"] = 6;
73
index_to_name_[6] = "RT";
74
index_to_description_[6] = "the retention time of an identification";
75
index_to_unit_[6] = "";
77
name_to_index_["MZ"] = 7;
78
index_to_name_[7] = "MZ";
79
index_to_description_[7] = "the MZ of an identification";
80
index_to_unit_[7] = "";
82
name_to_index_["predicted_RT"] = 8;
83
index_to_name_[8] = "predicted_RT";
84
index_to_description_[8] = "the predicted retention time of a peptide hit";
85
index_to_unit_[8] = "";
87
name_to_index_["predicted_RT_p_value"] = 9;
88
index_to_name_[9] = "predicted_RT_p_value";
89
index_to_description_[9] = "the predicted RT p-value of a peptide hit";
90
index_to_unit_[9] = "";
92
name_to_index_["spectrum_reference"] = 10;
93
index_to_name_[10] = "spectrum_reference";
94
index_to_description_[10] = "Refenference to a spectrum or feature number";
95
index_to_unit_[10] = "";
97
name_to_index_["ID"] = 11;
98
index_to_name_[11] = "ID";
99
index_to_description_[11] = "Some type of identifier";
100
index_to_unit_[11] = "";
102
name_to_index_["low_quality"] = 12;
103
index_to_name_[12] = "low_quality";
104
index_to_description_[12] = "Flag which indicatest that some entity has a low quality (e.g. a feature pair)";
105
index_to_unit_[12] = "";
107
name_to_index_["charge"] = 13;
108
index_to_name_[13] = "charge";
109
index_to_description_[13] = "Charge of a feature or peak";
110
index_to_unit_[13] = "";
113
MetaInfoRegistry::MetaInfoRegistry(const MetaInfoRegistry & rhs)
118
MetaInfoRegistry::~MetaInfoRegistry()
123
MetaInfoRegistry & MetaInfoRegistry::operator=(const MetaInfoRegistry & rhs)
128
#pragma omp critical (MetaInfoRegistry)
121
next_index_ = rhs.next_index_;
122
name_to_index_ = rhs.name_to_index_;
123
index_to_name_ = rhs.index_to_name_;
124
index_to_description_ = rhs.index_to_description_;
125
index_to_unit_ = rhs.index_to_unit_;
130
next_index_ = rhs.next_index_;
131
name_to_index_ = rhs.name_to_index_;
132
index_to_name_ = rhs.index_to_name_;
133
index_to_description_ = rhs.index_to_description_;
134
index_to_unit_ = rhs.index_to_unit_;
131
UInt MetaInfoRegistry::registerName(const String& name, const String& description, const String& unit) const
139
UInt MetaInfoRegistry::registerName(const String & name, const String & description, const String & unit) const
134
#pragma omp critical (MetaInfoRegistry)
142
#pragma omp critical (MetaInfoRegistry)
136
map<String,UInt>::iterator it = name_to_index_.find(name);
137
if (it == name_to_index_.end())
139
name_to_index_[name] = next_index_;
140
index_to_name_[next_index_] = name;
141
index_to_description_[next_index_] = description;
142
index_to_unit_[next_index_] = unit;
144
map<String, UInt>::iterator it = name_to_index_.find(name);
145
if (it == name_to_index_.end())
147
name_to_index_[name] = next_index_;
148
index_to_name_[next_index_] = name;
149
index_to_description_[next_index_] = description;
150
index_to_unit_[next_index_] = unit;
153
void MetaInfoRegistry::setDescription(UInt index, const String& description)
161
void MetaInfoRegistry::setDescription(UInt index, const String & description)
156
#pragma omp critical (MetaInfoRegistry)
164
#pragma omp critical (MetaInfoRegistry)
158
166
found = (index_to_name_.find(index) != index_to_name_.end());
166
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered index!",String(index));
174
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered index!", String(index));
170
void MetaInfoRegistry::setDescription(const String& name, const String& description)
178
void MetaInfoRegistry::setDescription(const String & name, const String & description)
173
#pragma omp critical (MetaInfoRegistry)
181
#pragma omp critical (MetaInfoRegistry)
175
183
found = (name_to_index_.find(name) != name_to_index_.end());
179
UInt index = getIndex(name);
180
setDescription(index, description);
184
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered name!",name);
188
void MetaInfoRegistry::setUnit(UInt index, const String& unit)
187
UInt index = getIndex(name);
188
setDescription(index, description);
192
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered name!", name);
196
void MetaInfoRegistry::setUnit(UInt index, const String & unit)
191
#pragma omp critical (MetaInfoRegistry)
199
#pragma omp critical (MetaInfoRegistry)
193
201
found = (index_to_name_.end() != index_to_name_.find(index));
201
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered index!",String(index));
209
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered index!", String(index));
205
void MetaInfoRegistry::setUnit(const String& name, const String& unit)
213
void MetaInfoRegistry::setUnit(const String & name, const String & unit)
208
#pragma omp critical (MetaInfoRegistry)
216
#pragma omp critical (MetaInfoRegistry)
210
218
found = (name_to_index_.find(name) != name_to_index_.end());
214
UInt index = getIndex(name);
215
setUnit(index, unit);
219
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered name!",name);
223
UInt MetaInfoRegistry::getIndex(const String& name) const
222
UInt index = getIndex(name);
223
setUnit(index, unit);
227
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered name!", name);
231
UInt MetaInfoRegistry::getIndex(const String & name) const
226
234
bool found = false;
227
#pragma omp critical (MetaInfoRegistry)
235
#pragma omp critical (MetaInfoRegistry)
229
map<String,UInt>::const_iterator it = name_to_index_.find(name);
230
if (it != name_to_index_.end())
237
map<String, UInt>::const_iterator it = name_to_index_.find(name);
238
if (it != name_to_index_.end())
238
registerName(name, String::EMPTY, String::EMPTY);
245
String MetaInfoRegistry::getDescription(UInt index) const
248
#pragma omp critical (MetaInfoRegistry)
250
map<UInt,String>::const_iterator it = index_to_description_.find(index);
251
if (it == index_to_description_.end())
253
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered index!",String(index));
260
String MetaInfoRegistry::getDescription(const String& name) const
263
UInt index = getIndex(name);
266
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered Name!",name);
268
#pragma omp critical (MetaInfoRegistry)
270
rv = (index_to_description_.find(index))->second;
275
String MetaInfoRegistry::getUnit(UInt index) const
278
#pragma omp critical (MetaInfoRegistry)
280
map<UInt,String>::const_iterator it = index_to_unit_.find(index);
281
if (it == index_to_unit_.end())
283
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered index!",String(index));
290
String MetaInfoRegistry::getUnit(const String& name) const
293
UInt index = getIndex(name);
296
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered Name!",name);
298
#pragma omp critical (MetaInfoRegistry)
300
rv = (index_to_unit_.find(index))->second;
246
registerName(name, String::EMPTY, String::EMPTY);
252
String MetaInfoRegistry::getDescription(UInt index) const
255
#pragma omp critical (MetaInfoRegistry)
257
map<UInt, String>::const_iterator it = index_to_description_.find(index);
258
if (it == index_to_description_.end())
260
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered index!", String(index));
267
String MetaInfoRegistry::getDescription(const String & name) const
270
UInt index = getIndex(name);
273
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered Name!", name);
275
#pragma omp critical (MetaInfoRegistry)
277
rv = (index_to_description_.find(index))->second;
282
String MetaInfoRegistry::getUnit(UInt index) const
285
#pragma omp critical (MetaInfoRegistry)
287
map<UInt, String>::const_iterator it = index_to_unit_.find(index);
288
if (it == index_to_unit_.end())
290
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered index!", String(index));
297
String MetaInfoRegistry::getUnit(const String & name) const
300
UInt index = getIndex(name);
303
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered Name!", name);
305
#pragma omp critical (MetaInfoRegistry)
307
rv = (index_to_unit_.find(index))->second;
305
312
String MetaInfoRegistry::getName(UInt index) const
309
#pragma omp critical (MetaInfoRegistry)
316
#pragma omp critical (MetaInfoRegistry)
311
map<UInt,String>::const_iterator it = index_to_name_.find(index);
312
if (it != index_to_name_.end())
318
map<UInt, String>::const_iterator it = index_to_name_.find(index);
319
if (it != index_to_name_.end())
318
if (!found) throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,"Unregistered index!",String(index));
326
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Unregistered index!", String(index));