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-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: Chris Bielow $
32 // $Authors: Chris Bielow, Tom Waschischeck $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
40 
41 #include <algorithm>
42 #include <map>
43 
44 namespace OpenMS
45 {
46  class MSExperiment;
47  class ConsensusMap;
48 
55  class OPENMS_DLLAPI QCBase
56  {
57  public:
61  enum class Requires
62  : UInt64 // 64 bit unsigned type for bitwise and/or operations (see below)
63  {
64  NOTHING, //< default, does not require anything
65  RAWMZML, //< mzML file is required
66  POSTFDRFEAT, //< Features with FDR-filtered pepIDs
67  PREFDRFEAT, //< Features with unfiltered pepIDs
68  CONTAMINANTS, //< Contaminant Database
69  TRAFOALIGN, //< transformationXMLs for RT-alignment
70  ID, //< idXML with protein IDs
71  SIZE_OF_REQUIRES
72  };
74  static const std::string names_of_requires[];
75 
76  enum class ToleranceUnit
77  {
78  AUTO,
79  PPM,
80  DA,
81  SIZE_OF_TOLERANCEUNIT
82  };
84  static const std::string names_of_toleranceUnit[];
85 
86 
90  class OPENMS_DLLAPI SpectraMap
91  {
92  public:
94  SpectraMap() = default;
95 
97  explicit SpectraMap(const MSExperiment& exp);
98 
100  ~SpectraMap() = default;
101 
103  void calculateMap(const MSExperiment& exp);
104 
107  UInt64 at(const String& identifier) const;
108 
110  void clear();
111 
113  bool empty() const;
114 
116  Size size() const;
117 
118  private:
119  std::map<String, UInt64> nativeid_to_index_; //< nativeID to index
120  };
121 
123 
124 
128  virtual const String& getName() const = 0;
129 
133  virtual Status requires() const = 0;
134 
135 
138  bool isRunnable(const Status& s) const;
139 
141  static bool isLabeledExperiment(const ConsensusMap& cm);
142 
144  template <typename MAP>
145  static bool hasPepID(const MAP& fmap)
146  {
147  if (!fmap.getUnassignedPeptideIdentifications().empty()) return true;
148 
149  return std::any_of(fmap.cbegin(), fmap.cend(), [](const auto& f)
150  { return !f.getPeptideIdentifications().empty();});
151  }
152  };
153 }
Stores and handles combinations of enum values, e.g. a set of flags as bits flipped in an UInt64...
Definition: FlagSet.h:53
A more convenient string class.
Definition: String.h:58
A container for consensus elements.
Definition: ConsensusMap.h:84
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
static bool hasPepID(const MAP &fmap)
does the container have a PeptideIdentification in its members or as unassignedPepID ...
Definition: QCBase.h:145
ToleranceUnit
Definition: QCBase.h:76
std::map< String, UInt64 > nativeid_to_index_
Definition: QCBase.h:119
Map to find a spectrum via its NativeID.
Definition: QCBase.h:90
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
Requires
Enum to encode a file type as a bit.
Definition: QCBase.h:61
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
This class serves as an abstract base class for all QC classes.
Definition: QCBase.h:55