| OpenMS 2.5.0

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