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

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:20 using doxygen 1.8.5