Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
QcMLFile.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-2017.
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: Mathias Walzer $
32 // $Authors: Mathias Walzer $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 #include <OpenMS/FORMAT/XMLFile.h>
40 
41 #include <vector>
42 #include <map>
43 #include <set>
44 #include <algorithm>
45 
46 namespace OpenMS
47 {
55  class OPENMS_DLLAPI QcMLFile :
56  public Internal::XMLHandler,
57  public Internal::XMLFile,
58  public ProgressLogger
59  {
60 public:
62  struct OPENMS_DLLAPI QualityParameter
63  {
72 
75 
77 
78  QualityParameter& operator=(const QualityParameter& rhs);
79  bool operator==(const QualityParameter& rhs) const;
80  bool operator<(const QualityParameter& rhs) const;
81  bool operator>(const QualityParameter& rhs) const;
82 
83  String toXMLString(UInt indentation_level) const;
84  };
85 
87  struct OPENMS_DLLAPI Attachment
88  {
98  std::vector<String> colTypes;
99  std::vector< std::vector<String> > tableRows;
100  //~ TODO -schema- coltypes with full definition (uintRef, unitAcc)
101 
103  Attachment();
104 
105  Attachment(const Attachment& rhs);
106 
107  Attachment& operator=(const Attachment& rhs);
108  bool operator==(const Attachment& rhs) const;
109  bool operator<(const Attachment& rhs) const;
110  bool operator>(const Attachment& rhs) const;
111 
112  String toXMLString(UInt indentation_level) const;
113  String toCSVString(String separator) const;
114  };
115 
117  QcMLFile();
119  ~QcMLFile() override;
120 
121  String map2csv(const std::map< String, std::map<String, String> >& cvs_table, const String& separator) const;
122  String exportIDstats(const String& filename) const;
123 
125  void registerRun(const String id, const String name);
127  void registerSet(const String id, const String name, const std::set<String>& names);
129  void addRunQualityParameter(String r, QualityParameter qp);
131  void addRunAttachment(String r, Attachment at);
133  void addSetQualityParameter(String r, QualityParameter qp);
135  void addSetAttachment(String r, Attachment at);
137  void removeAttachment(String r, std::vector<String>& ids, String at = "");
139  void removeAttachment(String r, String at);
141  void removeAllAttachments(String at);
143  void removeQualityParameter(String r, std::vector<String>& ids);
145  void merge(const QcMLFile & addendum, String setname = "");
147  void/* std::vector<String>& */ collectSetParameter(const String setname, const String qp, std::vector<String>& ret);
149  String exportAttachment(const String filename, const String qpname) const;
151  String exportQP(const String filename, const String qpname) const;
153  String exportQPs(const String filename, const StringList qpnames) const;
155  void getRunIDs (std::vector<String>& ids) const;
157  void getRunNames (std::vector<String>& ids) const;
159  bool existsRun(const String filename, bool checkname = false) const;
161  bool existsSet(const String filename, bool checkname = false) const;
163  void existsRunQualityParameter(const String filename, const String qpname, std::vector<String>& ids) const;
165  void existsSetQualityParameter(const String filename, const String qpname, std::vector<String>& ids) const;
167  void store(const String & filename) const;
169  void load(const String & filename);
170 
171  //~ int siz; //debug
172 
173 protected:
174  // Docu in base class
175  void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname) override;
176 
177  // Docu in base class
178  void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes) override;
179 
180  // Docu in base class
181  void characters(const XMLCh * const chars, const XMLSize_t length) override;
182 
183  std::map<String, std::vector< QualityParameter > > runQualityQPs_; //TODO run name attribute to schema of RunQuality
184  std::map<String, std::vector< Attachment > > runQualityAts_;
185  std::map<String, std::vector< QualityParameter > > setQualityQPs_;
186  std::map<String, std::vector< Attachment > > setQualityAts_;
187  std::map<String, std::set< String > > setQualityQPs_members_;
188  std::map<String, String > run_Name_ID_map_;
189  std::map<String, String > set_Name_ID_map_;
190 
195  std::vector<String> row_;
196  std::vector<String> header_;
199  std::set<String> names_;
200  std::vector<QualityParameter> qps_;
201  std::vector<Attachment> ats_;
202 
203  };
204 
205 } // namespace OpenMS
206 
String value
Value.
Definition: QcMLFile.h:66
String unitRef
cv reference of the unit
Definition: QcMLFile.h:94
A more convenient string class.
Definition: String.h:57
String value
Value.
Definition: QcMLFile.h:91
std::map< String, std::vector< Attachment > > setQualityAts_
Definition: QcMLFile.h:186
QualityParameter qp_
Definition: QcMLFile.h:193
std::vector< std::vector< String > > tableRows
cell values if QP has a table, type see colType
Definition: QcMLFile.h:99
String id
Name.
Definition: QcMLFile.h:90
String id
Identifier.
Definition: QcMLFile.h:65
String unitRef
cv reference of the unit
Definition: QcMLFile.h:69
String cvAcc
cv accession
Definition: QcMLFile.h:68
std::map< String, std::vector< QualityParameter > > runQualityQPs_
Definition: QcMLFile.h:183
std::map< String, String > set_Name_ID_map_
Definition: QcMLFile.h:189
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
String cvAcc
cv accession
Definition: QcMLFile.h:93
Attachment at_
Definition: QcMLFile.h:194
Base class for XML handlers.
Definition: XMLHandler.h:148
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
std::vector< String > row_
Definition: QcMLFile.h:195
String name_
Definition: QcMLFile.h:197
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:95
std::vector< String > header_
Definition: QcMLFile.h:196
String name
Name.
Definition: QcMLFile.h:64
std::map< String, std::set< String > > setQualityQPs_members_
Definition: QcMLFile.h:187
Representation of an attachment.
Definition: QcMLFile.h:87
String flag
cv accession of the unit
Definition: QcMLFile.h:71
std::map< String, String > run_Name_ID_map_
Definition: QcMLFile.h:188
String tag_
Definition: QcMLFile.h:191
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:70
std::map< String, std::vector< QualityParameter > > setQualityQPs_
Definition: QcMLFile.h:185
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
File adapter for QcML files.
Definition: QcMLFile.h:55
String cvRef
cv reference
Definition: QcMLFile.h:92
std::set< String > names_
Definition: QcMLFile.h:199
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
Representation of a quality parameter.
Definition: QcMLFile.h:62
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:48
UInt progress_
Definition: QcMLFile.h:192
std::vector< String > colTypes
type of the cols if QP has a table of values
Definition: QcMLFile.h:98
String name
Name.
Definition: QcMLFile.h:89
String qualityRef
reference to qp to which attachment, if empty attached to run/set
Definition: QcMLFile.h:97
String run_id_
Definition: QcMLFile.h:198
String cvRef
cv reference
Definition: QcMLFile.h:67
std::map< String, std::vector< Attachment > > runQualityAts_
Definition: QcMLFile.h:184
std::vector< Attachment > ats_
Definition: QcMLFile.h:201
String binary
binary content of the attachment
Definition: QcMLFile.h:96
std::vector< QualityParameter > qps_
Definition: QcMLFile.h:200

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:07 using doxygen 1.8.14