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