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 #ifndef OPENMS_FORMAT_QCMLFILE_H
36 #define OPENMS_FORMAT_QCMLFILE_H
37 
40 #include <OpenMS/FORMAT/XMLFile.h>
41 
42 #include <vector>
43 #include <map>
44 #include <set>
45 #include <algorithm>
46 
47 namespace OpenMS
48 {
56  class OPENMS_DLLAPI QcMLFile :
57  public Internal::XMLHandler,
58  public Internal::XMLFile,
59  public ProgressLogger
60  {
61 public:
63  struct OPENMS_DLLAPI QualityParameter
64  {
73 
76 
78 
79  QualityParameter& operator=(const QualityParameter& rhs);
80  bool operator==(const QualityParameter& rhs) const;
81  bool operator<(const QualityParameter& rhs) const;
82  bool operator>(const QualityParameter& rhs) const;
83 
84  String toXMLString(UInt indentation_level) const;
85  };
86 
88  struct OPENMS_DLLAPI Attachment
89  {
99  std::vector<String> colTypes;
100  std::vector< std::vector<String> > tableRows;
101  //~ TODO -schema- coltypes with full definition (uintRef, unitAcc)
102 
104  Attachment();
105 
106  Attachment(const Attachment& rhs);
107 
108  Attachment& operator=(const Attachment& rhs);
109  bool operator==(const Attachment& rhs) const;
110  bool operator<(const Attachment& rhs) const;
111  bool operator>(const Attachment& rhs) const;
112 
113  String toXMLString(UInt indentation_level) const;
114  String toCSVString(String separator) const;
115  };
116 
118  QcMLFile();
120  ~QcMLFile();
121 
122  String map2csv(const std::map< String, std::map<String, String> >& cvs_table, const String& separator) const;
123  String exportIDstats(const String& filename) const;
124 
126  void registerRun(const String id, const String name);
128  void registerSet(const String id, const String name, const std::set<String>& names);
130  void addRunQualityParameter(String r, QualityParameter qp);
132  void addRunAttachment(String r, Attachment at);
134  void addSetQualityParameter(String r, QualityParameter qp);
136  void addSetAttachment(String r, Attachment at);
138  void removeAttachment(String r, std::vector<String>& ids, String at = "");
140  void removeAttachment(String r, String at);
142  void removeAllAttachments(String at);
144  void removeQualityParameter(String r, std::vector<String>& ids);
146  void merge(const QcMLFile & addendum, String setname = "");
148  void/* std::vector<String>& */ collectSetParameter(const String setname, const String qp, std::vector<String>& ret);
150  String exportAttachment(const String filename, const String qpname) const;
152  String exportQP(const String filename, const String qpname) const;
154  String exportQPs(const String filename, const StringList qpnames) const;
156  void getRunIDs (std::vector<String>& ids) const;
158  void getRunNames (std::vector<String>& ids) const;
160  bool existsRun(const String filename, bool checkname = false) const;
162  bool existsSet(const String filename, bool checkname = false) const;
164  void existsRunQualityParameter(const String filename, const String qpname, std::vector<String>& ids) const;
166  void existsSetQualityParameter(const String filename, const String qpname, std::vector<String>& ids) const;
168  void store(const String & filename) const;
170  void load(const String & filename);
171 
172  //~ int siz; //debug
173 
174 protected:
175  // Docu in base class
176  virtual void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname);
177 
178  // Docu in base class
179  virtual void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes);
180 
181  // Docu in base class
182  virtual void characters(const XMLCh * const chars, const XMLSize_t length);
183 
184  std::map<String, std::vector< QualityParameter > > runQualityQPs_; //TODO run name attribute to schema of RunQuality
185  std::map<String, std::vector< Attachment > > runQualityAts_;
186  std::map<String, std::vector< QualityParameter > > setQualityQPs_;
187  std::map<String, std::vector< Attachment > > setQualityAts_;
188  std::map<String, std::set< String > > setQualityQPs_members_;
189  std::map<String, String > run_Name_ID_map_;
190  std::map<String, String > set_Name_ID_map_;
191 
196  std::vector<String> row_;
197  std::vector<String> header_;
200  std::set<String> names_;
201  std::vector<QualityParameter> qps_;
202  std::vector<Attachment> ats_;
203 
204  };
205 
206 } // namespace OpenMS
207 
208 #endif // OPENMS_FORMAT_QCMLFILE_H
String value
Value.
Definition: QcMLFile.h:67
String unitRef
cv reference of the unit
Definition: QcMLFile.h:95
A more convenient string class.
Definition: String.h:57
String value
Value.
Definition: QcMLFile.h:92
std::map< String, std::vector< Attachment > > setQualityAts_
Definition: QcMLFile.h:187
QualityParameter qp_
Definition: QcMLFile.h:194
std::vector< std::vector< String > > tableRows
cell values if QP has a table, type see colType
Definition: QcMLFile.h:100
String id
Name.
Definition: QcMLFile.h:91
String id
Identifier.
Definition: QcMLFile.h:66
String unitRef
cv reference of the unit
Definition: QcMLFile.h:70
String cvAcc
cv accession
Definition: QcMLFile.h:69
std::map< String, std::vector< QualityParameter > > runQualityQPs_
Definition: QcMLFile.h:184
std::map< String, String > set_Name_ID_map_
Definition: QcMLFile.h:190
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
String cvAcc
cv accession
Definition: QcMLFile.h:94
Attachment at_
Definition: QcMLFile.h:195
Base class for XML handlers.
Definition: XMLHandler.h:110
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
std::vector< String > row_
Definition: QcMLFile.h:196
String name_
Definition: QcMLFile.h:198
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:96
std::vector< String > header_
Definition: QcMLFile.h:197
String name
Name.
Definition: QcMLFile.h:65
std::map< String, std::set< String > > setQualityQPs_members_
Definition: QcMLFile.h:188
Representation of an attachment.
Definition: QcMLFile.h:88
String flag
cv accession of the unit
Definition: QcMLFile.h:72
std::map< String, String > run_Name_ID_map_
Definition: QcMLFile.h:189
String tag_
Definition: QcMLFile.h:192
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:71
std::map< String, std::vector< QualityParameter > > setQualityQPs_
Definition: QcMLFile.h:186
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:74
File adapter for QcML files.
Definition: QcMLFile.h:56
String cvRef
cv reference
Definition: QcMLFile.h:93
std::set< String > names_
Definition: QcMLFile.h:200
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
Representation of a quality parameter.
Definition: QcMLFile.h:63
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:49
UInt progress_
Definition: QcMLFile.h:193
std::vector< String > colTypes
type of the cols if QP has a table of values
Definition: QcMLFile.h:99
String name
Name.
Definition: QcMLFile.h:90
String qualityRef
reference to qp to which attachment, if empty attached to run/set
Definition: QcMLFile.h:98
String run_id_
Definition: QcMLFile.h:199
String cvRef
cv reference
Definition: QcMLFile.h:68
std::map< String, std::vector< Attachment > > runQualityAts_
Definition: QcMLFile.h:185
std::vector< Attachment > ats_
Definition: QcMLFile.h:202
String binary
binary content of the attachment
Definition: QcMLFile.h:97
std::vector< QualityParameter > qps_
Definition: QcMLFile.h:201

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13