OpenMS  3.0.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-2022.
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, Axel Walter $
32 // $Authors: Mathias Walzer $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 #include <OpenMS/FORMAT/XMLFile.h>
41 #include <vector>
42 
43 namespace OpenMS
44 {
45  class ConsensusMap;
46  class FeatureMap;
47 
57  class OPENMS_DLLAPI QcMLFile :
58  public Internal::XMLHandler,
59  public Internal::XMLFile,
60  public ProgressLogger
61  {
62 public:
64  class OPENMS_DLLAPI QualityParameter
65  {
66  public:
75 
78 
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  class OPENMS_DLLAPI Attachment
91  {
92  public:
102  std::vector<String> colTypes;
103  std::vector< std::vector<String> > tableRows;
104  //~ TODO -schema- coltypes with full definition (uintRef, unitAcc)
105 
107  Attachment();
108 
109  Attachment(const Attachment& rhs);
110 
111  Attachment& operator=(const Attachment& rhs);
112  bool operator==(const Attachment& rhs) const;
113  bool operator<(const Attachment& rhs) const;
114  bool operator>(const Attachment& rhs) const;
115 
116  String toXMLString(UInt indentation_level) const;
117  String toCSVString(const String& separator) const;
118  };
119 
121  QcMLFile();
123  ~QcMLFile() override;
124 
125  String map2csv(const std::map< String, std::map<String, String> >& cvs_table, const String& separator) const;
126  String exportIDstats(const String& filename) const;
127 
129  void registerRun(const String& id, const String& name);
131  void registerSet(const String& id, const String& name, const std::set<String>& names);
133  void addRunQualityParameter(const String& r, const QualityParameter& qp);
135  void addRunAttachment(const String& r, const Attachment& at);
137  void addSetQualityParameter(const String& r, const QualityParameter& qp);
139  void addSetAttachment(const String& r, const Attachment& at);
141  void removeAttachment(const String& r, std::vector<String>& ids, const String& at = "");
143  void removeAttachment(const String& r, const String& at);
145  void removeAllAttachments(const String& at);
147  void removeQualityParameter(const String& r, std::vector<String>& ids);
149  void merge(const QcMLFile & addendum, const String& setname = "");
151  void/* std::vector<String>& */ collectSetParameter(const String& setname, const String& qp, std::vector<String>& ret);
153  String exportAttachment(const String& filename, const String& qpname) const;
155  String exportQP(const String& filename, const String& qpname) const;
157  String exportQPs(const String& filename, const StringList& qpnames) const;
159  void getRunIDs (std::vector<String>& ids) const;
161  void getRunNames (std::vector<String>& ids) const;
163  bool existsRun(const String& filename, bool checkname = false) const;
165  bool existsSet(const String& filename, bool checkname = false) const;
167  void existsRunQualityParameter(const String& filename, const String& qpname, std::vector<String>& ids) const;
169  void existsSetQualityParameter(const String& filename, const String& qpname, std::vector<String>& ids) const;
171 
181  void collectQCData(std::vector<ProteinIdentification>& prot_ids,
182  std::vector<PeptideIdentification>& pep_ids,
183  const FeatureMap& feature_map,
184  const ConsensusMap& consensus_map,
185  const String& inputfile_raw,
186  const bool remove_duplicate_features,
187  const MSExperiment& exp);
189 
193  void store(const String& filename) const;
194 
196  void load(const String & filename);
197 
198  //~ int siz; //debug
199 
200 protected:
201  // Docu in base class
202  void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname) override;
203 
204  // Docu in base class
205  void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes) override;
206 
207  // Docu in base class
208  void characters(const XMLCh * const chars, const XMLSize_t length) override;
209 
210  std::map<String, std::vector< QualityParameter > > runQualityQPs_; //TODO run name attribute to schema of RunQuality
211  std::map<String, std::vector< Attachment > > runQualityAts_;
212  std::map<String, std::vector< QualityParameter > > setQualityQPs_;
213  std::map<String, std::vector< Attachment > > setQualityAts_;
214  std::map<String, std::set< String > > setQualityQPs_members_;
215  std::map<String, String > run_Name_ID_map_;
216  std::map<String, String > set_Name_ID_map_;
217 
222  std::vector<String> row_;
223  std::vector<String> header_;
226  std::set<String> names_;
227  std::vector<QualityParameter> qps_;
228  std::vector<Attachment> ats_;
229  };
230 
231 } // namespace OpenMS
Representation of an attachment.
Definition: QcMLFile.h:90
A more convenient string class.
Definition: String.h:58
std::map< String, std::vector< Attachment > > setQualityAts_
Definition: QcMLFile.h:213
QualityParameter qp_
Definition: QcMLFile.h:220
std::map< String, std::vector< QualityParameter > > runQualityQPs_
Definition: QcMLFile.h:210
std::map< String, String > set_Name_ID_map_
Definition: QcMLFile.h:216
A container for features.
Definition: FeatureMap.h:98
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
String id
Name.
Definition: QcMLFile.h:94
String name
Name.
Definition: QcMLFile.h:67
Attachment at_
Definition: QcMLFile.h:221
A container for consensus elements.
Definition: ConsensusMap.h:82
Base class for XML handlers.
Definition: XMLHandler.h:324
std::vector< String > colTypes
type of the cols if QP has a table of values
Definition: QcMLFile.h:102
std::vector< String > row_
Definition: QcMLFile.h:222
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
String cvRef
cv reference
Definition: QcMLFile.h:70
String name_
Definition: QcMLFile.h:224
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
String unitRef
cv reference of the unit
Definition: QcMLFile.h:72
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
String cvAcc
cv accession
Definition: QcMLFile.h:97
std::vector< String > header_
Definition: QcMLFile.h:223
std::map< String, std::set< String > > setQualityQPs_members_
Definition: QcMLFile.h:214
String binary
binary content of the attachment
Definition: QcMLFile.h:100
std::map< String, String > run_Name_ID_map_
Definition: QcMLFile.h:215
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:99
String tag_
Definition: QcMLFile.h:218
std::map< String, std::vector< QualityParameter > > setQualityQPs_
Definition: QcMLFile.h:212
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
String id
Identifier.
Definition: QcMLFile.h:68
File adapter for QcML files used to load and store QcML files.
Definition: QcMLFile.h:57
Representation of a quality parameter.
Definition: QcMLFile.h:64
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
String value
Value.
Definition: QcMLFile.h:95
String flag
cv accession of the unit
Definition: QcMLFile.h:74
std::set< String > names_
Definition: QcMLFile.h:226
String unitRef
cv reference of the unit
Definition: QcMLFile.h:98
String cvAcc
cv accession
Definition: QcMLFile.h:71
String qualityRef
reference to qp to which attachment, if empty attached to run/set
Definition: QcMLFile.h:101
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:73
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:48
UInt progress_
Definition: QcMLFile.h:219
String cvRef
cv reference
Definition: QcMLFile.h:96
String run_id_
Definition: QcMLFile.h:225
std::vector< std::vector< String > > tableRows
cell values if QP has a table, type see colType
Definition: QcMLFile.h:103
std::map< String, std::vector< Attachment > > runQualityAts_
Definition: QcMLFile.h:211
std::vector< Attachment > ats_
Definition: QcMLFile.h:228
String name
Name.
Definition: QcMLFile.h:93
String value
Value.
Definition: QcMLFile.h:69
std::vector< QualityParameter > qps_
Definition: QcMLFile.h:227