OpenMS  2.6.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 
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  {
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  struct OPENMS_DLLAPI Attachment
91  {
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 
198  std::vector<String> row_;
199  std::vector<String> header_;
202  std::set<String> names_;
203  std::vector<QualityParameter> qps_;
204  std::vector<Attachment> ats_;
205 
206  };
207 
208 } // namespace OpenMS
209 
OpenMS::QcMLFile::setQualityQPs_
std::map< String, std::vector< QualityParameter > > setQualityQPs_
Definition: QcMLFile.h:188
OpenMS::QcMLFile::getRunNames
void getRunNames(std::vector< String > &ids) const
Gives the names of the registered runs in the vector ids.
OpenMS::PeptideHit::getCharge
Int getCharge() const
returns the charge of the peptide
ConsensusXMLFile.h
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:144
OpenMS::Residue::getModificationName
const String & getModificationName() const
returns the name (ID) of the modification, or an empty string if none is set
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::tag_
String tag_
Definition: QcMLFile.h:194
OpenMS::AASequence::ConstIterator
ConstIterator for AASequence.
Definition: AASequence.h:121
OpenMS::QcMLFile::Attachment::cvRef
String cvRef
cv reference
Definition: QcMLFile.h:95
XMLFile.h
OpenMS::Math::sum
static double sum(IteratorType begin, IteratorType end)
Calculates the sum of a range of values.
Definition: StatisticFunctions.h:120
OpenMS::QcMLFile::Attachment::unitRef
String unitRef
cv reference of the unit
Definition: QcMLFile.h:97
OpenMS::QcMLFile::Attachment::binary
String binary
binary content of the attachment
Definition: QcMLFile.h:99
double
OpenMS::QcMLFile::Attachment::unitAcc
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:98
OpenMS::Math::median
static double median(IteratorType begin, IteratorType end, bool sorted=false)
Calculates the median of a range of values.
Definition: StatisticFunctions.h:151
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::ExperimentalSettings::getInstrument
const Instrument & getInstrument() const
returns a const reference to the MS instrument description
OpenMS::QcMLFile::getRunIDs
void getRunIDs(std::vector< String > &ids) const
Gives the ids of the registered runs in the vector ids.
OpenMS::PeptideHit::getSequence
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
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.
EnzymaticDigestion.h
OpenMS::Internal::XMLHandler
Base class for XML handlers.
Definition: XMLHandler.h:151
ControlledVocabulary.h
OpenMS::MSExperiment::sortSpectra
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
OpenMS::AASequence::end
Iterator end()
Definition: AASequence.h:585
OpenMS::ExperimentalSettings::getDateTime
const DateTime & getDateTime() const
returns the date the experiment was performed
OpenMS::Constants::k
const double k
OpenMS::QcMLFile::Attachment::qualityRef
String qualityRef
reference to qp to which attachment, if empty attached to run/set
Definition: QcMLFile.h:100
OpenMS::Instrument::getName
const String & getName() const
returns the name of the instrument
OpenMS::MetaInfoInterface::getMetaValue
const DataValue & getMetaValue(const String &name, const DataValue &default_value=DataValue::EMPTY) const
Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not fo...
OpenMS::QcMLFile::QualityParameter::cvRef
String cvRef
cv reference
Definition: QcMLFile.h:70
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:55
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::Residue::getOneLetterCode
const String & getOneLetterCode() const
returns the name as one letter code (String of size 1)
OpenMS::QcMLFile::run_Name_ID_map_
std::map< String, String > run_Name_ID_map_
Definition: QcMLFile.h:191
MzMLFile.h
OpenMS::String::removeWhitespaces
String & removeWhitespaces()
removes whitespaces (space, tab, line feed, carriage return)
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenSwath::norm
double norm(T beg, T end)
compute the norm of the vector
Definition: StatsHelpers.h:57
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::AASequence::getMonoWeight
double getMonoWeight(Residue::ResidueType type=Residue::Full, Int charge=0) const
IdXMLFile.h
FeatureXMLFile.h
OpenMS::QcMLFile::ats_
std::vector< Attachment > ats_
Definition: QcMLFile.h:204
StatisticFunctions.h
OpenMS::Peak2D::getIntensity
IntensityType getIntensity() const
Definition: Peak2D.h:166
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::AASequence::toString
String toString() const
returns the peptide as string with modifications embedded in brackets
XMLHandler.h
OpenMS::operator<
bool operator<(const QTCluster &q1, const QTCluster &q2)
OpenMS::FeatureMap::sortByMZ
void sortByMZ()
Sort features by m/z position.
OpenMS::Constants::PROTON_MASS_U
const double PROTON_MASS_U
OpenMS::QcMLFile::names_
std::set< String > names_
Definition: QcMLFile.h:202
OpenMS::QcMLFile::load
void load(const String &filename)
Load a QCFile.
OpenMS::MSExperiment::size
Size size() const
Definition: MSExperiment.h:127
OpenMS::QcMLFile::qp_
QualityParameter qp_
Definition: QcMLFile.h:196
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::QcMLFile::Attachment
Representation of an attachment.
Definition: QcMLFile.h:90
OpenMS::QcMLFile::QualityParameter::value
String value
Value.
Definition: QcMLFile.h:69
OpenMS::File::find
static String find(const String &filename, StringList directories=StringList())
Looks up the location of the file filename.
OpenMS::ConsensusFeature::end
const_iterator end() const
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:193
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:187
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:46
OpenMS::FeatureMap::updateRanges
void updateRanges() override
Updates minimum and maximum position/intensity.
OpenMS::QcMLFile::QualityParameter::unitRef
String unitRef
cv reference of the unit
Definition: QcMLFile.h:72
UniqueIdGenerator.h
OpenMS::QcMLFile::qps_
std::vector< QualityParameter > qps_
Definition: QcMLFile.h:203
OpenMS::QcMLFile::QualityParameter::cvAcc
String cvAcc
cv accession
Definition: QcMLFile.h:71
OpenMS::QcMLFile::at_
Attachment at_
Definition: QcMLFile.h:197
OpenMS::ProteinIdentification::SearchParameters::variable_modifications
std::vector< String > variable_modifications
Allowed variable modifications.
Definition: ProteinIdentification.h:267
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::Residue
Representation of a residue.
Definition: Residue.h:62
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:201
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...
OpenMS::MSSpectrum::sortByIntensity
void sortByIntensity(bool reverse=false)
Lexicographically sorts the peaks by their intensity.
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
ProteinIdentification.h
OpenMS::QcMLFile::addRunAttachment
void addRunAttachment(String r, Attachment at)
Just adds a attachment to run by the name r.
OpenMS::QcMLFile::Attachment::value
String value
Value.
Definition: QcMLFile.h:94
OpenMS::QcMLFile::Attachment::name
String name
Name.
Definition: QcMLFile.h:92
MathFunctions.h
OpenMS::ConsensusFeature
A consensus feature spanning multiple LC-MS/MS experiments.
Definition: ConsensusFeature.h:69
OpenMS::ChromatogramSettings::TOTAL_ION_CURRENT_CHROMATOGRAM
Definition: ChromatogramSettings.h:70
QcMLFile.h
OpenMS::QcMLFile::Attachment::cvAcc
String cvAcc
cv accession
Definition: QcMLFile.h:96
OpenMS::QcMLFile::name_
String name_
Definition: QcMLFile.h:200
OpenMS::QcMLFile::progress_
UInt progress_
Definition: QcMLFile.h:195
OpenMS::QcMLFile::setQualityQPs_members_
std::map< String, std::set< String > > setQualityQPs_members_
Definition: QcMLFile.h:190
OpenMS::QcMLFile::setQualityAts_
std::map< String, std::vector< Attachment > > setQualityAts_
Definition: QcMLFile.h:189
OpenMS::ControlledVocabulary::getTerm
const CVTerm & getTerm(const String &id) const
Returns a term specified by ID.
OpenMS::ConsensusFeature::const_iterator
HandleSetType::const_iterator const_iterator
Definition: ConsensusFeature.h:76
CsvFile.h
OpenMS::UniqueIdGenerator::getUniqueId
static UInt64 getUniqueId()
Returns a new unique id.
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:80
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::Peak2D::getRT
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:208
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::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::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:73
MSExperiment.h
OpenMS::StringConversions::toString
String toString(const T &i)
fallback template for general purpose using Boost::Karma; more specializations below
Definition: StringUtils.h:127
OpenMS::QcMLFile::set_Name_ID_map_
std::map< String, String > set_Name_ID_map_
Definition: QcMLFile.h:192
OpenMS::QcMLFile::QualityParameter::unitAcc
String unitAcc
cv accession of the unit
Definition: QcMLFile.h:73
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:97
OpenMS::QcMLFile
File adapter for QcML files used to load and store QcML files.
Definition: QcMLFile.h:57
OpenMS::ConsensusFeature::begin
const_iterator begin() const
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::FeatureHandle
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:57
OpenMS::Math::mean
static double mean(IteratorType begin, IteratorType end)
Calculates the mean of a range of values.
Definition: StatisticFunctions.h:133
OpenMS::PeptideHit::getScore
double getScore() const
returns the PSM score
OpenMS::QcMLFile::QualityParameter
Representation of a quality parameter.
Definition: QcMLFile.h:65
OpenMS::FeatureMap::sortByRT
void sortByRT()
Sort features by RT position.
OpenMS::FeatureXMLFile
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:68
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::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::AASequence::begin
Iterator begin()
Definition: AASequence.h:581
OpenMS::Peak2D::getMZ
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:196
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:186
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::QualityParameter::flag
String flag
cv accession of the unit
Definition: QcMLFile.h:74
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
OpenMS::ProteinIdentification::SearchParameters
Search parameters of the DB search.
Definition: ProteinIdentification.h:258
OpenMS::QcMLFile::header_
std::vector< String > header_
Definition: QcMLFile.h:199
OpenMS::QcMLFile::Attachment::id
String id
Name.
Definition: QcMLFile.h:93
OpenMS::FeatureHandle::getCharge
ChargeType getCharge() const
Returns the charge.
StandardTypes.h
OpenMS::Residue::isModified
bool isModified() const
true if the residue is a modified one
File.h
OpenMS::QcMLFile::row_
std::vector< String > row_
Definition: QcMLFile.h:198
OpenMS::ControlledVocabulary::getTermByName
const CVTerm & getTermByName(const String &name, const String &desc="") const
Returns a term specified by name.
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:62
OpenMS::IdXMLFile
Used to load and store idXML files.
Definition: IdXMLFile.h:63
OpenMS::QcMLFile::QualityParameter::name
String name
Name.
Definition: QcMLFile.h:67
OpenMS::ControlledVocabulary::exists
bool exists(const String &id) const
Returns true if the term is in the CV. Returns false otherwise.
OpenMS::DateTime::getDate
void getDate(UInt &month, UInt &day, UInt &year) const
Fills the arguments with the date.
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:55