OpenMS
QCBase.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-2023.
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: Chris Bielow $
32 // $Authors: Chris Bielow, Tom Waschischeck $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
40 #include <algorithm>
41 #include <map>
42 
43 namespace OpenMS
44 {
45  class MSExperiment;
46  class ConsensusMap;
47 
54  class OPENMS_DLLAPI QCBase
55  {
56  public:
60  enum class Requires : UInt64 // 64 bit unsigned type for bitwise and/or operations (see below)
61  {
62  NOTHING, //< default, does not require anything
63  RAWMZML, //< mzML file is required
64  POSTFDRFEAT, //< Features with FDR-filtered pepIDs
65  PREFDRFEAT, //< Features with unfiltered pepIDs
66  CONTAMINANTS, //< Contaminant Database
67  TRAFOALIGN, //< transformationXMLs for RT-alignment
68  ID, //< idXML with protein IDs
69  SIZE_OF_REQUIRES
70  };
72  static const std::string names_of_requires[];
73 
74  enum class ToleranceUnit
75  {
76  AUTO,
77  PPM,
78  DA,
79  SIZE_OF_TOLERANCEUNIT
80  };
82  static const std::string names_of_toleranceUnit[];
83 
84 
88  class OPENMS_DLLAPI SpectraMap
89  {
90  public:
92  SpectraMap() = default;
93 
95  explicit SpectraMap(const MSExperiment& exp);
96 
98  ~SpectraMap() = default;
99 
101  void calculateMap(const MSExperiment& exp);
102 
105  UInt64 at(const String& identifier) const;
106 
108  void clear();
109 
111  bool empty() const;
112 
114  Size size() const;
115 
116  private:
117  std::map<String, UInt64> nativeid_to_index_; //< nativeID to index
118  };
119 
121 
122 
126  virtual const String& getName() const = 0;
127 
131  virtual Status requirements() const = 0;
132 
133 
136  bool isRunnable(const Status& s) const;
137 
139  static bool isLabeledExperiment(const ConsensusMap& cm);
140 
142  template<typename MAP>
143  static bool hasPepID(const MAP& fmap)
144  {
145  if (!fmap.getUnassignedPeptideIdentifications().empty())
146  return true;
147 
148  return std::any_of(fmap.cbegin(), fmap.cend(), [](const auto& f) { return !f.getPeptideIdentifications().empty(); });
149  }
150  };
151 } // namespace OpenMS
A container for consensus elements.
Definition: ConsensusMap.h:92
Stores and handles combinations of enum values, e.g. a set of flags as bits flipped in an UInt64.
Definition: FlagSet.h:54
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
Map to find a spectrum via its NativeID.
Definition: QCBase.h:89
std::map< String, UInt64 > nativeid_to_index_
Definition: QCBase.h:117
bool empty() const
check if empty
SpectraMap(const MSExperiment &exp)
CTor which allows immediate indexing of an MSExperiment.
UInt64 at(const String &identifier) const
void calculateMap(const MSExperiment &exp)
calculate a new map, delete the old one
SpectraMap()=default
Constructor.
void clear()
clear the map
Size size() const
get size of map
~SpectraMap()=default
Destructor.
This class serves as an abstract base class for all QC classes.
Definition: QCBase.h:55
static bool hasPepID(const MAP &fmap)
does the container have a PeptideIdentification in its members or as unassignedPepID ?
Definition: QCBase.h:143
virtual Status requirements() const =0
Returns the input data requirements of the compute(...) function.
static bool isLabeledExperiment(const ConsensusMap &cm)
check if the IsobaricAnalyzer TOPP tool was used to create this ConsensusMap
bool isRunnable(const Status &s) const
Requires
Enum to encode a file type as a bit.
Definition: QCBase.h:61
virtual const String & getName() const =0
Returns the name of the metric.
ToleranceUnit
Definition: QCBase.h:75
A more convenient string class.
Definition: String.h:60
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48