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(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(String r, QualityParameter qp);
135  void addRunAttachment(String r, Attachment at);
137  void addSetQualityParameter(String r, QualityParameter qp);
139  void addSetAttachment(String r, Attachment at);
141  void removeAttachment(String r, std::vector<String>& ids, String at = "");
143  void removeAttachment(String r, String at);
145  void removeAllAttachments(String at);
147  void removeQualityParameter(String r, std::vector<String>& ids);
149  void merge(const QcMLFile & addendum, 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
OpenMS::QcMLFile::QualityParameter::id
String id
Identifier.
Definition: QcMLFile.h:68
OpenMS::QcMLFile::setQualityQPs_
std::map< String, std::vector< QualityParameter > > setQualityQPs_
Definition: QcMLFile.h:212
OpenMS::QcMLFile::getRunNames
void getRunNames(std::vector< String > &ids) const
Gives the names of the registered runs in the vector ids.
ConsensusXMLFile.h
OpenMS::MzQCFile::store
void store(const String &input_file, const String &output_file, const MSExperiment &exp, const String &contact_name, const String &contact_address, const String &description, const String &label, const FeatureMap &feature_map, std::vector< ProteinIdentification > &prot_ids, std::vector< PeptideIdentification > &pep_ids) const
Stores QC data in mzQC file with JSON format.
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:147
OpenMS::QcMLFile::QualityParameter
Representation of a quality parameter.
Definition: QcMLFile.h:64
OpenMS::QcMLFile::tag_
String tag_
Definition: QcMLFile.h:218
FileHandler.h
OpenMS::QcMLFile::QualityParameter::flag
String flag
cv accession of the unit
Definition: QcMLFile.h:74
OpenMS::QcMLFile::QualityParameter::cvAcc
String cvAcc
cv accession
Definition: QcMLFile.h:71
XMLFile.h
Size
OpenMS::QcMLFile::registerSet
void registerSet(const String id, const String name, const std::set< String > &names)
Registers a set in the qcml file with the respective mappings.
OpenMS::QcMLFile::getRunIDs
void getRunIDs(std::vector< String > &ids) const
Gives the ids of the registered runs in the vector ids.
OpenMS::ControlledVocabulary
Representation of a controlled vocabulary.
Definition: ControlledVocabulary.h:54
OpenMS::QcMLFile::addRunQualityParameter
void addRunQualityParameter(String r, QualityParameter qp)
Just adds a qualityparameter to run by the name r.
OpenMS::QcMLFile::Attachment::name
String name
Name.
Definition: QcMLFile.h:93
OpenMS::Internal::XMLHandler
Base class for XML handlers.
Definition: XMLHandler.h:323
OpenMS::QcMLFile::Attachment::binary
String binary
binary content of the attachment
Definition: QcMLFile.h:100
ControlledVocabulary.h
OpenMS::MSExperiment::sortSpectra
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
OpenMS::QcMLFile::Attachment::qualityRef
String qualityRef
reference to qp to which attachment, if empty attached to run/set
Definition: QcMLFile.h:101
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:57
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::QcMLFile::QualityParameter::unitAcc
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:73
OpenMS::QcMLFile::run_Name_ID_map_
std::map< String, String > run_Name_ID_map_
Definition: QcMLFile.h:215
MzMLFile.h
ConsensusMap.h
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
IdXMLFile.h
FeatureXMLFile.h
OpenMS::QcMLFile::ats_
std::vector< Attachment > ats_
Definition: QcMLFile.h:228
StatisticFunctions.h
OpenMS::QcMLFile::Attachment::unitAcc
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:99
XMLHandler.h
OpenMS::operator<
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
OpenMS::QcMLFile::names_
std::set< String > names_
Definition: QcMLFile.h:226
OpenMS::QcMLFile::load
void load(const String &filename)
Load a QCFile.
OpenMS::QcMLFile::qp_
QualityParameter qp_
Definition: QcMLFile.h:220
OpenMS::FileTypes::QCML
qcML (will undergo standardisation maybe) (.qcml)
Definition: FileTypes.h:77
OpenMS::QcMLFile::store
void store(const String &filename) const
Store the QCFile.
OpenMS::IdXMLFile::load
void load(const String &filename, std::vector< ProteinIdentification > &protein_ids, std::vector< PeptideIdentification > &peptide_ids)
Loads the identifications of an idXML file without identifier.
OpenMS::File::find
static String find(const String &filename, StringList directories=StringList())
Looks up the location of the file filename.
OpenMS::ListUtils::concatenate
static String concatenate(const std::vector< T > &container, const String &glue="")
Concatenates all elements of the container and puts the glue string between elements.
Definition: ListUtils.h:209
OpenMS::ControlledVocabulary::loadFromOBO
void loadFromOBO(const String &name, const String &filename)
Loads the CV from an OBO file.
OpenMS::ControlledVocabulary::CVTerm::id
String id
Identifier.
Definition: ControlledVocabulary.h:83
OpenMS::QcMLFile::runQualityAts_
std::map< String, std::vector< Attachment > > runQualityAts_
Definition: QcMLFile.h:211
OpenMS::ControlledVocabulary::CVTerm::name
String name
if it is a score type, lookup has_order
Definition: ControlledVocabulary.h:82
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::FeatureMap::updateRanges
void updateRanges() override
UniqueIdGenerator.h
OpenMS::QcMLFile::qps_
std::vector< QualityParameter > qps_
Definition: QcMLFile.h:227
OpenMS::QcMLFile::at_
Attachment at_
Definition: QcMLFile.h:221
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
OpenMS::QcMLFile::QualityParameter::value
String value
Value.
Definition: QcMLFile.h:69
ProgressLogger.h
OpenMS::QcMLFile::addSetQualityParameter
void addSetQualityParameter(String r, QualityParameter qp)
Just adds a qualityparameter to set by the name r.
OpenMS::QcMLFile::run_id_
String run_id_
Definition: QcMLFile.h:225
OpenMS::MzMLFile::load
void load(const String &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
MzQCFile.h
OpenMS::QcMLFile::Attachment::unitRef
String unitRef
cv reference of the unit
Definition: QcMLFile.h:98
OpenMS::QcMLFile::exportIDstats
String exportIDstats(const String &filename) const
OpenMS::QcMLFile::exportQPs
String exportQPs(const String filename, const StringList qpnames) const
Returns a String of a tab separated qualityparameter by the name qpname in run/set by the name filena...
OpenMS::FeatureXMLFile::load
void load(const String &filename, FeatureMap &feature_map)
loads the file with name filename into map and calls updateRanges().
FeatureMap.h
OpenMS::FileTypes::Type
Type
Actual file types enum.
Definition: FileTypes.h:56
OpenMS::QcMLFile::addRunAttachment
void addRunAttachment(String r, Attachment at)
Just adds a attachment to run by the name r.
MathFunctions.h
OpenMS::FileTypes::MZQC
mzQC (HUPO PSI format) (.mzQC)
Definition: FileTypes.h:78
OpenMS::QcMLFile::Attachment::colTypes
std::vector< String > colTypes
type of the cols if QP has a table of values
Definition: QcMLFile.h:102
QcMLFile.h
OpenMS::FileHandler::getConsistentOutputfileType
static FileTypes::Type getConsistentOutputfileType(const String &output_filename, const String &requested_type)
Useful function for TOPP tools which have an 'out_type' parameter and want to know what output format...
OpenMS::QcMLFile::name_
String name_
Definition: QcMLFile.h:224
OpenMS::QcMLFile::progress_
UInt progress_
Definition: QcMLFile.h:219
OpenMS::QcMLFile::setQualityQPs_members_
std::map< String, std::set< String > > setQualityQPs_members_
Definition: QcMLFile.h:214
OpenMS::QcMLFile::setQualityAts_
std::map< String, std::vector< Attachment > > setQualityAts_
Definition: QcMLFile.h:213
OpenMS::ControlledVocabulary::getTerm
const CVTerm & getTerm(const String &id) const
Returns a term specified by ID.
CsvFile.h
OpenMS::UniqueIdGenerator::getUniqueId
static UInt64 getUniqueId()
Returns a new unique id.
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:82
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::QcMLFile::existsRunQualityParameter
void existsRunQualityParameter(const String filename, const String qpname, std::vector< String > &ids) const
Returns the ids of the parameter name given if found in given run empty else.
OpenMS::ConsensusXMLFile::load
void load(const String &filename, ConsensusMap &map)
Loads a consensus map from file and calls updateRanges.
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::QcMLFile::Attachment::value
String value
Value.
Definition: QcMLFile.h:95
OpenMS::QcMLFile::exportAttachment
String exportAttachment(const String filename, const String qpname) const
Returns a String of a tab separated rows if found empty string else from run/set by the name filename...
OpenMS::QcMLFile::QualityParameter::name
String name
Name.
Definition: QcMLFile.h:67
OpenMS::CsvFile
This class handles csv files. Currently only loading is implemented.
Definition: CsvFile.h:49
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
MSExperiment.h
OpenMS::QcMLFile::set_Name_ID_map_
std::map< String, String > set_Name_ID_map_
Definition: QcMLFile.h:216
OpenMS::QcMLFile::Attachment::cvRef
String cvRef
cv reference
Definition: QcMLFile.h:96
OpenMS::MzQCFile
File adapter for mzQC files used to load and store mzQC files.
Definition: MzQCFile.h:51
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:98
OpenMS::QcMLFile
File adapter for QcML files used to load and store QcML files.
Definition: QcMLFile.h:57
OpenMS::ControlledVocabulary::CVTerm
Representation of a CV term.
Definition: ControlledVocabulary.h:60
OpenMS::Internal::operator==
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::QcMLFile::addSetAttachment
void addSetAttachment(String r, Attachment at)
Just adds a attachment to set by the name r.
OpenMS::QcMLFile::Attachment
Representation of an attachment.
Definition: QcMLFile.h:90
OpenMS::FeatureMap::sortByRT
void sortByRT()
Sort features by RT position.
OpenMS::QcMLFile::QualityParameter::unitRef
String unitRef
cv reference of the unit
Definition: QcMLFile.h:72
OpenMS::FeatureXMLFile
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:62
OpenMS::QcMLFile::QualityParameter::cvRef
String cvRef
cv reference
Definition: QcMLFile.h:70
OpenMS::Internal::XMLFile
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:48
OpenMS::QcMLFile::registerRun
void registerRun(const String id, const String name)
Registers a run in the qcml file with the respective mappings.
String.h
OpenMS::MSExperiment::updateRanges
void updateRanges() override
OpenMS::QcMLFile::existsRun
bool existsRun(const 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...
OpenMS::QcMLFile::Attachment::id
String id
Name.
Definition: QcMLFile.h:94
OpenMS::QcMLFile::merge
void merge(const QcMLFile &addendum, String setname="")
merges the given QCFile into this one
OpenMS::QcMLFile::runQualityQPs_
std::map< String, std::vector< QualityParameter > > runQualityQPs_
Definition: QcMLFile.h:210
OpenMS::QcMLFile::existsSetQualityParameter
void existsSetQualityParameter(const String filename, const String qpname, std::vector< String > &ids) const
Returns the ids of the parameter name given if found in given set, empty else.
OpenMS::QcMLFile::header_
std::vector< String > header_
Definition: QcMLFile.h:223
StandardTypes.h
File.h
OpenMS::QcMLFile::row_
std::vector< String > row_
Definition: QcMLFile.h:222
OpenMS::ControlledVocabulary::getTermByName
const CVTerm & getTermByName(const String &name, const String &desc="") const
Returns a term specified by name.
OpenMS::QcMLFile::collectQCData
void collectQCData(std::vector< ProteinIdentification > &prot_ids, std::vector< PeptideIdentification > &pep_ids, const FeatureMap &feature_map, const ConsensusMap &consensus_map, const String &inputfile_raw, const bool remove_duplicate_features, const MSExperiment &exp)
Calculation and collection of QC data.
OpenMS::QcMLFile::Attachment::tableRows
std::vector< std::vector< String > > tableRows
cell values if QP has a table, type see colType
Definition: QcMLFile.h:103
TOPPBase.h
OpenMS::QcMLFile::existsSet
bool existsSet(const 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...
OpenMS::ConsensusXMLFile
This class provides Input functionality for ConsensusMaps and Output functionality for alignments and...
Definition: ConsensusXMLFile.h:58
OpenMS::IdXMLFile
Used to load and store idXML files.
Definition: IdXMLFile.h:68
OpenMS::ControlledVocabulary::exists
bool exists(const String &id) const
Returns true if the term is in the CV. Returns false otherwise.
OpenMS::QcMLFile::Attachment::cvAcc
String cvAcc
cv accession
Definition: QcMLFile.h:97