OpenMS  3.0.0
MzTabBase.h
Go to the documentation of this file.
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-2022.
6 //
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.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Oliver Alka $
32 // $Authors: Timo Sachsenberg, Oliver Alka $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 
42 #include <map>
43 #include <vector>
44 #include <list>
45 #include <algorithm>
46 
47 
48 namespace OpenMS
49 {
58  {
64  };
65 
66  class OPENMS_DLLAPI MzTabDouble
67  {
68 public:
69  MzTabDouble();
70 
71  explicit MzTabDouble(const double v);
72 
73  void set(const double& value);
74 
75  double get() const;
76 
77  String toCellString() const;
78 
79  void fromCellString(const String& s);
80 
81  bool isNull() const;
82 
83  void setNull(bool b);
84 
85  bool isNaN() const;
86 
87  void setNaN();
88 
89  bool isInf() const;
90 
91  void setInf();
92 
93  ~MzTabDouble() = default;
94 
95  bool operator<(const MzTabDouble& rhs) const;
96 
97  bool operator==(const MzTabDouble& rhs) const;
98 
99 protected:
100  double value_;
102  };
103 
104  class OPENMS_DLLAPI MzTabDoubleList
105  {
106 public:
107  MzTabDoubleList() = default;
108 
109  bool isNull() const;
110 
111  void setNull(bool b);
112 
113  String toCellString() const;
114 
115  void fromCellString(const String& s);
116 
117  std::vector<MzTabDouble> get() const;
118 
119  void set(const std::vector<MzTabDouble>& entries);
120 
121  ~MzTabDoubleList() = default;
122 protected:
123  std::vector<MzTabDouble> entries_;
124  };
125 
126  class OPENMS_DLLAPI MzTabInteger
127  {
128 public:
129  MzTabInteger();
130 
131  explicit MzTabInteger(const int v);
132 
133  void set(const Int& value);
134 
135  Int get() const;
136 
137  String toCellString() const;
138 
139  void fromCellString(const String& s);
140 
141  bool isNull() const;
142 
143  void setNull(bool b);
144 
145  bool isNaN() const;
146 
147  void setNaN();
148 
149  bool isInf() const;
150 
151  void setInf();
152 
153  ~MzTabInteger() = default;
154 protected:
157  };
158 
159  class OPENMS_DLLAPI MzTabIntegerList
160  {
161 public:
162  MzTabIntegerList() = default;
163 
164  bool isNull() const;
165 
166  void setNull(bool b);
167 
168  String toCellString() const;
169 
170  void fromCellString(const String& s);
171 
172  std::vector<MzTabInteger> get() const;
173 
174  void set(const std::vector<MzTabInteger>& entries);
175 
176  ~MzTabIntegerList() = default;
177 protected:
178  std::vector<MzTabInteger> entries_;
179  };
180 
181  class OPENMS_DLLAPI MzTabBoolean
182  {
183 public:
184  MzTabBoolean();
185 
186  bool isNull() const;
187 
188  void setNull(bool b);
189 
190  explicit MzTabBoolean(bool v);
191 
192  void set(const bool& value);
193 
194  Int get() const;
195 
196  String toCellString() const;
197 
198  void fromCellString(const String& s);
199 
200  ~MzTabBoolean() = default;
201 protected:
202  int value_;
203  };
204 
205  class OPENMS_DLLAPI MzTabString
206  {
207 public:
208  MzTabString();
209 
210  explicit MzTabString(const String& s);
211 
212  bool isNull() const;
213 
214  void setNull(bool b);
215 
216  void set(const String& value);
217 
218  String get() const;
219 
220  String toCellString() const;
221 
222  void fromCellString(const String& s);
223 
224  ~MzTabString() = default;
225 protected:
227  };
228 
229  typedef std::pair<String, MzTabString> MzTabOptionalColumnEntry; //< column name (not null able), value (null able)
230 
231  class OPENMS_DLLAPI MzTabParameter
232  {
233  public:
234  MzTabParameter();
235 
236  bool isNull() const;
237 
238  void setNull(bool b);
239 
240  void setCVLabel(const String& CV_label);
241 
242  void setAccession(const String& accession);
243 
244  void setName(const String& name);
245 
246  void setValue(const String& value);
247 
248  String getCVLabel() const;
249 
250  String getAccession() const;
251 
252  String getName() const;
253 
254  String getValue() const;
255 
256  String toCellString() const;
257 
258  void fromCellString(const String& s);
259 
260  ~MzTabParameter() = default;
261  protected:
266  };
267 
268  class OPENMS_DLLAPI MzTabParameterList
269  {
270  public:
271  MzTabParameterList() = default;
272 
273  bool isNull() const;
274 
275  void setNull(bool b);
276 
277  String toCellString() const;
278 
279  void fromCellString(const String& s);
280 
281  std::vector<MzTabParameter> get() const;
282 
283  void set(const std::vector<MzTabParameter>& parameters);
284 
285  ~MzTabParameterList() = default;
286 
287  protected:
288  std::vector<MzTabParameter> parameters_;
289  };
290 
291  class OPENMS_DLLAPI MzTabStringList
292  {
293  public:
294  MzTabStringList();
295 
296  bool isNull() const;
297 
298  void setNull(bool b);
299 
301  void setSeparator(char sep);
302 
303  String toCellString() const;
304 
305  void fromCellString(const String& s);
306 
307  std::vector<MzTabString> get() const;
308 
309  void set(const std::vector<MzTabString>& entries);
310 
311  ~MzTabStringList() = default;
312  protected:
313  std::vector<MzTabString> entries_;
314  char sep_;
315  };
316 
317  class OPENMS_DLLAPI MzTabSpectraRef
318  {
319  public:
320  MzTabSpectraRef();
321 
322  bool isNull() const;
323 
324  void setNull(bool b);
325 
326  void setMSFile(Size index);
327 
328  void setSpecRef(const String& spec_ref);
329 
330  String getSpecRef() const;
331 
332  Size getMSFile() const;
333 
334  void setSpecRefFile(const String& spec_ref);
335 
336  String toCellString() const;
337 
338  void fromCellString(const String& s);
339 
340  ~MzTabSpectraRef() = default;
341  protected:
342  Size ms_run_; //< number is specified in the meta data section.
344  };
345 
346  // MTD
347  struct OPENMS_DLLAPI MzTabSoftwareMetaData
348  {
350  std::map<Size, MzTabString> setting;
351  };
352 
353  struct OPENMS_DLLAPI MzTabSampleMetaData
354  {
356  std::map<Size, MzTabParameter> species;
357  std::map<Size, MzTabParameter> tissue;
358  std::map<Size, MzTabParameter> cell_type;
359  std::map<Size, MzTabParameter> disease;
360  std::map<Size, MzTabParameter> custom;
361  };
362 
363  struct OPENMS_DLLAPI MzTabCVMetaData
364  {
369  };
370 
371  struct OPENMS_DLLAPI MzTabInstrumentMetaData
372  {
375  std::map<Size, MzTabParameter> analyzer;
377  };
378 
379  struct OPENMS_DLLAPI MzTabContactMetaData
380  {
384  };
385 
386  class OPENMS_DLLAPI MzTabBase
387  {
388  public:
389  MzTabBase() = default;
390  virtual ~MzTabBase() = default;
391 
392  protected:
394  template <typename SectionRows>
395  std::vector<String> getOptionalColumnNames_(const SectionRows& rows) const
396  {
397  // vector is used to preserve the column order
398  std::vector<String> names;
399  for (typename SectionRows::const_iterator it = rows.begin(); it != rows.end(); ++it)
400  {
401  for (auto it_opt = it->opt_.cbegin(); it_opt != it->opt_.cend(); ++it_opt)
402  {
403  if (std::find(names.begin(), names.end(), it_opt->first) == names.end())
404  {
405  names.push_back(it_opt->first);
406  }
407  }
408  }
409  return names;
410  }
411  };
412 } // namespace OpenMS
Definition: MzTabBase.h:371
std::map< Size, MzTabParameter > disease
Definition: MzTabBase.h:359
A more convenient string class.
Definition: String.h:58
int value_
Definition: MzTabBase.h:202
MzTabString label
Definition: MzTabBase.h:365
Definition: MzTabBase.h:63
MzTabString version
Definition: MzTabBase.h:367
Definition: MzTabBase.h:61
Definition: MzTabBase.h:317
Definition: MzTabBase.h:205
Definition: MzTabBase.h:231
Size ms_run_
Definition: MzTabBase.h:342
String value_
Definition: MzTabBase.h:226
std::map< Size, MzTabString > setting
Definition: MzTabBase.h:350
String CV_label_
Definition: MzTabBase.h:262
MzTabParameter detector
Definition: MzTabBase.h:376
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
MzTabParameter software
Definition: MzTabBase.h:349
Definition: MzTabBase.h:268
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
char sep_
Definition: MzTabBase.h:314
Int value_
Definition: MzTabBase.h:155
Definition: MzTabBase.h:353
double value_
Definition: MzTabBase.h:100
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
std::vector< String > getOptionalColumnNames_(const SectionRows &rows) const
Helper function for "get...OptionalColumnNames" functions.
Definition: MzTabBase.h:395
Definition: MzTabBase.h:347
MzTabCellStateType
Base functionality to for MzTab data models.
Definition: MzTabBase.h:57
std::vector< MzTabInteger > entries_
Definition: MzTabBase.h:178
Definition: MzTabBase.h:181
String accession_
Definition: MzTabBase.h:263
Definition: MzTabBase.h:291
std::map< Size, MzTabParameter > cell_type
Definition: MzTabBase.h:358
std::map< Size, MzTabParameter > tissue
Definition: MzTabBase.h:357
Definition: MzTabBase.h:379
String spec_ref_
Definition: MzTabBase.h:343
std::vector< MzTabDouble > entries_
Definition: MzTabBase.h:123
MzTabString name
Definition: MzTabBase.h:381
MzTabString email
Definition: MzTabBase.h:383
std::vector< MzTabParameter > parameters_
Definition: MzTabBase.h:288
MzTabParameter name
Definition: MzTabBase.h:373
Definition: MzTabBase.h:104
Definition: MzTabBase.h:363
std::map< Size, MzTabParameter > analyzer
Definition: MzTabBase.h:375
MzTabParameter source
Definition: MzTabBase.h:374
Definition: MzTabBase.h:60
Definition: MzTabBase.h:66
MzTabString affiliation
Definition: MzTabBase.h:382
MzTabString full_name
Definition: MzTabBase.h:366
Definition: MzTabBase.h:62
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
MzTabString url
Definition: MzTabBase.h:368
std::map< Size, MzTabParameter > custom
Definition: MzTabBase.h:360
String name_
Definition: MzTabBase.h:264
MzTabCellStateType state_
Definition: MzTabBase.h:156
std::vector< MzTabString > entries_
Definition: MzTabBase.h:313
Definition: MzTabBase.h:159
Definition: MzTabBase.h:386
std::map< Size, MzTabParameter > species
Definition: MzTabBase.h:356
int Int
Signed integer type.
Definition: Types.h:102
Definition: MzTabBase.h:126
String value_
Definition: MzTabBase.h:265
MzTabCellStateType state_
Definition: MzTabBase.h:101
MzTabString description
Definition: MzTabBase.h:355
std::pair< String, MzTabString > MzTabOptionalColumnEntry
Definition: MzTabBase.h:229
Definition: MzTabBase.h:59