OpenMS
Loading...
Searching...
No Matches
QcMLFile.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Mathias Walzer, Axel Walter $
6// $Authors: Mathias Walzer $
7// --------------------------------------------------------------------------
8
9#pragma once
10
16#include <vector>
17
18namespace OpenMS
19{
20 class ConsensusMap;
21 class FeatureMap;
22
32 class OPENMS_DLLAPI QcMLFile :
34 public Internal::XMLFile,
35 public ProgressLogger
36 {
37public:
39 class OPENMS_DLLAPI QualityParameter
40 {
41 public:
42 std::string name;
43 std::string id;
44 std::string value;
45 std::string cvRef;
46 std::string cvAcc;
47 std::string unitRef;
48 std::string unitAcc;
49 std::string flag;
50
53
55
57 bool operator==(const QualityParameter& rhs) const;
58 bool operator<(const QualityParameter& rhs) const;
59 bool operator>(const QualityParameter& rhs) const;
60
61 std::string toXMLString(UInt indentation_level) const;
62 };
63
65 class OPENMS_DLLAPI Attachment
66 {
67 public:
68 std::string name;
69 std::string id;
70 std::string value;
71 std::string cvRef;
72 std::string cvAcc;
73 std::string unitRef;
74 std::string unitAcc;
75 std::string binary;
76 std::string qualityRef;
77 std::vector<std::string> colTypes;
78 std::vector< std::vector<std::string> > tableRows;
79 //~ TODO -schema- coltypes with full definition (uintRef, unitAcc)
80
83
85
87 bool operator==(const Attachment& rhs) const;
88 bool operator<(const Attachment& rhs) const;
89 bool operator>(const Attachment& rhs) const;
90
91 std::string toXMLString(UInt indentation_level) const;
92 std::string toCSVString(const std::string& separator) const;
93 };
94
98 ~QcMLFile() override;
99
100 std::string map2csv(const std::map< std::string, std::map<std::string, std::string> >& cvs_table, const std::string& separator) const;
101 std::string exportIDstats(const std::string& filename) const;
102
104 void registerRun(const std::string& id, const std::string& name);
106 void registerSet(const std::string& id, const std::string& name, const std::set<std::string>& names);
108 void addRunQualityParameter(const std::string& r, const QualityParameter& qp);
110 void addRunAttachment(const std::string& r, const Attachment& at);
112 void addSetQualityParameter(const std::string& r, const QualityParameter& qp);
114 void addSetAttachment(const std::string& r, const Attachment& at);
116 void removeAttachment(const std::string& r, std::vector<std::string>& ids, const std::string& at = "");
118 void removeAttachment(const std::string& r, const std::string& at);
120 void removeAllAttachments(const std::string& at);
122 void removeQualityParameter(const std::string& r, std::vector<std::string>& ids);
124 void merge(const QcMLFile & addendum, const std::string& setname = "");
126 void/* std::vector<std::string>& */ collectSetParameter(const std::string& setname, const std::string& qp, std::vector<std::string>& ret);
128 std::string exportAttachment(const std::string& filename, const std::string& qpname) const;
130 std::string exportQP(const std::string& filename, const std::string& qpname) const;
132 std::string exportQPs(const std::string& filename, const StringList& qpnames) const;
134 void getRunIDs (std::vector<std::string>& ids) const;
136 void getRunNames (std::vector<std::string>& ids) const;
138 bool existsRun(const std::string& filename, bool checkname = false) const;
140 bool existsSet(const std::string& filename, bool checkname = false) const;
142 void existsRunQualityParameter(const std::string& filename, const std::string& qpname, std::vector<std::string>& ids) const;
144 void existsSetQualityParameter(const std::string& filename, const std::string& qpname, std::vector<std::string>& ids) const;
146
156 void collectQCData(std::vector<ProteinIdentification>& prot_ids,
158 const FeatureMap& feature_map,
159 const ConsensusMap& consensus_map,
160 const std::string& inputfile_raw,
161 const bool remove_duplicate_features,
162 const MSExperiment& exp);
164
168 void store(const std::string& filename) const;
169
171 void load(const std::string & filename);
172
173 //~ int siz; //debug
174
175protected:
176 // Docu in base class
177 void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname) override;
178
179 // Docu in base class
180 void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes) override;
181
182 // Docu in base class
183 void characters(const XMLCh * const chars, const XMLSize_t length) override;
184
185 std::map<std::string, std::vector< QualityParameter > > runQualityQPs_; //TODO run name attribute to schema of RunQuality
186 std::map<std::string, std::vector< Attachment > > runQualityAts_;
187 std::map<std::string, std::vector< QualityParameter > > setQualityQPs_;
188 std::map<std::string, std::vector< Attachment > > setQualityAts_;
189 std::map<std::string, std::set< std::string > > setQualityQPs_members_;
190 std::map<std::string, std::string > run_Name_ID_map_;
191 std::map<std::string, std::string > set_Name_ID_map_;
192
193 std::string tag_;
197 std::vector<std::string> row_;
198 std::vector<std::string> header_;
199 std::string name_;
200 std::string run_id_;
201 std::set<std::string> names_;
202 std::vector<QualityParameter> qps_;
203 std::vector<Attachment> ats_;
204 };
205
206} // namespace OpenMS
char16_t XMLCh
Definition ClassTest.h:30
A container for consensus elements.
Definition ConsensusMap.h:67
A container for features.
Definition FeatureMap.h:78
Base class for loading and storing XML files via Xerces, with optional schema validation and transpar...
Definition XMLFile.h:38
Base class for XML handlers.
Definition XMLHandler.h:316
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
Representation of an attachment.
Definition QcMLFile.h:66
Attachment & operator=(const Attachment &rhs)
Attachment(const Attachment &rhs)
std::string toCSVString(const std::string &separator) const
std::string cvRef
cv reference
Definition QcMLFile.h:71
std::string value
Value.
Definition QcMLFile.h:70
std::string qualityRef
reference to qp to which attachment, if empty attached to run/set
Definition QcMLFile.h:76
std::vector< std::vector< std::string > > tableRows
cell values if QP has a table, type see colType
Definition QcMLFile.h:78
std::string toXMLString(UInt indentation_level) const
std::string cvAcc
cv accession
Definition QcMLFile.h:72
bool operator==(const Attachment &rhs) const
bool operator<(const Attachment &rhs) const
std::string name
Name.
Definition QcMLFile.h:68
Attachment()
Default constructor.
std::string binary
binary content of the attachment
Definition QcMLFile.h:75
std::vector< std::string > colTypes
type of the cols if QP has a table of values
Definition QcMLFile.h:77
std::string unitAcc
cv accession of the unit
Definition QcMLFile.h:74
std::string unitRef
cv reference of the unit
Definition QcMLFile.h:73
bool operator>(const Attachment &rhs) const
std::string id
Name.
Definition QcMLFile.h:69
Representation of a quality parameter.
Definition QcMLFile.h:40
bool operator<(const QualityParameter &rhs) const
QualityParameter(const QualityParameter &rhs)
QualityParameter()
Default constructor.
bool operator>(const QualityParameter &rhs) const
bool operator==(const QualityParameter &rhs) const
std::string cvRef
cv reference
Definition QcMLFile.h:45
std::string value
Value.
Definition QcMLFile.h:44
QualityParameter & operator=(const QualityParameter &rhs)
std::string toXMLString(UInt indentation_level) const
std::string cvAcc
cv accession
Definition QcMLFile.h:46
std::string flag
cv accession of the unit
Definition QcMLFile.h:49
std::string name
Name.
Definition QcMLFile.h:42
std::string unitAcc
cv accession of the unit
Definition QcMLFile.h:48
std::string unitRef
cv reference of the unit
Definition QcMLFile.h:47
std::string id
Identifier.
Definition QcMLFile.h:43
File adapter for QcML files used to load and store QcML files.
Definition QcMLFile.h:36
void collectQCData(std::vector< ProteinIdentification > &prot_ids, PeptideIdentificationList &pep_ids, const FeatureMap &feature_map, const ConsensusMap &consensus_map, const std::string &inputfile_raw, const bool remove_duplicate_features, const MSExperiment &exp)
Calculation and collection of QC data.
void existsSetQualityParameter(const std::string &filename, const std::string &qpname, std::vector< std::string > &ids) const
Returns the ids of the parameter name given if found in given set, empty else.
void store(const std::string &filename) const
Store the QCFile.
std::vector< std::string > header_
Definition QcMLFile.h:198
std::vector< Attachment > ats_
Definition QcMLFile.h:203
void removeAllAttachments(const std::string &at)
Removes attachment with cv accession at from all runs/sets.
std::string exportQPs(const std::string &filename, const StringList &qpnames) const
Returns a std::string of a tab separated qualityparameter by the name qpname in run/set by the name f...
void collectSetParameter(const std::string &setname, const std::string &qp, std::vector< std::string > &ret)
collects the values of given QPs (as CVid) of the given set
void addSetQualityParameter(const std::string &r, const QualityParameter &qp)
Just adds a qualityparameter to set by the name r.
void merge(const QcMLFile &addendum, const std::string &setname="")
merges the given QCFile into this one
bool existsSet(const std::string &filename, bool checkname=false) const
Returns true if the given set id is present in this file, if checkname is true it also checks the nam...
~QcMLFile() override
Destructor.
std::set< std::string > names_
Definition QcMLFile.h:201
std::map< std::string, std::string > set_Name_ID_map_
Definition QcMLFile.h:191
std::string exportAttachment(const std::string &filename, const std::string &qpname) const
Returns a std::string of a tab separated rows if found empty string else from run/set by the name fil...
std::string name_
Definition QcMLFile.h:199
void getRunIDs(std::vector< std::string > &ids) const
Gives the ids of the registered runs in the vector ids.
void registerRun(const std::string &id, const std::string &name)
Registers a run in the qcml file with the respective mappings.
Attachment at_
Definition QcMLFile.h:196
QualityParameter qp_
Definition QcMLFile.h:195
bool existsRun(const std::string &filename, bool checkname=false) const
Returns true if the given run id is present in this file, if checkname is true it also checks the nam...
void load(const std::string &filename)
Load a QCFile.
std::map< std::string, std::string > run_Name_ID_map_
Definition QcMLFile.h:190
void removeAttachment(const std::string &r, const std::string &at)
Removes attachment with cv accession at from run/set r.
void addRunAttachment(const std::string &r, const Attachment &at)
Just adds a attachment to run by the name r.
UInt progress_
Definition QcMLFile.h:194
std::map< std::string, std::vector< Attachment > > setQualityAts_
Definition QcMLFile.h:188
void addRunQualityParameter(const std::string &r, const QualityParameter &qp)
Just adds a qualityparameter to run by the name r.
std::string tag_
Definition QcMLFile.h:193
std::map< std::string, std::vector< QualityParameter > > runQualityQPs_
Definition QcMLFile.h:185
void registerSet(const std::string &id, const std::string &name, const std::set< std::string > &names)
Registers a set in the qcml file with the respective mappings.
std::string exportIDstats(const std::string &filename) const
std::vector< QualityParameter > qps_
Definition QcMLFile.h:202
void startElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname, const xercesc::Attributes &attributes) override
void existsRunQualityParameter(const std::string &filename, const std::string &qpname, std::vector< std::string > &ids) const
Returns the ids of the parameter name given if found in given run empty else.
QcMLFile()
Default constructor.
void getRunNames(std::vector< std::string > &ids) const
Gives the names of the registered runs in the vector ids.
std::vector< std::string > row_
Definition QcMLFile.h:197
void removeQualityParameter(const std::string &r, std::vector< std::string > &ids)
Just removes qualityparameter going by one of the ID attributes given in ids.
std::string exportQP(const std::string &filename, const std::string &qpname) const
Returns a std::string value in quotation of a qualityparameter by the name qpname in run/set by the n...
std::map< std::string, std::vector< QualityParameter > > setQualityQPs_
Definition QcMLFile.h:187
std::string run_id_
Definition QcMLFile.h:200
std::map< std::string, std::set< std::string > > setQualityQPs_members_
Definition QcMLFile.h:189
void removeAttachment(const std::string &r, std::vector< std::string > &ids, const std::string &at="")
Removes attachments referencing a id given in ids, from run/set r. All attachments if no attachment n...
void characters(const XMLCh *const chars, const XMLSize_t length) override
void endElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname) override
std::string map2csv(const std::map< std::string, std::map< std::string, std::string > > &cvs_table, const std::string &separator) const
std::map< std::string, std::vector< Attachment > > runQualityAts_
Definition QcMLFile.h:186
void addSetAttachment(const std::string &r, const Attachment &at)
Just adds a attachment to set by the name r.
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
std::vector< std::string > StringList
Vector of String.
Definition ListUtils.h:44
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19